tests: common: fix code style

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
This commit is contained in:
Anas Nashif 2017-06-16 21:58:25 -04:00 committed by Kumar Gala
commit 072c3d110a
9 changed files with 93 additions and 93 deletions

View file

@ -91,7 +91,7 @@ void atomic_test(void)
for (i = 0; i < 32; i++) {
target = 0x0F0F0F0F;
zassert_true(!!(atomic_test_bit(&target, i) == !!(target & (1 << i))),
"atomic_test_bit");
"atomic_test_bit");
}
/* atomic_test_and_clear_bit() */
@ -99,7 +99,7 @@ void atomic_test(void)
orig = 0x0F0F0F0F;
target = orig;
zassert_true(!!(atomic_test_and_clear_bit(&target, i)) == !!(orig & (1 << i)),
"atomic_test_and_clear_bit");
"atomic_test_and_clear_bit");
zassert_true(target == (orig & ~(1 << i)), "atomic_test_and_clear_bit");
}
@ -108,7 +108,7 @@ void atomic_test(void)
orig = 0x0F0F0F0F;
target = orig;
zassert_true(!!(atomic_test_and_set_bit(&target, i)) == !!(orig & (1 << i)),
"atomic_test_and_set_bit");
"atomic_test_and_set_bit");
zassert_true(target == (orig | (1 << i)), "atomic_test_and_set_bit");
}

View file

@ -12,39 +12,39 @@
void byteorder_test_memcpy_swap(void)
{
u8_t buf_orig[8] = { 0x00, 0x01, 0x02, 0x03,
0x04, 0x05, 0x06, 0x07 };
0x04, 0x05, 0x06, 0x07 };
u8_t buf_chk[8] = { 0x07, 0x06, 0x05, 0x04,
0x03, 0x02, 0x01, 0x00 };
0x03, 0x02, 0x01, 0x00 };
u8_t buf_dst[8] = { 0 };
sys_memcpy_swap(buf_dst, buf_orig, 8);
zassert_true((memcmp(buf_dst, buf_chk, 8) == 0),
"Swap memcpy failed");
"Swap memcpy failed");
sys_memcpy_swap(buf_dst, buf_chk, 8);
zassert_true((memcmp(buf_dst, buf_orig, 8) == 0),
"Swap memcpy failed");
"Swap memcpy failed");
}
void byteorder_test_mem_swap(void)
{
u8_t buf_orig_1[8] = { 0x00, 0x01, 0x02, 0x03,
0x04, 0x05, 0x06, 0x07 };
0x04, 0x05, 0x06, 0x07 };
u8_t buf_orig_2[11] = { 0x00, 0x01, 0x02, 0x03,
0x04, 0x05, 0x06, 0x07,
0x08, 0x09, 0xa0 };
0x04, 0x05, 0x06, 0x07,
0x08, 0x09, 0xa0 };
u8_t buf_chk_1[8] = { 0x07, 0x06, 0x05, 0x04,
0x03, 0x02, 0x01, 0x00 };
0x03, 0x02, 0x01, 0x00 };
u8_t buf_chk_2[11] = { 0xa0, 0x09, 0x08, 0x07,
0x06, 0x05, 0x04, 0x03,
0x02, 0x01, 0x00 };
0x06, 0x05, 0x04, 0x03,
0x02, 0x01, 0x00 };
sys_mem_swap(buf_orig_1, 8);
zassert_true((memcmp(buf_orig_1, buf_chk_1, 8) == 0),
"Swapping buffer failed");
"Swapping buffer failed");
sys_mem_swap(buf_orig_2, 11);
zassert_true((memcmp(buf_orig_2, buf_chk_2, 11) == 0),
"Swapping buffer failed");
"Swapping buffer failed");
}

View file

