tests: add mising braces to single line if statements

Following zephyr's style guideline, all if statements, including single
line statements shall have braces.

Signed-off-by: Anas Nashif <anas.nashif@intel.com>
This commit is contained in:
Anas Nashif 2022-07-06 08:07:42 -04:00
parent 718750f962
commit 02f2896586
10 changed files with 63 additions and 34 deletions

View file

@ -82,10 +82,11 @@ static __aligned(32) int32_t rx_data[XFERS][BUF_SIZE] = { { 0 } };
static void dma_callback(const struct device *dma_dev, void *user_data,
uint32_t channel, int status)
{
if (status)
if (status) {
TC_PRINT("tx callback status %d\n", status);
else
} else {
TC_PRINT("tx giving up\n");
}
}
static void dma_callback_rx(const struct device *dma_dev, void *user_data,
@ -196,13 +197,15 @@ static int check_transmission(void)
buffer[BUF_SIZE + i] = rx_data[1][i];
}
for (i = 0; i < 4; i++)
for (i = 0; i < 4; i++) {
pattern[i] = sine_buf[i];
}
TC_PRINT("tx_data (will be sent 2 times):\n");
for (i = 0; i < BUF_SIZE; i += 8) {
for (j = 0; j < 8; j++)
for (j = 0; j < 8; j++) {
TC_PRINT("0x%08x ", sine_buf[i + j]);
}
TC_PRINT("\n");
}
TC_PRINT("\n");
@ -238,8 +241,9 @@ static int check_transmission(void)
for (i = 0; i < BUF_SIZE; i++) {
TC_PRINT("tx 0x%08x rx 0x%08x\n", buffer[start_index + i], sine_buf[i]);
if (buffer[start_index + i] != sine_buf[i])
if (buffer[start_index + i] != sine_buf[i]) {
break;
}
}
if (i < BUF_SIZE - 1) {

View file

@ -113,9 +113,10 @@ static void check_empty_samples(int expected_count)
{
int i;
for (i = expected_count; i < BUFFER_SIZE; i++)
for (i = expected_count; i < BUFFER_SIZE; i++) {
zassert_equal(INVALID_ADC_VALUE, m_sample_buffer[i],
"[%u] should be empty", i);
}
}
/**
@ -502,9 +503,10 @@ static void test_adc_emul_input_higher_than_ref(void)
check_empty_samples(samples);
for (i = 0; i < samples; i++)
for (i = 0; i < samples; i++) {
zassert_equal(BIT_MASK(ADC_RESOLUTION), m_sample_buffer[i],
"[%u] raw value isn't max value", i);
}
}
/**

View file

@ -93,8 +93,9 @@ static int test_task(uint32_t chan_id, uint32_t blen)
}
k_sleep(K_MSEC(2000));
TC_PRINT("%s\n", rx_data);
if (strcmp(tx_data, rx_data) != 0)
if (strcmp(tx_data, rx_data) != 0) {
return TC_FAIL;
}
return TC_PASS;
}

View file

@ -121,17 +121,19 @@ static int test_task(int minor, int major)
TC_PRINT("%s\n", rx_data2);
if (minor == 0 && major == 1) {
/* major link only trigger lined channel minor loop once */
if (strncmp(tx_data, rx_data2,
dma_cfg.source_burst_length) != 0)
if (strncmp(tx_data, rx_data2, dma_cfg.source_burst_length) != 0) {
return TC_FAIL;
}
} else if (minor == 1 && major == 0) {
/* minor link trigger linked channel except the last one*/
if (strncmp(tx_data, rx_data2,
dma_block_cfg.block_size - dma_cfg.source_burst_length) != 0)
dma_block_cfg.block_size - dma_cfg.source_burst_length) != 0) {
return TC_FAIL;
}
} else if (minor == 1 && major == 1) {
if (strcmp(tx_data, rx_data2) != 0)
if (strcmp(tx_data, rx_data2) != 0) {
return TC_FAIL;
}
}
return TC_PASS;

View file

