Пример #1
0
static void verify_access(unsigned int n)
{
	struct tcase *tc = tcases + n;
	pid_t pid;

	access_test(tc, "root");

	pid = SAFE_FORK();
	if (pid) {
		SAFE_WAITPID(pid, NULL, 0);
	} else {
		SAFE_SETUID(uid);
		access_test(tc, "nobody");
	}
}
Пример #2
0
int main( )
{
    int rc = 0;
    //heap_dump();
    int original_count = heap_count( );
    
    try {
        if( !construct_test( )  || !heap_ok( "t1" ) ) rc = 1;
        if( !access_test( )     || !heap_ok( "t2" ) ) rc = 1;
        //if( !string_test( )     || !heap_ok( "t3" ) ) rc = 1;
        //if( !torture_test( )    || !heap_ok( "t4" ) ) rc = 1;
        //if( !clear_test( )      || !heap_ok( "t5" ) ) rc = 1;
        if( !iterator_test( )   || !heap_ok( "t6" ) ) rc = 1;
        if( !copy_test( )       || !heap_ok( "t7" ) ) rc = 1;
        if( !allocator_test( )  || !heap_ok( "t8" ) ) rc = 1;
        if( !bounds_test( )     || !heap_ok( "t9" ) ) rc = 1;
        if( !hint_ins_test( )   || !heap_ok( "tA" ) ) rc = 1;
    }
    catch( ... ) {
        std::cout << "Unexpected exception of unexpected type.\n";
        rc = 1;
    }
    int heap_diff = heap_count( ) - original_count;
    if( heap_diff ) {
        heap_dump();
        std::cout << "Possible memory leak! " << heap_diff << " " << original_count << "\n";
        rc = 1;
    }
    
    return( rc );
}
Пример #3
0
static void test_undivided (int reg_size, int size, int rank) 
{
    smi_region_info_t reginfo;
    smi_error_t err;
    int *shreg_id, p;
    char **shreg_addr;
    int all_ok = 1;

    shreg_id   = (int *)malloc(size*sizeof(int));
    shreg_addr = (char **)malloc(size*sizeof(char *));

    /* one UNDIVIDED region for each process */
    if (rank == 0) {
	printf ("*** testing creation of non-fixed UNDIVIDED regions (one per process), size %dkB\n",
		reg_size/1024);
	fflush (stdout);
    } 
    for (p = 0; p < size; p++) {
	SMI_Init_reginfo (&reginfo, reg_size, 0, p, SMI_ADPT_DEFAULT, 0, 0, NULL);
	err = SMI_Create_shreg(SMI_SHM_UNDIVIDED|SMI_SHM_NONFIXED, &reginfo, &shreg_id[p], 
			       (void **)&shreg_addr[p]);
	if (err != SMI_SUCCESS) {
	    if (rank == p) {
		printf ("###  creation failed for process %d with SMI error %d\n", rank, err);
		fflush (stdout);
	    } 
	    shreg_id[p] = -1;
	    all_ok = 0;
	} else {
	    /* test region by accessing it */
	    access_test(shreg_addr[p], reg_size);
	}
    }

    for (p = 0; p < size; p++) {
	if (shreg_id[p] != -1) {
	    SMI_Free_shreg(shreg_id[p]);
	}
    }

    if (rank == 0) {
	if (all_ok == 1)
	    printf (">>> non-fixed UNDIVIDED regions are o.k.\n");
	else
	    printf ("### some regions could not be created - try a smaller size\n");
	fflush (stdout);
    } 
    
    return;
}    
Пример #4
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 );
}
Пример #5
0
int main()
{

  sequences::piece_chain_method   sds_pc;
  neatpad::piece_chain            nep_pc; nep_pc.init();

  using clock_t      = std::chrono::steady_clock;
  using duration_t   = std::chrono::nanoseconds;
  using time_point_t = std::chrono::time_point<clock_t>;

  clock_t      clock;
  time_point_t start;
  time_point_t stop;

  const unsigned int counter = 1024;

  // append
  //////////////////////////////////////////////////////////////////////////////
  start = clock.now();
  append_test(sds_pc, counter*10);
  stop = clock.now();
  auto time_cnt = std::chrono::duration_cast<duration_t>(stop - start).count();
  std::cout << "sds chain append time " << std::right << std::setw(20)  << time_cnt << " ns" << std::endl;

  start = clock.now();
  append_test(nep_pc, counter*10);
  stop = clock.now();
  time_cnt = std::chrono::duration_cast<duration_t>(stop - start).count();
  std::cout << "nep chain append time " << std::right << std::setw(20)  << time_cnt << " ns" << std::endl;

  std::cout << std::endl << std::endl;
  // access
  //////////////////////////////////////////////////////////////////////////////
  start = clock.now();
  access_test(sds_pc);
  stop = clock.now();
  time_cnt = std::chrono::duration_cast<duration_t>(stop - start).count();
  std::cout << "sds chain access time " << std::right << std::setw(20)  << time_cnt << " ns" << std::endl;

  start = clock.now();
  access_test(nep_pc);
  stop = clock.now();
  time_cnt = std::chrono::duration_cast<duration_t>(stop - start).count();
  std::cout << "nep chain access time " << std::right << std::setw(20)  << time_cnt << " ns" << std::endl;

  std::cout << std::endl << std::endl;
  // insert
  //////////////////////////////////////////////////////////////////////////////
  start = clock.now();
  insert_orderer_char_test(sds_pc, counter*10);
  stop = clock.now();
  time_cnt = std::chrono::duration_cast<duration_t>(stop - start).count();
  std::cout << "sds chain insert ordered char time " << std::right << std::setw(20)  << time_cnt << " ns" << std::endl;

  start = clock.now();
  insert_orderer_char_test(nep_pc, counter*10);
  stop = clock.now();
  time_cnt = std::chrono::duration_cast<duration_t>(stop - start).count();
  std::cout << "nep chain insert ordered char time " << std::right << std::setw(20)  << time_cnt << " ns" << std::endl;

  std::cout << std::endl << std::endl;
  // access
  //////////////////////////////////////////////////////////////////////////////
  start = clock.now();
  access_test(sds_pc);
  stop = clock.now();
  time_cnt = std::chrono::duration_cast<duration_t>(stop - start).count();
  std::cout << "sds chain access time " << std::right << std::setw(20)  << time_cnt << " ns" << std::endl;

  start = clock.now();
  access_test(nep_pc);
  stop = clock.now();
  time_cnt = std::chrono::duration_cast<duration_t>(stop - start).count();
  std::cout << "nep chain access time " << std::right << std::setw(20)  << time_cnt << " ns" << std::endl;

  std::cout << std::endl << std::endl;
  // insert
  //////////////////////////////////////////////////////////////////////////////
  start = clock.now();
  insert_multiple_char_test(sds_pc, counter);
  stop = clock.now();
  time_cnt = std::chrono::duration_cast<duration_t>(stop - start).count();
  std::cout << "sds chain insert multiple char time " << std::right << std::setw(20)  << time_cnt << " ns" << std::endl;

  start = clock.now();
  insert_multiple_char_test(nep_pc, counter);
  stop = clock.now();
  time_cnt = std::chrono::duration_cast<duration_t>(stop - start).count();
  std::cout << "nep chain insert multiple char time " << std::right << std::setw(20)  << time_cnt << " ns" << std::endl;
  std::cout << std::endl << std::endl;
  // access
  //////////////////////////////////////////////////////////////////////////////
  start = clock.now();
  access_test(sds_pc);
  stop = clock.now();
  time_cnt = std::chrono::duration_cast<duration_t>(stop - start).count();
  std::cout << "sds chain access time " << std::right << std::setw(20)  << time_cnt << " ns" << std::endl;

  start = clock.now();
  access_test(nep_pc);
  stop = clock.now();
  time_cnt = std::chrono::duration_cast<duration_t>(stop - start).count();
  std::cout << "nep chain access time " << std::right << std::setw(20)  << time_cnt << " ns" << std::endl;
}