// compare performance with boost::mem_fn
int main()
{
  test_vector v;
  boost::timer t;
  double time1, time2;

  std::cout << 
      "Test case: sorting " << N << " objects.\n\n"
      "Criterion accessor called with | elasped seconds\n"
      "-------------------------------|----------------" << std::endl;

  setup_test(v);
  t.restart();
#if !BOOST_WORKAROUND(BOOST_MSVC, < 1400)
  do_test(v, BOOST_EXAMPLE_FAST_MEM_FN(& test::id));
#else // MSVC<8 does not like the implementation of the deduction macro:
  do_test(v, ::example::fast_mem_fn< int (test::*)() const, & test::id >());
#endif
  time1 = t.elapsed();
  std::cout << "fast_mem_fn                    | " << time1 << std::endl;

  setup_test(v);
  t.restart();
  do_test(v, boost::mem_fn(& test::id));
  time2 = t.elapsed();
  std::cout << "mem_fn                         | " << time2 << std::endl;

  std::cout << '\n' << (time2/time1-1)*100 << "% speedup" << std::endl;

  return 0;
}
Beispiel #2
0
static void test_redirect( void )
{
    static const WCHAR codeweavers[] = {'c','o','d','e','w','e','a','v','e','r','s','.','c','o','m',0};

    HANDLE ses, con, req;
    DWORD size, status;
    BOOL ret;
    struct info info, *context = &info;

    info.test  = redirect_test;
    info.count = sizeof(redirect_test) / sizeof(redirect_test[0]);
    info.index = 0;
    info.wait = NULL;

    ses = WinHttpOpen( user_agent, 0, NULL, NULL, 0 );
    ok(ses != NULL, "failed to open session %u\n", GetLastError());

    WinHttpSetStatusCallback( ses, check_notification, WINHTTP_CALLBACK_FLAG_ALL_NOTIFICATIONS, 0 );

    ret = WinHttpSetOption( ses, WINHTTP_OPTION_CONTEXT_VALUE, &context, sizeof(struct info *) );
    ok(ret, "failed to set context value %u\n", GetLastError());

    setup_test( &info, winhttp_connect, __LINE__ );
    con = WinHttpConnect( ses, codeweavers, 0, 0 );
    ok(con != NULL, "failed to open a connection %u\n", GetLastError());

    setup_test( &info, winhttp_open_request, __LINE__ );
    req = WinHttpOpenRequest( con, NULL, NULL, NULL, NULL, NULL, 0 );
    ok(req != NULL, "failed to open a request %u\n", GetLastError());

    setup_test( &info, winhttp_send_request, __LINE__ );
    ret = WinHttpSendRequest( req, NULL, 0, NULL, 0, 0, 0 );
    ok(ret, "failed to send request %u\n", GetLastError());

    setup_test( &info, winhttp_receive_response, __LINE__ );
    ret = WinHttpReceiveResponse( req, NULL );
    ok(ret, "failed to receive response %u\n", GetLastError());

    size = sizeof(status);
    ret = WinHttpQueryHeaders( req, WINHTTP_QUERY_STATUS_CODE | WINHTTP_QUERY_FLAG_NUMBER, NULL, &status, &size, NULL );
    ok(ret, "failed unexpectedly %u\n", GetLastError());
    ok(status == 200, "request failed unexpectedly %u\n", status);

    setup_test( &info, winhttp_close_handle, __LINE__ );
    WinHttpCloseHandle( req );
    WinHttpCloseHandle( con );
    WinHttpCloseHandle( ses );
}
Beispiel #3
0
void test_performance(void) {
  for (size_t write_size = 1; write_size < CENSUS_LOG_MAX_RECORD_SIZE;
       write_size *= 2) {
    setup_test(0);
    gpr_timespec start_time = gpr_now(GPR_CLOCK_REALTIME);
    int nrecords = 0;
    while (1) {
      void* record = census_log_start_write(write_size);
      if (record == NULL) {
        break;
      }
      census_log_end_write(record, write_size);
      nrecords++;
    }
    gpr_timespec write_time =
        gpr_time_sub(gpr_now(GPR_CLOCK_REALTIME), start_time);
    double write_time_micro =
        (double)write_time.tv_sec * 1000000 + (double)write_time.tv_nsec / 1000;
    census_log_shutdown();
    printf(
        "Wrote %d %d byte records in %.3g microseconds: %g records/us "
        "(%g ns/record), %g gigabytes/s\n",
        nrecords, (int)write_size, write_time_micro,
        nrecords / write_time_micro, 1000 * write_time_micro / nrecords,
        (double)((int)write_size * nrecords) / write_time_micro / 1000);
  }
}
Beispiel #4
0
int main(int argc, char **argv)
{
	(void)argc;
	(void)argv;
	const uint32_t net = 0x0a0a0a00;
	char *password;

	setup_test("tcpr-test", "test-spurious-fins");
	password = get_password(htonl(net | 2), 8888, htonl(net | 3), 9999);

	setup_connection(net | 2, net | 4, net | 3, 8888, 9999, 0xdeadbeef,
				0xcafebabe, test_options_size, test_options,
				peer_mss, peer_ws, password);

	fprintf(stderr, "Application: FIN (failure)\n");
	send_segment(internal_log, net | 4, net | 2, 9999, 8888,
			TH_ACK | TH_FIN, 0xcafebabe + 1, 0xdeadbeef + 1, 0,
			NULL, 0, NULL, password);

	fprintf(stderr, "     Filter: RST\n");
	recv_segment(internal_log, net | 2, net | 4, 8888, 9999, TH_RST,
			0xdeadbeef + 1, 0, 0, NULL, 0, NULL, password);

	cleanup_connection(net | 2, net | 4, 8888, 9999, 0xcafebabe + 1,
				0xdeadbeef + 1, 0);

	cleanup_test();
	return EXIT_SUCCESS;
}
Beispiel #5
0
// Fills circular log with records that may straddle end of a block.
void test_fill_circular_log_with_straddling_records(void) {
  printf("Starting test: fill circular log with straddling records\n");
  const int circular = 1;
  setup_test(circular);
  fill_log(LOG_SIZE_IN_BYTES, 0 /* block straddling records */, circular);
  census_log_shutdown();
}
Beispiel #6
0
int main(int ac, char **av)
{
    int lc, i;

    tst_parse_opts(ac, av, NULL, NULL);

    setup();

    for (lc = 0; TEST_LOOPING(lc); lc++) {

        tst_count = 0;

        for (i = 0; i < TST_TOTAL; i++) {

            /* Set up individual test */
            if (setup_test(i) == 0) {
                TEST(ltp_syscall(__NR_timer_settime, timer,
                                 flag, &new_set, old_temp));
                tst_resm((TEST_RETURN == 0 ?
                          TPASS :
                          TFAIL | TTERRNO),
                         "%s",
                         (TEST_RETURN ==
                          0 ? "passed" : "failed")
                        );
            }

        }
    }

    cleanup();
    tst_exit();
}
Beispiel #7
0
// Tests scenario where multiple writers and a single reader are using a log
// that is configured to discard old records.
void test_multiple_writers(void) {
  printf("Starting test: multiple writers\n");
  const int circular = 0;
  setup_test(circular);
  multiple_writers_single_reader(circular);
  census_log_shutdown();
}
Beispiel #8
0
// Tests scenario where block being read is detached from a core and put on the
// dirty list.
void test_detached_while_reading(void) {
  printf("Starting test: detached while reading\n");
  setup_test(0);
  // Start a write.
  static const size_t DWR_RECORD_SIZE = 10;
  void* record_written = census_log_start_write(DWR_RECORD_SIZE);
  GPR_ASSERT(record_written != NULL);
  census_log_end_write(record_written, DWR_RECORD_SIZE);
  // Read this record.
  census_log_init_reader();
  size_t bytes_available;
  const void* record_read = census_log_read_next(&bytes_available);
  GPR_ASSERT(record_read != NULL);
  GPR_ASSERT(DWR_RECORD_SIZE == bytes_available);
  // Now fill the log. This will move the block being read from core-local
  // array to the dirty list.
  while ((record_written = census_log_start_write(DWR_RECORD_SIZE))) {
    census_log_end_write(record_written, DWR_RECORD_SIZE);
  }

  // In this iteration, read_next() should only traverse blocks in the
  // core-local array. Therefore, we expect at most gpr_cpu_num_cores() more
  // blocks. As log is full, if read_next() is traversing the dirty list, we
  // will get more than gpr_cpu_num_cores() blocks.
  int block_read = 0;
  while ((record_read = census_log_read_next(&bytes_available))) {
    ++block_read;
    GPR_ASSERT(block_read <= (int)gpr_cpu_num_cores());
  }
  census_log_shutdown();
}
Beispiel #9
0
// Fills circular log with records sized such that size is a multiple of
// CENSUS_LOG_MAX_RECORD_SIZE (no per-block fragmentation).
void test_fill_circular_log_no_fragmentation(void) {
  printf("Starting test: fill circular log no fragmentation\n");
  const int circular = 1;
  setup_test(circular);
  fill_log(LOG_SIZE_IN_BYTES, 1 /* no fragmentation */, circular);
  census_log_shutdown();
}
Beispiel #10
0
int run_test()
{
	test_assert_ret(setup_test() == 0);

	odp_packet_t pkt_valid_eth_no_ip =
		pack_pkt(pool, valid_eth_src_beef, valid_eth_dst, 0, 0, 64, 0);
	odp_packet_t pkt_valid_eth_valid_ip =
		pack_pkt(pool, valid_eth_src, valid_eth_dst, valid_ip_src, valid_ip_dst, 64, 1);
	odp_packet_t pkt_valid_eth_invalid_ip =
		pack_pkt(pool, valid_eth_src, valid_eth_dst, invalid_ip_src, valid_ip_dst, 64, 1);

	odp_packet_t pkt_invalid_eth_no_ip =
		pack_pkt(pool, invalid_eth_src, valid_eth_dst, 0, 0, 64, 0);
	odp_packet_t pkt_invalid_eth_valid_ip =
		pack_pkt(pool, invalid_eth_src, valid_eth_dst, valid_ip_src, valid_ip_dst, 64, 1);
	odp_packet_t pkt_invalid_eth_invalid_ip =
		pack_pkt(pool, invalid_eth_src, valid_eth_dst, invalid_ip_src, valid_ip_dst, 64, 1);

	send_recv(pkt_valid_eth_no_ip, 10, 10);
	send_recv(pkt_valid_eth_valid_ip, 10, 10);
	send_recv(pkt_valid_eth_invalid_ip, 10, 10);

	send_recv(pkt_invalid_eth_no_ip, 10, 0);
	send_recv(pkt_invalid_eth_valid_ip, 10, 10);
	send_recv(pkt_invalid_eth_invalid_ip, 10, 0);

	test_assert_ret(term_test() == 0);

	return 0;
}
Beispiel #11
0
// Tries reading beyond pending write.
void test_read_beyond_pending_record(void) {
  printf("Starting test: read beyond pending record\n");
  setup_test(0);
  // Start a write.
  const size_t incomplete_record_size = 10;
  void* incomplete_record = census_log_start_write(incomplete_record_size);
  GPR_ASSERT(incomplete_record != NULL);
  const size_t complete_record_size = 20;
  void* complete_record = census_log_start_write(complete_record_size);
  GPR_ASSERT(complete_record != NULL);
  GPR_ASSERT(complete_record != incomplete_record);
  census_log_end_write(complete_record, complete_record_size);
  // Now iterate over blocks to read completed records.
  census_log_init_reader();
  size_t bytes_available;
  const void* record_read = census_log_read_next(&bytes_available);
  GPR_ASSERT(complete_record == record_read);
  GPR_ASSERT(complete_record_size == bytes_available);
  // Complete first record.
  census_log_end_write(incomplete_record, incomplete_record_size);
  // Have read past the incomplete record, so read_next() should return NULL.
  // NB: this test also assumes our thread did not get switched to a different
  // CPU between the two start_write calls
  record_read = census_log_read_next(&bytes_available);
  GPR_ASSERT(record_read == NULL);
  // Reset reader to get the newly completed record.
  census_log_init_reader();
  record_read = census_log_read_next(&bytes_available);
  GPR_ASSERT(incomplete_record == record_read);
  GPR_ASSERT(incomplete_record_size == bytes_available);
  assert_log_empty();
  census_log_shutdown();
}
Beispiel #12
0
int main(int argc, char **argv)
{
	int i=0;
	setsignals();
#ifdef RCU_SIGNAL
	rcu_init();
#endif
	setup_test(argc, argv);
	printf("nbthreads %lu nbupdaters %lu nbbuckets %lu perbucket-pbnodes %lu nbtest %d nbreaders %d nbcores %d"
#ifdef POPULATE
			" POPULATE"
#endif
			"\n", 
			nbthreads, nbupdaters, nbbuckets, pbnodes, NB_TEST, nbreaders, get_nbcores());

	for(; i < ITERATION; i++)
		test(i);

	double rops = get_avg(&trd_ops[0],ITERATION);
	double wops = get_avg(&twr_ops[0],ITERATION);
	printf("read ops per micsec = %g\n", rops);
	printf("write ops per micsec = %g\n", wops);
	printf("write/read = %g\n", wops/rops);

	printf("nbmallocs = %g\n", get_avg(&run_mallocs[0],ITERATION));
	printf("nbretry = %g\n", get_avg(&run_retry[0],ITERATION));
	printf("nbrelink = %g\n", get_avg(&run_relink[0],ITERATION));
	printf("nbreprev = %g\n", get_avg(&run_reprev[0],ITERATION));
	printf("nbblockeds = %g\n", get_avg(&run_blockeds[0],ITERATION));

	printf("sucess_search = %g on %g\n", get_avg(&run_sea[0],ITERATION), get_avg(&thd_ops[nbupdaters], nbreaders) );
	printf("sucess_insert = %g on %g\n", get_avg(&run_ins[0],ITERATION), get_avg(&thd_ops[0], nbupdaters)/2);
	printf("sucess_delete = %g on %g\n", get_avg(&run_del[0],ITERATION), get_avg(&thd_ops[0], nbupdaters)/2);
	
	printf("\n");

	printf("avg_max_read = %gus\n", get_max(&run_avg_rd[0],ITERATION));
	printf("avg_avg_read = %gus\n", get_avg(&run_avg_rd[0],ITERATION));
	printf("avg_min_read = %gus\n", get_min(&run_avg_rd[0],ITERATION));
	
	printf("\n");

	printf("avg_max_write = %gus\n", get_max(&run_avg_wr[0],ITERATION));
	printf("avg_avg_write = %gus\n", get_avg(&run_avg_wr[0],ITERATION));
	printf("avg_min_write = %gus\n", get_min(&run_avg_wr[0],ITERATION));

	printf("\n");

	printf("max_read = %gus\n", get_max(&run_max_rd[0],ITERATION));
	printf("min_read = %gus\n", get_min(&run_min_rd[0],ITERATION));
	
	printf("\n");

	printf("max_write = %gus\n", get_max(&run_max_wr[0],ITERATION));
	printf("min_write = %gus\n", get_min(&run_min_wr[0],ITERATION));

	//printf("cpu time = %gus\n", get_avg(&run_cput[0],ITERATION));//FIXME

	return 0;
}
Beispiel #13
0
/* Tests scenario where multiple writers and a single reader are using a log
   that is configured to discard old records. */
