Skip to content

Commit

Permalink
libc: add passing custom parameter to unix-socket test
Browse files Browse the repository at this point in the history
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
  • Loading branch information
adamdebek committed Oct 10, 2024
1 parent aba8104 commit 7128227
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 10 deletions.
3 changes: 0 additions & 3 deletions libc/socket/common.h
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
4 changes: 1 addition & 3 deletions libc/socket/inet-socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -28,9 +28,7 @@
#include "common.h"
#include "unity_fixture.h"

char data[DATA_SIZE];
char buf[DATA_SIZE];

static char data[DATA_SIZE];

TEST_GROUP(test_inet_socket);

Expand Down
23 changes: 19 additions & 4 deletions libc/socket/unix-socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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]);
Expand Down Expand Up @@ -930,6 +931,20 @@ 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]);
if (pollTimeoutDelay <= 0) {
fprintf(stderr, "--extra-poll-delay-ms argument is not positive integer\n");
exit(EXIT_FAILURE);
}
break;
}
}

/* Assume /tmp dir is missing */
int isMissing = 0;

Expand All @@ -939,7 +954,7 @@ int main(int argc, char *argv[])

int failures = UnityMain(argc, (const char **)argv, runner);

if (isMissing) {
if (isMissing != 0) {
rmdir("/tmp");
}

Expand Down
6 changes: 6 additions & 0 deletions libc/test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down

0 comments on commit 7128227

Please sign in to comment.