Ejemplo n.º 1
0
int main(int argc, char** argv) {
	int i;
	int num_passed = 0;

	init_tests();

	printf("\nRunning DanglOS p_queue Test Suite\n\n");

	for (i = 0; i < N_TESTS; i++) {
		
		char* pass = "******";
		char* fail = "FAIL\0";
		char* result = NULL;

		if (test[i].test() == TEST_SUCCESS) {
			result = pass;
			num_passed++;
		} else {
			result = fail;
		}
		
		printf("\t[%s] - %s\n", result, (test[i].name));
	
	}
	printf("\nPassed %d of %d tests.\n\n", num_passed, N_TESTS);
	return 0;
}
Ejemplo n.º 2
0
int main(int argc, const char *argv[])
{
	init_tools();
	init_values();
	init_evaluator();
	init_interpreter();
	init_tests();
	init_sexp_to_c();
	
	// TO TRY: Add an -O3 flag to Xcode's compile. Then compile and profile, and see if it runs faster.
	
//	run_tests();
//	run_benchmarks();
		
	if (argc > 1) {
		if (streq(argv[1], "test")) {
			run_tests();
		} else if (streq(argv[1], "benchmark")) {
			run_benchmarks();
		} else {
			value str = value_set_str(argv[1]);
			value_import(str);
			value_clear(&str);
		}
	} else {
		run_interpreter();
	}
	
	return 0;
}
Ejemplo n.º 3
0
int main(int argc, char **argv) {
  int status = EXIT_FAILURE;

  if (init_tests() == EXIT_FAILURE) {
    ERROR_LOG("Failed to initialize imager tests");
    goto error;
  }
  utest_run("getting the memory map", test_get_mmap());
  utest_run("creating a raw image", test_dump_memory_raw());
  utest_run("creating an elf image", test_dump_memory_elf());
  utest_run("creating a mach-o image", test_dump_memory_macho());
  utest_summary();
  if (cleanup_tests() == EXIT_FAILURE) {
    ERROR_LOG("Failed to release test resources");
    goto error;
  }
  status = EXIT_SUCCESS;
error:
  return status;
}
Ejemplo n.º 4
0
/*
 * Tests: add and remove
 */