void test_multiple_writers_circular_log(void) {
  const int circular = 1;
  printf("Starting test: multiple writers circular log\n");
  setup_test(circular);
  multiple_writers_single_reader(circular);
  census_log_shutdown();
}
Beispiel #14
0
int main(int ac, char **av)
{

	int lc, i;
	char *msg;

	if ((msg = parse_opts(ac, av, NULL, NULL)) != NULL)
		tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);

	setup();

	for (lc = 0; TEST_LOOPING(lc); lc++) {

		for (i = 0; i < TST_TOTAL; i++) {

			tst_count = 0;
			if (i == 0) {
				TEST(reboot(INVALID_PARAMETER));
			} else {
				/*change the user to nobody */
				if (setup_test() == 0) {
					TEST(reboot(LINUX_REBOOT_CMD_CAD_ON));
					/* Set effective user id back to root */
					if (seteuid(0) == -1) {
						tst_brkm(TBROK, cleanup,
							 "seteuid failed to "
							 "set the effective uid"
							 " to root");
						perror("seteuid");
					}
				} else {
					tst_resm(TWARN, "skipping the test");
					continue;
				}
			}
			/* check return code */
			if ((TEST_RETURN == -1)
			    && (TEST_ERRNO == testcase[i].exp_errno)) {
				tst_resm(TPASS,
					 "reboot(2) expected failure;"
					 " Got errno - %s : %s",
					 testcase[i].exp_errval,
					 testcase[i].err_desc);
			} else {
				tst_resm(TFAIL, "reboot(2) failed to produce"
					 " expected error; %d, errno"
					 ": %s and got %d",
					 testcase[i].exp_errno,
					 testcase[i].exp_errval, TEST_ERRNO);
			}

			TEST_ERROR_LOG(TEST_ERRNO);
		}		/*End of TEST LOOPS */
	}

	/*Clean up and exit */
	cleanup();

	tst_exit();
}				/*End of main */
Beispiel #15
0
int main(int ac, char **av)
{
	int lc, i;
	char *msg;

	if ((msg = parse_opts(ac, av, NULL, NULL)) != NULL)
		tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);

	setup();

	for (lc = 0; TEST_LOOPING(lc); lc++) {

		tst_count = 0;

		for (i = 0; i < TST_TOTAL; i++) {

			if (setup_test(i) < 0)
				continue;

			TEST(ltp_syscall(__NR_clock_settime, clocks[i], temp));

			/* Change the UID back to root */
			if (i == TST_TOTAL - 1) {
				if (seteuid(0) == -1) {
					tst_brkm(TBROK | TERRNO, cleanup,
						 "Failed to set the effective "
						 "uid to root");
				}
			}

			/* check return code */
			if (TEST_RETURN == -1 && TEST_ERRNO == testcases[i]) {
				tst_resm(TPASS | TTERRNO,
					 "clock_settime(2) got expected "
					 "failure.");
			} else {
				tst_resm(TFAIL | TTERRNO,
					 "clock_settime(2) failed to produce "
					 "expected error (return code = %ld)",
					 TEST_RETURN);
				/* Restore the clock to its previous state. */
				if (TEST_RETURN == 0) {
					if (ltp_syscall(__NR_clock_settime,
						    CLOCK_REALTIME,
						    &saved) < 0) {
						tst_resm(TWARN | TERRNO,
							 "FATAL: could not set "
							 "the clock!");
					}
				}
			}

		}

	}

	cleanup();
	tst_exit();
}
Beispiel #16
0
int main(int ac, char **av)
{
	int lc, i;

	tst_parse_opts(ac, av, NULL, NULL);

	setup();

	/* check looping state */
	for (lc = 0; TEST_LOOPING(lc); lc++) {

		tst_count = 0;

		for (i = 0; i < TST_TOTAL; i++) {

			if (setup_test(i)) {
				tst_resm(TFAIL, "mlockall() Failed while setup "
					 "for checking error %s", TC[i].edesc);
				continue;
			}

			TEST(mlockall(TC[i].flag));

			/* check return code */
			if (TEST_RETURN == -1) {
				if (TEST_ERRNO != TC[i].error)
					tst_brkm(TFAIL, cleanup,
						 "mlock() Failed with wrong "
						 "errno, expected errno=%s, "
						 "got errno=%d : %s",
						 TC[i].edesc, TEST_ERRNO,
						 strerror(TEST_ERRNO));
				else
					tst_resm(TPASS,
						 "expected failure - errno "
						 "= %d : %s",
						 TEST_ERRNO,
						 strerror(TEST_ERRNO));
			} else {
				if (i <= 1)
					tst_resm(TCONF,
						 "mlockall02 did not BEHAVE as expected.");
				else
					tst_brkm(TFAIL, cleanup,
						 "mlock() Failed, expected "
						 "return value=-1, got %ld",
						 TEST_RETURN);
			}
			cleanup_test(i);
		}
	}

	/* cleanup and exit */
	cleanup();

	tst_exit();
}
Beispiel #17
0
int main(int argc, char *argv[])
{
    int ret;
    setup_test();

    ret = test_main(argc, argv);

    return finish_test(ret);
}
Beispiel #18
0
int main(void)
{
    setup_test();

    test_get_random_generator();
    test_get_hasher();

	return (0);
}
Beispiel #19
0
int main(int argc, char **argv)
{
    int initialized = setup_test(argc, argv);
    if (initialized)
    {
        test_blit_speed();
        SDL_Quit();
    }
    return(!initialized);
}
bam_hdr_t * setup_test_4(merged_header_t *merged_hdr) {
    const char* t4_init_text =
        "@HD\tVN:1.4\tSO:unknown\n"
        "@SQ\tSN:fish\tLN:133\tSP:frog\n"
        "@RG\tID:fish\tPU:out\n";

    return setup_test(t4_init_text, init_refs, NELE(init_refs),
                      test_4_trans_text, test_4_refs, NELE(test_4_refs),
                      merged_hdr);
}
Beispiel #21
0
int main(int argc, char ** argv)
{
    if (setup_test())
        return 1;

    run_tests();

    teardown_test();

    return 0;
}
bam_hdr_t * setup_test_5(merged_header_t *merged_hdr) {
    const char* t5_init_text =
        "@HD\tVN:1.4\tSO:unknown\n"
        "@SQ\tSN:fish\tLN:133\tSP:frog\n"
        "@RG\tID:fish\tPU:out\n"
        "@PG\tXX:dummyx\tID:fish\tDS:out\n"
        "@PG\tPP:fish\tID:hook\tDS:out\n";

    return setup_test(t5_init_text, init_refs, NELE(init_refs),
                      test_5_trans_text, test_5_refs, NELE(test_5_refs),
                      merged_hdr);
}
Beispiel #23
0
int
main(int ac, char **av)
{
	int lc, i;	/* loop counter */
	char *msg;	/* message returned from parse_opts */

	if ((msg = parse_opts(ac, av, (option_t *) NULL, NULL)) !=
			(char *) NULL) {
		tst_brkm(TBROK, tst_exit, "OPTION PARSING ERROR - %s", msg);
	}

	/* perform global setup for test */
	setup();

	/* check looping state if -i option given */
	for (lc = 0; TEST_LOOPING(lc); lc++) {

		/* reset Tst_count in case we are looping. */
		Tst_count = 0;

		for (i = 0; i < TST_TOTAL; i++) {

			/* Set up individual test */
			if (setup_test(i) < 0) {
				continue;	/* We are skipping this test */
			}

			TEST(timer_settime(timer, flag, &new_set, old_temp));

			if (TEST_ERRNO == ENOSYS) {
				/* system call is not implemented */
				Tst_count = TST_TOTAL;
				perror("timer_settime");
				tst_brkm(TBROK, cleanup, "");
			}
			if (TEST_RETURN == -1) {
				TEST_ERROR_LOG(TEST_ERRNO);
				tst_resm(TFAIL, "timer_settime(2) Failed and"
						" set errno to %d", TEST_ERRNO);
			} else {
				tst_resm(TPASS, "timer_settime(2) Passed");
			}
		}	/* End of TEST CASE LOOPING */
	}		/* End for TEST_LOOPING */

	/* Clean up and exit */
	cleanup();

	/* NOTREACHED */
	return 0;
}
Beispiel #24
0
// Tests end_write() with a different size than what was specified in
// start_write().
void test_end_write_with_different_size(void) {
  static const size_t START_WRITE_SIZE = 10;
  static const size_t END_WRITE_SIZE = 7;
  printf("Starting test: end write with different size\n");
  setup_test(0);
  void* record_written = census_log_start_write(START_WRITE_SIZE);
  GPR_ASSERT(record_written != NULL);
  census_log_end_write(record_written, END_WRITE_SIZE);
  census_log_init_reader();
  size_t bytes_available;
  const void* record_read = census_log_read_next(&bytes_available);
  GPR_ASSERT(record_written == record_read);
  GPR_ASSERT(END_WRITE_SIZE == bytes_available);
  assert_log_empty();
  census_log_shutdown();
}
Beispiel #25
0
int
main(int ac, char **av)
{
	int lc, i;			/* loop counter */
	char *msg;			/* message returned from parse_opts */
	timer_t created_timer_id;	/* holds the returned timer_id */
	char *message[] = {
		"SIGEV_SIGNAL",
		"NULL",
		"SIGEV_NONE"
	};

	/* parse standard options */
	if ((msg = parse_opts(ac, av, (option_t *) NULL, NULL)) !=
			(char *) NULL) {
		tst_brkm(TBROK, tst_exit, "OPTION PARSING ERROR - %s", msg);
	}

	/* perform global setup for test */
	setup();

	/* check looping state if -i option given */
	for (lc = 0; TEST_LOOPING(lc); lc++) {

		/* reset Tst_count in case we are looping. */
		Tst_count = 0;

		for (i = 0; i < TST_TOTAL; i++) {

			setup_test(i);
			TEST(syscall(__NR_timer_create, CLOCK_MONOTONIC,
					evp_ptr, &created_timer_id));

			tst_resm((TEST_RETURN == 0 ? TPASS : TFAIL | TTERRNO),
				"%s with notification type = %s",
				(TEST_RETURN == 0 ? "passed" : "failed"),
				message[i]);

		}	/* End of TEST CASE LOOPING */

	}		/* End for TEST_LOOPING */

	/* Clean up and exit */
	cleanup();
	tst_exit();
}
Beispiel #26
0
Datei: corelib.c Projekt: 8l/awl
void test_corelib_do(void) {
    awlenv* e = setup_test();

    TEST_ASSERT_TYPE(e, "(do x)", AWLVAL_ERR);
    TEST_ASSERT_TYPE(e, "(do (/ 1 0))", AWLVAL_ERR);

    TEST_ASSERT_EQ(e, "(do (let ((x 5) (y 6)) (+ x y)))", "11");
    TEST_ASSERT_TYPE(e, "x", AWLVAL_ERR);
    TEST_ASSERT_TYPE(e, "y", AWLVAL_ERR);

    TEST_ASSERT_EQ(e, "(do 1 2 3 4 5)", "5");
    TEST_ASSERT_EQ(e, "(do (define x 5) (define y 6) (+ x y))", "11");
    TEST_ASSERT_EQ(e, "x", "5");
    TEST_ASSERT_EQ(e, "y", "6");

    teardown_test(e);
}
int main(int argc, char **argv)
{
	(void)argc;
	(void)argv;
	const uint32_t net = 0x0a0a0a00;
	char *password;

	setup_test("tcpr-test", "test-recover-peer-send");
	password = get_password(htonl(net | 2), 8888, htonl(net | 3), 9999);

	setup_connection(net | 2, net | 4, net | 3, 8888, 9999, 0xdeadbeef,
				0xcafebabe, test_options_size, test_options,
				peer_mss, peer_ws, password);

	recover_connection(net | 5, net | 2, net | 3, 9999, 8888, 0xfeedbead,
				0xcafebabe, 0xdeadbeef, test_options_size, test_options,
				peer_mss, peer_ws, TCPR_HAVE_ACK | TCPR_HAVE_PEER_MSS
				| TCPR_HAVE_PEER_WS, password);

	fprintf(stderr, "       Peer: \"baz\" (retransmit)\n");
	send_segment(external_log, net | 2, net | 3, 8888, 9999, TH_ACK,
			0xdeadbeef + 1, 0xcafebabe + 1, 0, NULL, 4, "baz", password);
	recv_segment(internal_log, net | 2, net | 5, 8888, 9999, TH_ACK,
			0xdeadbeef + 1, 0xfeedbead + 1, 0, NULL, 4, "baz", password);

	fprintf(stderr, "Application: ACK\n");
	send_segment(internal_log, net | 5, net | 2, 9999, 8888, TH_ACK,
			0xfeedbead + 1, 0xdeadbeef + 5, 0, NULL, 0, NULL, password);

	fprintf(stderr, "Application: update\n");
	send_update(net | 2, net | 5, 8888, 9999, 0xcafebabe + 1,
			0xdeadbeef + 5, 0, 0,
			(0xfeedbead + 1) - (0xcafebabe + 1), TCPR_HAVE_ACK);

	fprintf(stderr, "     Filter: ACK\n");
	recv_segment(external_log, net | 3, net | 2, 9999, 8888, TH_ACK,
			0xcafebabe + 1, 0xdeadbeef + 5, 0, NULL, 0, NULL, password);

	cleanup_connection(net | 2, net | 4, 8888, 9999, 0xcafebabe + 1,
				0xdeadbeef + 1,
				(0xfeedbead + 1) - (0xcafebabe + 1));

	cleanup_test();
	return EXIT_SUCCESS;
}
Beispiel #28
0
// Attempts to create a record of invalid size (size >
// CENSUS_LOG_MAX_RECORD_SIZE).
void test_invalid_record_size(void) {
  static const size_t INVALID_SIZE = CENSUS_LOG_MAX_RECORD_SIZE + 1;
  static const size_t VALID_SIZE = 1;
  printf("Starting test: invalid record size\n");
  setup_test(0);
  void* record = census_log_start_write(INVALID_SIZE);
  GPR_ASSERT(record == NULL);
  // Now try writing a valid record.
  record = census_log_start_write(VALID_SIZE);
  GPR_ASSERT(record != NULL);
  census_log_end_write(record, VALID_SIZE);
  // Verifies that available space went down by one block. In theory, this
  // check can fail if the thread is context switched to a new CPU during the
  // start_write execution (multiple blocks get allocated), but this has not
  // been observed in practice.
  //  GPR_ASSERT(LOG_SIZE_IN_BYTES - CENSUS_LOG_MAX_RECORD_SIZE ==
  //             census_log_remaining_space());
  census_log_shutdown();
}
Beispiel #29
0
int
main(int ac, char **av)
{
	int lc, i;			/* loop counter */
	char *msg;			/* message returned from parse_opts */
	kernel_timer_t created_timer_id;	/* holds the returned timer_id */
	char *message[] = {
		"SIGEV_SIGNAL",
		"NULL",
		"SIGEV_NONE"
	};

	/* parse standard options */
	if ((msg = parse_opts(ac, av, (option_t *) NULL, NULL)) !=
			(char *) NULL) {
		tst_brkm(TBROK, NULL, "OPTION PARSING ERROR - %s", msg);
	}

	setup();

	for (lc = 0; TEST_LOOPING(lc); lc++) {

		Tst_count = 0;

		for (i = 0; i < TST_TOTAL; i++) {

			setup_test(i);
			TEST(syscall(__NR_timer_create, CLOCK_MONOTONIC,
					evp_ptr, &created_timer_id));

			tst_resm((TEST_RETURN == 0 ? TPASS : TFAIL | TTERRNO),
				"%s with notification type = %s",
				(TEST_RETURN == 0 ? "passed" : "failed"),
				message[i]);

		}

	}

	cleanup();
	tst_exit();
}
Beispiel #30
0
// Verifies that pending records are not available via read_next().
void test_read_pending_record(void) {
  static const size_t PR_RECORD_SIZE = 1024;
  printf("Starting test: read pending record\n");
  setup_test(0);
  // Start a write.
  void* record_written = census_log_start_write(PR_RECORD_SIZE);
  GPR_ASSERT(record_written != NULL);
  // As write is pending, read should fail.
  census_log_init_reader();
  size_t bytes_available;
  const void* record_read = census_log_read_next(&bytes_available);
  GPR_ASSERT(record_read == NULL);
  // A read followed by end_write() should succeed.
  census_log_end_write(record_written, PR_RECORD_SIZE);
  census_log_init_reader();
  record_read = census_log_read_next(&bytes_available);
  GPR_ASSERT(record_written == record_read);
  GPR_ASSERT(PR_RECORD_SIZE == bytes_available);
  assert_log_empty();
  census_log_shutdown();
}