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"
14 if (create_temp_file ("tst-getopt_long1", &fname) < 0)
16 printf ("cannot create temp file: %m\n");
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' },
36 if (freopen (fname, "w+", stderr) == NULL)
38 printf ("freopen failed: %m\n");
42 char *argv[] = { (char *) "program", (char *) "--on" };
45 int c = getopt_long (argc, argv, "12345", opts, NULL);
46 printf ("return value: %c\n", c);
51 if (getline (&line, &len, stderr) < 0)
53 printf ("cannot read stderr redirect: %m\n");
56 printf ("message = \"%s\"\n", line);
58 static const char expected[] = "\
59 program: option '--on' is ambiguous; possibilities: '--one' '--one-one' '--onto'\n";
61 return c != '?' || strcmp (line, expected) != 0;