tinycrypt: Fix style issues
This commit solves some style issues found at the tests/include/test_utils.h file: - Lines over 80 characters - Unused arguments - Missing {} in if-else Change-Id: Ifaee81ec7c57a250b2c368b2efda38dc69d02c81 Signed-off-by: Flavio Santes <flavio.santes@intel.com>
This commit is contained in:
parent
1a19e14d97
commit
f73c86d096
1 changed files with 30 additions and 21 deletions
|
@ -37,38 +37,47 @@
|
|||
|
||||
static inline void show_str(const char *label, const uint8_t *s, size_t len)
|
||||
{
|
||||
uint32_t i;
|
||||
uint32_t i;
|
||||
|
||||
TC_PRINT("%s = ", label);
|
||||
for (i = 0; i < (uint32_t) len; ++i) {
|
||||
TC_PRINT("%02x", s[i]);
|
||||
}
|
||||
TC_PRINT("\n");
|
||||
TC_PRINT("%s = ", label);
|
||||
for (i = 0; i < (uint32_t)len; ++i) {
|
||||
TC_PRINT("%02x", s[i]);
|
||||
}
|
||||
TC_PRINT("\n");
|
||||
}
|
||||
|
||||
static inline void fatal(uint32_t testnum, const void *expected, size_t expectedlen,
|
||||
const void *computed, size_t computedlen)
|
||||
static inline
|
||||
void fatal(uint32_t testnum, const void *expected, size_t expectedlen,
|
||||
const void *computed, size_t computedlen)
|
||||
{
|
||||
|
||||
TC_ERROR("\tTest #%d Failed!\n", testnum);
|
||||
show_str("\t\tExpected", expected, expectedlen);
|
||||
show_str("\t\tComputed ", computed, computedlen);
|
||||
TC_PRINT("\n");
|
||||
TC_ERROR("\tTest #%d Failed!\n", testnum);
|
||||
show_str("\t\tExpected", expected, expectedlen);
|
||||
show_str("\t\tComputed ", computed, computedlen);
|
||||
TC_PRINT("\n");
|
||||
}
|
||||
|
||||
static inline uint32_t check_result(uint32_t testnum, const void *expected, size_t expectedlen,
|
||||
const void *computed, size_t computedlen, uint32_t verbose)
|
||||
static inline
|
||||
uint32_t check_result(uint32_t testnum, const void *expected,
|
||||
size_t expectedlen, const void *computed,
|
||||
size_t computedlen, uint32_t verbose)
|
||||
{
|
||||
uint32_t result = TC_PASS;
|
||||
|
||||
ARG_UNUSED(verbose);
|
||||
|
||||
if (expectedlen != computedlen) {
|
||||
TC_ERROR("The length of the computed buffer (%zu)", computedlen);
|
||||
TC_ERROR("does not match the expected length (%zu).", expectedlen);
|
||||
TC_ERROR("The length of the computed buffer (%zu)",
|
||||
computedlen);
|
||||
TC_ERROR("does not match the expected length (%zu).",
|
||||
expectedlen);
|
||||
result = TC_FAIL;
|
||||
} else if (memcmp(computed, expected, computedlen) != 0) {
|
||||
fatal(testnum, expected, expectedlen, computed, computedlen);
|
||||
result = TC_FAIL;
|
||||
}
|
||||
} else {
|
||||
if (memcmp(computed, expected, computedlen) != 0) {
|
||||
fatal(testnum, expected, expectedlen,
|
||||
computed, computedlen);
|
||||
result = TC_FAIL;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue