Skip to content

Commit 7be8b69

Browse files
committed
[utest][drivers][serial_v2] 优化测试例程
1 parent 5217a83 commit 7be8b69

File tree

12 files changed

+15
-16
lines changed

12 files changed

+15
-16
lines changed

examples/utest/testcases/drivers/serial_v2/posix/uart_posix_echo_block.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,7 @@ static void uart_rec_entry(void *parameter)
115115

116116
rev_len = *(rt_uint16_t *)parameter;
117117
rt_uint8_t *uart_write_buffer;
118-
uart_write_buffer = (rt_uint8_t *)rt_calloc(1, sizeof(rt_uint8_t) * (rev_len + 1));
118+
uart_write_buffer = (rt_uint8_t *)rt_calloc(1, rev_len + 1);
119119
rt_int32_t cnt, i;
120120
rt_uint8_t last_old_data;
121121
rt_bool_t fisrt_flag = RT_TRUE;

examples/utest/testcases/drivers/serial_v2/posix/uart_posix_nonblock.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,7 @@ static rt_err_t uart_api()
108108
goto __exit;
109109
}
110110

111-
uart_write_buffer = (rt_uint8_t *)rt_malloc(sizeof(rt_uint8_t) * 100);
111+
uart_write_buffer = (rt_uint8_t *)rt_malloc(100);
112112

