1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2025-12-15 09:33:50 +01:00

test/unittest: cleanup most vera++ complains

This commit is contained in:
Karl Fessel 2022-10-27 16:11:19 +02:00
parent 578d328ff4
commit c29d2f1afb
21 changed files with 1146 additions and 1106 deletions

File diff suppressed because it is too large Load Diff

View File

@ -157,7 +157,8 @@ static void test_clif_decode_links(void)
"</sensors/light>;rt=\"light-lux\";if=sensor,"
"<http://www.example.com/sensors/t123>;"
"anchor=\"/sensors/temp\";rel=\"describedby\";sz=1234,"
"</t>;anchor=\"/sensors/temp\";rel=\"alternate\";a;s=\"This is \\\"escaped and has , \\\"\","
"</t>;anchor=\"/sensors/temp\";rel=\"alternate\";a;s=\""
"This is \\\"escaped and has , \\\"\","
"</riot/board>,</riot/info>;obs";
/* ordered expected types to be decoded */

View File

@ -215,7 +215,8 @@ static void test_bitarithm_bits_set_random(void)
static void test_bitarithm_bits_set_u32_random(void)
{
TEST_ASSERT_EQUAL_INT(21, bitarithm_bits_set_u32(4072524027)); /* Source: https://www.random.org/bytes */
TEST_ASSERT_EQUAL_INT(21, bitarithm_bits_set_u32(4072524027));
/* Source: https://www.random.org/bytes */
}
Test *tests_core_bitarithm_tests(void)

View File

@ -26,7 +26,8 @@ XFA_INIT_CONST(xfatest_t, xfatest_use_const);
XFA(xfatest_use, 0) xfatest_t _xfatest_use1 = { .val = 3333, .text = "xfatest_use1" };
XFA(xfatest_use, 0) xfatest_t _xfatest_use_again = { .val = 555, .text = "xfatest use again" };
XFA_CONST(xfatest_use_const, 0) xfatest_t _xfatest_use_const1 = { .val = 4444, .text = "xfatest_use_const1" };
XFA_CONST(xfatest_use_const, 0) xfatest_t _xfatest_use_const1 =
{ .val = 4444, .text = "xfatest_use_const1" };
int hack1;
/** @} */

View File

@ -19,8 +19,10 @@
#include "tests-core-xfa.h"
XFA(xfatest, 0) xfatest_t _xfatest2 = { .val = 0xbeef, .text = "another test string" };
XFA_CONST(xfatest_const, 0) xfatest_t _xfatest_const2 = { .val = 32444, .text = "const string xfa 2" };
XFA_CONST(xfatest_const, 0) xfatest_t _xfatest_const2 =
{ .val = 32444, .text = "const string xfa 2" };
XFA(xfatest_use, 0) xfatest_t _xfatest_use2 = { .val = 11111, .text = "xfatest_use2" };
XFA_CONST(xfatest_use_const, 0) xfatest_t _xfatest_use_const2 = { .val = 22222, .text = "xfatest_use_const2" };
XFA_CONST(xfatest_use_const, 0) xfatest_t _xfatest_use_const2 =
{ .val = 22222, .text = "xfatest_use_const2" };
/** @} */

View File

