~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

TOMOYO Linux Cross Reference
Linux/tools/testing/selftests/futex/functional/futex_wait_wouldblock.c

Version: ~ [ linux-5.14-rc3 ] ~ [ linux-5.13.5 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.53 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.135 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.198 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.240 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.276 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.276 ] ~ [ linux-4.3.6 ] ~ [ linux-4.2.8 ] ~ [ linux-4.1.52 ] ~ [ linux-4.0.9 ] ~ [ linux-3.18.140 ] ~ [ linux-3.16.85 ] ~ [ linux-3.14.79 ] ~ [ linux-3.12.74 ] ~ [ linux-3.10.108 ] ~ [ linux-2.6.32.71 ] ~ [ linux-2.6.0 ] ~ [ linux-2.4.37.11 ] ~ [ unix-v6-master ] ~ [ ccs-tools-1.8.5 ] ~ [ policy-sample ] ~
Architecture: ~ [ i386 ] ~ [ alpha ] ~ [ m68k ] ~ [ mips ] ~ [ ppc ] ~ [ sparc ] ~ [ sparc64 ] ~

  1 /******************************************************************************
  2  *
  3  *   Copyright © International Business Machines  Corp., 2009
  4  *
  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.
  9  *
 10  * DESCRIPTION
 11  *      Test if FUTEX_WAIT op returns -EWOULDBLOCK if the futex value differs
 12  *      from the expected one.
 13  *
 14  * AUTHOR
 15  *      Gowrishankar <gowrishankar.m@in.ibm.com>
 16  *
 17  * HISTORY
 18  *      2009-Nov-14: Initial version by Gowrishankar <gowrishankar.m@in.ibm.com>
 19  *
 20  *****************************************************************************/
 21 
 22 #include <errno.h>
 23 #include <getopt.h>
 24 #include <stdio.h>
 25 #include <stdlib.h>
 26 #include <string.h>
 27 #include <time.h>
 28 #include "futextest.h"
 29 #include "logging.h"
 30 
 31 #define timeout_ns 100000
 32 
 33 void usage(char *prog)
 34 {
 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);
 40 }
 41 
 42 int main(int argc, char *argv[])
 43 {
 44         struct timespec to = {.tv_sec = 0, .tv_nsec = timeout_ns};
 45         futex_t f1 = FUTEX_INITIALIZER;
 46         int res, ret = RET_PASS;
 47         int c;
 48 
 49         while ((c = getopt(argc, argv, "cht:v:")) != -1) {
 50                 switch (c) {
 51                 case 'c':
 52                         log_color(1);
 53                         break;
 54                 case 'h':
 55                         usage(basename(argv[0]));
 56                         exit(0);
 57                 case 'v':
 58                         log_verbosity(atoi(optarg));
 59                         break;
 60                 default:
 61                         usage(basename(argv[0]));
 62                         exit(1);
 63                 }
 64         }
 65 
 66         printf("%s: Test the unexpected futex value in FUTEX_WAIT\n",
 67                basename(argv[0]));
 68 
 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) : "");
 74                 ret = RET_FAIL;
 75         }
 76 
 77         print_result(ret);
 78         return ret;
 79 }
 80 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~

kernel.org | git.kernel.org | LWN.net | Project Home | Wiki (Japanese) | Wiki (English) | SVN repository | Mail admin

Linux® is a registered trademark of Linus Torvalds in the United States and other countries.
TOMOYO® is a registered trademark of NTT DATA CORPORATION.

osdn.jp