1
0
mirror of https://github.com/RIOT-OS/RIOT.git synced 2024-12-29 04:50:03 +01:00

Merge pull request #18807 from kfessel/p-cleanup-vera-unittest

test/unittest: cleanup most vera++ complains
This commit is contained in:
Karl Fessel 2022-10-28 14:40:05 +02:00 committed by GitHub
commit 754e272d74
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
21 changed files with 1146 additions and 1106 deletions

File diff suppressed because it is too large Load Diff

View File

@ -108,7 +108,7 @@ static void test_clif_encode_links(void)
}
pos += res;
res = clif_encode_link(&links[i],NULL, 0);
res = clif_encode_link(&links[i], NULL, 0);
if (res <= 0) {
break;
}
@ -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

@ -146,7 +146,7 @@ static void tests_core_ringbuffer_remove_underflow(void)
ringbuffer_add_one(&buf, 0);
ringbuffer_add_one(&buf, 1);
ringbuffer_remove(&buf,1);
ringbuffer_remove(&buf, 1);
TEST_ASSERT_EQUAL_INT(1, ringbuffer_get_one(&buf));
TEST_ASSERT_EQUAL_INT(1, ringbuffer_empty(&buf));

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

@ -250,7 +250,7 @@ static void test_fib_06_remove_one_entry(void)
TEST_ASSERT_EQUAL_INT(20, fib_get_num_used_entries(&test_fib_table));
TEST_ASSERT_EQUAL_INT(20, universal_address_get_num_used_entries());
fib_remove_entry(&test_fib_table, (uint8_t *)addr_dst,add_buf_size - 1);
fib_remove_entry(&test_fib_table, (uint8_t *)addr_dst, add_buf_size - 1);
#if (TEST_FIB_SHOW_OUTPUT == 1)
fib_print_fib_table(&test_fib_table);
@ -725,7 +725,7 @@ static void test_fib_17_get_entry_set(void)
size_t arr_size = 20;
fib_destination_set_entry_t arr_dst[arr_size];
char prefix[addr_buf_size];
memset(prefix,0, addr_buf_size);
memset(prefix, 0, addr_buf_size);
/* cppcheck-suppress redundantCopy
* (reason: prefix is set to all 0 before adding an address) */
snprintf(prefix, addr_buf_size, "Test address 1");
@ -739,7 +739,7 @@ static void test_fib_17_get_entry_set(void)
TEST_ASSERT_EQUAL_INT(10, arr_size);
arr_size = 20;
memset(prefix,0, addr_buf_size);
memset(prefix, 0, addr_buf_size);
/* cppcheck-suppress redundantCopy
* (reason: prefix is set to all 0 before adding an address) */
snprintf(prefix, addr_buf_size, "Test address 0");
@ -768,8 +768,8 @@ static void test_fib_17_get_entry_set(void)
#if (TEST_FIB_SHOW_OUTPUT == 1)
puts("");
for(size_t i = 0; i < arr_size; ++i) {
for( size_t j = 0; j < arr_dst[i].dest_size; ++j) {
for (size_t i = 0; i < arr_size; ++i) {
for (size_t j = 0; j < arr_dst[i].dest_size; ++j) {
printf("%c", (char)arr_dst[i].dest[j]);
}
puts("");
@ -796,7 +796,7 @@ static void test_fib_18_get_next_hop_invalid_parameters(void)
_fill_FIB_multiple(entries, 11);
int ret = fib_get_next_hop(&test_fib_table, NULL, NULL,
NULL, NULL,NULL, add_buf_size - 1, 0x13);
NULL, NULL, NULL, add_buf_size - 1, 0x13);
TEST_ASSERT_EQUAL_INT(-EINVAL, ret);
@ -839,7 +839,7 @@ static void test_fib_19_default_gateway(void)
snprintf(addr_lookup, add_buf_size, "Some address X1");
/* set the bytes to 0x01..0x10 of the next-hop */
for(size_t i = 0; i < add_buf_size; i++) {
for (size_t i = 0; i < add_buf_size; i++) {
addr_nxt[i] = i+1;
}
@ -861,7 +861,7 @@ static void test_fib_19_default_gateway(void)
memset(addr_nxt_hop, 0, add_buf_size);
/* set the bytes to 0x02..0x11 of the new next-hop for the default gateway */
for(size_t i = 0; i < add_buf_size; ++i) {
for (size_t i = 0; i < add_buf_size; ++i) {
addr_nxt[i] = i+2;
}
@ -906,17 +906,17 @@ static void test_fib_20_replace_prefix(void)
memset(addr_lookup, 0, add_buf_size);
/* set the bytes to 0x01..0x10 of the next-hop */
for(size_t i = 0; i < add_buf_size; i++) {
for (size_t i = 0; i < add_buf_size; i++) {
addr_nxt[i] = i+1;
}
/* set the bytes to 0x01..0x08 of the destination prefix */
for(size_t i = 0; i < add_buf_size/2; i++) {
for (size_t i = 0; i < add_buf_size/2; i++) {
addr_dst[i] = i+1;
}
/* set the bytes to 0x01..0x0e of the lookup address */
for(size_t i = 0; i < 14; i++) {
for (size_t i = 0; i < 14; i++) {
addr_lookup[i] = i+1;
}
@ -942,12 +942,12 @@ static void test_fib_20_replace_prefix(void)
memset(addr_nxt_hop, 0, add_buf_size);
/* set the bytes to 0x02..0x11 of the new next-hop */
for(size_t i = 0; i < add_buf_size; ++i) {
for (size_t i = 0; i < add_buf_size; ++i) {
addr_nxt[i] = i+2;
}
/* set the bytes to 0x01..0x0d of the new destination prefix */
for(size_t i = 0; i < 13; i++) {
for (size_t i = 0; i < 13; i++) {
addr_dst[i] = i+1;
}

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

@ -615,7 +615,7 @@ static void test_nib_ft_del__unknown(void)
iface++;
}
gnrc_ipv6_nib_ft_del(&dst, dst_len);
while(gnrc_ipv6_nib_ft_iter(NULL, 0, &iter_state, &fte)) {
while (gnrc_ipv6_nib_ft_iter(NULL, 0, &iter_state, &fte)) {
count++;
}
TEST_ASSERT_EQUAL_INT(MAX_NUMOF, count);
@ -636,7 +636,7 @@ static void test_nib_ft_del__success(void)
TEST_ASSERT_EQUAL_INT(0, gnrc_ipv6_nib_ft_add(&dst, GLOBAL_PREFIX_LEN,
&next_hop, IFACE, 0));
gnrc_ipv6_nib_ft_del(&dst, GLOBAL_PREFIX_LEN);
TEST_ASSERT(!gnrc_ipv6_nib_ft_iter(NULL ,0, &iter_state, &fte));
TEST_ASSERT(!gnrc_ipv6_nib_ft_iter(NULL, 0, &iter_state, &fte));
}
/**

View File

@ -93,13 +93,13 @@ static void test_gnrc_mac_queue_tx_packet(void)
#if CONFIG_GNRC_MAC_NEIGHBOR_COUNT != 0
gnrc_pktsnip_t *pkt_head;
TEST_ASSERT(gnrc_mac_queue_tx_packet(&tx,1,pkt1));
TEST_ASSERT(gnrc_mac_queue_tx_packet(&tx, 1, pkt1));
pkt_head = gnrc_priority_pktqueue_head(&tx.neighbors[1].queue);
TEST_ASSERT(pkt_head == pkt1);
TEST_ASSERT(1 == gnrc_priority_pktqueue_length(&tx.neighbors[1].queue));
TEST_ASSERT_EQUAL_STRING(TEST_STRING4, pkt_head->next->data);
TEST_ASSERT(gnrc_mac_queue_tx_packet(&tx,0,pkt2));
TEST_ASSERT(gnrc_mac_queue_tx_packet(&tx, 0, pkt2));
pkt_head = gnrc_priority_pktqueue_head(&tx.neighbors[1].queue);
TEST_ASSERT(pkt_head == pkt2);
TEST_ASSERT(2 == gnrc_priority_pktqueue_length(&tx.neighbors[1].queue));
@ -114,13 +114,13 @@ static void test_gnrc_mac_queue_tx_packet(void)
TEST_ASSERT(pkt_head == pkt1);
TEST_ASSERT_EQUAL_STRING(TEST_STRING4, pkt_head->next->data);
TEST_ASSERT(gnrc_mac_queue_tx_packet(&tx,0,pkt3));
TEST_ASSERT(gnrc_mac_queue_tx_packet(&tx, 0, pkt3));
pkt_head = gnrc_priority_pktqueue_head(&tx.neighbors[2].queue);
TEST_ASSERT(pkt_head == pkt3);
TEST_ASSERT(1 == gnrc_priority_pktqueue_length(&tx.neighbors[2].queue));
TEST_ASSERT_EQUAL_STRING(TEST_STRING16, pkt_head->next->data);
TEST_ASSERT(gnrc_mac_queue_tx_packet(&tx,0,pkt_bcast));
TEST_ASSERT(gnrc_mac_queue_tx_packet(&tx, 0, pkt_bcast));
pkt_head = gnrc_priority_pktqueue_head(&tx.neighbors[0].queue);
TEST_ASSERT(pkt_head == pkt_bcast);
TEST_ASSERT(1 == gnrc_priority_pktqueue_length(&tx.neighbors[0].queue));
@ -128,26 +128,26 @@ static void test_gnrc_mac_queue_tx_packet(void)
#else
TEST_ASSERT(gnrc_mac_queue_tx_packet(&tx,1,pkt1));
TEST_ASSERT(gnrc_mac_queue_tx_packet(&tx, 1, pkt1));
TEST_ASSERT(1 == gnrc_priority_pktqueue_length(&tx.queue));
gnrc_pktsnip_t *pkt_head;
pkt_head = gnrc_priority_pktqueue_head(&tx.queue);
TEST_ASSERT(pkt_head == pkt1);
TEST_ASSERT_EQUAL_STRING(TEST_STRING4, pkt_head->next->data);
TEST_ASSERT(gnrc_mac_queue_tx_packet(&tx,1,pkt2));
TEST_ASSERT(gnrc_mac_queue_tx_packet(&tx, 1, pkt2));
TEST_ASSERT(2 == gnrc_priority_pktqueue_length(&tx.queue));
pkt_head = gnrc_priority_pktqueue_head(&tx.queue);
TEST_ASSERT(pkt_head == pkt1);
TEST_ASSERT_EQUAL_STRING(TEST_STRING4, pkt_head->next->data);
TEST_ASSERT(gnrc_mac_queue_tx_packet(&tx,0,pkt3));
TEST_ASSERT(gnrc_mac_queue_tx_packet(&tx, 0, pkt3));
TEST_ASSERT(3 == gnrc_priority_pktqueue_length(&tx.queue));
pkt_head = gnrc_priority_pktqueue_head(&tx.queue);
TEST_ASSERT(pkt_head == pkt3);
TEST_ASSERT_EQUAL_STRING(TEST_STRING16, pkt_head->next->data);
TEST_ASSERT(gnrc_mac_queue_tx_packet(&tx,0,pkt_bcast));
TEST_ASSERT(gnrc_mac_queue_tx_packet(&tx, 0, pkt_bcast));
TEST_ASSERT(4 == gnrc_priority_pktqueue_length(&tx.queue));
pkt_head = gnrc_priority_pktqueue_head(&tx.queue);
TEST_ASSERT(pkt_head == pkt3);
@ -198,7 +198,7 @@ static void test_gnrc_mac_queue_rx_packet(void)
gnrc_pktsnip_t *pkt3 = gnrc_pktbuf_add(NULL, TEST_STRING16, sizeof(TEST_STRING16),
GNRC_NETTYPE_UNDEF);
TEST_ASSERT(gnrc_mac_queue_rx_packet(&rx,1,pkt1));
TEST_ASSERT(gnrc_mac_queue_rx_packet(&rx, 1, pkt1));
TEST_ASSERT(1 == gnrc_priority_pktqueue_length(&rx.queue));
gnrc_pktsnip_t *pkt_head;
@ -207,7 +207,7 @@ static void test_gnrc_mac_queue_rx_packet(void)
TEST_ASSERT(pkt_head == pkt1);
TEST_ASSERT_EQUAL_STRING(TEST_STRING4, pkt_head->data);
TEST_ASSERT(gnrc_mac_queue_rx_packet(&rx,1,pkt2));
TEST_ASSERT(gnrc_mac_queue_rx_packet(&rx, 1, pkt2));
TEST_ASSERT(2 == gnrc_priority_pktqueue_length(&rx.queue));
pkt_head = gnrc_priority_pktqueue_head(&rx.queue);
@ -215,7 +215,7 @@ static void test_gnrc_mac_queue_rx_packet(void)
TEST_ASSERT(pkt_head == pkt1);
TEST_ASSERT_EQUAL_STRING(TEST_STRING4, pkt_head->data);
TEST_ASSERT(gnrc_mac_queue_rx_packet(&rx,0,pkt3));
TEST_ASSERT(gnrc_mac_queue_rx_packet(&rx, 0, pkt3));
TEST_ASSERT(3 == gnrc_priority_pktqueue_length(&rx.queue));
pkt_head = gnrc_priority_pktqueue_head(&rx.queue);

View File

@ -64,18 +64,20 @@ static const char *_resultarray[TEST_CASES_NUM + 2] =
#define TEST_CASES_HMAC_NUM (5)
#define TEST1_HMAC "Hi There"
#define TEST2_HMAC "what do ya want for nothing?"
#define TEST1_HMAC "Hi There"
#define TEST2_HMAC "what do ya want for nothing?"
#define TEST3_HMAC "Test With Truncation"
#define TEST4_HMAC "Test Using Larger Than Block-Size Key - Hash Key First"
#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 "
"larger than block-size data. The key needs to be hashed "
"before being used by the HMAC algorithm.";
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 "
"larger than block-size data. The key needs to be hashed "
"before being used by the HMAC algorithm.";
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

@ -50,7 +50,7 @@ static void test_gnrc_priority_pktqueue_node_init(void)
gnrc_pktsnip_t pkt = PKT_INIT_ELEM_STATIC_DATA(TEST_STRING8, NULL);
gnrc_priority_pktqueue_node_t elem;
gnrc_priority_pktqueue_node_init(&elem,TEST_UINT32,&pkt);
gnrc_priority_pktqueue_node_init(&elem, TEST_UINT32, &pkt);
TEST_ASSERT_NULL(elem.next);
TEST_ASSERT(elem.pkt == &pkt);
@ -61,26 +61,30 @@ static void test_gnrc_priority_pktqueue_node_init(void)
static void test_gnrc_priority_pktqueue_push_one(void)
{
gnrc_pktsnip_t pkt = PKT_INIT_ELEM_STATIC_DATA(TEST_STRING8, NULL);
gnrc_priority_pktqueue_node_t elem = PRIORITY_PKTQUEUE_NODE_INIT(TEST_UINT32,&pkt);
gnrc_priority_pktqueue_node_t elem = PRIORITY_PKTQUEUE_NODE_INIT(TEST_UINT32, &pkt);
gnrc_priority_pktqueue_push(&pkt_queue,&elem);
gnrc_priority_pktqueue_push(&pkt_queue, &elem);
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)
{
gnrc_pktsnip_t pkt1 = PKT_INIT_ELEM_STATIC_DATA(TEST_STRING8, NULL);
gnrc_pktsnip_t pkt2 = PKT_INIT_ELEM_STATIC_DATA(TEST_STRING16, NULL);
gnrc_priority_pktqueue_node_t elem1 = PRIORITY_PKTQUEUE_NODE_INIT(1,&pkt1);
gnrc_priority_pktqueue_node_t elem2 = PRIORITY_PKTQUEUE_NODE_INIT(0,&pkt2);
gnrc_priority_pktqueue_node_t elem1 = PRIORITY_PKTQUEUE_NODE_INIT(1, &pkt1);
gnrc_priority_pktqueue_node_t elem2 = PRIORITY_PKTQUEUE_NODE_INIT(0, &pkt2);
gnrc_priority_pktqueue_push(&pkt_queue, &elem1);
gnrc_priority_pktqueue_push(&pkt_queue, &elem2);
@ -92,22 +96,29 @@ 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)
{
gnrc_pktsnip_t pkt1 = PKT_INIT_ELEM_STATIC_DATA(TEST_STRING8, NULL);
gnrc_pktsnip_t pkt2 = PKT_INIT_ELEM_STATIC_DATA(TEST_STRING16, NULL);
gnrc_priority_pktqueue_node_t elem1 = PRIORITY_PKTQUEUE_NODE_INIT(1,&pkt1);
gnrc_priority_pktqueue_node_t elem2 = PRIORITY_PKTQUEUE_NODE_INIT(0,&pkt2);
gnrc_priority_pktqueue_node_t elem1 = PRIORITY_PKTQUEUE_NODE_INIT(1, &pkt1);
gnrc_priority_pktqueue_node_t elem2 = PRIORITY_PKTQUEUE_NODE_INIT(0, &pkt2);
TEST_ASSERT_EQUAL_INT(0, gnrc_priority_pktqueue_length(&pkt_queue));
@ -127,8 +138,8 @@ static void test_gnrc_priority_pktqueue_flush(void)
TEST_ASSERT_NOT_NULL(pkt1);
TEST_ASSERT_NOT_NULL(pkt2);
gnrc_priority_pktqueue_node_t elem1 = PRIORITY_PKTQUEUE_NODE_INIT(1,pkt1);
gnrc_priority_pktqueue_node_t elem2 = PRIORITY_PKTQUEUE_NODE_INIT(0,pkt2);
gnrc_priority_pktqueue_node_t elem1 = PRIORITY_PKTQUEUE_NODE_INIT(1, pkt1);
gnrc_priority_pktqueue_node_t elem2 = PRIORITY_PKTQUEUE_NODE_INIT(0, pkt2);
gnrc_priority_pktqueue_push(&pkt_queue, &elem1);
gnrc_priority_pktqueue_push(&pkt_queue, &elem2);
@ -151,9 +162,9 @@ static void test_gnrc_priority_pktqueue_head(void)
TEST_ASSERT_NOT_NULL(pkt2);
TEST_ASSERT_NOT_NULL(pkt3);
gnrc_priority_pktqueue_node_t elem1 = PRIORITY_PKTQUEUE_NODE_INIT(1,pkt1);
gnrc_priority_pktqueue_node_t elem2 = PRIORITY_PKTQUEUE_NODE_INIT(1,pkt2);
gnrc_priority_pktqueue_node_t elem3 = PRIORITY_PKTQUEUE_NODE_INIT(0,pkt3);
gnrc_priority_pktqueue_node_t elem1 = PRIORITY_PKTQUEUE_NODE_INIT(1, pkt1);
gnrc_priority_pktqueue_node_t elem2 = PRIORITY_PKTQUEUE_NODE_INIT(1, pkt2);
gnrc_priority_pktqueue_node_t elem3 = PRIORITY_PKTQUEUE_NODE_INIT(0, pkt3);
gnrc_pktsnip_t *head = gnrc_priority_pktqueue_head(&pkt_queue);
TEST_ASSERT_NULL(head);
@ -194,8 +205,8 @@ static void test_gnrc_priority_pktqueue_pop(void)
{
gnrc_pktsnip_t pkt1 = PKT_INIT_ELEM_STATIC_DATA(TEST_STRING8, NULL);
gnrc_pktsnip_t pkt2 = PKT_INIT_ELEM_STATIC_DATA(TEST_STRING16, NULL);
gnrc_priority_pktqueue_node_t elem1 = PRIORITY_PKTQUEUE_NODE_INIT(1,&pkt1);
gnrc_priority_pktqueue_node_t elem2 = PRIORITY_PKTQUEUE_NODE_INIT(0,&pkt2);
gnrc_priority_pktqueue_node_t elem1 = PRIORITY_PKTQUEUE_NODE_INIT(1, &pkt1);
gnrc_priority_pktqueue_node_t elem2 = PRIORITY_PKTQUEUE_NODE_INIT(0, &pkt2);
gnrc_pktsnip_t *res;
gnrc_pktsnip_t *head;
@ -207,7 +218,7 @@ static void test_gnrc_priority_pktqueue_pop(void)
TEST_ASSERT(res == &pkt2);
TEST_ASSERT_NULL(elem2.pkt);
TEST_ASSERT_NULL(elem2.next);
TEST_ASSERT_EQUAL_INT(0,elem2.priority);
TEST_ASSERT_EQUAL_INT(0, elem2.priority);
TEST_ASSERT((gnrc_priority_pktqueue_node_t *)(pkt_queue.first) == &elem1);
TEST_ASSERT_EQUAL_INT(1, ((gnrc_priority_pktqueue_node_t *)(pkt_queue.first))->priority);
TEST_ASSERT_EQUAL_INT(1, res->users);
@ -221,7 +232,7 @@ static void test_gnrc_priority_pktqueue_pop(void)
TEST_ASSERT_NULL(pkt_queue.first);
TEST_ASSERT_NULL(elem1.pkt);
TEST_ASSERT_NULL(elem1.next);
TEST_ASSERT_EQUAL_INT(0,elem1.priority);
TEST_ASSERT_EQUAL_INT(0, elem1.priority);
TEST_ASSERT(res == &pkt1);
TEST_ASSERT_EQUAL_INT(1, res->users);
TEST_ASSERT_NULL(res->next);

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);