int
run_main (int , ACE_TCHAR *[])
{
  ACE_START_TEST (ACE_TEXT ("Bug_4055_Regression_Test"));
# if defined (ACE_HAS_THREADS)
  int status = 1;

  ACE_Thread_Mutex mutex_;
  ACE_Condition_Thread_Mutex condition_ (mutex_);
  ACE_Condition_Attributes_T<ACE_Monotonic_Time_Policy> monotonic_cond_attr_;
  ACE_Condition_Thread_Mutex monotonic_condition_ (mutex_, monotonic_cond_attr_);

  if (mutex_.acquire () != 0)
  {
    ACE_ERROR ((LM_ERROR, "(%P|%t) ERROR: Failed to acquire mutex.\n"));
  }
  else
  {
    ACE_Time_Value waittime;
    waittime = waittime.now ();
    if (test_timer (condition_, waittime))
    {
      ACE_Time_Value_T<ACE_Monotonic_Time_Policy> monotonic_waittime;
      monotonic_waittime = monotonic_waittime.now ();
      if (test_timer (monotonic_condition_, monotonic_waittime, true))
        status = 0;
    }
  }
# else
  int status = 0;
# endif
  ACE_END_TEST;
  return status;
}
Beispiel #2
0
int main (int argc, char *argv[])
{
    flux_t h;
    flux_reactor_t *reactor;

    plan (4+11+3+4+3+5+2);

    (void)setenv ("FLUX_CONNECTOR_PATH", CONNECTOR_PATH, 0);
    ok ((h = flux_open ("loop://", 0)) != NULL,
        "opened loop connector");
    if (!h)
        BAIL_OUT ("can't continue without loop handle");
    flux_fatal_set (h, fatal_err, NULL);
    ok ((reactor = flux_get_reactor (h)) != NULL,
        "obtained reactor");
    if (!reactor)
        BAIL_OUT ("can't continue without reactor");

    ok (flux_reactor_run (reactor, 0) == 0,
        "general: reactor ran to completion (no watchers)");
    errno = 0;
    ok (flux_sleep_on (h, FLUX_MATCH_ANY) < 0 && errno == EINVAL,
        "general: flux_sleep_on outside coproc fails with EINVAL");

    test_timer (reactor); // 11
    test_fd (reactor); // 3
    test_zmq (reactor); // 4
    test_msg (h); // 3
    test_multmatch (h); // 5

    /* Misc
     */
    lives_ok ({ reactor_destroy_early ();},
        "destroying reactor then watcher doesn't segfault");
Beispiel #3
0
Datei: main.c Projekt: JMR-b/RIOT
int main(void)
{
    int res = 0;

    puts("\nTest for peripheral TIMERs\n");
    puts("This test will test all configured peripheral timers of the\n"
         "targeted platform. For each timer, it will set each channel with\n"
         "an incrementing timeout. CH0 set to 5ms, CH1 to 10ms, CH2 to 15ms\n"
         "and so on.\n"
         "In the output you should see that every channel fired, after an\n"
         "evenly distributed amount of time -> the shown diff values should\n"
         "be pretty much equal (to some jitter...)\n"
         "This test does however NOT show, if the timeouts were correct in\n"
         "relation to the expected real-time ~ use e.g. tests/xtimer_msg for\n"
         "this.\n\n");

    printf("Available timers: %i\n", TIMER_NUMOF);

    /* test all configured timers */
    for (unsigned i = 0; i < TIMER_NUMOF; i++) {
        printf("\nTesting TIMER_%u:\n", i);
        res += test_timer(i);
    }
    /* draw conclusion */
    if (res == TIMER_NUMOF) {
        puts("\nTEST SUCCEEDED");
    }
    else {
        puts("\nTEST FAILED");
    }

    return 0;
}
Beispiel #4
0
/*===========================================================================
 * Main routine
 */
int main(int argc, char **argv)
{
        char filename[] = "/dev/timerx";
        int fd, timer, rate, rval, c;
        int period = 10;
        unsigned int count;

        while (-1 != (c = getopt(argc, argv, "hp:"))) {
                switch (c) {
                case 'p':
                        period = strtol(optarg, NULL, 0);
                        break;
                case 'h':
                default:
                        fprintf(stderr,
                                "USAGE: tmr_interval_test [-h]"
                                "[-p period in seconds]");
                        return -1;
                }
        }

        printf("Have patience. Each test takes %d seconds to run.\n", period);

        /* Test each of the four timers at each clock rate
         */
        for (timer = 1; timer <= 4; ++timer) {
                filename[10] = '0' + timer;
                fd = open(filename, O_RDWR);
                if (-1 == fd) {
                        fprintf(stderr, "open: %s: ", filename);
                        perror("");
                        return -1;
                }

                /* Timers 1 & 2 are 16 bits, timers 3 & 4 are 32 bits. We set
                   the count to expire every 25 milliseconds for timers 1 & 2
                   and every 2 seconds for timers 3 & 4.
                 */
                count = ((1 == timer) || (2 == timer)) ? 50000 : 4000000;
                /* With each pass, the frequency is halved, so we also halve
                   the count to avoid getting too few iterations.
                 */
                for (rate = 2000; rate >= 250; rate >>= 1, count >>= 1) {
                        rval = test_timer(fd, count, rate, period);
                        printf("Test timer %d at %d khz: %s\n", timer, rate,
                               (rval) ? "FAIL" : "PASS");
                }

                if (close(fd)) {
                        perror("close");
                        return -1;
                }
        }

        return 0;
}
Beispiel #5
0
static void test_reinitialization(void)
{
  diag("test_reinitialization");

  my_timer_deinit();
  ok(my_timer_init_ext() == 0, "my_timer_init_ext");
  test_timer();
  my_timer_deinit();
  ok(my_timer_init_ext() == 0, "my_timer_init_ext");
}
Beispiel #6
0
void timer()
{
	#ifdef MOD_TEST
		test_timer();
	#else
		benc_timer();
		robk_timer();
		vinh_timer();
		game_timer();
	#endif
}
Beispiel #7
0
static void test_init(void)
{
    uint64_t barsize;

    dev = get_device();

    dev_bar = qpci_iomap(dev, 0, &barsize);

    qpci_device_enable(dev);

    test_timer();
}
clock_t Timer::startTest(const String & test)
{
  std::map<String, test_timer>::const_iterator cit=theInstance().timeRecorder.find(test);

  if (cit == theInstance().timeRecorder.end())
  {
    theInstance().currentTest=test;
    test_timer t=test_timer();
    theInstance().timeRecorder[test]=t;
    return theInstance().timeRecorder[test].cpu;
  }

  return static_cast<clock_t> (-1);
}
Beispiel #9
0
int main()
{
test_getpid();
test_lcd();
//test_conmov();
//test_structarray();
//test_interrupt();
test_timer();


//p = (int*) ((int)shared_space | 0x100000);
//*p = 15; 

}
Beispiel #10
0
void do_tests()
{
  plan(49);

  ok(my_timer_init_ext() == 0, "my_timer_init_ext");

  test_create_and_delete();
  test_reset();
  test_timer();
  test_timer_reuse();
  test_independent_timers();
  test_concurrently("per-thread", test_timer_per_thread, THREADS, 5);
  test_reinitialization();

  my_timer_deinit();
}
Beispiel #11
0
int TestApp::main()
{
	// Create a console window for text-output if not available
	ConsoleWindow console("Console");

	try
	{

		Console::write_line("ClanLib Test Suite:");
		Console::write_line("-------------------");
#ifdef WIN32
		Console::write_line("Target: WIN32");
#else
		Console::write_line("Target: LINUX");
#endif
		Console::write_line("Directory: API/Display/Window");

		test_timer();
		
		Console::write_line("All Tests Complete");
		console.display_close_message();
	}

	catch(Exception error)
	{
		Console::write_line("Exception caught:");
		Console::write_line(error.message);

/*
		// Display the stack trace (if available)
		std::vector<std::string> stacktrace = error.get_stack_trace();
		int size = stacktrace.size();
		if (size > 0)
		{
			Console::write_line("Stack Trace:");
			for (int cnt=0; cnt < size; cnt++)
			{
				Console::write_line(stacktrace[cnt]);
			}
		}
*/	
		console.display_close_message();
		return -1;
	}

	return 0;
}
Beispiel #12
0
static void test_independent_timers(void)
{
  int rc, state;
  test_timer_t test;

  diag("test_independent_timers");

  test_timer_create(&test);

  rc= my_timer_set(&test.timer, 3600000U);
  ok(rc == 0, "my_timer_set");

  test_timer();

  rc= my_timer_reset(&test.timer, &state);
  ok(rc == 0, "my_timer_reset");

  ok(state == 1, "timer state is nonsignaled");
  ok(test.fired == 0, "timer has not fired");

  test_timer_destroy(&test);
}
Beispiel #13
0
static void
test_cancel_repeat_timer (void)
{
  Repeat_Timer_Handler *handler = new Repeat_Timer_Handler;
  ACE_Time_Value timeout (Repeat_Timer_Handler::REPEAT_INTERVAL);
  long t_id = ACE_Proactor::instance ()->schedule_repeating_timer
    (*handler, 0, timeout);
  if (t_id == -1)
    {
      ACE_ERROR ((LM_ERROR,
                  ACE_TEXT ("%p\n"),
                  ACE_TEXT ("schedule_repeating_timer")));
      delete handler;
      return;
    }

  ACE_Time_Value test_timer (4 * Repeat_Timer_Handler::REPEAT_INTERVAL);
  if (-1 == ACE_Proactor::instance ()->proactor_run_event_loop (test_timer))
    ACE_ERROR ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("proactor loop fail")));

  // handler should be deleted by its own handle_time_out().
  return;
}
Beispiel #14
0
bool gen_trees()
{
	for(int i = 0; i < 3; i++)
	{
		trees[cnt].type = i;
		eval(i);
		t[1].push_back(cnt);
		cnt++;
	}
	first[1] = 0;
	last[1] = cnt;
	for(int size = 2; size < 21; size++)
	{
		first[size] = cnt;
		for(int type = 3; type < 8; type++)
		{
			if (!good_op[type])
				continue;
			for(int i = first[size-1]; i < last[size-1]; i++)
			{
				trees[cnt].type = type;
				trees[cnt].lhs = i;
				if (eval(cnt))
					cnt++;
				if (is_the_same())
					return true;
				if (test_timer())
					return false;
				//if (cnt >= max_size - 2)
				//return false;
			}
		}
		for(int type = 8; type < 12; type++)
		{
			if (!good_op[type])
				continue;
			for(int left_size = 1; left_size < size - 1; left_size++)
			{
				int right_size = size - 1 - left_size;
				if (left_size < right_size)
					continue;
				for(int i = first[left_size]; i < last[left_size]; i++)
					for(int j = first[right_size]; j < last[right_size] && j <= i; j++)
					{
						trees[cnt].type = type;
						trees[cnt].lhs = i;
						trees[cnt].rhs = j;
						if (eval(cnt))
							cnt++;
						if (is_the_same())
							return true;
						if (test_timer())
							return false;
						//if (cnt >= max_size - 2)
						//return false;
					}
			}
		}
		for(int type = 12; type < 13; type++)
		{
			if (!good_op[type])
				continue;
			for(int left_size = 1; left_size < size - 2; left_size++)
				for(int right_size = 1; right_size + left_size < size - 2; right_size++)
				{
					int last_size = size - 1 - left_size - right_size;
					{
						for(int i = first[left_size]; i < last[left_size]; i++)
							for(int j = first[right_size]; j < last[right_size]; j++)
								for(int k = first[last_size]; k < last[last_size]; k++)
								{
									trees[cnt].type = type;
									trees[cnt].lhs = i;
									trees[cnt].rhs = j;
									trees[cnt].if_cond = k;
									if (eval(cnt))
										cnt++;
									if (is_the_same())
										return true;
									if (test_timer())
										return false;
									//if (cnt >= max_size - 2)
									//return false;
								}
					}
				}
		}
		last[size] = cnt;
		printf("%d %d\n", size, last[size] - first[size]);
		if (last[size] - first[size] > 0)
		{
			int best_if = build_if();
			if (best_if != -1)
				return best_if;
		}
		fflush(stdout);
	}
	return false;
}
Beispiel #15
0
int main()
#endif
{
	do
	{
		int y, x;

		for(y = 0; y < 16; ++y){
			printf("{");
			for(x = 0; x < 16; ++x){
				printf("%d, ", (2 * ( y / 8 ) + ( x / 8 )));
			}
			printf("}\n");
		}


		/* Print copyright information */
		printf("Doubango Project\nCopyright (C) 2009 Mamadou Diop \n\n");

#if RUN_TEST_LISTS || RUN_TEST_ALL
		/* linked lists */
		test_basic_list();
		printf("\n\n");
		test_complex_list();
		printf("\n\n");
		test_filtered_list();
		printf("\n\n");
#endif

#if RUN_TEST_HEAP || RUN_TEST_ALL
		/* heap */
		test_heap();
		printf("\n\n");
#endif

#if RUN_TEST_STRINGS || RUN_TEST_ALL
		/* strings */
		test_strings();
		printf("\n\n");
#endif

#if RUN_TEST_URL || RUN_TEST_ALL
		/* url */
		test_url();
		printf("\n\n");
#endif

#if RUN_TEST_THREADS || RUN_TEST_ALL
		/* threads */
		test_threads();
		printf("\n\n");
#endif

#if RUN_TEST_MUTEX || RUN_TEST_ALL
		/* mutex */
		test_mutex();
		printf("\n\n");
#endif

#if RUN_TEST_CONDWAIT || RUN_TEST_ALL
		/* condwait */
		test_condwait();
		printf("\n\n");
#endif

#if RUN_TEST_SEMAPHORE || RUN_TEST_ALL
		/* semaphore */
		test_semaphore();
		printf("\n\n");
#endif

#if RUN_TEST_SAFEOBJECT || RUN_TEST_ALL
	/* safe object */
		//test_safeobject();
		printf("\n\n");
#endif

#if RUN_TEST_OBJECT || RUN_TEST_ALL
	/* object */
		//test_object();
		printf("\n\n");
#endif

#if RUN_TEST_PARAMS || RUN_TEST_ALL
		/* parameters */
		test_params();
		printf("\n\n");
#endif

#if RUN_TEST_OPTIONS || RUN_TEST_ALL
		/* options */
		test_options();
		printf("\n\n");
#endif

#if RUN_TEST_TIMER || RUN_TEST_ALL
		/* timer */
		test_timer();
		printf("\n\n");
#endif
		
#if RUN_TEST_RUNNABLE || RUN_TEST_ALL
		/* test runnable. */
		test_runnable();
		printf("\n\n");
#endif


#if RUN_TEST_BUFFER || RUN_TEST_ALL
		/* test buffer */
		test_buffer();
#endif


#if RUN_TEST_MD5 || RUN_TEST_ALL
		/* test md5 and hmac_md5 */
		test_md5();
		test_hmac_md5();
#endif

#if RUN_TEST_SHA1 || RUN_TEST_ALL
		/* test sha1 and hmac_sha-1 */
		test_sha1();
		test_hmac_sha1();
#endif

#if RUN_TEST_BASE64 || RUN_TEST_ALL
		/* test base64 encoding/decoding */
		test_base64();
#endif

#if RUN_TEST_UUID || RUN_TEST_ALL
		/* test fake UUID (version5) */
		test_uuid();
#endif

#if RUN_TEST_FSM || RUN_TEST_ALL
		/* test FSM */
		test_fsm();
#endif

	}
	while(LOOP);

	getchar();

	return 0;
}
Beispiel #16
0
int main (void) {
  START("CoolTimer");
  test_timer();
  SUMMARY();
  return 0;
}