@ -6,11 +6,11 @@
#include <ztest.h>
#define ALIGN_MS_BOUNDARY \
do {\
u32_t t = k_uptime_get_32();\
while (t == k_uptime_get_32())\
;\
#define ALIGN_MS_BOUNDARY \
do { \
u32_t t = k_uptime_get_32(); \
while (t == k_uptime_get_32()) \
; \
} while (0)
static void tclock_uptime(void)
@ -58,7 +58,7 @@ static void tclock_cycle(void)
c32 = k_cycle_get_32();
/*break if cycle counter wrap around*/
while (k_cycle_get_32() > c32 &&
k_cycle_get_32() < (c32 + sys_clock_hw_cycles_per_tick))
k_cycle_get_32() < (c32 + sys_clock_hw_cycles_per_tick))
;
/**TESTPOINT: cycle/uptime cross check*/
@ -72,10 +72,10 @@ static void tclock_cycle(void)
if (c1 > c0) {
/* delta cycle should be greater than 1 milli-second*/
zassert_true((c1 - c0) >
(sys_clock_hw_cycles_per_sec / MSEC_PER_SEC), NULL);
(sys_clock_hw_cycles_per_sec / MSEC_PER_SEC), NULL);
/* delta NS should be greater than 1 milli-second */
zassert_true(SYS_CLOCK_HW_CYCLES_TO_NS(c1 - c0) >
(NSEC_PER_SEC / MSEC_PER_SEC), NULL);
(NSEC_PER_SEC / MSEC_PER_SEC), NULL);
}
}

View file

@ -171,30 +171,30 @@ void dlist_test(void)
/* Appending node 1 */
sys_dlist_append(&test_list, &test_node_1.node);
zassert_true((verify_content_amount(&test_list, 1)),
"test_list has wrong content");
"test_list has wrong content");
zassert_true((verify_tail_head(&test_list, &test_node_1.node,
&test_node_1.node, true)),
&test_node_1.node, true)),
"test_list head/tail are wrong");
/* Finding and removing node 1 */
sys_dlist_remove(&test_node_1.node);
zassert_true((verify_emptyness(&test_list)),
"test_list should be empty");
"test_list should be empty");
/* Prepending node 1 */
sys_dlist_prepend(&test_list, &test_node_1.node);
zassert_true((verify_content_amount(&test_list, 1)),
"test_list has wrong content");
"test_list has wrong content");
zassert_true((verify_tail_head(&test_list, &test_node_1.node,
&test_node_1.node, true)),
"test_list head/tail are wrong");
&test_node_1.node, true)),
"test_list head/tail are wrong");
/* Removing node 1 */
sys_dlist_remove(&test_node_1.node);
zassert_true((verify_emptyness(&test_list)),
"test_list should be empty");
"test_list should be empty");
/* Appending node 1 */
sys_dlist_append(&test_list, &test_node_1.node);
@ -202,69 +202,69 @@ void dlist_test(void)
sys_dlist_prepend(&test_list, &test_node_2.node);
zassert_true((verify_content_amount(&test_list, 2)),
"test_list has wrong content");
"test_list has wrong content");
zassert_true((verify_tail_head(&test_list, &test_node_2.node,
&test_node_1.node, false)),
"test_list head/tail are wrong");
&test_node_1.node, false)),
"test_list head/tail are wrong");
/* Appending node 3 */
sys_dlist_append(&test_list, &test_node_3.node);
zassert_true((verify_content_amount(&test_list, 3)),
"test_list has wrong content");
"test_list has wrong content");
zassert_true((verify_tail_head(&test_list, &test_node_2.node,
&test_node_3.node, false)),
"test_list head/tail are wrong");
&test_node_3.node, false)),
"test_list head/tail are wrong");
zassert_true((sys_dlist_peek_next(&test_list, &test_node_2.node) ==
&test_node_1.node),
"test_list node links are wrong");
&test_node_1.node),
"test_list node links are wrong");
/* Inserting node 4 after node 2 */
sys_dlist_insert_after(&test_list, &test_node_2.node,
&test_node_4.node);
zassert_true((verify_tail_head(&test_list, &test_node_2.node,
&test_node_3.node, false)),
"test_list head/tail are wrong");
&test_node_3.node, false)),
"test_list head/tail are wrong");
zassert_true((sys_dlist_peek_next(&test_list, &test_node_2.node) ==
&test_node_4.node),
"test_list node links are wrong");
&test_node_4.node),
"test_list node links are wrong");
/* Finding and removing node 1 */
sys_dlist_remove(&test_node_1.node);
zassert_true((verify_content_amount(&test_list, 3)),
"test_list has wrong content");
"test_list has wrong content");
zassert_true((verify_tail_head(&test_list, &test_node_2.node,
&test_node_3.node, false)),
"test_list head/tail are wrong");
&test_node_3.node, false)),
"test_list head/tail are wrong");
/* Removing node 3 */
sys_dlist_remove(&test_node_3.node);
zassert_true((verify_content_amount(&test_list, 2)),
"test_list has wrong content");
"test_list has wrong content");
zassert_true((verify_tail_head(&test_list, &test_node_2.node,
&test_node_4.node, false)),
"test_list head/tail are wrong");
&test_node_4.node, false)),
"test_list head/tail are wrong");
/* Removing node 4 */
sys_dlist_remove(&test_node_4.node);
zassert_true((verify_content_amount(&test_list, 1)),
"test_list has wrong content");
"test_list has wrong content");
zassert_true((verify_tail_head(&test_list, &test_node_2.node,
&test_node_2.node, true)),
"test_list head/tail are wrong");
&test_node_2.node, true)),
"test_list head/tail are wrong");
/* Removing node 2 */
sys_dlist_remove(&test_node_2.node);
zassert_true((verify_emptyness(&test_list)),
"test_list should be empty");
"test_list should be empty");
/* test iterator from a node */
struct data_node {

View file

@ -63,7 +63,7 @@ void printk_test(void)
int count;
printk("%lld %llu %llx",
1LL, -1ULL, -1ULL);
1LL, -1ULL, -1ULL);
_old_char_out = __printk_get_hook();
__printk_hook_install(ram_console_out);
@ -86,8 +86,8 @@ void printk_test(void)
count = 0;
count += snprintk(ram_console + count, sizeof(ram_console) - count,
"%zu %hhu %hu %u %lu %llu\n",
stv, uc, usi, ui, ul, ull);
"%zu %hhu %hu %u %lu %llu\n",
stv, uc, usi, ui, ul, ull);
count += snprintk(ram_console + count, sizeof(ram_console) - count,
"%c %hhd %hd %d %ld %lld\n", c, c, ssi, si, sl, sll);
count += snprintk(ram_console + count, sizeof(ram_console) - count,

View file

@ -48,7 +48,7 @@ void rand32_test(void)
}
for (i = 1; i < N_VALUES; i++) {
zassert_false((rnd_values[i - 1] == rnd_values[i]),
"random number subsequent calls return same value");
"random number subsequent calls return same value");
}
}

