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)
|
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);
|
TC_PRINT("%s = ", label);
|
||||||
for (i = 0; i < (uint32_t) len; ++i) {
|
for (i = 0; i < (uint32_t)len; ++i) {
|
||||||
TC_PRINT("%02x", s[i]);
|
TC_PRINT("%02x", s[i]);
|
||||||
}
|
}
|
||||||
TC_PRINT("\n");
|
TC_PRINT("\n");
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void fatal(uint32_t testnum, const void *expected, size_t expectedlen,
|
static inline
|
||||||
const void *computed, size_t computedlen)
|
void fatal(uint32_t testnum, const void *expected, size_t expectedlen,
|
||||||
|
const void *computed, size_t computedlen)
|
||||||
{
|
{
|
||||||
|
TC_ERROR("\tTest #%d Failed!\n", testnum);
|
||||||
TC_ERROR("\tTest #%d Failed!\n", testnum);
|
show_str("\t\tExpected", expected, expectedlen);
|
||||||
show_str("\t\tExpected", expected, expectedlen);
|
show_str("\t\tComputed ", computed, computedlen);
|
||||||
show_str("\t\tComputed ", computed, computedlen);
|
TC_PRINT("\n");
|
||||||
TC_PRINT("\n");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline uint32_t check_result(uint32_t testnum, const void *expected, size_t expectedlen,
|
static inline
|
||||||
const void *computed, size_t computedlen, uint32_t verbose)
|
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;
|
uint32_t result = TC_PASS;
|
||||||
|
|
||||||
|
ARG_UNUSED(verbose);
|
||||||
|
|
||||||
if (expectedlen != computedlen) {
|
if (expectedlen != computedlen) {
|
||||||
TC_ERROR("The length of the computed buffer (%zu)", computedlen);
|
TC_ERROR("The length of the computed buffer (%zu)",
|
||||||
TC_ERROR("does not match the expected length (%zu).", expectedlen);
|
computedlen);
|
||||||
|
TC_ERROR("does not match the expected length (%zu).",
|
||||||
|
expectedlen);
|
||||||
result = TC_FAIL;
|
result = TC_FAIL;
|
||||||
} else if (memcmp(computed, expected, computedlen) != 0) {
|
} else {
|
||||||
fatal(testnum, expected, expectedlen, computed, computedlen);
|
if (memcmp(computed, expected, computedlen) != 0) {
|
||||||
result = TC_FAIL;
|
fatal(testnum, expected, expectedlen,
|
||||||
}
|
computed, computedlen);
|
||||||
|
result = TC_FAIL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue