6 one_test (const char *fmt
, int argc
, char *argv
[], int expected
[argc
- 1])
9 for (int i
= 0; i
< argc
- 1; ++i
)
12 if (ftruncate (fileno (stderr
), 0) != 0)
14 puts ("cannot truncate file");
18 int c
= getopt (argc
, argv
, fmt
);
21 printf ("format '%s' test %d failed: expected '%c', got '%c'\n",
22 fmt
, i
, expected
[i
], c
);
25 if (ftell (stderr
) == 0)
27 printf ("format '%s' test %d failed: not printed to stderr\n",
40 char *fname
= tmpnam (NULL
);
43 puts ("cannot generate name for temporary file");
47 if (freopen (fname
, "w+", stderr
) == NULL
)
49 puts ("cannot redirect stderr");
56 int ret
= one_test ("+a", 2,
57 (char *[2]) { (char *) "bug-getopt2", (char *) "-+" },
61 ret
|= one_test ("+a", 2,
62 (char *[2]) { (char *) "bug-getopt2", (char *) "-+" },
71 #define TEST_FUNCTION do_test ()
72 #include "../test-skeleton.c"