예제 #1
0
void spice_test_config_parse_args(int argc, char **argv)
{
    struct option options[] = {
#ifdef AUTOMATED_TESTS
        {"automated-tests", no_argument, &has_automated_tests, 1},
#endif
        {NULL, 0, NULL, 0},
    };
    int option_index;
    int val;

    while ((val = getopt_long(argc, argv, "", options, &option_index)) != -1) {
        switch (val) {
        case '?':
            printf("unrecognized option %s", argv[optind]);
            goto invalid_option;
        case 0:
            break;
        }
    }

    if (has_automated_tests) {
        init_automated();
    }
    return;

invalid_option:
    printf("Invalid option!\n"
           "usage: %s [--automated-tests]\n", argv[0]);
    exit(0);
}
예제 #2
0
void spice_test_config_parse_args(int argc, char **argv)
{
    struct option options[] = {
#ifdef AUTOMATED_TESTS
        {"automated-tests", no_argument, &has_automated_tests, 1},
#endif
        {NULL, 0, NULL, 0},
    };
    int option_index;
    int val;

    while ((val = getopt_long(argc, argv, "", options, &option_index)) != -1) {
        switch (val) {
        case '?':
            printf("unrecognized option '%s'\n", argv[optind - 1]);
            usage(argv[0], EXIT_FAILURE);
        case 0:
            break;
        }
    }

    if (argc > optind) {
        printf("unknown argument '%s'\n", argv[optind]);
        usage(argv[0], EXIT_FAILURE);
    }
    if (has_automated_tests) {
        init_automated();
    }
    return;
}