static void run_tests(rba_buffer_t *b) {
  uint32_t i, h, n;

  check_tree(b);
  init_tests();

  // add all power products
  n = NUM_TESTS;
  for (i=0; i<n; i++) {
    test_add(b, test[i]);
  }
  printf("\nAfter %"PRIu32" additions\n", n);
  printf("   num_nodes = %"PRIu32"\n", b->num_nodes);
  printf("   num_terms = %"PRIu32"\n", b->nterms);
  printf("   root node = %"PRIu32"\n", b->root);
  if (is_balanced(b, b->root, &h)) {
    printf("   b-height    = %"PRIu32"\n", h);
    printf("   full height = %"PRIu32"\n", tree_height(b));
  } else {
    printf("   not balanced\n");
  }
  printf("\n");

  // remove half
  n = NUM_TESTS/2;
  for (i=0; i<n; i++) {
    test_remove(b, test[i]);
  }
  printf("\nAfter %"PRIu32" removals\n", n);
  printf("   num_nodes = %"PRIu32"\n", b->num_nodes);
  printf("   num_terms = %"PRIu32"\n", b->nterms);
  printf("   root node = %"PRIu32"\n", b->root);
  if (is_balanced(b, b->root, &h)) {
    printf("   b-height    = %"PRIu32"\n", h);
    printf("   full height = %"PRIu32"\n", tree_height(b));
  } else {
    printf("   not balanced\n");
  }

  // add them back
  for (i=0; i<n; i++) {
    test_add(b, test[i]);
  }
  printf("\nAfter %"PRIu32" additions\n", n);
  printf("   num_nodes = %"PRIu32"\n", b->num_nodes);
  printf("   num_terms = %"PRIu32"\n", b->nterms);
  printf("   root node = %"PRIu32"\n", b->root);
  if (is_balanced(b, b->root, &h)) {
    printf("   b-height    = %"PRIu32"\n", h);
    printf("   full height = %"PRIu32"\n", tree_height(b));
  } else {
    printf("   not balanced\n");
  }
  printf("\n");


  // Try again after reset
  reset_rba_buffer(b);
  n = NUM_TESTS/2;
  i = n;
  while (i > 0) {
    i --;
    test_add(b, test[i]);
  }

  printf("\nAfter %"PRIu32" additions\n", n);
  printf("   num_nodes = %"PRIu32"\n", b->num_nodes);
  printf("   num_terms = %"PRIu32"\n", b->nterms);
  printf("   root node = %"PRIu32"\n", b->root);
  if (is_balanced(b, b->root, &h)) {
    printf("   b-height    = %"PRIu32"\n", h);
    printf("   full height = %"PRIu32"\n", tree_height(b));
  } else {
    printf("   not balanced\n");
  }
  printf("\n");

  i = n;
  while (i > 0) {
    i --;
    test_remove(b, test[i]);
  }

  printf("\nAfter %"PRIu32" removals\n", n);
  printf("   num_nodes = %"PRIu32"\n", b->num_nodes);
  printf("   num_terms = %"PRIu32"\n", b->nterms);
  printf("   root node = %"PRIu32"\n", b->root);
  if (is_balanced(b, b->root, &h)) {
    printf("   b-height    = %"PRIu32"\n", h);
    printf("   full height = %"PRIu32"\n", tree_height(b));
  } else {
    printf("   not balanced\n");
  }



  fflush(stdout);
}
Ejemplo n.º 5
0
//In our parameters processing, if the return of getopt_long_only() is 1 we exit, on 0 success, on -1 error
void process_params(int argc, char **argv, parsed_options_t *set_options, test_t **test_list, index_t *test_length, iteration_data_t **iterations, index_t *iterations_length){
  int opt_index;
  int value;
  index_t option_string_length=0;
  char *message_file_path = NULL;
  char *input_file_path = NULL;

  memset(set_options, '\0', sizeof(parsed_options_t));
  set_options->maximum_size = MAXSIZE;
  set_options->minimum_size = MINSIZE;
  set_options->output_file = stdout;

  while(1){
    value = getopt_long_only(argc, argv, "", long_options, &opt_index);
    if(value == -1){
      break;
    }
    switch(value) {
      case 1:
        print_version();
        exit(0);
      case 2:
        print_version();
        print_help();
        exit(0);
      case 3:
        set_options->disable_cache = 1;
        break;
      case 4:
        set_options->warmup_run = 1;
        break;
      case 5:
        option_string_length = strlen(optarg)+1;
        set_options->output_file_path = malloc(option_string_length);
        memcpy(set_options->output_file_path, optarg, option_string_length);
        break;
      case 7:
        option_string_length = strlen(optarg)+1;
        message_file_path = malloc(option_string_length);
        memcpy(message_file_path, optarg, option_string_length);
        break;
      case 8:
        set_options->minimum_size = process_string_to_number(optarg);
        break;
      case 9:
        set_options->maximum_size = process_string_to_number(optarg);
        break;
      case 10:
        set_options->run_time = process_string_to_number(optarg);
        break;
      case 11:
        option_string_length = strlen(optarg)+1;
        input_file_path = malloc(option_string_length);
        memcpy(input_file_path, optarg, option_string_length);
        break;
      case 12:
        set_options->affinity_test = 1;
        if(N_PES != 2){
          fprintf(stderr, "The --affinity flag requires the use of exactly 2 PEs!\n");
          abort();
        }
        break;
      case '?':
        break;
      default:
        fprintf(stderr, "Unknown option 0%o\n", value);
    }
  }

  init_tests();

  if(set_options->output_file_path != NULL) {
    set_options->output_file = fopen(set_options->output_file_path, "w");
  }

  if(input_file_path != NULL){
    process_test_file(input_file_path, test_list, test_length, set_options);
    free(input_file_path);
  } else {
    if(set_options->affinity_test == 0){
      *test_length = all_tests(test_list);
      if(shmem_my_pe() == 0)fprintf(set_options->output_file, "Created all test list.\n");
    } else {
      *test_length = affinity_tests(test_list);
      if(shmem_my_pe() == 0)fprintf(set_options->output_file, "created affinity test list.\n");
    }
  }

  if(shmem_my_pe() == 0) fprintf(set_options->output_file, "Will be running with %lu different tests\n", (*test_length));

  if(message_file_path != NULL) {
    process_iteration_file(message_file_path, iterations, iterations_length);
    free(message_file_path);
  } else {
    *iterations_length = init_iterations(iterations, set_options->minimum_size, set_options->maximum_size);
  }

  if(shmem_my_pe() == 0) fprintf(set_options->output_file, "Will be running with %lu different size configurations\n", (*iterations_length));
}