View file

@ -13,10 +13,10 @@
SYS_RING_BUF_DECLARE_POW2(ring_buf, 8);
char data[] = "ABCDEFGHIJKLMNOPQRSTUVWX";
#define TYPE 1
#define VALUE 2
#define TYPE 1
#define VALUE 2
#define INITIAL_SIZE 2
#define INITIAL_SIZE 2
void ring_buffer_test(void)
{
@ -35,7 +35,7 @@ void ring_buffer_test(void)
break;
}
SYS_LOG_DBG("inserted %d chunks, %d remaining", dsize,
sys_ring_buf_space_get(&ring_buf));
sys_ring_buf_space_get(&ring_buf));
dsize = (dsize + 1) % SIZE32_OF(data);
put_count++;
}
@ -53,8 +53,8 @@ void ring_buffer_test(void)
&getsize);
zassert_true((ret == 0), "Couldn't retrieve a stored value");
SYS_LOG_DBG("got %u chunks of type %u and val %u, %u remaining",
getsize, gettype, getval,
sys_ring_buf_space_get(&ring_buf));
getsize, gettype, getval,
sys_ring_buf_space_get(&ring_buf));
zassert_true((memcmp((char *)getdata, data, getsize * sizeof(u32_t)) == 0),
"data corrupted");

View file