113113
for (i = 0; i < RT_SERIAL_TC_SEND_ITERATIONS; i++)
114114
{

examples/utest/testcases/drivers/serial_v2/uart_flush_rx.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -115,8 +115,8 @@ static rt_bool_t uart_api()
115115

116116
rt_uint8_t *uart_write_buffer;
117117
rt_uint32_t i;
118-
uart_write_buffer = (rt_uint8_t *)rt_malloc(sizeof(rt_uint8_t) * (RT_SERIAL_TC_TXBUF_SIZE * 5 + 1));
119-
for (rt_uint32_t count = 0; count < sizeof(rt_uint8_t) * (RT_SERIAL_TC_TXBUF_SIZE * 5 + 1); count++)
118+
uart_write_buffer = (rt_uint8_t *)rt_malloc(RT_SERIAL_TC_RXBUF_SIZE * 5 + 1);
119+
for (rt_uint32_t count = 0; count < (RT_SERIAL_TC_RXBUF_SIZE * 5 + 1); count++)
120120
{
121121
uart_write_buffer[count] = count;
122122
}

examples/utest/testcases/drivers/serial_v2/uart_flush_txb.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -125,8 +125,8 @@ static rt_bool_t uart_api()
125125
rt_uint8_t *uart_write_buffer;
126126
rt_uint32_t i;
127127
rt_int32_t tx_timeout = 10 * 1000;
128-
uart_write_buffer = (rt_uint8_t *)rt_malloc(sizeof(rt_uint8_t) * (RT_SERIAL_TC_TXBUF_SIZE * 5 + 10));
129-
for (rt_uint32_t count = 0; count < sizeof(rt_uint8_t) * (RT_SERIAL_TC_TXBUF_SIZE * 5 + 10); count++)
128+
uart_write_buffer = (rt_uint8_t *)rt_malloc(RT_SERIAL_TC_TXBUF_SIZE * 5 + 10);
129+
for (rt_uint32_t count = 0; count < (RT_SERIAL_TC_TXBUF_SIZE * 5 + 10); count++)
130130
{
131131
uart_write_buffer[count] = count;
132132
}

examples/utest/testcases/drivers/serial_v2/uart_flush_txnb.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,8 @@ static rt_bool_t uart_api()
124124
rt_uint8_t *uart_write_buffer;
125125
rt_uint32_t i;
126126
rt_int32_t tx_timeout = 1;
127-
uart_write_buffer = (rt_uint8_t *)rt_malloc(sizeof(rt_uint8_t) * (RT_SERIAL_TC_RXBUF_SIZE * 5 + 10));
128-
for (rt_uint32_t count = 0; count < sizeof(rt_uint8_t) * (RT_SERIAL_TC_TXBUF_SIZE * 5 + 10); count++)
127+
uart_write_buffer = (rt_uint8_t *)rt_malloc(RT_SERIAL_TC_RXBUF_SIZE * 5 + 10);
128+
for (rt_uint32_t count = 0; count < (RT_SERIAL_TC_TXBUF_SIZE * 5 + 10); count++)
129129
{
130130
uart_write_buffer[count] = count;
131131
}

examples/utest/testcases/drivers/serial_v2/uart_get_unread_bytes_count.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ static rt_bool_t uart_api()
9292

9393
rt_uint8_t *uart_write_buffer;
9494
rt_uint32_t i;
95-
uart_write_buffer = (rt_uint8_t *)rt_malloc(sizeof(rt_uint8_t) * (RT_SERIAL_TC_TXBUF_SIZE * 5 + 1));
95+
uart_write_buffer = (rt_uint8_t *)rt_malloc(RT_SERIAL_TC_TXBUF_SIZE * 5 + 1);
9696

9797
srand(rt_tick_get());
9898
for (i = 0; i < RT_SERIAL_TC_SEND_ITERATIONS; i++)

examples/utest/testcases/drivers/serial_v2/uart_overflow_rxb_txb.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,7 @@ static void uart_rec_entry(void *parameter)
7070
rt_uint8_t *uart_write_buffer;
7171
rt_int32_t cnt, i;
7272
rev_len = *(rt_uint32_t *)parameter;
73-
uart_write_buffer = (rt_uint8_t *)rt_malloc(sizeof(rt_uint8_t) * (rev_len + 1));
73+
uart_write_buffer = (rt_uint8_t *)rt_malloc(rev_len + 1);
7474

7575
while (1)
7676
{

examples/utest/testcases/drivers/serial_v2/uart_rxb_txb.c

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,13 +69,12 @@ static void uart_rec_entry(void *parameter)
6969

7070
rev_len = *(rt_uint16_t *)parameter;
7171
rt_uint8_t *uart_write_buffer;
72-
uart_write_buffer = (rt_uint8_t *)rt_calloc(1, sizeof(rt_uint8_t) * (rev_len + 1));
72+
uart_write_buffer = (rt_uint8_t *)rt_calloc(1, rev_len + 1);
7373
rt_int32_t cnt, i;
7474
rt_uint8_t last_old_data;
7575
rt_bool_t fisrt_flag = RT_TRUE;
7676
rt_uint32_t all_receive_length = 0;
7777

78-
7978
while (1)
8079
{
8180
cnt = rt_device_read(&serial->parent, 0, (void *)uart_write_buffer, rev_len);

examples/utest/testcases/drivers/serial_v2/uart_rxb_txnb.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ static void uart_rec_entry(void *parameter)
8383

8484
rev_len = *(rt_uint16_t *)parameter;
8585
rt_uint8_t *uart_write_buffer;
86-
uart_write_buffer = (rt_uint8_t *)rt_calloc(1, sizeof(rt_uint8_t) * (rev_len + 1));
86+
uart_write_buffer = (rt_uint8_t *)rt_calloc(1, rev_len + 1);
8787
rt_int32_t cnt, i;
8888
rt_uint8_t last_old_data;
8989
rt_bool_t fisrt_flag = RT_TRUE;

examples/utest/testcases/drivers/serial_v2/uart_rxnb_txb.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ static void uart_rec_entry(void *parameter)
7979

8080
rev_len = *(rt_uint16_t *)parameter;
8181
rt_uint8_t *uart_write_buffer;
82-
uart_write_buffer = (rt_uint8_t *)rt_calloc(1, sizeof(rt_uint8_t) * (rev_len + 1));
82+
uart_write_buffer = (rt_uint8_t *)rt_calloc(1, rev_len + 1);
8383
rt_int32_t cnt, i;
8484
rt_uint8_t last_old_data;
8585
rt_bool_t fisrt_flag = RT_TRUE;

0 commit comments

Comments
 (0)