@ -121,7 +121,8 @@ static void test_frac_scale32(void)
if ((uint32_t)expected != actual) {
int32_t diff = actual - expected;
DEBUG("%" PRIu32 " * (%" PRIu32 " / %" PRIu32 ")"
" tmp %" PRIu64 " expect %" PRIu32 ", actual %" PRIu32 ", diff = %" PRId32 " shift=%u\n",
" tmp %" PRIu64 " expect %" PRIu32 ", actual %" PRIu32
", diff = %" PRId32 " shift=%u\n",
u32_test_values[i], num, den, tmp, (uint32_t)expected,
actual, diff, frac.shift);

View File

@ -55,7 +55,8 @@ static gcoap_listener_t listener_second = {
.next = NULL
};
static const char *resource_list_str = "</second/part>,</act/switch>,</sensor/temp>,</test/info/all>";
static const char *resource_list_str =
"</second/part>,</act/switch>,</sensor/temp>,</test/info/all>";
/*
* Client GET request success case. Test request generation.

View File

@ -71,11 +71,13 @@ static const char *_resultarray[TEST_CASES_NUM + 2] =
#define TEST5_HMAC "Test Using Larger Than Block-Size Key and Larger Than One Block-Size Data"
static const uint8_t _hmac_key1[]={
0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b
0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b,
0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b, 0x0b
};
static const uint8_t _hmac_key2[]= "Jefe";
static const uint8_t _hmac_key3[]={
0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c
0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c,
0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c, 0x0c
};
static const uint8_t _hmac_key4[]={
0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa, 0xaa,
@ -181,11 +183,16 @@ static void test_hashes_sha1(void)
TEST_ASSERT(calc_and_compare_hash2(_testarray[2], _resultarray[4]) == 0);
TEST_ASSERT(calc_and_compare_hash2(_testarray[3], _resultarray[5]) == 0);
TEST_ASSERT(calc_and_compare_hash_hmac(TEST1_HMAC, _resultarray_hmac[0], _hmac_key1, sizeof(_hmac_key1)) == 0);
TEST_ASSERT(calc_and_compare_hash_hmac(TEST2_HMAC, _resultarray_hmac[1], _hmac_key2, sizeof(_hmac_key2)) == 0);
TEST_ASSERT(calc_and_compare_hash_hmac(TEST3_HMAC, _resultarray_hmac[2], _hmac_key3, sizeof(_hmac_key3)) == 0);
TEST_ASSERT(calc_and_compare_hash_hmac(TEST4_HMAC, _resultarray_hmac[3], _hmac_key4, sizeof(_hmac_key4)) == 0);
TEST_ASSERT(calc_and_compare_hash_hmac(TEST5_HMAC, _resultarray_hmac[4], _hmac_key5, sizeof(_hmac_key5)) == 0);
TEST_ASSERT(calc_and_compare_hash_hmac(TEST1_HMAC, _resultarray_hmac[0],
_hmac_key1, sizeof(_hmac_key1)) == 0);
TEST_ASSERT(calc_and_compare_hash_hmac(TEST2_HMAC, _resultarray_hmac[1],
_hmac_key2, sizeof(_hmac_key2)) == 0);
TEST_ASSERT(calc_and_compare_hash_hmac(TEST3_HMAC, _resultarray_hmac[2],
_hmac_key3, sizeof(_hmac_key3)) == 0);
TEST_ASSERT(calc_and_compare_hash_hmac(TEST4_HMAC, _resultarray_hmac[3],
_hmac_key4, sizeof(_hmac_key4)) == 0);
TEST_ASSERT(calc_and_compare_hash_hmac(TEST5_HMAC, _resultarray_hmac[4],
_hmac_key5, sizeof(_hmac_key5)) == 0);
}
Test *tests_hashes_sha1_tests(void)

View File

@ -141,9 +141,11 @@ static void test_hashes_hmac_sha256_hash_PRF5(void)
static void test_hashes_hmac_sha256_hash_PRF6(void)
{
/* Test Case PRF-6: */
static const unsigned char strPRF6[] = "This is a test using a larger than block-size key and a "
static const unsigned char strPRF6[] =
"This is a test using a larger than block-size key and a "
"larger than block-size data. The key needs to be hashed "
"before being used by the HMAC algorithm.";
unsigned char longKey[131];
static unsigned char hmac[SHA256_DIGEST_LENGTH];
memset(longKey, 0xaa, sizeof(longKey));
@ -287,9 +289,11 @@ static void test_hashes_hmac_sha256_ite_hash_PRF6(void)
{
/* Test Case PRF-6: */
hmac_context_t ctx;
static const unsigned char strPRF6[] = "This is a test using a larger than block-size key and a "
static const unsigned char strPRF6[] =
"This is a test using a larger than block-size key and a "
"larger than block-size data. The key needs to be hashed "
"before being used by the HMAC algorithm.";
unsigned char longKey[131];
static unsigned char hmac[SHA256_DIGEST_LENGTH];
memset(longKey, 0xaa, sizeof(longKey));
@ -308,9 +312,12 @@ static void test_hashes_hmac_sha256_ite_hash_PRF6_split(void)
{
/* Test Case PRF-6: */
hmac_context_t ctx;
static const unsigned char strPRF6_1[] = "This is a test using a larger than block-size key and a ";
static const unsigned char strPRF6_2[] = "larger than block-size data. The key needs to be hashed ";
static const unsigned char strPRF6_3[] = "before being used by the HMAC algorithm.";
static const unsigned char strPRF6_1[] =
"This is a test using a larger than block-size key and a ";
static const unsigned char strPRF6_2[] =
"larger than block-size data. The key needs to be hashed ";
static const unsigned char strPRF6_3[] =
"before being used by the HMAC algorithm.";
unsigned char longKey[131];
static unsigned char hmac[SHA256_DIGEST_LENGTH];

View File

@ -204,7 +204,8 @@ static void test_hashes_sha256_hash_sequence_04(void)
static void test_hashes_sha256_hash_sequence_digits_letters(void)
{
static const char *teststring = "0123456789abcde-0123456789abcde-0123456789abcde-0123456789abcde-";
static const char *teststring =
"0123456789abcde-0123456789abcde-0123456789abcde-0123456789abcde-";
TEST_ASSERT(calc_and_compare_hash(teststring, hdigits_letters));
TEST_ASSERT(calc_and_compare_hash_wrapper(teststring, hdigits_letters));
}

View File

@ -303,7 +303,8 @@ static int calc_and_compare_hash_256(const uint8_t *msg, size_t msg_len, const u
}
static int calc_steps_and_compare_hash_256(const uint8_t *msg1, size_t msg1_len,
const uint8_t *msg2, size_t msg2_len, const uint8_t *expected)
const uint8_t *msg2, size_t msg2_len,
const uint8_t *expected)
{
static unsigned char hash[SHA3_256_DIGEST_LENGTH];
keccak_state_t state;
@ -326,7 +327,8 @@ static int calc_and_compare_hash_384(const uint8_t *msg, size_t msg_len, const u
}
static int calc_steps_and_compare_hash_384(const uint8_t *msg1, size_t msg1_len,
const uint8_t *msg2, size_t msg2_len, const uint8_t *expected)
const uint8_t *msg2, size_t msg2_len,
const uint8_t *expected)
{
static unsigned char hash[SHA3_384_DIGEST_LENGTH];
keccak_state_t state;
@ -349,7 +351,8 @@ static int calc_and_compare_hash_512(const uint8_t *msg, size_t msg_len, const u
}
static int calc_steps_and_compare_hash_512(const uint8_t *msg1, size_t msg1_len,
const uint8_t *msg2, size_t msg2_len, const uint8_t *expected)
const uint8_t *msg2, size_t msg2_len,
const uint8_t *expected)
{
static unsigned char hash[SHA3_512_DIGEST_LENGTH];
keccak_state_t state;

View File

@ -1031,7 +1031,8 @@ static void test_ipv6_addr_from_str__success6(void)
ipv6_addr_t result;
#ifdef MODULE_IPV4_ADDR
TEST_ASSERT_NOT_NULL(ipv6_addr_from_str(&result, "ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255"));
TEST_ASSERT_NOT_NULL(ipv6_addr_from_str(&result, "ffff:ffff:ffff:ffff:ffff:ffff"
":255.255.255.255"));
#else
TEST_ASSERT_NOT_NULL(ipv6_addr_from_str(&result, "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff"));
#endif
@ -1078,9 +1079,11 @@ static void test_ipv6_addr_from_buf__success(void)
ipv6_addr_t result;
#ifdef MODULE_IPV4_ADDR
TEST_ASSERT_NOT_NULL(ipv6_addr_from_buf(&result, "ffff:ffff:ffff:ffff:ffff:ffff:255.255.255.255%tap0", 45));
TEST_ASSERT_NOT_NULL(ipv6_addr_from_buf(&result, "ffff:ffff:ffff:ffff:ffff:ffff"
":255.255.255.255%tap0", 45));
#else
TEST_ASSERT_NOT_NULL(ipv6_addr_from_buf(&result, "ffff:ffff:ffff:ffff:ffff:ffff:ffff:ffff%tap0", 39));
TEST_ASSERT_NOT_NULL(ipv6_addr_from_buf(&result, "ffff:ffff:ffff:ffff:ffff:ffff"
":ffff:ffff%tap0", 39));
#endif
TEST_ASSERT(ipv6_addr_equal(&a, &result));
}

View File

@ -622,7 +622,6 @@ static void test_nanocoap__option_remove_delta_512(void)
__test_option_remove(512U);
}
static void test_nanocoap__option_remove_no_payload(void)
{
/* header 4, token 2, option length 3, 0 payload marker 1 */

View File

@ -150,7 +150,8 @@ static void test_pktbuf_add__pkt_NOT_NULL__data_NULL__size_not_0(void)
TEST_ASSERT_NOT_NULL(next);
TEST_ASSERT_NOT_NULL((pkt = gnrc_pktbuf_add(next, NULL, sizeof(TEST_STRING8), GNRC_NETTYPE_TEST)));
TEST_ASSERT_NOT_NULL((pkt = gnrc_pktbuf_add(next, NULL, sizeof(TEST_STRING8),
GNRC_NETTYPE_TEST)));
TEST_ASSERT(pkt->next == next);
TEST_ASSERT_NOT_NULL(pkt->data);
@ -232,7 +233,8 @@ static void test_pktbuf_add__packed_struct(void)
34, -4469, 149699748, -46590430597
};
test_pktbuf_struct_t *data_cpy;
gnrc_pktsnip_t *pkt = gnrc_pktbuf_add(NULL, &data, sizeof(test_pktbuf_struct_t), GNRC_NETTYPE_TEST);
gnrc_pktsnip_t *pkt = gnrc_pktbuf_add(NULL, &data, sizeof(test_pktbuf_struct_t),
GNRC_NETTYPE_TEST);
data_cpy = (test_pktbuf_struct_t *)pkt->data;
TEST_ASSERT_EQUAL_INT(data.u8, data_cpy->u8);
@ -509,7 +511,8 @@ static void test_pktbuf_realloc_data__size_0(void)
TEST_ASSERT(gnrc_pktbuf_is_empty());
}
#ifndef MODULE_GNRC_PKTBUF_MALLOC /* CONFIG_GNRC_PKTBUF_SIZE does not apply for gnrc_pktbuf_malloc */
#ifndef MODULE_GNRC_PKTBUF_MALLOC /* CONFIG_GNRC_PKTBUF_SIZE does not*/
/* apply for gnrc_pktbuf_malloc */
static void test_pktbuf_realloc_data__memfull(void)
{
gnrc_pktsnip_t *pkt = gnrc_pktbuf_add(NULL, NULL, sizeof(TEST_STRING8), GNRC_NETTYPE_TEST);

View File

@ -67,12 +67,16 @@ static void test_gnrc_priority_pktqueue_push_one(void)
TEST_ASSERT((gnrc_priority_pktqueue_node_t *)(pkt_queue.first) == &elem);
TEST_ASSERT_NULL(((gnrc_priority_pktqueue_node_t *)(pkt_queue.first))->next);
TEST_ASSERT_EQUAL_INT(TEST_UINT32, ((gnrc_priority_pktqueue_node_t *)(pkt_queue.first))->priority);
TEST_ASSERT_EQUAL_INT(TEST_UINT32,
((gnrc_priority_pktqueue_node_t *)(pkt_queue.first))->priority);
TEST_ASSERT_EQUAL_INT(1, ((gnrc_priority_pktqueue_node_t *)(pkt_queue.first))->pkt->users);
TEST_ASSERT_NULL(((gnrc_priority_pktqueue_node_t *)(pkt_queue.first))->pkt->next);
TEST_ASSERT_EQUAL_STRING(TEST_STRING8, ((gnrc_priority_pktqueue_node_t *)(pkt_queue.first))->pkt->data);
TEST_ASSERT_EQUAL_INT(sizeof(TEST_STRING8), ((gnrc_priority_pktqueue_node_t *)(pkt_queue.first))->pkt->size);
TEST_ASSERT_EQUAL_INT(GNRC_NETTYPE_UNDEF, ((gnrc_priority_pktqueue_node_t *)(pkt_queue.first))->pkt->type);
TEST_ASSERT_EQUAL_STRING(TEST_STRING8,
((gnrc_priority_pktqueue_node_t *)(pkt_queue.first))->pkt->data);
TEST_ASSERT_EQUAL_INT(sizeof(TEST_STRING8),
((gnrc_priority_pktqueue_node_t *)(pkt_queue.first))->pkt->size);
TEST_ASSERT_EQUAL_INT(GNRC_NETTYPE_UNDEF,
((gnrc_priority_pktqueue_node_t *)(pkt_queue.first))->pkt->type);
}
static void test_gnrc_priority_pktqueue_push_two(void)
@ -92,14 +96,21 @@ static void test_gnrc_priority_pktqueue_push_two(void)
TEST_ASSERT_EQUAL_INT(1, ((gnrc_priority_pktqueue_node_t *)(pkt_queue.first))->next->priority);
TEST_ASSERT_EQUAL_INT(1, ((gnrc_priority_pktqueue_node_t *)(pkt_queue.first))->pkt->users);
TEST_ASSERT_NULL(((gnrc_priority_pktqueue_node_t *)(pkt_queue.first))->pkt->next);
TEST_ASSERT_EQUAL_STRING(TEST_STRING16, ((gnrc_priority_pktqueue_node_t *)(pkt_queue.first))->pkt->data);
TEST_ASSERT_EQUAL_INT(sizeof(TEST_STRING16), ((gnrc_priority_pktqueue_node_t *)(pkt_queue.first))->pkt->size);
TEST_ASSERT_EQUAL_INT(GNRC_NETTYPE_UNDEF, ((gnrc_priority_pktqueue_node_t *)(pkt_queue.first))->pkt->type);
TEST_ASSERT_EQUAL_INT(1, ((gnrc_priority_pktqueue_node_t *)(pkt_queue.first))->next->pkt->users);
TEST_ASSERT_EQUAL_STRING(TEST_STRING16,
((gnrc_priority_pktqueue_node_t *)(pkt_queue.first))->pkt->data);
TEST_ASSERT_EQUAL_INT(sizeof(TEST_STRING16),
((gnrc_priority_pktqueue_node_t *)(pkt_queue.first))->pkt->size);
TEST_ASSERT_EQUAL_INT(GNRC_NETTYPE_UNDEF,
((gnrc_priority_pktqueue_node_t *)(pkt_queue.first))->pkt->type);
TEST_ASSERT_EQUAL_INT(1,
((gnrc_priority_pktqueue_node_t *)(pkt_queue.first))->next->pkt->users);
TEST_ASSERT_NULL(((gnrc_priority_pktqueue_node_t *)(pkt_queue.first))->next->pkt->next);
TEST_ASSERT_EQUAL_STRING(TEST_STRING8, ((gnrc_priority_pktqueue_node_t *)(pkt_queue.first))->next->pkt->data);
TEST_ASSERT_EQUAL_INT(sizeof(TEST_STRING8), ((gnrc_priority_pktqueue_node_t *)(pkt_queue.first))->next->pkt->size);
TEST_ASSERT_EQUAL_INT(GNRC_NETTYPE_UNDEF, ((gnrc_priority_pktqueue_node_t *)(pkt_queue.first))->next->pkt->type);
TEST_ASSERT_EQUAL_STRING(TEST_STRING8,
((gnrc_priority_pktqueue_node_t *)(pkt_queue.first))->next->pkt->data);
TEST_ASSERT_EQUAL_INT(sizeof(TEST_STRING8),
((gnrc_priority_pktqueue_node_t *)(pkt_queue.first))->next->pkt->size);
TEST_ASSERT_EQUAL_INT(GNRC_NETTYPE_UNDEF,
((gnrc_priority_pktqueue_node_t *)(pkt_queue.first))->next->pkt->type);
}
static void test_gnrc_priority_pktqueue_length(void)