@ -171,30 +171,30 @@ void slist_test(void)
/* Appending node 1 */
sys_slist_append(&test_list, &test_node_1.node);
zassert_true((verify_content_amount(&test_list, 1)),
"test_list has wrong content");
"test_list has wrong content");
zassert_true((verify_tail_head(&test_list, &test_node_1.node,
&test_node_1.node, true)),
"test_list head/tail are wrong");
&test_node_1.node, true)),
"test_list head/tail are wrong");
/* Finding and removing node 1 */
sys_slist_find_and_remove(&test_list, &test_node_1.node);
zassert_true((verify_emptyness(&test_list)),
"test_list should be empty");
"test_list should be empty");
/* Prepending node 1 */
sys_slist_prepend(&test_list, &test_node_1.node);
zassert_true((verify_content_amount(&test_list, 1)),
"test_list has wrong content");
"test_list has wrong content");
zassert_true((verify_tail_head(&test_list, &test_node_1.node,
&test_node_1.node, true)),
"test_list head/tail are wrong");
&test_node_1.node, true)),
"test_list head/tail are wrong");
/* Removing node 1 */
sys_slist_remove(&test_list, NULL, &test_node_1.node);
zassert_true((verify_emptyness(&test_list)),
"test_list should be empty");
"test_list should be empty");
/* Appending node 1 */
sys_slist_append(&test_list, &test_node_1.node);
@ -202,68 +202,68 @@ void slist_test(void)
sys_slist_prepend(&test_list, &test_node_2.node);
zassert_true((verify_content_amount(&test_list, 2)),
"test_list has wrong content");
"test_list has wrong content");
zassert_true((verify_tail_head(&test_list, &test_node_2.node,
&test_node_1.node, false)),
"test_list head/tail are wrong");
&test_node_1.node, false)),
"test_list head/tail are wrong");
/* Appending node 3 */
sys_slist_append(&test_list, &test_node_3.node);
zassert_true((verify_content_amount(&test_list, 3)),
"test_list has wrong content");
"test_list has wrong content");
zassert_true((verify_tail_head(&test_list, &test_node_2.node,
&test_node_3.node, false)),
"test_list head/tail are wrong");
&test_node_3.node, false)),
"test_list head/tail are wrong");
zassert_true((sys_slist_peek_next(&test_node_2.node) ==
&test_node_1.node),
"test_list node links are wrong");
&test_node_1.node),
"test_list node links are wrong");
/* Inserting node 4 after node 2 */
sys_slist_insert(&test_list, &test_node_2.node, &test_node_4.node);
zassert_true((verify_tail_head(&test_list, &test_node_2.node,
&test_node_3.node, false)),
"test_list head/tail are wrong");
&test_node_3.node, false)),
"test_list head/tail are wrong");
zassert_true((sys_slist_peek_next(&test_node_2.node) ==
&test_node_4.node),
"test_list node links are wrong");
&test_node_4.node),
"test_list node links are wrong");
/* Finding and removing node 1 */
sys_slist_find_and_remove(&test_list, &test_node_1.node);
zassert_true((verify_content_amount(&test_list, 3)),
"test_list has wrong content");
"test_list has wrong content");
zassert_true((verify_tail_head(&test_list, &test_node_2.node,
&test_node_3.node, false)),
"test_list head/tail are wrong");
&test_node_3.node, false)),
"test_list head/tail are wrong");
/* Removing node 3 */
sys_slist_remove(&test_list, &test_node_4.node, &test_node_3.node);
zassert_true((verify_content_amount(&test_list, 2)),
"test_list has wrong content");
"test_list has wrong content");
zassert_true((verify_tail_head(&test_list, &test_node_2.node,
&test_node_4.node, false)),
"test_list head/tail are wrong");
&test_node_4.node, false)),
"test_list head/tail are wrong");
/* Removing node 4 */
sys_slist_remove(&test_list, &test_node_2.node, &test_node_4.node);
zassert_true((verify_content_amount(&test_list, 1)),
"test_list has wrong content");
"test_list has wrong content");
zassert_true((verify_tail_head(&test_list, &test_node_2.node,
&test_node_2.node, true)),
"test_list head/tail are wrong");
&test_node_2.node, true)),
"test_list head/tail are wrong");
/* Removing node 2 */
sys_slist_remove(&test_list, NULL, &test_node_2.node);
zassert_true((verify_emptyness(&test_list)),
"test_list should be empty");
"test_list should be empty");
/* test iterator from a node */
struct data_node {

View file

@ -75,7 +75,7 @@ void timeout_order_test(void)
for (ii = 0; ii < NUM_TIMEOUTS; ii++) {
zassert_equal(poll_events[ii].state,
K_POLL_STATE_SEM_AVAILABLE, "");
K_POLL_STATE_SEM_AVAILABLE, "");
}
for (ii = 0; ii < NUM_TIMEOUTS; ii++) {
zassert_equal(results[ii], ii, "");