int main (void) { /* This test validates that stderr is used correctly, so move the original into fd 10. */ if (dup2 (STDERR_FILENO, BACKUP_STDERR_FILENO) != BACKUP_STDERR_FILENO || (myerr = fdopen (BACKUP_STDERR_FILENO, "w")) == NULL) return 2; ASSERT (freopen ("test-getopt.tmp", "w", stderr) == stderr); /* These default values are required by POSIX. */ ASSERT (optind == 1); ASSERT (opterr != 0); setenv ("POSIXLY_CORRECT", "1", 1); test_getopt (); #if GNULIB_TEST_GETOPT_GNU test_getopt_long_posix (); #endif unsetenv ("POSIXLY_CORRECT"); test_getopt (); #if GNULIB_TEST_GETOPT_GNU test_getopt_long (); test_getopt_long_only (); #endif ASSERT (fclose (stderr) == 0); ASSERT (remove ("test-getopt.tmp") == 0); return 0; }
int main(int argc, char **argv) { printf("Begin test getopt.\n"); printf("getopt_long输出:\n"); test_getopt_long(argc, argv); return 0; }
int main () { unsetenv ("POSIXLY_CORRECT"); test_getopt (); #if GNULIB_GETOPT_GNU test_getopt_long (); #endif return 0; }