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

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

Version: ~ [ linux-5.15-rc5 ] ~ [ linux-5.14.11 ] ~ [ linux-5.13.19 ] ~ [ linux-5.12.19 ] ~ [ linux-5.11.22 ] ~ [ linux-5.10.72 ] ~ [ linux-5.9.16 ] ~ [ linux-5.8.18 ] ~ [ linux-5.7.19 ] ~ [ linux-5.6.19 ] ~ [ linux-5.5.19 ] ~ [ linux-5.4.152 ] ~ [ linux-5.3.18 ] ~ [ linux-5.2.21 ] ~ [ linux-5.1.21 ] ~ [ linux-5.0.21 ] ~ [ linux-4.20.17 ] ~ [ linux-4.19.210 ] ~ [ linux-4.18.20 ] ~ [ linux-4.17.19 ] ~ [ linux-4.16.18 ] ~ [ linux-4.15.18 ] ~ [ linux-4.14.250 ] ~ [ linux-4.13.16 ] ~ [ linux-4.12.14 ] ~ [ linux-4.11.12 ] ~ [ linux-4.10.17 ] ~ [ linux-4.9.286 ] ~ [ linux-4.8.17 ] ~ [ linux-4.7.10 ] ~ [ linux-4.6.7 ] ~ [ linux-4.5.7 ] ~ [ linux-4.4.288 ] ~ [ 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 // SPDX-License-Identifier: GPL-2.0-or-later
  2 /******************************************************************************
  3  *
  4  *   Copyright © International Business Machines  Corp., 2009
  5  *
  6  * DESCRIPTION
  7  *      Test if FUTEX_WAIT op returns -EWOULDBLOCK if the futex value differs
  8  *      from the expected one.
  9  *
 10  * AUTHOR
 11  *      Gowrishankar <gowrishankar.m@in.ibm.com>
 12  *
 13  * HISTORY
 14  *      2009-Nov-14: Initial version by Gowrishankar <gowrishankar.m@in.ibm.com>
 15  *
 16  *****************************************************************************/
 17 
 18 #include <errno.h>
 19 #include <getopt.h>
 20 #include <stdio.h>
 21 #include <stdlib.h>
 22 #include <string.h>
 23 #include <time.h>
 24 #include "futextest.h"
 25 #include "logging.h"
 26 
 27 #define TEST_NAME "futex-wait-wouldblock"
 28 #define timeout_ns 100000
 29 
 30 void usage(char *prog)
 31 {
 32         printf("Usage: %s\n", prog);
 33         printf("  -c    Use color\n");
 34         printf("  -h    Display this help message\n");
 35         printf("  -v L  Verbosity level: %d=QUIET %d=CRITICAL %d=INFO\n",
 36                VQUIET, VCRITICAL, VINFO);
 37 }
 38 
 39 int main(int argc, char *argv[])
 40 {
 41         struct timespec to = {.tv_sec = 0, .tv_nsec = timeout_ns};
 42         futex_t f1 = FUTEX_INITIALIZER;
 43         int res, ret = RET_PASS;
 44         int c;
 45 
 46         while ((c = getopt(argc, argv, "cht:v:")) != -1) {
 47                 switch (c) {
 48                 case 'c':
 49                         log_color(1);
 50                         break;
 51                 case 'h':
 52                         usage(basename(argv[0]));
 53                         exit(0);
 54                 case 'v':
 55                         log_verbosity(atoi(optarg));
 56                         break;
 57                 default:
 58                         usage(basename(argv[0]));
 59                         exit(1);
 60                 }
 61         }
 62 
 63         ksft_print_header();
 64         ksft_set_plan(1);
 65         ksft_print_msg("%s: Test the unexpected futex value in FUTEX_WAIT\n",
 66                basename(argv[0]));
 67 
 68         info("Calling futex_wait on f1: %u @ %p with val=%u\n", f1, &f1, f1+1);
 69         res = futex_wait(&f1, f1+1, &to, FUTEX_PRIVATE_FLAG);
 70         if (!res || errno != EWOULDBLOCK) {
 71                 fail("futex_wait returned: %d %s\n",
 72                      res ? errno : res, res ? strerror(errno) : "");
 73                 ret = RET_FAIL;
 74         }
 75 
 76         print_result(TEST_NAME, ret);
 77         return ret;
 78 }
 79 

~ [ 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