@ -84,8 +84,9 @@ void test_led_get_info(void)
uint8_t led;
int ret;
if (!led_ctrl || !num_leds)
if (!led_ctrl || !num_leds) {
ztest_test_skip();
}
for (led = 0; led < num_leds; led++) {
const struct led_info *info;
@ -116,8 +117,9 @@ void test_led_get_info(void)
TC_PRINT("LED %d - label: %s, index: %d, num_colors: %d",
led, info->label, info->index, info->num_colors);
if (!info->num_colors)
if (!info->num_colors) {
continue;
}
TC_PRINT(" color_mapping: ");
@ -138,8 +140,9 @@ void test_led_on(void)
uint8_t led;
int ret;
if (!led_ctrl || !num_leds)
if (!led_ctrl || !num_leds) {
ztest_test_skip();
}
for (led = 0; led < num_leds; led++) {
ret = led_on(led_ctrl, led);
@ -152,8 +155,9 @@ void test_led_off(void)
uint8_t led;
int ret;
if (!led_ctrl || !num_leds)
if (!led_ctrl || !num_leds) {
ztest_test_skip();
}
for (led = 0; led < num_leds; led++) {
ret = led_off(led_ctrl, led);
@ -167,8 +171,9 @@ void test_led_set_color(void)
uint8_t colors[TEST_MAX_COLORS + 1];
int ret;
if (!led_ctrl || !num_leds)
if (!led_ctrl || !num_leds) {
ztest_test_skip();
}
for (led = 0; led < num_leds; led++) {
uint8_t num_colors = test_led_info[led].num_colors;
@ -226,8 +231,9 @@ void test_led_set_brightness(void)
uint8_t led;
int ret;
if (!led_ctrl || !num_leds)
if (!led_ctrl || !num_leds) {
ztest_test_skip();
}
for (led = 0; led < num_leds; led++) {
uint16_t level;

View file

@ -424,8 +424,9 @@ void test_read_abort(void)
* that may affect following test on RX
*/
uart_rx_enable(uart_dev, rx_buf, sizeof(rx_buf), 50 * USEC_PER_MSEC);
while (k_sem_take(&rx_rdy, K_MSEC(1000)) != -EAGAIN)
while (k_sem_take(&rx_rdy, K_MSEC(1000)) != -EAGAIN) {
;
}
uart_rx_disable(uart_dev);
}

View file

@ -278,8 +278,9 @@ ZTEST(device, test_device_init_level)
* correct, and it should be 1, 2, 3, 4
*/
for (int i = 0; i < 4; i++) {
if (init_level_sequence[i] != (i+1))
if (init_level_sequence[i] != (i + 1)) {
seq_correct = false;
}
}
zassert_true((seq_correct == true),
@ -304,8 +305,9 @@ ZTEST(device, test_device_init_priority)
* and it should be 1, 2, 3, 4
*/
for (int i = 0; i < 4; i++) {
if (init_priority_sequence[i] != (i+1))
if (init_priority_sequence[i] != (i + 1)) {
sequence_correct = false;
}
}
zassert_true((sequence_correct == true),

View file

@ -133,10 +133,11 @@ static void multi_thread_sem_give(void *p1, void *p2, void *p3)
count = atomic_get(&atomic_count);
k_sem_give(&limit_sem);
if (count < TOTAL_MAX)
if (count < TOTAL_MAX) {
zassert_equal(k_sem_count_get(&limit_sem), count, "multi get sem error");
else
} else {
zassert_equal(k_sem_count_get(&limit_sem), SEM_MAX_VAL, "count > SEM_MAX_VAL");
}
k_sem_take(&sync_sem, K_FOREVER);
}
@ -149,10 +150,11 @@ static void multi_thread_sem_take(void *p1, void *p2, void *p3)
(void)atomic_dec(&atomic_count);
count = atomic_get(&atomic_count);
if (count >= 0)
if (count >= 0) {
zassert_equal(k_sem_count_get(&limit_sem), count, "multi take sem error");
else
} else {
zassert_equal(k_sem_count_get(&limit_sem), 0, "count < SEM_INIT_VAL");
}
k_sem_give(&sync_sem);
}

View file

@ -443,64 +443,72 @@ ZTEST(test_c_lib, test_checktype)
char *ptr = buf;
for (int i = 0; i < 128; i++) {
if (isalnum(i))
if (isalnum(i)) {
*ptr++ = i;
}
}
*ptr = '\0';
zassert_equal(strcmp(buf, exp_alnum), 0, "isalnum error");
ptr = buf;
for (int i = 0; i < 128; i++) {
if (isalpha(i))
if (isalpha(i)) {
*ptr++ = i;
}
}
*ptr = '\0';
zassert_equal(strcmp(buf, exp_alpha), 0, "isalpha error");
ptr = buf;
for (int i = 0; i < 128; i++) {
if (isdigit(i))
if (isdigit(i)) {
*ptr++ = i;
}
}
*ptr = '\0';
zassert_equal(strcmp(buf, exp_digit), 0, "isdigit error");
ptr = buf;
for (int i = 0; i < 128; i++) {
if (isgraph(i))
if (isgraph(i)) {
*ptr++ = i;
}
}
*ptr = '\0';
zassert_equal(strcmp(buf, exp_graph), 0, "isgraph error");
ptr = buf;
for (int i = 0; i < 128; i++) {
if (isprint(i))
if (isprint(i)) {
*ptr++ = i;
}
}
*ptr = '\0';
zassert_equal(strcmp(buf, exp_print), 0, "isprint error");
ptr = buf;
for (int i = 0; i < 128; i++) {
if (isupper(i))
if (isupper(i)) {
*ptr++ = i;
}
}
*ptr = '\0';
zassert_equal(strcmp(buf, exp_upper), 0, "isupper error");
ptr = buf;
for (int i = 0; i < 128; i++) {
if (isspace(i))
if (isspace(i)) {
*ptr++ = i;
}
}
*ptr = '\0';
zassert_equal(strcmp(buf, exp_space), 0, "isspace error");
ptr = buf;
for (int i = 0; i < 128; i++) {
if (isxdigit(i))
if (isxdigit(i)) {
*ptr++ = i;
}
}
*ptr = '\0';
zassert_equal(strcmp(buf, exp_xdigit), 0, "isxdigit error");

View file

@ -296,8 +296,9 @@ static void iface_cb(struct net_if *iface, void *user_data)
*/
if ((iface != net_if_lookup_by_dev(DEVICE_GET(eth3_test))) &&
(iface != net_if_lookup_by_dev(DEVICE_GET(eth2_test))) &&
(iface != net_if_lookup_by_dev(DEVICE_GET(eth1_test))))
(iface != net_if_lookup_by_dev(DEVICE_GET(eth1_test)))) {
return;
}
DBG("Interface %p (%s) [%d]\n", iface, iface2str(iface),
net_if_get_by_iface(iface));