From 8790843c99386cd9995eb7865e106286307cc980 Mon Sep 17 00:00:00 2001 From: adamdebek Date: Mon, 7 Oct 2024 14:22:53 +0200 Subject: [PATCH] libc: add passing custom parameter to unix-socket test Add passing custom parameter to unix-socket test on armv7a9-zynq7000-qemu since blocking interval significantly overruns timeout due to host system scheduling delays JIRA: CI-501 --- libc/socket/common.h | 3 --- libc/socket/inet-socket.c | 3 --- libc/socket/unix-socket.c | 19 +++++++++++++++---- libc/test.yaml | 6 ++++++ 4 files changed, 21 insertions(+), 10 deletions(-) diff --git a/libc/socket/common.h b/libc/socket/common.h index cd63b8dda..a1bf0f33d 100644 --- a/libc/socket/common.h +++ b/libc/socket/common.h @@ -29,9 +29,6 @@ #define DATA_SIZE 10000 #endif -extern char data[DATA_SIZE]; -extern char buf[DATA_SIZE]; - ssize_t msg_send(int sock, void *buf, size_t len, int *fd, size_t fdcnt); ssize_t msg_recv(int sock, void *buf, size_t len, int *fd, size_t *fdcnt); diff --git a/libc/socket/inet-socket.c b/libc/socket/inet-socket.c index 967571f73..c088ea645 100644 --- a/libc/socket/inet-socket.c +++ b/libc/socket/inet-socket.c @@ -28,9 +28,6 @@ #include "common.h" #include "unity_fixture.h" -char data[DATA_SIZE]; -char buf[DATA_SIZE]; - TEST_GROUP(test_inet_socket); diff --git a/libc/socket/unix-socket.c b/libc/socket/unix-socket.c index adb11a4ff..d380be52a 100644 --- a/libc/socket/unix-socket.c +++ b/libc/socket/unix-socket.c @@ -34,8 +34,9 @@ #include "unity_fixture.h" -char data[DATA_SIZE]; -char buf[DATA_SIZE]; +static char data[DATA_SIZE]; +static char buf[DATA_SIZE]; +static int pollTimeoutDelay = 30; ssize_t unix_named_socket(int type, const char *name) @@ -859,7 +860,7 @@ void unix_poll(int type) TEST_ASSERT(rv == 0); TEST_ASSERT(fds[0].revents == 0); TEST_ASSERT(fds[1].revents == 0); - TEST_ASSERT_LESS_THAN(350, ms); + TEST_ASSERT_LESS_THAN(300 + pollTimeoutDelay, ms); TEST_ASSERT_GREATER_THAN(290, ms); clock_gettime(CLOCK_REALTIME, &ts[0]); @@ -930,6 +931,16 @@ void runner(void) int main(int argc, char *argv[]) { + /* Due to scheduling delays of host system on which emulator runs, + * add some extra value to poll timeout checks + */ + for (int i = 1; i < argc; i++) { + if (strcmp(argv[i], "--extra-poll-delay-ms") == 0) { + pollTimeoutDelay = atoi(argv[i + 1]); + break; + } + } + /* Assume /tmp dir is missing */ int isMissing = 0; @@ -939,7 +950,7 @@ int main(int argc, char *argv[]) int failures = UnityMain(argc, (const char **)argv, runner); - if (isMissing) { + if (isMissing != 0) { rmdir("/tmp"); } diff --git a/libc/test.yaml b/libc/test.yaml index 0f96e6766..2bc458df3 100644 --- a/libc/test.yaml +++ b/libc/test.yaml @@ -66,8 +66,14 @@ test: - name: unix-socket execute: test-libc-unix-socket targets: + exclude: [armv7a9-zynq7000-qemu] include: [host-generic-pc] + - name: unix-socket + execute: test-libc-unix-socket --extra-poll-delay-ms 150 + targets: + value: [armv7a9-zynq7000-qemu] + - name: inet-socket execute: test-libc-inet-socket targets: