Esempio n. 1
0
// Argument: pass name of a file with at least 2000 lines of text entries (words)
int main(int argc, char* argv[])
{
	int errors = argc - argc;  // 0

	REPORT_CHECK(basic_insertion_test<char>());
	REPORT_CHECK(basic_insertion_test<wchar_t>());
	REPORT_CHECK(element_range_test<char>());
	REPORT_CHECK(element_range_test<wchar_t>());

	REPORT_CHECK(mapped_value_test());
	REPORT_CHECK(copy_test());

	REPORT_CHECK(localization_test());
	REPORT_CHECK(iterator_test(argv[1]));
	REPORT_CHECK(erase_test(argv[1]));

	REPORT_CHECK(prefix_range_test(argv[1]));
	REPORT_CHECK(longest_match_test());
	REPORT_CHECK(partial_match_test(argv[1]));
	REPORT_CHECK(hamming_search_test(argv[1]));
	REPORT_CHECK(levenshtein_search_test());
	REPORT_CHECK(scrabble_search_test(argv[1]));

	return errors;
}
Esempio n. 2
0
File: debug.c Progetto: taphier/lk
static int bio_test_device(bdev_t* device)
{
    ssize_t num_errors = erase_test(device);
    if (num_errors < 0) {
        printf("error %ld performing erase test\n", num_errors);
        return -1;
    }
    printf("discovered %ld error(s) while testing erase.\n", num_errors);
    if (num_errors) {
        // No point in continuing the tests if we couldn't erase the device.
        printf("not continuing to test writes.\n");
        return -1;
    }

    num_errors = write_test(device);
    printf("Discovered %ld error(s) while testing write.\n", num_errors);
    if (num_errors) {
        return -1;
    }

    printf ("Testing sub-erase...\n");
    bool success = sub_erase_test(device, SUB_ERASE_TEST_SAMPLES);
    if (!success) {
        printf("Discovered errors while testing sub-erase.\n");
        return -1;
    } else {
        printf("No errors while testing sub-erase.\n");
    }

    return 0;
}
Esempio n. 3
0
int main( )
{
  int rc = 0;
  int original_count = heap_count( );

  try {
    if( !construct_test( )         || !heap_ok( "t01" ) ) rc = 1;
    if( !assign_test( )            || !heap_ok( "t02" ) ) rc = 1;
    if( !access_test( )            || !heap_ok( "t03" ) ) rc = 1;
    if( !relational_test( )        || !heap_ok( "t04" ) ) rc = 1;
    if( !capacity_test( )          || !heap_ok( "t05" ) ) rc = 1;
    if( !iterator_test( )          || !heap_ok( "t06" ) ) rc = 1;
    if( !append_test( )            || !heap_ok( "t07" ) ) rc = 1;
    if( !insert_test( )            || !heap_ok( "t08" ) ) rc = 1;
    if( !erase_test( )             || !heap_ok( "t09" ) ) rc = 1;
    if( !replace_test( )           || !heap_ok( "t10" ) ) rc = 1;
    if( !iterator_replace_test( )  || !heap_ok( "t11" ) ) rc = 1;
    if( !copy_test( )              || !heap_ok( "t12" ) ) rc = 1;
    if( !swap_test( )              || !heap_ok( "t13" ) ) rc = 1;
    if( !cstr_test( )              || !heap_ok( "t14" ) ) rc = 1;
    if( !find_test( )              || !heap_ok( "t15" ) ) rc = 1;
    if( !rfind_test( )             || !heap_ok( "t16" ) ) rc = 1;
    if( !find_first_of_test( )     || !heap_ok( "t17" ) ) rc = 1;
    if( !find_last_of_test( )      || !heap_ok( "t18" ) ) rc = 1;
    if( !find_first_not_of_test( ) || !heap_ok( "t19" ) ) rc = 1;
    if( !find_last_not_of_test( )  || !heap_ok( "t20" ) ) rc = 1;
    if( !substr_test( )            || !heap_ok( "t21" ) ) rc = 1;
  }
  catch( std::out_of_range e ) {
    std::cout << "Unexpected out_of_range exception: " << e.what( ) << "\n";
    rc = 1;
  }
  catch( std::length_error e ) {
    std::cout << "Unexpected length_error exception: " << e.what( ) << "\n";
    rc = 1;
  }
  catch( ... ) {
    std::cout << "Unexpected exception of unexpected type.\n";
    rc = 1;
  }

  if( heap_count( ) != original_count ) {
    std::cout << "Possible memory leak!\n";
    rc = 1;
  }
  return( rc );
}
Esempio n. 4
0
int mymain()
{
	unsigned char c = 68;
	//clock_init();
	uart_init();
	// 初始化nandflash
	nand_init();
	
	while (1)
	{
		printf("\r\n********Nandflash R/W Test*******\r\n");
		printf("[i] Read ID\r\n");
		printf("[e] Erase Nandflash\r\n");
		printf("[w] Write Nandflash\r\n");
		printf("[r] Read  Nandflash\r\n");
		printf("[n] read sdram to nand\r\n");
		printf("Enter your choice: ");
		c = getc();
		printf("%c\r\n",c);
		
		switch(c)
		{
		case 'i':
			nand_read_id();
			break;
		case 'e':
			erase_test();
			break;
		case 'w':
			write_test();
			break;
		case 'r':
			read_test();
			break;
		case 'n':
			sdram_to_nand_test();
			break;
		}
	}
	return 0;
}
Esempio n. 5
0
File: debug.c Progetto: 0xBADCA7/lk
static int bio_test_device(bdev_t *device)
{
    ssize_t num_errors = erase_test(device);
    if (num_errors < 0) {
        printf("error %ld performing erase test\n", num_errors);
        return -1;
    }
    printf("discovered %ld error(s) while testing erase.\n", num_errors);
    if (num_errors) {
        // No point in continuing the tests if we couldn't erase the device.
        printf("not continuing to test writes.\n");
        return -1;
    }

    num_errors = write_test(device);
    printf("Discovered %ld error(s) while testing write.\n", num_errors);
    if (num_errors) {
        return -1;
    }

    printf ("Testing sub-erase...\n");
    bool success = sub_erase_test(device, SUB_ERASE_TEST_SAMPLES);
    if (!success) {
        printf("Discovered errors while testing sub-erase.\n");
        return -1;
    } else {
        printf("No errors while testing sub-erase.\n");
    }

    printf("Testing memory mapped mode...\n");
    status_t test_result = memory_mapped_test(device);
    if (test_result != NO_ERROR) {
        printf("Memory mapped test returned error %d\n", test_result);
    } else {
        printf("Memory mapped mode tests returned successfully\n");
    }

    return 0;
}
Esempio n. 6
0
int
run_tests (const char **test_data)
{
  int argc_after, argc_before;
  char ** argv_before, ** argv_after;
  int i, j, k, fails, failed;

  i = j = fails = 0;
  /* Loop over all the tests */
  while (test_data[j])
    {
      /* Write test data */
      writeout_test (i, test_data[j++]);
      /* Copy argv before */
      argv_before = dupargv ((char **) &test_data[j]);

      /* Count argc before/after */
      argc_before = 0;
      argc_after = 0;
      while (test_data[j + argc_before])
        argc_before++;
      j += argc_before + 1; /* Skip null */
      while (test_data[j + argc_after])
        argc_after++;

      /* Copy argv after */
      argv_after = dupargv ((char **) &test_data[j]);

      /* Run all possible replaces */
      for (k = 0; k < argc_before; k++)
        run_replaces (argv_before[k]);
      for (k = 0; k < argc_after; k++)
        run_replaces (argv_after[k]);

      /* Run test: Expand arguments */
      expandargv (&argc_before, &argv_before);

      failed = 0;
      /* Compare size first */
      if (argc_before != argc_after)
        {
          printf ("FAIL: test-expandargv-%d. Number of arguments don't match.\n", i);
	  failed++;
        }
      /* Compare each of the argv's ... */
      else
        for (k = 0; k < argc_after; k++)
          if (strcmp (argv_before[k], argv_after[k]) != 0)
            {
              printf ("FAIL: test-expandargv-%d. Arguments don't match.\n", i);
              failed++;
            }

      if (!failed)
        printf ("PASS: test-expandargv-%d.\n", i);
      else
        fails++;

      freeargv (argv_before);
      freeargv (argv_after);
      /* Advance to next test */
      j += argc_after + 1;
      /* Erase test file */
      erase_test (i);
      i++;
    }
  return fails;
}