/** * Recognized arguments are removed from @a argv. The updated array * length is returned in @a argc. */ static void process_args(int *argc, char *argv[], unsigned *force_samples, struct piglit_gl_test_config *config) { int j; piglit_binary_name = argv[0]; piglit_parse_subtest_args(argc, argv, config->subtests, &config->selected_subtests, &config->num_selected_subtests); /* Find/remove "-auto" and "-fbo" from the argument vector. */ for (j = 1; j < *argc; j++) { if (!strcmp(argv[j], "-auto")) { piglit_automatic = 1; delete_arg(argv, *argc, j--); *argc -= 1; } else if (!strcmp(argv[j], "-fbo")) { piglit_use_fbo = true; delete_arg(argv, *argc, j--); *argc -= 1; } else if (!strcmp(argv[j], "-png")) { piglit_dump_png = true; delete_arg(argv, *argc, j--); *argc -= 1; } else if (!strcmp(argv[j], "-rlimit")) { char *ptr; unsigned long lim; int i; j++; if (j >= *argc) { fprintf(stderr, "-rlimit requires an argument\n"); piglit_report_result(PIGLIT_FAIL); } lim = strtoul(argv[j], &ptr, 0); if (ptr == argv[j]) { fprintf(stderr, "-rlimit requires an argument\n"); piglit_report_result(PIGLIT_FAIL); } piglit_set_rlimit(lim); /* Remove 2 arguments (hence the 'i - 2') from the * command line. */ for (i = j + 1; i < *argc; i++) { argv[i - 2] = argv[i]; } *argc -= 2; j -= 2; } else if (!strncmp(argv[j], "-samples=", 9)) { *force_samples = atoi(argv[j]+9); delete_arg(argv, *argc, j--); *argc -= 1; } else if (!strcmp(argv[j], "-khr_no_error")) { piglit_khr_no_error = true; delete_arg(argv, *argc, j--); *argc -= 1; if (config->khr_no_error_support == PIGLIT_UNKNOWN_ERROR_STATUS) { fprintf(stderr, "khr_no_error_support unknown " "skipping test!\n"); piglit_report_result(PIGLIT_SKIP); } else if (config->khr_no_error_support == PIGLIT_HAS_ERRORS) { piglit_report_result(PIGLIT_SKIP); } else { assert(config->khr_no_error_support == PIGLIT_NO_ERRORS); } } } }
int main(int argc, char *argv[]) { int j; /* Find/remove "-auto" and "-fbo" from the argument vector. */ for (j = 1; j < argc; j++) { if (!strcmp(argv[j], "-auto")) { piglit_automatic = 1; delete_arg(argv, argc--, j--); } else if (!strcmp(argv[j], "-fbo")) { piglit_use_fbo = true; delete_arg(argv, argc--, j--); } else if (!strcmp(argv[j], "-rlimit")) { char *ptr; unsigned long lim; int i; j++; if (j >= argc) { fprintf(stderr, "-rlimit requires an argument\n"); piglit_report_result(PIGLIT_FAIL); } lim = strtoul(argv[j], &ptr, 0); if (ptr == argv[j]) { fprintf(stderr, "-rlimit requires an argument\n"); piglit_report_result(PIGLIT_FAIL); } piglit_set_rlimit(lim); /* Remove 2 arguments (hence the 'i - 2') from the * command line. */ for (i = j + 1; i < argc; i++) { argv[i - 2] = argv[i]; } argc -= 2; j -= 2; } } if (piglit_use_fbo) { if (!piglit_framework_fbo_init()) piglit_use_fbo = false; } if (!piglit_use_fbo) piglit_framework_glut_init(argc, argv); piglit_init(argc, argv); if (piglit_use_fbo) { result = piglit_display(); piglit_framework_fbo_destroy(); } else { glutMainLoop(); } piglit_report_result(result); /* UNREACHED */ return 0; }