7 one_test (const char *fmt
, int argc
, char *argv
[], int expected
[argc
- 1])
10 for (int i
= 0; i
< argc
- 1; ++i
)
13 if (ftruncate (fileno (stderr
), 0) != 0)
15 puts ("cannot truncate file");
19 int c
= getopt (argc
, argv
, fmt
);
22 printf ("format '%s' test %d failed: expected '%c', got '%c'\n",
23 fmt
, i
, expected
[i
], c
);
26 if (ftell (stderr
) == 0)
28 printf ("format '%s' test %d failed: not printed to stderr\n",
41 char fname
[] = "/tmp/bug-getopt2.XXXXXX";
42 int fd
= mkstemp (fname
);
45 printf ("mkstemp failed: %m\n");
50 if (freopen (fname
, "w+", stderr
) == NULL
)
52 puts ("cannot redirect stderr");
59 int ret
= one_test ("+a", 2,
60 (char *[2]) { (char *) "bug-getopt2", (char *) "-+" },
64 ret
|= one_test ("+a", 2,
65 (char *[2]) { (char *) "bug-getopt2", (char *) "-+" },
74 #define TEST_FUNCTION do_test ()
75 #include "../test-skeleton.c"