コード例 #1
0
ファイル: my_test_mem.c プロジェクト: coweatyou/school
/*
 * Main program.
 *
 * Initialize the memory allocator, then perform a single-threaded
 * and a multi-thread test.
 */
int
main(int ac, char *av[])
{
  const long long magic = 0xdeadbeefdeadbeefLL;
  leftfence = rightfence = magic;
  /* Initialize memory allocator. */
  mem_init(memory, sizeof memory);
  
/* ~~~~~~~~~~~~~~~       CUSTOM CODE      ~~~~~~~~~~~~~~~ */
  test1();/* Test basic functionality */
  test2();/* Test the memory allocator in a single thread. */
  test3();/* Test the memory allocator with NTHREADS concurrent threads. */
  test4(magic);/* Test basic functionality and ensure there is no memory corruption */
  use_first_fit(false);
  printf("Using best fit\n");
  test1();/* Test basic functionality */
  test2();/* Test the memory allocator in a single thread. */
  test3();/* Test the memory allocator with NTHREADS concurrent threads. */
  test4(magic);/* Test basic functionality and ensure there is no memory corruption */
  return(0);
/* ~~~~~~~~~~~~~~~     END CUSTOM CODE     ~~~~~~~~~~~~~~~ */

  basic_tests();
  basic_tests();
  printf("Test 1 (basic functionality) passed.\n");

  /* Test the memory allocator in a single thread. */
  test_single(0);
  check_free_list_size();
  printf("Test 2 (single-threaded) passed.\n");

  /* Test the memory allocator with NTHREADS concurrent threads. */
  pthread_t threads[NTHREADS];
  int i;
  for (i = 0; i < NTHREADS; i++)
    if (pthread_create(threads + i, (const pthread_attr_t*)NULL, test_single, (void*)i) == -1)
      {
        printf("error creating pthread\n");
        exit(-1);
      }

  /* Wait for threads to finish. */
  for (i = 0; i < NTHREADS; i++)
    pthread_join(threads[i], NULL);

  check_free_list_size();
  printf("Test 3 (with %d threads) passed.\n", NTHREADS);

  basic_tests();
  ASSERT (leftfence == magic || !!!"Memory corruption");
  ASSERT (rightfence == magic || !!!"Memory corruption");
  printf("Test 4 (basic functionality) passed.\n");
  return 0;
}
コード例 #2
0
static void
run_tests(void)
{
  basic_tests();
  union_tests();
  pointer_tests();
  array_tests();
  context_handle_test();
}
コード例 #3
0
int main()
{
  std::cout << "------------------------------------------ BASIC TESTS\n";
  basic_tests();
  std::cout << "------------------------------------------ LOOP TESTS\n";
  loop_tests();
  std::cout << "------------------------------------------ ONE MIN TESTS\n";
  one_min_tests();
}
コード例 #4
0
ファイル: main.cpp プロジェクト: Oliviers-OSS/dbgflags
int main(int argc, char *argv[]) {
    int error = EXIT_SUCCESS;

    basic_tests();
    basic_tests_32();
    basic_byte_tests();
    basic_format_tests();

    return error;
}
コード例 #5
0
int main()
{
    basic_tests();

//  All the iterator categories
    test<input_iterator        <const int*> >();
    test<forward_iterator      <const int*> >();
    test<bidirectional_iterator<const int*> >();
    test<random_access_iterator<const int*> >();
    test<const int*>();
    test<      int*>();
}
コード例 #6
0
ファイル: mm-test.c プロジェクト: 01org/murphy
int main(int argc, char *argv[])
{
    int max;

    if (argc > 1)
        max = (int)strtol(argv[1], NULL, 10);
    else
        max = 256;

    info("Running basic tests...");
    basic_tests(max);

    info("Running object pool tests...");
    pool_tests();

    return 0;
}
コード例 #7
0
ファイル: panel.c プロジェクト: playya/Enlightenment
void setup_panel(Evas *_e)
{
	int w;
	Panel_Button *pbutton1, *pbutton2, *pbutton3;

	o_panel = evas_object_image_add(_e);
	evas_object_image_file_set(o_panel, IM "panel.png",
			IM "panel.png");

	evas_object_image_size_get(o_panel, &w, NULL);
	evas_object_move(o_panel, 0, 0);
	evas_object_resize(o_panel, w, win_h);
	evas_object_image_fill_set(o_panel, 0, 0, w, win_h);
	evas_object_layer_set(o_panel, 200);

	evas_object_show(o_panel);

	/* Panel title */
	o_txt_paneltitle = evas_object_text_add(_e);
	evas_object_text_font_set(o_txt_paneltitle, "sinon", 17);
	evas_object_text_text_set(o_txt_paneltitle, "Etox Test");
	evas_object_color_set(o_txt_paneltitle, 255, 255, 255, 255);
	evas_object_layer_set(o_txt_paneltitle, 250);
	evas_object_show(o_txt_paneltitle);

	/* Panel buttons */
	pbutton1 = panel_button(evas, "Basic", basic_tests());
	pbuttons = eina_list_append(pbuttons, pbutton1);

	pbutton2 = panel_button(evas, "Style", style_tests());
	pbuttons = eina_list_append(pbuttons, pbutton2);

	pbutton3 = panel_button(evas, "Callbacks", callback_tests());
	pbuttons = eina_list_append(pbuttons, pbutton3);

}
コード例 #8
0
ファイル: ctrlm.c プロジェクト: doorleyr/blinkm-projects
int main( void )
{    
    _delay_ms(100);
    // set clock speed
    CLKPR = _BV( CLKPCE );                 // enable clock prescale change
    CLKPR = 0;                             // full speed (8MHz);

#if defined(__AVR_ATtiny25__) || defined(__AVR_ATtiny45__) || \
      defined(__AVR_ATtiny85__)

    // set up periodic timer for state machine ('script_tick')
    TCCR0B = _BV( CS02 ) | _BV(CS00); // start timer, prescale CLK/1024
    TIFR   = _BV( TOV0 );          // clear interrupt flag
    TIMSK  = _BV( TOIE0 );         // enable overflow interrupt

    // set up output pins   
    PORTB = INPI2C_MASK;          // turn on pullups 
    DDRB  = LED_MASK;             // set LED port pins to output

#elif defined(__AVR_ATtiny24__) || defined(__AVR_ATtiny44__) || \
      defined(__AVR_ATtiny84__)

    // set up periodic timer for state machine ('script_tick')
    //TCCR0B = _BV( CS02 ) | _BV(CS00); // start timer, prescale CLK/1024
    //TIFR0  = _BV( TOV0 );          // clear interrupt flag
    //TIMSK0 = _BV( TOIE0 );         // enable overflow interrupt
    // set up output pins   
    PORTA = INPI2C_MASK;          // turn on pullups 
    DDRA  = 0xFF; //LEDA_MASK;            // set LED port pins to output
    DDRB  = 0xFF; //LEDB_MASK;            // set LED port pins to output
    
#endif
    
    fanfare( 3, 300 );

#if 0
    // test for ATtiny44/84 MaxM
    fanfare( 3, 300 );

    IRsend_enableIROut();

    while( 1 ) {
        _delay_ms(10);
        IRsend_iroff();
        _delay_ms(10);
        IRsend_iron();
    }

    /*
    uint8_t f = OCR1B;
    while( 1 ) {
        _delay_ms(10);
        f++; 
        if( f== OCR1A ) f=0;  // OCR1A == period
        OCR1B = f;            // OCR1B == duty cycle (0-OCR1A)
    }
    */
#endif

#if 0
    // test timing of script_tick
    _delay_ms(2000);
    sei();
    _delay_ms(500);  // this should cause script_tick to equal 15
    uint8_t j = script_tick;
    for( int i=0; i<j; i++ ) {
        led_flash();
        _delay_ms(300);
    }
#endif

    //////  begin normal startup

    uint8_t boot_mode      = eeprom_read_byte( &ee_boot_mode );
    uint8_t boot_script_id = eeprom_read_byte( &ee_boot_script_id );
    uint8_t boot_reps      = eeprom_read_byte( &ee_boot_reps );
    //uint8_t boot_fadespeed = eeprom_read_byte( &ee_boot_fadespeed );
    uint8_t boot_timeadj   = eeprom_read_byte( &ee_boot_timeadj );

    // initialize i2c interface
    uint8_t i2c_addr = eeprom_read_byte( &ee_i2c_addr );
    if( i2c_addr==0 || i2c_addr>0x7f) i2c_addr = I2C_ADDR;  // just in case

    i2c_addrs[0] = i2c_addr;
    for( uint8_t i = 1; i<slaveAddressesCount; i++ ) {
        i2c_addrs[i] = i2c_addrs[0] + i;
    }
    usiTwiSlaveInit( i2c_addrs );

    timeadj    = boot_timeadj;
    if( boot_mode == BOOT_PLAY_SCRIPT ) {
        play_script( boot_script_id, boot_reps, 0 );
    }

    sei();                      // enable interrupts

#if 0
    basic_tests();
#endif

    RB_Init();
    // This loop runs forever. 
    // If the TWI Transceiver is busy the execution will just 
    // continue doing other operations.
    for(;;) {
        handle_i2c();
        handle_inputs();
        handle_script();
        handle_ir_queue();
    }
    
} // end
コード例 #9
0
ファイル: my_test_mem.c プロジェクト: coweatyou/school
void test4(const long long magic) {
  basic_tests();
  ASSERT (leftfence == magic || !!!"Memory corruption");
  ASSERT (rightfence == magic || !!!"Memory corruption");
  printf("Test 4 (basic functionality) passed.\n");
}
コード例 #10
0
ファイル: my_test_mem.c プロジェクト: coweatyou/school
/* ~~~~~~~~~~~~~~~       CUSTOM CODE      ~~~~~~~~~~~~~~~ */
void test1() {
  basic_tests();
//  printf("\nRunning basic_test again\n\n\n");
  basic_tests();
  printf("Test 1 (basic functionality) passed.\n");
}