Skip to content
Snippets Groups Projects
Commit e6f59e4c authored by Bin Meng's avatar Bin Meng Committed by Thomas Huth
Browse files

tests/qtest: microbit-test: Fix socket access for win32


Sockets on Windows do not use *nix-style file descriptors, so
write()/read()/close() do not work on Windows.

Switch over to use send()/recv()/closesocket() which work with
sockets on all platforms.

Signed-off-by: default avatarBin Meng <bin.meng@windriver.com>
Reviewed-by: default avatarMarc-André Lureau <marcandre.lureau@redhat.com>
Message-Id: <20220925113032.1949844-45-bmeng.cn@gmail.com>
Signed-off-by: default avatarThomas Huth <thuth@redhat.com>
parent a6866706
No related branches found
No related tags found
No related merge requests found
......@@ -51,7 +51,7 @@ static void uart_rw_to_rxd(QTestState *qts, int sock_fd, const char *in,
{
int i, in_len = strlen(in);
g_assert_true(write(sock_fd, in, in_len) == in_len);
g_assert_true(send(sock_fd, in, in_len, 0) == in_len);
for (i = 0; i < in_len; i++) {
g_assert_true(uart_wait_for_event(qts, NRF51_UART_BASE +
A_UART_RXDRDY));
......@@ -77,7 +77,7 @@ static void test_nrf51_uart(void)
char s[10];
QTestState *qts = qtest_init_with_serial("-M microbit", &sock_fd);
g_assert_true(write(sock_fd, "c", 1) == 1);
g_assert_true(send(sock_fd, "c", 1, 0) == 1);
g_assert_cmphex(qtest_readl(qts, NRF51_UART_BASE + A_UART_RXD), ==, 0x00);
qtest_writel(qts, NRF51_UART_BASE + A_UART_ENABLE, 0x04);
......@@ -97,17 +97,17 @@ static void test_nrf51_uart(void)
qtest_writel(qts, NRF51_UART_BASE + A_UART_STARTTX, 0x01);
uart_w_to_txd(qts, "d");
g_assert_true(read(sock_fd, s, 10) == 1);
g_assert_true(recv(sock_fd, s, 10, 0) == 1);
g_assert_cmphex(s[0], ==, 'd');
qtest_writel(qts, NRF51_UART_BASE + A_UART_SUSPEND, 0x01);
qtest_writel(qts, NRF51_UART_BASE + A_UART_TXD, 'h');
qtest_writel(qts, NRF51_UART_BASE + A_UART_STARTTX, 0x01);
uart_w_to_txd(qts, "world");
g_assert_true(read(sock_fd, s, 10) == 5);
g_assert_true(recv(sock_fd, s, 10, 0) == 5);
g_assert_true(memcmp(s, "world", 5) == 0);
close(sock_fd);
closesocket(sock_fd);
qtest_quit(qts);
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment