int main(int argc, char **argv) { struct Config conf; struct Options opts; if (parse_args(argc, argv, &opts)) { return -1; } if (read_config(&conf)) { free_config(&conf); return -1; } while (optind < argc) { printf("generating code from %s to %s\n", argv[optind], opts.outfile); struct TestFile *tf = generate_code(argv[optind], opts.outfile, &conf); if (tf) { if (opts.just_output_fortran) goto pass; printf("building test for %s\n", opts.outfile); build_test(tf, &conf); if (opts.stop_after_build) goto pass; printf("running test %s\n", tf->exe); run_test(tf->exe); pass: close_testfile(tf); } // XXX what does it mean if tf == NULL? optind++; } free_config(&conf); return 0; }
/** * Main program. */ void main(int argc, char** argv) { CHR_TEST_HANDLE testHandle; CHR_API_RC rc; int argNo; int loadTestEnabled = 0; /* Get command-line parameters. */ for (argNo = 1; argNo < argc; ++argNo) { const char* ap = argv[argNo]; if (strcmp(ap, "--load") == 0) loadTestEnabled = 1; else if (strcmp(ap, "--noload") == 0) loadTestEnabled = 0; else { printf("Unrecognized option: %s\n", ap); exit(EXIT_FAILURE); } } /* Initialize the Chariot API. */ printf("Initializing the API...\n"); initialize_api(); /* Create test object. */ rc = CHR_test_new(&testHandle); if (rc != CHR_OK) show_error(CHR_NULL_HANDLE, rc, "test_new"); if (loadTestEnabled) { /* Load results into test object. */ printf("Loading test results... (%s)\n", lc_testFile); rc = CHR_test_load( testHandle, lc_testFile, strlen(lc_testFile)); if (rc != CHR_OK) show_error(testHandle, rc, "test_load"); } else { /* Load network configuration. */ printf("Loading the configuration... (%s)\n", lc_configFile); rc = CHR_test_load_ixia_network_configuration( testHandle, lc_configFile, strlen(lc_configFile)); if (rc != CHR_OK) show_error(testHandle, rc, "test_load_ixia_network_configuration"); /* Create the test. */ printf("Building the test...\n"); build_test(testHandle); /* Save the test before running it. */ printf("Saving the test... (%s)\n", lc_testFile); rc = CHR_test_save(testHandle); if (rc != CHR_OK) show_error(testHandle, rc, "test_save"); /* Run the test. */ printf("Starting the test...\n"); run_test(testHandle); /* Save results of test. */ printf("Saving the results... (%s)\n", lc_testFile); rc = CHR_test_save(testHandle); if (rc != CHR_OK) show_error(testHandle, rc, "test_save"); } /* Process the results. */ printf("Processing the results...\n"); process_results(testHandle); /* We're finished! */ exit(EXIT_SUCCESS); } /* main */