diff options
author | Rich Salz <rsalz@openssl.org> | 2017-04-18 14:34:43 -0400 |
---|---|---|
committer | Rich Salz <rsalz@openssl.org> | 2017-04-18 14:34:43 -0400 |
commit | b66411f6cda6970c01283ddde6d8063c57b3b7d9 (patch) | |
tree | 7e9074efb3d8ebefc6d8797f0145c49345292e34 /test/pbelutest.c | |
parent | 0fef74486ede58e34eeac2fab38c3f467ea31f95 (diff) | |
download | openssl-b66411f6cda6970c01283ddde6d8063c57b3b7d9.zip openssl-b66411f6cda6970c01283ddde6d8063c57b3b7d9.tar.gz openssl-b66411f6cda6970c01283ddde6d8063c57b3b7d9.tar.bz2 |
Convert more tests
recordlentest, srptest, ecdsatest, enginetest, pbelutest
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from https://github.com/openssl/openssl/pull/3237)
Diffstat (limited to 'test/pbelutest.c')
-rw-r--r-- | test/pbelutest.c | 43 |
1 files changed, 26 insertions, 17 deletions
diff --git a/test/pbelutest.c b/test/pbelutest.c index e226d43..11189b4 100644 --- a/test/pbelutest.c +++ b/test/pbelutest.c @@ -8,40 +8,49 @@ */ #include <openssl/evp.h> -#include <stdio.h> -#include <string.h> +#include "testutil.h" +#include "test_main.h" /* * Password based encryption (PBE) table ordering test. * Attempt to look up all supported algorithms. */ -int main(int argc, char **argv) +static int test_pbelu(void) { - size_t i; - int rv = 0; - int pbe_type, pbe_nid; - int last_type = -1, last_nid = -1; + int i, failed = 0, ok; + int pbe_type, pbe_nid, last_type = -1, last_nid = -1; + for (i = 0; EVP_PBE_get(&pbe_type, &pbe_nid, i) != 0; i++) { - if (EVP_PBE_find(pbe_type, pbe_nid, NULL, NULL, 0) == 0) { - rv = 1; + if (!TEST_true(EVP_PBE_find(pbe_type, pbe_nid, NULL, NULL, 0))) { + TEST_info("i=%d, pbe_type=%d, pbe_nid=%d", i, pbe_type, pbe_nid); + failed = 1; break; } } - if (rv == 0) - return 0; + + if (!failed) + return 1; + /* Error: print out whole table */ for (i = 0; EVP_PBE_get(&pbe_type, &pbe_nid, i) != 0; i++) { if (pbe_type > last_type) - rv = 0; + ok = 0; else if (pbe_type < last_type || pbe_nid < last_nid) - rv = 1; + ok = 1; else - rv = 0; - fprintf(stderr, "PBE type=%d %d (%s): %s\n", pbe_type, pbe_nid, - OBJ_nid2sn(pbe_nid), rv ? "ERROR" : "OK"); + ok = 0; + if (!ok) + failed = 1; + TEST_info("PBE type=%d %d (%s): %s\n", pbe_type, pbe_nid, + OBJ_nid2sn(pbe_nid), ok ? "ERROR" : "OK"); last_type = pbe_type; last_nid = pbe_nid; } - return 1; + return failed ? 0 : 1; +} + +void register_tests(void) +{ + ADD_TEST(test_pbelu); } |