Exemple #1
0
/*---------------------------------------------------------------------------*/
void
assert_acc_value()
{
  int idx;
  int32_t x = 0;
  int32_t y = 0;
  int32_t z = 0;

  // wait for stable values
  _delay_ms(100);

  for (idx = 0; idx < 2; idx++) {
    x += acc_sensor.value(ACC_X);
    y += acc_sensor.value(ACC_Y);
    z += acc_sensor.value(ACC_Z);
  }
  x >>= 1;
  y >>= 1;
  z >>= 1;
  // calc ^2 of vec length
  int32_t static_g = x*x + y*y + z*z;
  // test for 1g +/- 10%
  TEST_REPORT("x-axis", (int16_t) x, 1, "mg");
  TEST_REPORT("y-axis", (int16_t) y, 1, "mg");
  TEST_REPORT("z-axis", (int16_t) z, 1, "mg");

  TEST_LEQ(static_g, ACC_TEST_CFG_MAX_ACC*ACC_TEST_CFG_MAX_ACC);
  TEST_GEQ(static_g, ACC_TEST_CFG_MIN_ACC*ACC_TEST_CFG_MIN_ACC);
}
Exemple #2
0
int main(int argc, char ** argv) {

	RUN(test_basic_diffusion);
	RUN(test_near_borders);
	RUN(test_border_temperatures);
	RUN(test_on_border_edge_case);

	return TEST_REPORT();
}
Exemple #3
0
int main(void) {
  TEST_INIT();
  TEST_RUN(bxmlparser_1);
  TEST_RUN(bxmlparser_2);
  TEST_RUN(bxmlparser_3);
  TEST_RUN(bxmlparser_4);
  TEST_RUN(bxmlparser_5);
  TEST_RUN(bxmlparser_6);
  TEST_RUN(bxmlparser_7);
  TEST_RUN(bxmlparser_fn_1);


  TEST_REPORT();
}
Exemple #4
0
bool radixSortTest()
{
	TEST_INIT;
	
	int maxSize = 1024*256;

	b3AlignedObjectArray<b3SortData> buf0Host;
	buf0Host.resize(maxSize);
	b3AlignedObjectArray<b3SortData> buf1Host;
	buf1Host.resize(maxSize );
	b3OpenCLArray<b3SortData> buf2CL(g_context,g_queue,maxSize);

	b3RadixSort32CL* sort = new b3RadixSort32CL(g_context,g_device,g_queue,maxSize);

	int dx = maxSize/NUM_TESTS;
	for(int iter=0; iter<NUM_TESTS; iter++)
	{
		int size = b3Min( 128+dx*iter, maxSize-512 );
		size = NEXTMULTIPLEOF( size, 512 );//not necessary
		
		buf0Host.resize(size);

		for(int i=0; i<size; i++)
		{
			b3SortData v;
			v.m_key = getRandom(0,0xff);
			v.m_value = i;
			buf0Host[i] = v;
		}

		buf2CL.copyFromHost( buf0Host);
		

		sort->executeHost( buf0Host);
		sort->execute(buf2CL);

		buf2CL.copyToHost(buf1Host);
				
		for(int i=0; i<size; i++) 
		{
			TEST_ASSERT( buf0Host[i].m_value == buf1Host[i].m_value && buf0Host[i].m_key == buf1Host[i].m_key );
		}
	}

	delete sort;

	TEST_REPORT( "radixSort" );

	return g_testFailed;
}
Exemple #5
0
int main(void) {
  Buf buf;
  Buf * cont;
  Mixin * mix;
  TEST_INIT();
  printf("Offsetof mix1: %u\n", offsetof(Buf, Mixin));
  cont = container_of((buf.Mixin), Buf, Mixin);
  mix  = mixin_of(&buf, Mixin); 
  //cont = (Buf*)(((char *)&buf.mix1) - offsetof(Buf, mix1));
  printf("&buf, cont, mix: %p %p %p %d\n", &buf, cont, mix, cont == &buf); 
  puts(SI_OS);
  TEST_RUN(siwire_new);
  TEST_RUN(siwire_const);
  TEST_RUN(siwire_dup);
  TEST_REPORT();
}
Exemple #6
0
void prefixScanTest()
{
	TEST_INIT;

	int maxSize = 1024*256;

	b3AlignedObjectArray<unsigned int> buf0Host;
	b3AlignedObjectArray<unsigned int> buf1Host;

	b3OpenCLArray<unsigned int> buf2CL(g_context,g_queue,maxSize);
	b3OpenCLArray<unsigned int> buf3CL(g_context,g_queue,maxSize);
	
	
	b3PrefixScanCL* scan = new b3PrefixScanCL(g_context,g_device,g_queue,maxSize);
		
	int dx = maxSize/NUM_TESTS;
	for(int iter=0; iter<NUM_TESTS; iter++)
	{
		int size = b3Min( 128+dx*iter, maxSize );
		buf0Host.resize(size);
		buf1Host.resize(size);

		for(int i=0; i<size; i++) 
			buf0Host[i] = 1;
		
		buf2CL.copyFromHost( buf0Host);
	
		unsigned int sumHost, sumGPU;

		scan->executeHost(buf0Host, buf1Host, size, &sumHost );
		scan->execute( buf2CL, buf3CL, size, &sumGPU );

		buf3CL.copyToHost(buf0Host);
		
		TEST_ASSERT( sumHost == sumGPU );
		for(int i=0; i<size; i++) 
			TEST_ASSERT( buf1Host[i] == buf0Host[i] );
	}

	delete scan;

	TEST_REPORT( "scanTest" );
}
Exemple #7
0
inline void fillIntTest()
{
	TEST_INIT;

	b3FillCL* fillCL = new b3FillCL(g_context,g_device,g_queue);
	int maxSize=1024*256;
	b3OpenCLArray<int> intBuffer(g_context,g_queue,maxSize);
	intBuffer.resize(maxSize);
	
#define NUM_TESTS 7

	int dx = maxSize/NUM_TESTS;
	for (int iter=0;iter<NUM_TESTS;iter++)
	{
		int size = b3Min( 11+dx*iter, maxSize );

		int value = 2;
		

		int offset=0;
		fillCL->execute(intBuffer,value,size,offset);

		b3AlignedObjectArray<int> hostBuf2;
		hostBuf2.resize(size);
		fillCL->executeHost(hostBuf2,value,size,offset);

		b3AlignedObjectArray<int> hostBuf;
		intBuffer.copyToHost(hostBuf);

		for(int i=0; i<size; i++)
		{
				TEST_ASSERT( hostBuf[i] == hostBuf2[i] );
				TEST_ASSERT( hostBuf[i] == hostBuf2[i] );
		}
	}

	

	delete fillCL;

	TEST_REPORT( "fillIntTest" );
}
Exemple #8
0
int main(void) {
  TEST_INIT();
  TEST_RUN(token);
  TEST_REPORT();
}
Exemple #9
0
int main(void) {
  TEST_INIT();
  TEST_RUN(tr_path);
  TEST_REPORT();
}
Exemple #10
0
int main(void) {
    TEST_INIT();
    TEST_RUN(spritelayout);
    TEST_REPORT();
}
Exemple #11
0
int main(void) {
  TEST_INIT();
  TEST_RUN(react);
  TEST_REPORT();
}
Exemple #12
0
int main(void) {
  TEST_INIT();
  TEST_RUN(obj);
  TEST_REPORT();
}
Exemple #13
0
int main(void) {
  TEST_INIT();
  TEST_RUN(pique);
  TEST_REPORT();
}
Exemple #14
0
int main(void) {
  TEST_INIT();
  TEST_RUN(ses);
  TEST_REPORT();
}
Exemple #15
0
void boundSearchTest( )
{
	TEST_INIT;

	int maxSize = 1024*256;
	int bucketSize = 256;

	b3OpenCLArray<b3SortData> srcCL(g_context,g_queue,maxSize);
	b3OpenCLArray<unsigned int> upperCL(g_context,g_queue,maxSize);
	b3OpenCLArray<unsigned int> lowerCL(g_context,g_queue,maxSize);
	
	b3AlignedObjectArray<b3SortData> srcHost;
	b3AlignedObjectArray<unsigned int> upperHost;
	b3AlignedObjectArray<unsigned int> lowerHost;
	b3AlignedObjectArray<unsigned int> upperHostCompare;
	b3AlignedObjectArray<unsigned int> lowerHostCompare;
	
	b3BoundSearchCL* search = new b3BoundSearchCL(g_context,g_device,g_queue, maxSize);


	int dx = maxSize/NUM_TESTS;
	for(int iter=0; iter<NUM_TESTS; iter++)
	{
		
		int size = b3Min( 128+dx*iter, maxSize );

		upperHost.resize(bucketSize);
		lowerHost.resize(bucketSize);
		upperHostCompare.resize(bucketSize);
		lowerHostCompare.resize(bucketSize);

		srcHost.resize(size);

		for(int i=0; i<size; i++) 
		{
			b3SortData v;
//			v.m_key = i<2? 0 : 5;
			v.m_key = getRandom(0,bucketSize);

			v.m_value = i;
			srcHost.at(i) = v;
		}

		srcHost.quickSort(b3SortDataCompare());
		srcCL.copyFromHost(srcHost);

		{
			
			for(int i=0; i<bucketSize; i++) 
			{
				lowerHost[i] = -1;
				lowerHostCompare[i] = -1;
				upperHost[i] = -1;
				upperHostCompare[i] = -1;
			}
			upperCL.copyFromHost(upperHost);
			lowerCL.copyFromHost(lowerHost);
		}

		search->execute(srcCL,size,upperCL,bucketSize,b3BoundSearchCL::BOUND_UPPER);
		search->execute(srcCL,size,lowerCL,bucketSize,b3BoundSearchCL::BOUND_LOWER);

		search->executeHost(srcHost,size,upperHostCompare,bucketSize,b3BoundSearchCL::BOUND_UPPER);
		search->executeHost(srcHost,size,lowerHostCompare,bucketSize,b3BoundSearchCL::BOUND_LOWER);

		lowerCL.copyToHost(lowerHost);
		upperCL.copyToHost(upperHost);
		for(int i=0; i<bucketSize; i++)
		{
			TEST_ASSERT(upperHostCompare[i] == upperHost[i]);
			TEST_ASSERT(lowerHostCompare[i] == lowerHost[i]);
		}
		/*
		for(int i=1; i<bucketSize; i++)
		{
			int lhi_1 = lowerHost[i-1];
			int lhi = lowerHost[i];

			for(int j=lhi_1; j<lhi; j++)
			//for(int j=lowerHost[i-1]; j<lowerHost[i]; j++)
			{
				TEST_ASSERT( srcHost[j].m_key < i );
			}
		}

		for(int i=0; i<bucketSize; i++)
		{
			int jMin = (i==0)?0:upperHost[i-1];
			for(int j=jMin; j<upperHost[i]; j++)
			{
				TEST_ASSERT( srcHost[j].m_key <= i );
			}
		}
		*/


		for(int i=0; i<bucketSize; i++)
		{
			int lhi = lowerHost[i];
			int uhi = upperHost[i];

			for(int j=lhi; j<uhi; j++)
			{
				if ( srcHost[j].m_key != i )
				{
					printf("error %d != %d\n",srcHost[j].m_key,i);
				}
				TEST_ASSERT( srcHost[j].m_key == i );
			}
		}

	}

	delete search;

	TEST_REPORT( "boundSearchTest" );
}
PROCESS_THREAD(test_process, ev, data)
{
	static int n;
	static uint32_t i;
	static int errors = 0;
	static struct etimer timer;
	static uint32_t time_start, time_stop;

	PROCESS_BEGIN();

	/* Initialize the flash before the storage comes along */
	PRINTF("Intializing Flash...\n");
	BUNDLE_STORAGE.format();

	PROCESS_PAUSE();

	profiling_init();
	profiling_start();

	// Wait again
	etimer_set(&timer, CLOCK_SECOND);
	PROCESS_WAIT_UNTIL(etimer_expired(&timer));

	printf("Init done, starting test using %s storage\n", BUNDLE_STORAGE.name);

	profiling_init();
	profiling_start();

	// Measure the current time
	time_start = test_precise_timestamp();

	PRINTF("Create and Verify bundles in sequence\n");
	for(i=0; i<TEST_BUNDLES; i++) {
		PROCESS_PAUSE();

		if( my_create_bundle(i, &bundle_numbers[i], 3600) ) {
			PRINTF("\tBundle %lu created successfully \n", i);
		} else {
			PRINTF("\tBundle %lu could not be created \n", i);
			errors ++;
			continue;
		}

		if( my_verify_bundle(bundle_numbers[i], i) ) {
			PRINTF("\tBundle %lu read back successfully \n", i);
		} else {
			PRINTF("\tBundle %lu could not be read back and verified \n", i);
			errors ++;
		}
	}

	printf("Reinitialize storage\n");
	/* Reinitialize the storage and see, if the bundles persist */
	BUNDLE_STORAGE.init();

	PRINTF("Verify and Delete bundles in sequence\n");
	for(i=0; i<TEST_BUNDLES; i++) {
		if( my_verify_bundle(bundle_numbers[i], i) ) {
			PRINTF("\tBundle %lu read back successfully \n", i);
		} else {
			PRINTF("\tBundle %lu could not be read back and verified \n", i);
			errors ++;
		}

		n = BUNDLE_STORAGE.del_bundle(bundle_numbers[i], REASON_DELIVERED);

		if( n ) {
			PRINTF("\tBundle %lu deleted successfully\n", i);
		} else {
			PRINTF("\tBundle %lu could not be deleted\n", i);
			errors++;
		}
	}

	time_stop = test_precise_timestamp();

	watchdog_stop();
	profiling_report("persistent-storage", 0);

	TEST_REPORT("No of errors", errors, 1, "errors");
	TEST_REPORT("Duration", time_stop-time_start, CLOCK_SECOND, "s");

	if( errors > 0 ) {
		TEST_FAIL("More than 1 error occured");
	} else {
		TEST_PASS();
	}

	PROCESS_END();
}
Exemple #17
0
int main(void) {
  TEST_INIT();
  TEST_RUN(raku_parser);
  TEST_REPORT();
}
Exemple #18
0
int main(void) {
  TEST_INIT();
  TEST_RUN(mode);
  TEST_REPORT();
}
Exemple #19
0
int main()
{
    test_kinesix_device_all();

    return TEST_REPORT();
}
Exemple #20
0
/*---------------------------------------------------------------------------*/
PROCESS_THREAD(coffee_test_process, ev, data)
{
  int fd_write, n, i;
  static int cnt = 0;
  uint8_t buffer[FILE_SIZE];
  clock_time_t now;
  unsigned short now_fine;
  static uint32_t time_start, time_stop;

  printf("###########################################################\n");

  PROCESS_BEGIN();

  printf("process running\n");

  // wait for 5 sec
  etimer_set(&et, CLOCK_SECOND * 5);
  PROCESS_YIELD_UNTIL(etimer_expired(&et));

#if (COFFEE_DEVICE == 6)
  int initialized = 0, i;

  SDCARD_POWER_ON();

  //--- Detecting devices and partitions
  TEST_EQUALS(diskio_detect_devices(), DISKIO_SUCCESS);

  info = diskio_devices();
  for (i = 0; i < DISKIO_MAX_DEVICES; i++) {
    if ((info + i)->type == (DISKIO_DEVICE_TYPE_SD_CARD | DISKIO_DEVICE_TYPE_PARTITION)) {
      info += i;
      initialized = 1;
      break; 
    }
  }
  TEST_EQUALS(initialized, 1);

  diskio_set_default_device(info);
#endif

  printf("fomartting...\n");
  TEST_EQUALS(cfs_coffee_format(), 0);
  //printf("test starting\n");

  do {
    now_fine = clock_time();
    now = clock_seconds();
  } while (now_fine != clock_time());
  time_start = ((unsigned long)now)*CLOCK_SECOND + now_fine%CLOCK_SECOND;

  while(1) {
    // Shortest possible pause
    PROCESS_PAUSE();

    // Determine the filename
    char b_file[8];
    sprintf(b_file,"%u.b", cnt);

    // Set the file size
    printf("Reserving '%s'...\n", b_file);
    TEST_EQUALS(cfs_coffee_reserve(b_file, FILE_SIZE), 0);

      // And open it
    printf("Opening '%s'...\n", b_file);
    fd_write = cfs_open(b_file, CFS_WRITE);
    TEST_NEQ(fd_write, -1);

    // fill buffer
    for(i=0; i<FILE_SIZE; i++) {
      buffer[i] = cnt % 0xFF;
    }

    // Open was successful, write has to be successful too since the size has been reserved
    printf("Writing'%s'...\n", b_file);
    n = cfs_write(fd_write, buffer, FILE_SIZE);
    cfs_close(fd_write);

    TEST_EQUALS(n, FILE_SIZE);

    printf("%s written\n", b_file);

    if( cnt >= FILES_IN_STORAGE ) {
      int fd_read;

      // Figure out the filename
      char r_file[8];
      sprintf(r_file,"%u.b", cnt - FILES_IN_STORAGE);

      // Open the bundle file
      printf("Reopening '%s'...\n", r_file);
      fd_read = cfs_open(r_file, CFS_READ);
      if(fd_read == -1) {
        // Could not open file
        printf("############# STORAGE: could not open file %s\n", r_file);
        fail();
      }

      memset(buffer, 0, FILE_SIZE);

      // And now read the bundle back from flash
      printf("Reading '%s'...\n", b_file);
      if (cfs_read(fd_read, buffer, FILE_SIZE) == -1){
        printf("############# STORAGE: cfs_read error\n");
        cfs_close(fd_read);
        fail();
      }
      cfs_close(fd_read);

      for(i=0; i<FILE_SIZE; i++) {
        if( buffer[i] != (cnt - FILES_IN_STORAGE) % 0xFF ) {
          printf("############# STORAGE: verify error\n");
          fail();
        }
      }

      if( cfs_remove(r_file) == -1 ) {
        printf("############# STORAGE: unable to remove %s\n", r_file);
        fail();
      }

      printf("%s deleted\n", r_file);
    }

    cnt ++;

    if( cnt >= 10 ) {
      do {
        now_fine = clock_time();
        now = clock_seconds();
      } while (now_fine != clock_time());
      time_stop = ((unsigned long)now)*CLOCK_SECOND + now_fine%CLOCK_SECOND;

      TEST_REPORT("data written", FILE_SIZE*cnt*CLOCK_SECOND, time_stop-time_start, "bytes/s");
      TEST_PASS();
      watchdog_stop();
      while(1);
    }
  }

  PROCESS_END();
}
int main_0038_performance (int argc, char **argv) {
	const char *topic = test_mk_topic_name(__FUNCTION__, 1);
	const int partition = 0;
	const int msgsize = 100;
	uint64_t testid;
	rd_kafka_conf_t *conf;
	rd_kafka_t *rk;
	rd_kafka_topic_t *rkt;
	test_timing_t t_create, t_produce, t_consume;
	int totsize = 1024*1024*128;
	int msgcnt;

	if (!strcmp(test_mode, "valgrind") || !strcmp(test_mode, "helgrind") ||
	    !strcmp(test_mode, "drd"))
		totsize = 1024*1024*8; /* 8 meg, valgrind is slow. */

	msgcnt = totsize / msgsize;

	TEST_SAY("Producing %d messages of size %d to %s [%d]\n",
		 msgcnt, (int)msgsize, topic, partition);
	testid = test_id_generate();
	test_conf_init(&conf, NULL, 120);
	rd_kafka_conf_set_dr_cb(conf, test_dr_cb);
	test_conf_set(conf, "queue.buffering.max.messages", "10000000");
	rk = test_create_handle(RD_KAFKA_PRODUCER, conf);
	rkt = test_create_producer_topic(rk, topic, "acks", "1", NULL);

	/* First produce one message to create the topic, etc, this might take 
	 * a while and we dont want this to affect the throughput timing. */
	TIMING_START(&t_create, "CREATE TOPIC");
	test_produce_msgs(rk, rkt, testid, partition, 0, 1, NULL, msgsize);
	TIMING_STOP(&t_create);

	TIMING_START(&t_produce, "PRODUCE");
	test_produce_msgs(rk, rkt, testid, partition, 1, msgcnt-1, NULL, msgsize);
	TIMING_STOP(&t_produce);

	TEST_SAY("Destroying producer\n");
	rd_kafka_topic_destroy(rkt);
	rd_kafka_destroy(rk);

	TEST_SAY("Creating consumer\n");
	test_conf_init(&conf, NULL, 120);
	rk = test_create_consumer(NULL, NULL, conf, NULL, NULL);
	rkt = rd_kafka_topic_new(rk, topic, NULL);

	test_consumer_start("CONSUME", rkt, partition,
			    RD_KAFKA_OFFSET_BEGINNING);
	TIMING_START(&t_consume, "CONSUME");
	test_consume_msgs("CONSUME", rkt, testid, partition, TEST_NO_SEEK,
			  0, msgcnt, 1);
	TIMING_STOP(&t_consume);
	test_consumer_stop("CONSUME", rkt, partition);

	rd_kafka_topic_destroy(rkt);
	rd_kafka_destroy(rk);

	TEST_REPORT("{ \"producer\": "
		    " { \"mb_per_sec\": %.2f, \"records_per_sec\": %.2f },"
		    " \"consumer\": "
		    "{ \"mb_per_sec\": %.2f, \"records_per_sec\": %.2f } "
		    "}",
		    (double)
		    (totsize/((double)TIMING_DURATION(&t_produce)/1000000.0f)) /
		    1000000.0f,
		    (float)
		    (msgcnt/((double)TIMING_DURATION(&t_produce)/1000000.0f)),
		    (double)
		    (totsize/((double)TIMING_DURATION(&t_consume)/1000000.0f)) /
		    1000000.0f,
		    (float)
		    (msgcnt/((double)TIMING_DURATION(&t_consume)/1000000.0f)));
	return 0;
}
Exemple #22
0
int main(void) {
  TEST_INIT();
  TEST_RUN(tr_sprite);
  TEST_REPORT();
}
Exemple #23
0
int main(void) {
  TEST_INIT();
  TEST_RUN(rebox);
  TEST_REPORT();
}
PROCESS_THREAD(test_process, ev, data)
{
	static uint32_t time_start = 0;
	static uint32_t time_stop = 0;
	static uint32_t errors = 0;
	static uint32_t collisions = 0;
	uint32_t i = 0;
	uint32_t test_data[10] = {251284450, 371537862, 425973621, 81975339, 170405567, 225666122, 421777121, 118094495, 410814580, 414999832};

	PROCESS_BEGIN();
	PROCESS_PAUSE();

	printf("Init done, starting test using redudancy implementation %s\n", REDUNDANCE.name);

	// Initialize the profiling
	profiling_init();
	profiling_start();

	// Measure the current time
	time_start = test_precise_timestamp();

	// -----------------------------------
	// Check if no bundles are stored
	printf("Making sure list is empty\n");
	for(i=0; i<0xFFFFF; i++) {
		if( REDUNDANCE.check(i) ) {
			errors ++;
			printf("ERROR: %lu reported to be set but should be empty\n", i);
		}

		// Keep the watchdog happy
		if( i % 10 == 0 ) {
			watchdog_periodic();
		}

		if( i % 10000 == 0 ) {
			printf("\t%lu...\n", i);
		}
	}

	// -----------------------------------
	// Store 10 bundles
	printf("Storing 10 bundles...\n");
	for(i=0; i<10; i++) {
		REDUNDANCE.set(test_data[i]);

		// Keep the watchdog happy
		if( i % 5 == 0 ) {
			watchdog_periodic();
		}
	}

	// Keep the watchdog happy
	watchdog_periodic();

	// -----------------------------------
	// Retrieve the 10 bundles
	printf("Reading 10 bundles back...\n");
	for(i=0; i<10; i++) {
		if( !REDUNDANCE.check(test_data[i]) ) {
			printf("ERROR: %lu should be set but is not\n", i);
			errors++;
		} else {
			printf("\t%lu is fine\n", test_data[i]);
		}
	}

	// Keep the watchdog happy
	watchdog_periodic();

	// -----------------------------------
	// Check how many bundle ID are actually reported as set
	printf("Counting collisions...\n");
	for(i=0; i<0xFFFFF; i++) {
		if( REDUNDANCE.check(i) ) {
			printf("\tcollision at %lu\n", i);
			collisions ++;
		}

		// Keep the watchdog happy
		if( i % 10 == 0 ) {
			watchdog_periodic();
		}

		if( i % 10000 == 0 ) {
			printf("\t%lu...\n", i);
		}
	}

	printf("We have %lu collisions\n", collisions);

	// Keep the watchdog happy
	watchdog_periodic();

	// -----------------------------------
	// Now set 1000 bundle IDs and check the last 10 of them
	printf("Setting 1000 bundle IDs...\n");
	for(i=0; i<1000; i++) {
		REDUNDANCE.set(i);

		// Keep the watchdog happy
		if( i % 5 == 0 ) {
			watchdog_periodic();
		}
	}

	// Keep the watchdog happy
	watchdog_periodic();

	printf("Verifying IDs...\n");
	for(i=990; i<1000; i++) {
		if( !REDUNDANCE.check(i) ) {
			printf("ERROR: %lu should be set but is not\n", i);
			errors++;
		}

		// Keep the watchdog happy
		if( i % 5 == 0 ) {
			watchdog_periodic();
		}
	}

	printf("Done\n");

	// Measure the current time
	time_stop = test_precise_timestamp();

	watchdog_stop();
	profiling_report("redundancy", 0);

	TEST_REPORT("No of errors", errors, 1, "errors");
	TEST_REPORT("Duration", time_stop-time_start, CLOCK_SECOND, "s");
	TEST_REPORT("No of collisions", collisions, 1, "collisions");

	if( errors > 0 ) {
		TEST_FAIL("More than 1 error occurred");
	} else {
		TEST_PASS();
	}

	PROCESS_END();
}
Exemple #25
0
int main(void) {
  TEST_INIT();
  TEST_RUN(tr_audio);
  TEST_REPORT();
}
PROCESS_THREAD(test_process, ev, data)
{
    static int n;
    static int i;
    static int errors = 0;
    static struct etimer timer;
    static uint32_t time_start, time_stop;
    uint8_t buffer[128];
    int bundle_length;
    struct mmem * bundle_original = NULL;
    struct mmem * bundle_restored = NULL;
    struct mmem * bundle_spare = NULL;
    uint32_t bundle_number;
    uint32_t bundle_number_spare;

    PROCESS_BEGIN();

    PROCESS_PAUSE();

    profiling_init();
    profiling_start();

    // Wait again
    etimer_set(&timer, CLOCK_SECOND);
    PROCESS_WAIT_UNTIL(etimer_expired(&timer));

    /* Profile initialization separately */
    profiling_stop();
    watchdog_stop();
    profiling_report("init", 0);
    watchdog_start();
    printf("Init done, starting test using %s storage\n", BUNDLE_STORAGE.name);

    profiling_init();
    profiling_start();

    // Measure the current time
    time_start = test_precise_timestamp();

    for(i=0; i<=1; i++) {
        struct mmem bla;
        if( i > 0 ) {
            mmem_alloc(&bla, 1);
        }

        printf("Serializing and deserializing bundle...\n");
        if( my_create_bundle(0, &bundle_number, 3600) ) {
            printf("\tBundle created successfully \n");
        } else {
            printf("\tBundle could not be created \n");
            errors ++;
        }

        printf("Serializing and deserializing bundle...\n");
        if( my_create_bundle(1, &bundle_number_spare, 3600) ) {
            printf("\tSpare Bundle created successfully \n");
        } else {
            printf("\tSpare Bundle could not be created \n");
            errors ++;
        }

        bundle_original = BUNDLE_STORAGE.read_bundle(bundle_number);
        if( bundle_original == NULL ) {
            printf("VERIFY: MMEM ptr is invalid\n");
            errors ++;
        }

        bundle_spare = BUNDLE_STORAGE.read_bundle(bundle_number_spare);
        if( bundle_spare == NULL ) {
            printf("VERIFY: MMEM ptr is invalid\n");
            errors ++;
        }

        // Fake timing information in the bundle to make verify successful
        struct bundle_t * bundle_original_bundle = (struct bundle_t *) MMEM_PTR(bundle_original);
        bundle_original_bundle->aeb_value_ms = 54;
        bundle_original_bundle->rec_time = clock_time();

        // Serialize the bundle
        memset(buffer, 0, 128);
        bundle_length = bundle_encode_bundle(bundle_original, buffer, 128);
        if( bundle_length < 0 ) {
            printf("SERIALIZE: fail\n");
            errors ++;
        }

        n = my_static_compare(buffer, bundle_length);
        if( n > 0 ) {
            printf("COMPARE: fail\n");
            errors += n;
        }

        // Deserialize it
        bundle_restored = bundle_recover_bundle(buffer, bundle_length);
        if( bundle_restored == NULL ) {
            printf("DESERIALIZE: unable to recover\n");
            errors ++;
        }

        n = my_compare_bundles(bundle_original, bundle_restored);
        if( n == 0 ) {
            printf("\tBundle serialized and deserialized successfully\n");
        } else {
            printf("COMPARE: differences\n");
            errors ++;
        }

        // Dellocate memory
        bundle_decrement(bundle_restored);
        bundle_restored = NULL;

        bundle_decrement(bundle_original);
        bundle_original = NULL;

        bundle_decrement(bundle_spare);
        bundle_spare = NULL;

        memset(buffer, 0, 128);

        // Delete bundle from storage
        n = BUNDLE_STORAGE.del_bundle(bundle_number, REASON_DELIVERED);
        if( n ) {
            printf("\tBundle deleted successfully\n");
        } else {
            printf("\tBundle could not be deleted\n");
            errors++;
        }


        printf("Comparing static bundle...\n");
        if( my_create_bundle(0, &bundle_number, 3600) ) {
            printf("\tReference Bundle created successfully \n");
        } else {
            printf("\ttReference Bundle could not be created \n");
            errors ++;
        }

        bundle_original = BUNDLE_STORAGE.read_bundle(bundle_number);
        if( bundle_original == NULL ) {
            printf("VERIFY: MMEM ptr is invalid\n");
            errors ++;
        }

        // Deserialize it
        bundle_restored = bundle_recover_bundle(static_compare_bundle, sizeof(static_compare_bundle));
        if( bundle_restored == NULL ) {
            printf("DESERIALIZE: unable to recover static bundle\n");
            errors ++;
        }

        // Deserialize it one more time
        bundle_spare = bundle_recover_bundle(static_compare_bundle, sizeof(static_compare_bundle));
        if( bundle_spare == NULL ) {
            printf("DESERIALIZE: unable to recover static bundle\n");
            errors ++;
        }

        n = my_compare_bundles(bundle_original, bundle_restored);
        if( n == 0 ) {
            printf("\tStatic Bundle verified successfully\n");
        } else {
            printf("COMPARE: differences\n");
            errors ++;
        }

        n = my_compare_bundles(bundle_original, bundle_spare);
        if( n == 0 ) {
            printf("\tStatic Bundle verified successfully\n");
        } else {
            printf("COMPARE: differences\n");
            errors ++;
        }

        // Dellocate memory
        bundle_decrement(bundle_restored);
        bundle_restored = NULL;

        bundle_decrement(bundle_original);
        bundle_original = NULL;

        bundle_decrement(bundle_spare);
        bundle_spare = NULL;
    }

    time_stop = test_precise_timestamp();

    watchdog_stop();
    profiling_report("serializer", 0);

    TEST_REPORT("No of errors", errors, 1, "errors");
    TEST_REPORT("Duration", time_stop-time_start, CLOCK_SECOND, "s");

    if( errors > 0 ) {
        TEST_FAIL("More than 0 errors occured");
    } else {
        TEST_PASS();
    }

    PROCESS_END();
}
Exemple #27
0
int main(void) {
  TEST_INIT();
  TEST_RUN(intgrid);
  TEST_REPORT();
}
Exemple #28
0
int main(void) {
  TEST_INIT();
  TEST_RUN(silist);
  TEST_REPORT();
}