diff options
author | Joel Kitching <kitching@google.com> | 2018-08-02 16:21:17 +0800 |
---|---|---|
committer | chrome-bot <chrome-bot@chromium.org> | 2018-08-03 01:31:21 -0700 |
commit | 9ad8a41b8cedef9ac1f0513992ce6958eb86c257 (patch) | |
tree | 2a1fe0e028829dc579840dce386047ce661ac6d3 /tests/test_common.c | |
parent | c239374ac3e1af342c10f4f3244bc98d76c2413a (diff) | |
download | vboot-9ad8a41b8cedef9ac1f0513992ce6958eb86c257.tar.gz |
vboot: bulk fix tabs and spacing inconsistency
Problem files were found with:
find . -name '*.c' -o -name '*.h' | xargs grep '^ [^*]'
and edited manually.
Ignores utility/ and cgpt/, since they seem to globally adhere
to a two-space tab convention.
BUG=None
TEST=make clean runtests
TEST=emerge vboot_reference depthcharge
Change-Id: I5a678484a119c8f1911f717e1968bdb4f1a0810f
Reviewed-on: https://chromium-review.googlesource.com/1160131
Commit-Ready: Joel Kitching <kitching@chromium.org>
Tested-by: Joel Kitching <kitching@chromium.org>
Reviewed-by: Randall Spangler <rspangler@chromium.org>
Diffstat (limited to 'tests/test_common.c')
-rw-r--r-- | tests/test_common.c | 227 |
1 files changed, 115 insertions, 112 deletions
diff --git a/tests/test_common.c b/tests/test_common.c index 972a3ffe..ddd81052 100644 --- a/tests/test_common.c +++ b/tests/test_common.c @@ -17,156 +17,159 @@ int gTestSuccess = 1; int test_eq(int result, int expected, const char *preamble, const char *desc, const char *comment) { - if (result == expected) { - fprintf(stderr, "%s: %s ... " COL_GREEN "PASSED\n" COL_STOP, - preamble, comment ? comment : desc); - return 1; - } else { - fprintf(stderr, "%s: %s ... " COL_RED "FAILED\n" COL_STOP, - preamble, comment ? comment : desc); - fprintf(stderr, " Expected: 0x%x (%d), got: 0x%x (%d)\n", - expected, expected, result, result); - gTestSuccess = 0; - return 0; - } + if (result == expected) { + fprintf(stderr, "%s: %s ... " COL_GREEN "PASSED\n" COL_STOP, + preamble, comment ? comment : desc); + return 1; + } else { + fprintf(stderr, "%s: %s ... " COL_RED "FAILED\n" COL_STOP, + preamble, comment ? comment : desc); + fprintf(stderr, " Expected: 0x%x (%d), got: 0x%x (%d)\n", + expected, expected, result, result); + gTestSuccess = 0; + return 0; + } } int test_neq(int result, int not_expected, const char *preamble, const char *desc, const char *comment) { - if (result != not_expected) { - fprintf(stderr, "%s: %s, %s ... " COL_GREEN "PASSED\n" COL_STOP, - preamble, desc, comment); - return 1; - } else { - fprintf(stderr, "%s: %s, %s ... " COL_RED "FAILED\n" COL_STOP, - preamble, desc, comment); - fprintf(stderr, " Didn't expect 0x%x (%d), but got it.\n", - not_expected, not_expected); - gTestSuccess = 0; - return 0; - } + if (result != not_expected) { + fprintf(stderr, "%s: %s, %s ... " COL_GREEN "PASSED\n" COL_STOP, + preamble, desc, comment); + return 1; + } else { + fprintf(stderr, "%s: %s, %s ... " COL_RED "FAILED\n" COL_STOP, + preamble, desc, comment); + fprintf(stderr, " Didn't expect 0x%x (%d), but got it.\n", + not_expected, not_expected); + gTestSuccess = 0; + return 0; + } } int test_ptr_eq(const void* result, const void* expected, const char *preamble, const char *desc, const char *comment) { - if (result == expected) { - fprintf(stderr, "%s: %s, %s ... " COL_GREEN "PASSED\n" COL_STOP, - preamble, desc, comment); - return 1; - } else { - fprintf(stderr, "%s: %s, %s ... " COL_RED "FAILED\n" COL_STOP, - preamble, desc, comment); - fprintf(stderr, " Expected: 0x%lx, got: 0x%lx\n", (long)expected, - (long)result); - gTestSuccess = 0; - return 0; - } + if (result == expected) { + fprintf(stderr, "%s: %s, %s ... " COL_GREEN "PASSED\n" COL_STOP, + preamble, desc, comment); + return 1; + } else { + fprintf(stderr, "%s: %s, %s ... " COL_RED "FAILED\n" COL_STOP, + preamble, desc, comment); + fprintf(stderr, " Expected: 0x%lx, got: 0x%lx\n", + (long)expected, (long)result); + gTestSuccess = 0; + return 0; + } } int test_ptr_neq(const void* result, const void* not_expected, const char *preamble, const char *desc, const char *comment) { - if (result != not_expected) { - fprintf(stderr, "%s: %s, %s ... " COL_GREEN "PASSED\n" COL_STOP, - preamble, desc, comment); - return 1; - } else { - fprintf(stderr, "%s: %s, %s ... " COL_RED "FAILED\n" COL_STOP, - preamble, desc, comment); - fprintf(stderr, " Didn't expect 0x%lx, but got it\n", - (long)not_expected); - gTestSuccess = 0; - return 0; - } + if (result != not_expected) { + fprintf(stderr, "%s: %s, %s ... " COL_GREEN "PASSED\n" COL_STOP, + preamble, desc, comment); + return 1; + } else { + fprintf(stderr, "%s: %s, %s ... " COL_RED "FAILED\n" COL_STOP, + preamble, desc, comment); + fprintf(stderr, " Didn't expect 0x%lx, but got it\n", + (long)not_expected); + gTestSuccess = 0; + return 0; + } } int test_str_eq(const char* result, const char* expected, const char *preamble, const char *desc, const char *comment) { - if (!result || !expected) { - fprintf(stderr, "%s: %s, %s ... " COL_RED "FAILED\n" COL_STOP, - preamble, desc, comment); - fprintf(stderr, " String compare with NULL\n"); - gTestSuccess = 0; - return 0; - } else if (!strcmp(result, expected)) { - fprintf(stderr, "%s: %s, %s ... " COL_GREEN "PASSED\n" COL_STOP, - preamble, desc, comment); - return 1; - } else { - fprintf(stderr, "%s " COL_RED "FAILED\n" COL_STOP, comment); - fprintf(stderr, " Expected: \"%s\", got: \"%s\"\n", expected, - result); - gTestSuccess = 0; - return 0; - } + if (!result || !expected) { + fprintf(stderr, "%s: %s, %s ... " COL_RED "FAILED\n" COL_STOP, + preamble, desc, comment); + fprintf(stderr, " String compare with NULL\n"); + gTestSuccess = 0; + return 0; + } else if (!strcmp(result, expected)) { + fprintf(stderr, "%s: %s, %s ... " COL_GREEN "PASSED\n" COL_STOP, + preamble, desc, comment); + return 1; + } else { + fprintf(stderr, "%s " COL_RED "FAILED\n" COL_STOP, comment); + fprintf(stderr, " Expected: \"%s\", got: \"%s\"\n", + expected, result); + gTestSuccess = 0; + return 0; + } } int test_str_neq(const char* result, const char* not_expected, const char *preamble, const char *desc, const char *comment) { - if (!result || !not_expected) { - fprintf(stderr, "%s: %s, %s ... " COL_RED "FAILED\n" COL_STOP, - preamble, desc, comment); - fprintf(stderr, " String compare with NULL\n"); - gTestSuccess = 0; - return 0; - } else if (strcmp(result, not_expected)) { - fprintf(stderr, "%s: %s, %s ... " COL_GREEN "PASSED\n" COL_STOP, - preamble, desc, comment); - return 1; - } else { - fprintf(stderr, "%s: %s, %s ... " COL_RED "FAILED\n" COL_STOP, - preamble, desc, comment); - fprintf(stderr, " Didn't expect: \"%s\", but got it\n", not_expected); - gTestSuccess = 0; - return 0; - } + if (!result || !not_expected) { + fprintf(stderr, "%s: %s, %s ... " COL_RED "FAILED\n" COL_STOP, + preamble, desc, comment); + fprintf(stderr, " String compare with NULL\n"); + gTestSuccess = 0; + return 0; + } else if (strcmp(result, not_expected)) { + fprintf(stderr, "%s: %s, %s ... " COL_GREEN "PASSED\n" COL_STOP, + preamble, desc, comment); + return 1; + } else { + fprintf(stderr, "%s: %s, %s ... " COL_RED "FAILED\n" COL_STOP, + preamble, desc, comment); + fprintf(stderr, " Didn't expect: \"%s\", but got it\n", + not_expected); + gTestSuccess = 0; + return 0; + } } int test_succ(int result, const char *preamble, const char *desc, const char *comment) { - if (result == 0) { - fprintf(stderr, "%s: %s ... " COL_GREEN "PASSED\n" COL_STOP, - preamble, comment ? comment : desc); - } else { - fprintf(stderr, "%s: %s ... " COL_RED "FAILED\n" COL_STOP, - preamble, comment ? comment : desc); - fprintf(stderr, " Expected SUCCESS, got: 0x%x (%d)\n", result, result); - gTestSuccess = 0; - } - return !result; + if (result == 0) { + fprintf(stderr, "%s: %s ... " COL_GREEN "PASSED\n" COL_STOP, + preamble, comment ? comment : desc); + } else { + fprintf(stderr, "%s: %s ... " COL_RED "FAILED\n" COL_STOP, + preamble, comment ? comment : desc); + fprintf(stderr, " Expected SUCCESS, got: 0x%x (%d)\n", + result, result); + gTestSuccess = 0; + } + return !result; } int test_true(int result, const char *preamble, const char *desc, const char *comment) { - if (result) { - fprintf(stderr, "%s: %s, %s ... " COL_GREEN "PASSED\n" COL_STOP, - preamble, desc, comment); - } else { - fprintf(stderr, "%s: %s, %s ... " COL_RED "FAILED\n" COL_STOP, - preamble, desc, comment); - fprintf(stderr, " Expected TRUE, got 0\n"); - gTestSuccess = 0; - } - return result; + if (result) { + fprintf(stderr, "%s: %s, %s ... " COL_GREEN "PASSED\n" COL_STOP, + preamble, desc, comment); + } else { + fprintf(stderr, "%s: %s, %s ... " COL_RED "FAILED\n" COL_STOP, + preamble, desc, comment); + fprintf(stderr, " Expected TRUE, got 0\n"); + gTestSuccess = 0; + } + return result; } int test_false(int result, const char *preamble, const char *desc, const char *comment) { - if (!result) { - fprintf(stderr, "%s: %s, %s ... " COL_GREEN "PASSED\n" COL_STOP, - preamble, desc, comment); - } else { - fprintf(stderr, "%s: %s, %s ... " COL_RED "FAILED\n" COL_STOP, - preamble, desc, comment); - fprintf(stderr, " Expected FALSE, got: 0x%lx\n", (long)result); - gTestSuccess = 0; - } - return !result; + if (!result) { + fprintf(stderr, "%s: %s, %s ... " COL_GREEN "PASSED\n" COL_STOP, + preamble, desc, comment); + } else { + fprintf(stderr, "%s: %s, %s ... " COL_RED "FAILED\n" COL_STOP, + preamble, desc, comment); + fprintf(stderr, " Expected FALSE, got: 0x%lx\n", + (long)result); + gTestSuccess = 0; + } + return !result; } |