1 /******************************************************************************
3 * Copyright © International Business Machines Corp., 2009
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
11 * Test if FUTEX_WAIT op returns -EWOULDBLOCK if the futex value differs
12 * from the expected one.
15 * Gowrishankar <gowrishankar.m@in.ibm.com>
18 * 2009-Nov-14: Initial version by Gowrishankar <gowrishankar.m@in.ibm.com>
20 *****************************************************************************/
28 #include "futextest.h"
31 #define timeout_ns 100000
33 void usage(char *prog
)
35 printf("Usage: %s\n", prog
);
36 printf(" -c Use color\n");
37 printf(" -h Display this help message\n");
38 printf(" -v L Verbosity level: %d=QUIET %d=CRITICAL %d=INFO\n",
39 VQUIET
, VCRITICAL
, VINFO
);
42 int main(int argc
, char *argv
[])
44 struct timespec to
= {.tv_sec
= 0, .tv_nsec
= timeout_ns
};
45 futex_t f1
= FUTEX_INITIALIZER
;
46 int res
, ret
= RET_PASS
;
49 while ((c
= getopt(argc
, argv
, "cht:v:")) != -1) {
55 usage(basename(argv
[0]));
58 log_verbosity(atoi(optarg
));
61 usage(basename(argv
[0]));
66 printf("%s: Test the unexpected futex value in FUTEX_WAIT\n",
69 info("Calling futex_wait on f1: %u @ %p with val=%u\n", f1
, &f1
, f1
+1);
70 res
= futex_wait(&f1
, f1
+1, &to
, FUTEX_PRIVATE_FLAG
);
71 if (!res
|| errno
!= EWOULDBLOCK
) {
72 fail("futex_wait returned: %d %s\n",
73 res
? errno
: res
, res
? strerror(errno
) : "");