diff --git a/.github/workflows/smoketest.yaml b/.github/workflows/smoketest.yaml index 1bfdcb2..c1ca1a9 100644 --- a/.github/workflows/smoketest.yaml +++ b/.github/workflows/smoketest.yaml @@ -115,4 +115,5 @@ jobs: ./socket_test.sh & # Guard against endless loop in QEMU run (120 CPU secs) ulimit -t 120 - $CFG_QEMU_BIN -M ${{ matrix.config.qemu-machine }} $CFG_QEMU_OPT $CFG_QEMU_IMG -display none -nographic -semihosting -sd sdcard.img -netdev user,id=net0,hostfwd=tcp::5000-:5000 -device usb-net,netdev=net0 + # Run QEMU with simulated network + $CFG_QEMU_BIN -M ${{ matrix.config.qemu-machine }} $CFG_QEMU_OPT $CFG_QEMU_IMG -display none -nographic -semihosting -sd sdcard.img -netdev \"user,id=net0,hostfwd=tcp::5000-:5000,guestfwd=tcp:10.0.2.100:5001-cmd:yes simulated server\" -device usb-net,netdev=net0 diff --git a/libs/circle-newlib b/libs/circle-newlib index b36e770..8558c64 160000 --- a/libs/circle-newlib +++ b/libs/circle-newlib @@ -1 +1 @@ -Subproject commit b36e7707b2ff77d17364c23a861aaf4a74606af1 +Subproject commit 8558c64b81c3c07da84a9ea3f7aee2d6e366529d diff --git a/samples/05-smoketest/kernel.cpp b/samples/05-smoketest/kernel.cpp index 2f8b591..f171eb2 100644 --- a/samples/05-smoketest/kernel.cpp +++ b/samples/05-smoketest/kernel.cpp @@ -908,8 +908,6 @@ void CKernel::SocketTest(void) PErrorExit("close (fd) failed"); } -#if 0 - // TODO this attempt to use connect() hangs. fd = socket(AF_INET, SOCK_STREAM, 0); if (fd == -1) @@ -936,7 +934,7 @@ void CKernel::SocketTest(void) read_result = read(fd, buffer, sizeof(buffer)); if (read_result < 0) { - PErrorExit("connect() failed"); + PErrorExit("read() failed after connect"); } Report("Read %d bytes from server", read_result); @@ -944,17 +942,18 @@ void CKernel::SocketTest(void) char const expected_data[] = "simulated server"; if (strncmp(buffer, expected_data, sizeof(expected_data) - 1) != 0) { - Report("read() from socket returned unexpeted data"); + Report("read() from socket returned unexpected data"); exit(1); } + Report("Received expected data from server"); + if (close(fd) < 0) { PErrorExit("close (fd) failed"); } Report("Read from client connection successful"); -#endif } Report("Basic socket lifecycle test successful"); diff --git a/samples/05-smoketest/socket_test.sh b/samples/05-smoketest/socket_test.sh index 7449da5..f5fffd1 100755 --- a/samples/05-smoketest/socket_test.sh +++ b/samples/05-smoketest/socket_test.sh @@ -1,9 +1,5 @@ #!/bin/bash -# echo "Starting socat server in the background" - -#socat -U TCP4-LISTEN:5001 "EXEC:yes socat server" & - echo "Waiting for QEMU to open socket 5000..." while ! nc -z localhost 5000; do