examples/fips_validation: cleanup bypass tests in response file

Message ID 20220519060730.3624877-1-gmuthukrishn@marvell.com (mailing list archive)
State Superseded, archived
Delegated to: akhil goyal
Headers
Series examples/fips_validation: cleanup bypass tests in response file |

Checks

Context Check Description
ci/checkpatch success coding style OK
ci/Intel-compilation warning apply issues
ci/iol-testing warning apply patch failure

Commit Message

Gowrishankar Muthukrishnan May 19, 2022, 6:07 a.m. UTC
  Remove garbage entries for bypassed tests in response file.

Signed-off-by: Gowrishankar Muthukrishnan <gmuthukrishn@marvell.com>
---
Depends-on: series-22738 ("Add JSON vector set support to fips validation")
---
 examples/fips_validation/main.c | 74 ++++++++++++++++-----------------
 1 file changed, 35 insertions(+), 39 deletions(-)
  

Patch

diff --git a/examples/fips_validation/main.c b/examples/fips_validation/main.c
index aa8034c29f..8af4dc1894 100644
--- a/examples/fips_validation/main.c
+++ b/examples/fips_validation/main.c
@@ -805,7 +805,7 @@  prepare_aes_xform(struct rte_crypto_sym_xform *xform)
 		RTE_LOG(ERR, USER1, "PMD %s key length %u IV length %u\n",
 				info.device_name, cipher_xform->key.length,
 				cipher_xform->iv.length);
-		return -EPERM;
+		return -ENOTSUP;
 	}
 
 	return 0;
@@ -853,7 +853,7 @@  prepare_tdes_xform(struct rte_crypto_sym_xform *xform)
 		RTE_LOG(ERR, USER1, "PMD %s key length %u IV length %u\n",
 				info.device_name, cipher_xform->key.length,
 				cipher_xform->iv.length);
-		return -EPERM;
+		return -ENOTSUP;
 	}
 
 	return 0;
@@ -890,7 +890,7 @@  prepare_hmac_xform(struct rte_crypto_sym_xform *xform)
 		RTE_LOG(ERR, USER1, "PMD %s key length %u IV length %u\n",
 				info.device_name, auth_xform->key.length,
 				auth_xform->digest_length);
-		return -EPERM;
+		return -ENOTSUP;
 	}
 
 	return 0;
@@ -936,7 +936,7 @@  prepare_gcm_xform(struct rte_crypto_sym_xform *xform)
 				aead_xform->digest_length,
 				aead_xform->aad_length,
 				aead_xform->iv.length);
-		return -EPERM;
+		return -ENOTSUP;
 	}
 
 	return 0;
@@ -981,7 +981,7 @@  prepare_gmac_xform(struct rte_crypto_sym_xform *xform)
 				info.device_name, auth_xform->key.length,
 				auth_xform->digest_length,
 				auth_xform->iv.length);
-		return -EPERM;
+		return -ENOTSUP;
 	}
 
 	return 0;
@@ -1019,7 +1019,7 @@  prepare_cmac_xform(struct rte_crypto_sym_xform *xform)
 		RTE_LOG(ERR, USER1, "PMD %s key length %u IV length %u\n",
 				info.device_name, auth_xform->key.length,
 				auth_xform->digest_length);
-		return -EPERM;
+		return -ENOTSUP;
 	}
 
 	return 0;
@@ -1065,7 +1065,7 @@  prepare_ccm_xform(struct rte_crypto_sym_xform *xform)
 				aead_xform->digest_length,
 				aead_xform->aad_length,
 				aead_xform->iv.length);
-		return -EPERM;
+		return -ENOTSUP;
 	}
 
 	return 0;
@@ -1100,7 +1100,7 @@  prepare_sha_xform(struct rte_crypto_sym_xform *xform)
 		RTE_LOG(ERR, USER1, "PMD %s key length %u digest length %u\n",
 				info.device_name, auth_xform->key.length,
 				auth_xform->digest_length);
-		return -EPERM;
+		return -ENOTSUP;
 	}
 
 	return 0;
@@ -1140,7 +1140,7 @@  prepare_xts_xform(struct rte_crypto_sym_xform *xform)
 		RTE_LOG(ERR, USER1, "PMD %s key length %u IV length %u\n",
 				info.device_name, cipher_xform->key.length,
 				cipher_xform->iv.length);
-		return -EPERM;
+		return -ENOTSUP;
 	}
 
 	return 0;
@@ -1255,7 +1255,7 @@  fips_generic_test(void)
 
 	ret = fips_run_test();
 	if (ret < 0) {
-		if (ret == -EPERM || ret == -ENOTSUP) {
+		if (ret == -ENOTSUP) {
 			fprintf(info.fp_wr, "Bypass\n\n");
 			return 0;
 		}
@@ -1290,7 +1290,7 @@  fips_generic_test(void)
 		fprintf(info.fp_wr, "\n");
 	free(val.val);
 
-	return 0;
+	return 1;
 }
 
 static int
@@ -1459,7 +1459,7 @@  fips_mct_tdes_test(void)
 
 	free(val.val);
 
-	return 0;
+	return 1;
 }
 
 static int
@@ -1538,7 +1538,7 @@  fips_mct_aes_ecb_test(void)
 
 	free(val.val);
 
-	return 0;
+	return 1;
 }
 static int
 fips_mct_aes_test(void)
@@ -1646,7 +1646,7 @@  fips_mct_aes_test(void)
 
 	free(val.val);
 
-	return 0;
+	return 1;
 }
 
 static int
@@ -1732,7 +1732,7 @@  fips_mct_sha_test(void)
 
 	free(val.val);
 
-	return 0;
+	return 1;
 }
 
 
@@ -1847,18 +1847,15 @@  fips_test_one_file(void)
 		}
 
 		ret = fips_test_parse_one_case();
-		switch (ret) {
-		case 0:
-			ret = test_ops.test();
-			if (ret == 0)
-				break;
-			RTE_LOG(ERR, USER1, "Error %i: test block\n",
+		if (ret < 0) {
+			RTE_LOG(ERR, USER1, "Error %i: Parse block\n",
 					ret);
 			goto error_one_case;
-		case 1:
-			break;
-		default:
-			RTE_LOG(ERR, USER1, "Error %i: Parse block\n",
+		}
+
+		ret = test_ops.test();
+		if (ret < 0) {
+			RTE_LOG(ERR, USER1, "Error %i: test block\n",
 					ret);
 			goto error_one_case;
 		}
@@ -1908,22 +1905,21 @@  fips_test_one_test_case(void)
 	int ret;
 
 	ret = fips_test_parse_one_json_case();
+	if (ret < 0) {
+		RTE_LOG(ERR, USER1, "Error %i: Parse block\n",
+				ret);
+		goto exit;
+	}
 
-	switch (ret) {
-	case 0:
-		ret = test_ops.test();
-		if (ret == 0)
-			break;
+	ret = test_ops.test();
+	if (ret < 0) {
 		RTE_LOG(ERR, USER1, "Error %i: test block\n",
 				ret);
-		break;
-	case 1:
-		break;
-	default:
-		RTE_LOG(ERR, USER1, "Error %i: Parse block\n",
-				ret);
+		goto exit;
 	}
-	return 0;
+
+exit:
+	return ret;
 }
 
 static int
@@ -1968,8 +1964,8 @@  fips_test_one_test_group(void)
 	tests_size = json_array_size(tests);
 	for (test_idx = 0; test_idx < tests_size; test_idx++) {
 		json_info.json_test_case = json_array_get(tests, test_idx);
-		fips_test_one_test_case();
-		json_array_append_new(write_tests, json_info.json_write_case);
+		if (fips_test_one_test_case() > 0)
+			json_array_append_new(write_tests, json_info.json_write_case);
 	}
 
 	return 0;