View File

@ -54,7 +54,6 @@
"path/that/doesnt/fit/inside/sixtyfour/" \
"chars/of/buffer/space"
static char addr[CONFIG_SOCK_URLPATH_MAXLEN];
static char urlpath[CONFIG_SOCK_URLPATH_MAXLEN];
@ -160,7 +159,6 @@ static void test_sock_util_urlsplit__null_path_buffer(void)
TEST_ASSERT_EQUAL_STRING(TEST_URL_LOCALPART, (char*)urlpath);
}
static void test_sock_util_str2ep__ipv6_noport(void)
{
sock_udp_ep_t ep;
@ -199,7 +197,6 @@ static void test_sock_util_str2ep__ipv4_bracketed(void)
TEST_ASSERT_EQUAL_INT(-EINVAL, sock_udp_str2ep(&ep, test_str));
}
static void test_sock_util_str2ep__invalid_bracket_missing(void)
{
sock_udp_ep_t ep;

View File

@ -151,7 +151,8 @@ static void test_vfs_constfs_read_lseek(void)
TEST_ASSERT_EQUAL_INT(sizeof(str_data) / 2, pos);
nbytes = vfs_read(fd, strbuf, sizeof(strbuf));
TEST_ASSERT_EQUAL_INT((sizeof(str_data) + 1) / 2, nbytes); /* + 1 for rounding up */
TEST_ASSERT_EQUAL_STRING((const char *)&str_data[sizeof(str_data) / 2], (const char *)&strbuf[0]);
TEST_ASSERT_EQUAL_STRING((const char *)&str_data[sizeof(str_data) / 2],
(const char *)&strbuf[0]);
/* lseek to near the end */
memset(strbuf, '\0', sizeof(strbuf));
@ -159,7 +160,8 @@ static void test_vfs_constfs_read_lseek(void)
TEST_ASSERT_EQUAL_INT(sizeof(str_data) - 1, pos);
nbytes = vfs_read(fd, strbuf, sizeof(strbuf));
TEST_ASSERT_EQUAL_INT(1, nbytes);
TEST_ASSERT_EQUAL_STRING((const char *)&str_data[sizeof(str_data) - 1], (const char *)&strbuf[0]);
TEST_ASSERT_EQUAL_STRING((const char *)&str_data[sizeof(str_data) - 1],
(const char *)&strbuf[0]);
res = vfs_fcntl(fd, F_GETFL, 0);
TEST_ASSERT_EQUAL_INT(O_RDONLY, res);