Files
graphene/LibOS/shim/test/regression/futex-timeout.c
Dmitrii Kuvaiskii 402020f8da [LibOS/regression] Add futex-timeout test
Before PR #554, futex() syscall incorrectly failed
if user-supplied timeout expired (also see PR #438).
This patch adds test on futex() with timeout.
2019-05-06 13:46:26 -07:00

25 lines
516 B
C

#include <unistd.h>
#include <stdio.h>
#include <sys/syscall.h>
#include <linux/futex.h>
#include <sys/time.h>
#include <errno.h>
int main (int argc, const char** argv) {
int myfutex = 0;
int ret;
struct timespec t = {
.tv_sec = 1,
.tv_nsec = 0
};
puts("invoke futex syscall with 1-second timeout");
ret = syscall(SYS_futex, &myfutex, FUTEX_WAIT, 0, &t, NULL, 0);
if (ret == -1 && errno == ETIMEDOUT) {
puts("futex correctly timed out");
}
return 0;
}