diff options
author | Randall Spangler <rspangler@chromium.org> | 2014-06-05 13:32:11 -0700 |
---|---|---|
committer | chrome-internal-fetch <chrome-internal-fetch@google.com> | 2014-06-07 01:37:21 +0000 |
commit | b9be53640efdee92b1b42e60adda274563236301 (patch) | |
tree | f8f2f5ef809c7a0d163334f9e2675b016fae3ca4 /tests/test_common.c | |
parent | b64f097891e697eaf3b2794baae934f8b4d82d14 (diff) | |
download | vboot-b9be53640efdee92b1b42e60adda274563236301.tar.gz |
vboot2: Use more specific error codesstabilize-5944.Bstabilize-5943.Bstabilize-5942.Bfactory-samus-5939.B
Error codes reported by the crypto and storage APIs are now very
specific, and tests verify the proper errors are reported.
More specific error codes coming to other files next, but I don't want
this CL to get too long.
This also changes test_common.c so TEST_EQ() reports mismatched values
in both decimal and hex, and adds TEST_SUCC() to test for a successful
return value.
BUG=chromium:370082
BRANCH=none
TEST=make clean && VBOOT2=1 COV=1 make
Change-Id: I255c8e5769284fbc286b9d94631b19677a71cdd0
Signed-off-by: Randall Spangler <rspangler@chromium.org>
Reviewed-on: https://chromium-review.googlesource.com/202778
Reviewed-by: Bill Richardson <wfrichar@chromium.org>
Diffstat (limited to 'tests/test_common.c')
-rw-r--r-- | tests/test_common.c | 17 |
1 files changed, 15 insertions, 2 deletions
diff --git a/tests/test_common.c b/tests/test_common.c index 2fa445f6..3804245e 100644 --- a/tests/test_common.c +++ b/tests/test_common.c @@ -24,7 +24,8 @@ int TEST_EQ(int result, int expected_result, const char* testname) { return 1; } else { fprintf(stderr, "%s Test " COL_RED "FAILED\n" COL_STOP, testname); - fprintf(stderr, " Expected: %d, got: %d\n", expected_result, result); + fprintf(stderr, " Expected: 0x%x (%d), got: 0x%x (%d)\n", + expected_result, expected_result, result, result); gTestSuccess = 0; return 0; } @@ -36,7 +37,8 @@ int TEST_NEQ(int result, int not_expected_result, const char* testname) { return 1; } else { fprintf(stderr, "%s Test " COL_RED "FAILED\n" COL_STOP, testname); - fprintf(stderr, " Didn't expect %d, but got it.\n", not_expected_result); + fprintf(stderr, " Didn't expect 0x%x (%d), but got it.\n", + not_expected_result, not_expected_result); gTestSuccess = 0; return 0; } @@ -91,6 +93,17 @@ int TEST_STR_EQ(const char* result, const char* expected_result, } +int TEST_SUCC(int result, const char* testname) { + if (result == 0) { + fprintf(stderr, "%s Test " COL_GREEN "PASSED\n" COL_STOP, testname); + } else { + fprintf(stderr, "%s Test " COL_RED "FAILED\n" COL_STOP, testname); + fprintf(stderr, " Expected SUCCESS, got: 0x%lx\n", (long)result); + gTestSuccess = 0; + } + return !result; +} + int TEST_TRUE(int result, const char* testname) { if (result) { fprintf(stderr, "%s Test " COL_GREEN "PASSED\n" COL_STOP, testname); |