Skip to content

Commit

Permalink
test: check for properly raised errors during param conversion
Browse files Browse the repository at this point in the history
Reviewed-by: Richard Levitte <levitte@openssl.org>
(Merged from #17440)

(cherry picked from commit 291c5b3)
Reviewed-by: Hugo Landau <hlandau@openssl.org>
  • Loading branch information
paulidale authored and t8m committed Nov 9, 2022
1 parent 5954864 commit c737132
Showing 1 changed file with 10 additions and 5 deletions.
15 changes: 10 additions & 5 deletions test/params_conversion_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,8 @@ static int param_conversion_test(const PARAM_CONVERSION *pc, int line)
double d;

if (!pc->valid_i32) {
if (!TEST_false(OSSL_PARAM_get_int32(pc->param, &i32))) {
if (!TEST_false(OSSL_PARAM_get_int32(pc->param, &i32))
|| !TEST_ulong_ne(ERR_get_error(), 0)) {
TEST_note("unexpected valid conversion to int32 on line %d", line);
return 0;
}
Expand All @@ -210,7 +211,8 @@ static int param_conversion_test(const PARAM_CONVERSION *pc, int line)
}

if (!pc->valid_i64) {
if (!TEST_false(OSSL_PARAM_get_int64(pc->param, &i64))) {
if (!TEST_false(OSSL_PARAM_get_int64(pc->param, &i64))
|| !TEST_ulong_ne(ERR_get_error(), 0)) {
TEST_note("unexpected valid conversion to int64 on line %d", line);
return 0;
}
Expand All @@ -230,7 +232,8 @@ static int param_conversion_test(const PARAM_CONVERSION *pc, int line)
}

if (!pc->valid_u32) {
if (!TEST_false(OSSL_PARAM_get_uint32(pc->param, &u32))) {
if (!TEST_false(OSSL_PARAM_get_uint32(pc->param, &u32))
|| !TEST_ulong_ne(ERR_get_error(), 0)) {
TEST_note("unexpected valid conversion to uint32 on line %d", line);
return 0;
}
Expand All @@ -250,7 +253,8 @@ static int param_conversion_test(const PARAM_CONVERSION *pc, int line)
}

if (!pc->valid_u64) {
if (!TEST_false(OSSL_PARAM_get_uint64(pc->param, &u64))) {
if (!TEST_false(OSSL_PARAM_get_uint64(pc->param, &u64))
|| !TEST_ulong_ne(ERR_get_error(), 0)) {
TEST_note("unexpected valid conversion to uint64 on line %d", line);
return 0;
}
Expand All @@ -270,7 +274,8 @@ static int param_conversion_test(const PARAM_CONVERSION *pc, int line)
}

if (!pc->valid_d) {
if (!TEST_false(OSSL_PARAM_get_double(pc->param, &d))) {
if (!TEST_false(OSSL_PARAM_get_double(pc->param, &d))
|| !TEST_ulong_ne(ERR_get_error(), 0)) {
TEST_note("unexpected valid conversion to double on line %d", line);
return 0;
}
Expand Down

0 comments on commit c737132

Please sign in to comment.