alpha: Fix redefinition of __isnanl macro warning
[glibc.git] / posix / tst-getopt_long1.c
blobe0ecd121908de5f8e70ca8badb18ac2ca11aceb3
1 static void do_prepare (void);
2 #define PREPARE(argc, argv) do_prepare ()
3 static int do_test (void);
4 #define TEST_FUNCTION do_test ()
5 #include "../test-skeleton.c"
8 static char *fname;
11 static void
12 do_prepare (void)
14 if (create_temp_file ("tst-getopt_long1", &fname) < 0)
16 printf ("cannot create temp file: %m\n");
17 exit (1);
22 static const struct option opts[] =
24 { "one", no_argument, NULL, '1' },
25 { "two", no_argument, NULL, '2' },
26 { "one-one", no_argument, NULL, '3' },
27 { "four", no_argument, NULL, '4' },
28 { "onto", no_argument, NULL, '5' },
29 { NULL, 0, NULL, 0 }
33 static int
34 do_test (void)
36 if (freopen (fname, "w+", stderr) == NULL)
38 printf ("freopen failed: %m\n");
39 return 1;
42 char *argv[] = { "program", "--on" };
43 int argc = 2;
45 int c = getopt_long (argc, argv, "12345", opts, NULL);
46 printf ("return value: %c\n", c);
48 rewind (stderr);
49 char *line = NULL;
50 size_t len = 0;
51 if (getline (&line, &len, stderr) < 0)
53 printf ("cannot read stderr redirect: %m\n");
54 return 1;
56 printf ("message = \"%s\"\n", line);
58 static const char expected[] = "\
59 program: option '--on' is ambiguous; possibilities: '--one' '--onto' '--one-one'\n";
61 return c != '?' || strcmp (line, expected) != 0;