当前位置: 首页>>代码示例>>C++>>正文


C++ setup_test函数代码示例

本文整理汇总了C++中setup_test函数的典型用法代码示例。如果您正苦于以下问题:C++ setup_test函数的具体用法?C++ setup_test怎么用?C++ setup_test使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了setup_test函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: main

// 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;
}
开发者ID:HuangChunLinGit,项目名称:boost-doc-zh,代码行数:32,代码来源:fast_mem_fn_example.cpp

示例2: test_redirect

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 );
}
开发者ID:Kelimion,项目名称:wine,代码行数:48,代码来源:notification.c

示例3: test_performance

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);
  }
}
开发者ID:github188,项目名称:grpc,代码行数:27,代码来源:mlog_test.c

示例4: main

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;
}
开发者ID:psp26,项目名称:tcpr,代码行数:29,代码来源:tcpr-test-spurious-fins.c

示例5: test_fill_circular_log_with_straddling_records

// 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();
}
开发者ID:github188,项目名称:grpc,代码行数:8,代码来源:mlog_test.c

示例6: main

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();
}
开发者ID:Nan619,项目名称:ltp,代码行数:33,代码来源:timer_settime02.c

示例7: test_multiple_writers

// 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();
}
开发者ID:github188,项目名称:grpc,代码行数:9,代码来源:mlog_test.c

示例8: test_detached_while_reading

// 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();
}
开发者ID:github188,项目名称:grpc,代码行数:33,代码来源:mlog_test.c

示例9: test_fill_circular_log_no_fragmentation

// 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();
}
开发者ID:github188,项目名称:grpc,代码行数:9,代码来源:mlog_test.c

示例10: run_test

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;
}
开发者ID:kalray,项目名称:odp-mppa,代码行数:30,代码来源:dispatch_simple.c

示例11: test_read_beyond_pending_record

// 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();
}
开发者ID:github188,项目名称:grpc,代码行数:34,代码来源:mlog_test.c

示例12: main

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;
}
开发者ID:soc-lip6,项目名称:gecos,代码行数:60,代码来源:mrow.c

示例13: test_multiple_writers_circular_log

/* 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();
}
开发者ID:An-mol,项目名称:grpc,代码行数:9,代码来源:census_log_tests.c

示例14: main

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 */
开发者ID:Altiscale,项目名称:sig-core-t_ltp,代码行数:60,代码来源:reboot02.c

示例15: main

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();
}
开发者ID:LeqiaoP1,项目名称:ltp,代码行数:59,代码来源:clock_settime03.c


注:本文中的setup_test函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。