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


C++ run_test函数代码示例

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


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

示例1: run_main

int
run_main (int argc, ACE_TCHAR *argv[])
{
  ACE_START_TEST (ACE_TEXT ("Map_Manager_Test"));
  ACE_LOG_MSG->clr_flags (ACE_Log_Msg::VERBOSE_LITE);
  int result = 0;
  size_t table_size = ACE_MAX_ITERATIONS / 2;
  size_t iterations = ACE_MAX_ITERATIONS;
  int test_iterators = 1;

  if (argc > 1)
    table_size = ACE_OS::atoi (argv[1]);

  if (argc > 2)
    iterations = ACE_OS::atoi (argv[2]);

  if (argc > 3)
    test_iterators = ACE_OS::atoi (argv[3]);

  if (table_size == 0)
    {
      ACE_ERROR ((LM_ERROR, "[email protected] size is 0\n"));
      ++result;
    }
  else
    {
      // Test the <ACE_Map_Manager>.
      result += run_test (&test_map_manager,
                          table_size,
                          iterations,
                          test_iterators,
                          ACE_TEXT ("Map_Manager"));

      // Test the <ACE_Hash_Map_Manager>.
      result += run_test (&test_hash_map_manager,
                          table_size,
                          iterations,
                          test_iterators,
                          ACE_TEXT ("Hash_Map_Manager"));

      // Test the <ACE_Hash_Map_Manager>.
      result += run_test (&test_active_map_manager,
                          table_size,
                          iterations,
                          test_iterators,
                          ACE_TEXT ("Active_Map_Manager"));

      // Test the <ACE_Cache_Map_Manager>.
      result += run_test (&test_cache_map_manager,
                          table_size,
                          iterations,
                          test_iterators,
                          ACE_TEXT ("Cache_Map_Manager"));

      // Test the <ACE_Hash_Cache_Map_Manager>.
      result += run_test (&test_hash_cache_map_manager,
                          table_size,
                          iterations,
                          test_iterators,
                          ACE_TEXT ("Hash_Cache_Map_Manager"));
    }
  ACE_LOG_MSG->set_flags (ACE_Log_Msg::VERBOSE_LITE);
  ACE_END_TEST;
  return result;
}
开发者ID:CCJY,项目名称:ACE,代码行数:65,代码来源:Map_Manager_Test.cpp

示例2: run_step

/*
 * Take one step along the current "run" path
 *
 * Called with a real direction to begin a new run, and with zero
 * to continue a run in progress.
 */
void run_step(int dir)
{
	int x, y;

	/* Start run */
	if (dir)
	{
		/* Initialize */
		run_init(dir);

		/* Hack -- Set the run counter */
		p_ptr->running = (p_ptr->command_arg ? p_ptr->command_arg : 1000);

		/* Calculate torch radius */
		p_ptr->update |= (PU_TORCH);
	}

	/* Continue run */
	else
	{
		if (!p_ptr->running_withpathfind)
		{
			/* Update run */
			if (run_test())
			{
				/* Disturb */
				disturb(0, 0);
	
				/* Done */
				return;
			}
		}
		else
		{
			/* Abort if we have finished */
			if (pf_result_index < 0)
			{
				disturb(0, 0);
				p_ptr->running_withpathfind = FALSE;
				return;
			}

			/* Abort if we would hit a wall */
			else if (pf_result_index == 0)
			{
				/* Get next step */
				y = p_ptr->py + ddy[pf_result[pf_result_index] - '0'];
				x = p_ptr->px + ddx[pf_result[pf_result_index] - '0'];

				/* Known wall */
				if ((cave_info[y][x] & (CAVE_MARK)) && !cave_floor_bold(y, x))
				{
					disturb(0,0);
					p_ptr->running_withpathfind = FALSE;
					return;
				}
			}

			/*
			 * Hack -- walking stick lookahead.
			 *
			 * If the player has computed a path that is going to end up in a wall,
			 * we notice this and convert to a normal run. This allows us to click
			 * on unknown areas to explore the map.
			 *
			 * We have to look ahead two, otherwise we don't know which is the last
			 * direction moved and don't initialise the run properly.
			 */
			else if (pf_result_index > 0)
			{
				/* Get next step */
				y = p_ptr->py + ddy[pf_result[pf_result_index] - '0'];
				x = p_ptr->px + ddx[pf_result[pf_result_index] - '0'];

				/* Known wall */
				if ((cave_info[y][x] & (CAVE_MARK)) && !cave_floor_bold(y, x))
				{
					disturb(0,0);
					p_ptr->running_withpathfind = FALSE;
					return;
				}

				/* Get step after */
				y = y + ddy[pf_result[pf_result_index-1] - '0'];
				x = x + ddx[pf_result[pf_result_index-1] - '0'];

				/* Known wall */
				if ((cave_info[y][x] & (CAVE_MARK)) && !cave_floor_bold(y, x))
				{
					p_ptr->running_withpathfind = FALSE;

					run_init(pf_result[pf_result_index] - '0');
				}
			}
//.........这里部分代码省略.........
开发者ID:EpicMan,项目名称:angband,代码行数:101,代码来源:pathfind.c

示例3: main

int main(void)
{
 run_test(test);
 return 0;
}
开发者ID:Ravenbrook,项目名称:mps,代码行数:5,代码来源:11.c

示例4: main

int main(int argc, char *argv[]) {
    MPI_Init(&argc, &argv);
    mpi = vex::mpi::comm_data(MPI_COMM_WORLD);

    if (mpi.rank == 0) std::cout << "World size: " << mpi.size << std::endl;

    try {
        vex::Context ctx( vex::Filter::Exclusive(
                    vex::Filter::Env && vex::Filter::Count(1) ) );

        mpi.precondition(!ctx.empty(), "No OpenCL devices found");

        for(int i = 0; i < mpi.size; ++i) {
            if (i == mpi.rank)
                std::cout << mpi.rank << ": " << ctx.device(0) << std::endl;

            MPI_Barrier(mpi.comm);
        }

        boost::this_thread::sleep_for(boost::chrono::milliseconds(100));
        if (mpi.rank == 0) std::cout << std::endl;

        run_test("Allocate mpi::vector", [&]() -> bool {
                const size_t n = 1024;
                bool rc = true;

                vex::mpi::vector<double> x(mpi.comm, ctx, n);

                rc = rc && x.local_size() == n;
                rc = rc && x.global_size() == n * mpi.size;

                return rc;
                });

        run_test("Assign constant to mpi::vector", [&]() -> bool {
                const size_t n = 1024;
                bool rc = true;

                vex::mpi::vector<double> x(mpi.comm, ctx, n);

                x = 42;

                rc = rc && x[n/2] == 42;

                return rc;
                });

        run_test("Copy constructor for mpi::vector", [&]() -> bool {
                const size_t n = 1024;
                bool rc = true;

                vex::mpi::vector<double> x(mpi.comm, ctx, n);
                x = 42;

                vex::mpi::vector<double> y = x;

                rc = rc && y[n/2] == 42;

                return rc;
                });

        run_test("Assign arithmetic expression to mpi::vector", [&]() -> bool {
                const size_t n = 1024;
                bool rc = true;

                vex::mpi::vector<double> x(mpi.comm, ctx, n);
                vex::mpi::vector<double> y(mpi.comm, ctx, n);

                x = 42;
                y = vex::cos(x / 7);

                rc = rc && fabs(y[n/2] - cos(6.0)) < 1e-8;

                return rc;
                });

        run_test("Reduce mpi::vector", [&]() -> bool {
                const size_t n = 1024;
                bool rc = true;

                vex::mpi::vector<double> x(mpi.comm, ctx, n);
                vex::mpi::Reductor<double, vex::SUM> sum(mpi.comm, ctx);

                x = 1;

                rc = rc && fabs(sum(x) - x.global_size()) < 1e-8;

                return rc;
                });

        run_test("Allocate mpi::multivector", [&]() -> bool {
                const size_t n = 1024;
                const size_t m = 3;
                bool rc = true;

                vex::mpi::multivector<double,m> x(mpi.comm, ctx, n);

                rc = rc && x.local_size() == n;
                rc = rc && x.global_size() == n * mpi.size;

//.........这里部分代码省略.........
开发者ID:raedwulf,项目名称:vexcl,代码行数:101,代码来源:mpitests.cpp

示例5: node_testmess

void node_testmess(xml_data_node *node)
{
	xml_data_node *child_node;
	xml_attribute_node *attr_node;
	int result;

	pile_init(&command_pile);
	command_pool = pool_alloc_lib(NULL);

	memset(&new_command, 0, sizeof(new_command));
	command_count = 0;

	/* 'driver' attribute */
	attr_node = xml_get_attribute(node, "driver");
	if (!attr_node)
	{
		error_missingattribute("driver");
		return;
	}
	current_testcase.driver = attr_node->value;

	/* 'name' attribute */
	attr_node = xml_get_attribute(node, "name");
	current_testcase.name = attr_node ? attr_node->value : current_testcase.driver;

	/* 'bios' attribute */
	attr_node = xml_get_attribute(node, "bios");
	current_testcase.bios = attr_node ? attr_node->value : NULL;

	/* 'ramsize' attribute */
	attr_node = xml_get_attribute(node, "ramsize");
	current_testcase.ram = attr_node ? ram_parse_string(attr_node->value) : 0;

	/* 'wavwrite' attribute */
	attr_node = xml_get_attribute(node, "wavwrite");
	current_testcase.wavwrite = attr_node && (atoi(attr_node->value) != 0);

	/* 'enabled' attribute */
	attr_node = xml_get_attribute(node, "enabled");
	current_testcase.enabled = (!attr_node || atoi(attr_node->value)) ? TRUE : FALSE;

	/* report the beginning of the test case */
	report_testcase_begin(current_testcase.name);

	if (current_testcase.enabled)
	{
		current_testcase.commands = NULL;

		for (child_node = node->child; child_node; child_node = child_node->next)
		{
			if (!strcmp(child_node->name, "wait"))
				node_wait(child_node);
			else if (!strcmp(child_node->name, "input"))
				node_input(child_node);
			else if (!strcmp(child_node->name, "rawinput"))
				node_rawinput(child_node);
			else if (!strcmp(child_node->name, "switch"))
				node_switch(child_node);
			else if (!strcmp(child_node->name, "screenshot"))
				node_screenshot(child_node);
			else if (!strcmp(child_node->name, "checkblank"))
				node_checkblank(child_node);
			else if (!strcmp(child_node->name, "imagecreate"))
				node_imagecreate(child_node);
			else if (!strcmp(child_node->name, "imageload"))
				node_imageload(child_node);
			else if (!strcmp(child_node->name, "memverify"))
				node_memverify(child_node);
			else if (!strcmp(child_node->name, "imageverify"))
				node_imageverify(child_node);
			else if (!strcmp(child_node->name, "trace"))
				node_trace(child_node);
			else if (!strcmp(child_node->name, "reset"))
				node_soft_reset(child_node);
			else if (!strcmp(child_node->name, "hardreset"))
				node_hard_reset(child_node);
		}

		memset(&new_command, 0, sizeof(new_command));
		new_command.command_type = MESSTEST_COMMAND_END;
		if (!append_command())
		{
			error_outofmemory();
			return;
		}

		result = run_test(0, NULL);
	}
	else
	{
		/* report that the test case was skipped */
		report_message(MSG_INFO, "Test case skipped");
		result = 0;
	}

	report_testcase_ran(result);
	pile_delete(&command_pile);
	pool_free_lib(command_pool);
}
开发者ID:rogerjowett,项目名称:ClientServerMAME,代码行数:99,代码来源:testmess.c

示例6: main

int main(int argc, char *argv[])
{
	struct weston_config *config;
	struct weston_config_section *section;
	const char *name;
	char *s;
	int r, b, i;
	int32_t n;
	uint32_t u;

	config = run_test(t0);
	assert(config);
	weston_config_destroy(config);

	config = run_test(t1);
	assert(config);
	section = weston_config_get_section(config, "mollusc", NULL, NULL);
	assert(section == NULL);

	section = weston_config_get_section(config, "foo", NULL, NULL);
	r = weston_config_section_get_string(section, "a", &s, NULL);
	assert(r == 0 && strcmp(s, "b") == 0);
	free(s);

	section = weston_config_get_section(config, "foo", NULL, NULL);
	r = weston_config_section_get_string(section, "b", &s, NULL);
	assert(r == -1 && errno == ENOENT && s == NULL);

	section = weston_config_get_section(config, "foo", NULL, NULL);
	r = weston_config_section_get_string(section, "name", &s, NULL);
	assert(r == 0 && strcmp(s, "Roy Batty") == 0);
	free(s);

	section = weston_config_get_section(config, "bar", NULL, NULL);
	r = weston_config_section_get_string(section, "a", &s, "boo");
	assert(r == -1 && errno == ENOENT && strcmp(s, "boo") == 0);
	free(s);

	section = weston_config_get_section(config, "bar", NULL, NULL);
	r = weston_config_section_get_int(section, "number", &n, 600);
	assert(r == 0 && n == 5252);

	section = weston_config_get_section(config, "bar", NULL, NULL);
	r = weston_config_section_get_int(section, "+++", &n, 700);
	assert(r == -1 && errno == ENOENT && n == 700);

	section = weston_config_get_section(config, "bar", NULL, NULL);
	r = weston_config_section_get_uint(section, "number", &u, 600);
	assert(r == 0 && u == 5252);

	section = weston_config_get_section(config, "bar", NULL, NULL);
	r = weston_config_section_get_uint(section, "+++", &u, 600);
	assert(r == -1 && errno == ENOENT && u == 600);

	section = weston_config_get_section(config, "bar", NULL, NULL);
	r = weston_config_section_get_bool(section, "flag", &b, 600);
	assert(r == 0 && b == 0);

	section = weston_config_get_section(config, "stuff", NULL, NULL);
	r = weston_config_section_get_bool(section, "flag", &b, -1);
	assert(r == 0 && b == 1);

	section = weston_config_get_section(config, "stuff", NULL, NULL);
	r = weston_config_section_get_bool(section, "bonk", &b, -1);
	assert(r == -1 && errno == ENOENT && b == -1);

	section = weston_config_get_section(config, "bucket", "color", "blue");
	r = weston_config_section_get_string(section, "contents", &s, NULL);
	assert(r == 0 && strcmp(s, "live crabs") == 0);
	free(s);

	section = weston_config_get_section(config, "bucket", "color", "red");
	r = weston_config_section_get_string(section, "contents", &s, NULL);
	assert(r == 0 && strcmp(s, "sand") == 0);
	free(s);

	section = weston_config_get_section(config, "bucket", "color", "pink");
	assert(section == NULL);
	r = weston_config_section_get_string(section, "contents", &s, "eels");
	assert(r == -1 && errno == ENOENT && strcmp(s, "eels") == 0);
	free(s);

	section = NULL;
	i = 0;
	while (weston_config_next_section(config, &section, &name))
		assert(strcmp(section_names[i++], name) == 0);
	assert(i == 5);

	weston_config_destroy(config);

	config = run_test(t2);
	assert(config == NULL);

	config = run_test(t3);
	assert(config == NULL);

	config = run_test(t4);
	assert(config == NULL);

	weston_config_destroy(NULL);
//.........这里部分代码省略.........
开发者ID:antognolli,项目名称:weston,代码行数:101,代码来源:config-parser-test.c

示例7: compares_tests

void
compares_tests(void)
{
	test_fixture_start();

	fixture_setup(&setup);

	run_test(test_eq_compare_true);
	run_test(test_eq_compare_false);
	run_test(test_ne_compare_true);
	run_test(test_ne_compare_false);
	run_test(test_lt_compare_true);
	run_test(test_lt_compare_false);
	run_test(test_le_compare_true);
	run_test(test_le_compare_false);
	run_test(test_ge_compare_true);
	run_test(test_ge_compare_false);
	run_test(test_gt_compare_true);
	run_test(test_gt_compare_false);
	run_test(test_compares_prefer_numbers);
	run_test(test_compares_convert_string_to_numbers);
	run_test(test_leading_spaces_ok);
	run_test(test_trailing_spaces_ok);
	run_test(test_spaces_before_op_ok);
	run_test(test_spaces_after_op_ok);
	run_test(test_spaces_in_op_fail);
	run_test(test_wrong_op_fail);

	test_fixture_end();
}
开发者ID:KryDos,项目名称:vifm,代码行数:30,代码来源:compares.c

示例8: TEST_F

TEST_F(MemoryFootprintTest, test_TC_MEMKIND_DEFAULT_only_malloc_large_allocations_1_thread)
{
    run_test(MEMKIND_DEFAULT, 2 * MB, 10 * MB, 1, 1.0, 100);
}
开发者ID:krzycz,项目名称:memkind,代码行数:4,代码来源:memory_footprint_test.cpp

示例9: run_test

static bool run_test(const char *cmd, struct test *test)
{
	char *output;
	FILE *outf;
	int status;

	if (test->done)
		return test->answer;

	if (test->depends) {
		size_t len;
		const char *deps = test->depends;
		char *dep;

		/* Space-separated dependencies, could be ! for inverse. */
		while ((len = strcspn(deps, " "))) {
			bool positive = true;
			if (deps[len]) {
				dep = strdup(deps);
				dep[len] = '\0';
			} else {
				dep = (char *)deps;
			}

			if (dep[0] == '!') {
				dep++;
				positive = false;
			}
			if (run_test(cmd, find_test(dep)) != positive) {
				test->answer = false;
				test->done = true;
				return test->answer;
			}
			deps += len;
			deps += strspn(deps, " ");
		}
	}

	outf = fopen(INPUT_FILE, "w");
	if (!outf)
		err(1, "creating %s", INPUT_FILE);

	fprintf(outf, "%s", PRE_BOILERPLATE);
	switch (test->style & ~(EXECUTE|MAY_NOT_COMPILE)) {
	case INSIDE_MAIN:
		fprintf(outf, "%s", MAIN_START_BOILERPLATE);
		fprintf(outf, "%s", test->fragment);
		fprintf(outf, "%s", MAIN_END_BOILERPLATE);
		break;
	case OUTSIDE_MAIN:
		fprintf(outf, "%s", test->fragment);
		fprintf(outf, "%s", MAIN_START_BOILERPLATE);
		fprintf(outf, "%s", MAIN_BODY_BOILERPLATE);
		fprintf(outf, "%s", MAIN_END_BOILERPLATE);
		break;
	case DEFINES_FUNC:
		fprintf(outf, "%s", test->fragment);
		fprintf(outf, "%s", MAIN_START_BOILERPLATE);
		fprintf(outf, "%s", USE_FUNC_BOILERPLATE);
		fprintf(outf, "%s", MAIN_BODY_BOILERPLATE);
		fprintf(outf, "%s", MAIN_END_BOILERPLATE);
		break;
	case DEFINES_EVERYTHING:
		fprintf(outf, "%s", test->fragment);
		break;
	default:
		abort();

	}
	fclose(outf);

	if (verbose > 1)
		if (system("cat " INPUT_FILE) == -1);

	if (test->link) {
		char *newcmd;
		newcmd = malloc(strlen(cmd) + strlen(" ")
				+ strlen(test->link) + 1);
		sprintf(newcmd, "%s %s", cmd, test->link);
		if (verbose > 1)
			printf("Extra link line: %s", newcmd);
		cmd = newcmd;
	}

	output = run(cmd, &status);
	if (status != 0 || strstr(output, "warning")) {
		if (verbose)
			printf("Compile %s for %s, status %i: %s\n",
			       status ? "fail" : "warning",
			       test->name, status, output);
		if ((test->style & EXECUTE) && !(test->style & MAY_NOT_COMPILE))
			errx(1, "Test for %s did not compile:\n%s",
			     test->name, output);
		test->answer = false;
		free(output);
	} else {
		/* Compile succeeded. */
		free(output);
		/* We run INSIDE_MAIN tests for sanity checking. */
		if ((test->style & EXECUTE) || (test->style & INSIDE_MAIN)) {
//.........这里部分代码省略.........
开发者ID:dhanunjaya,项目名称:ccan,代码行数:101,代码来源:configurator.c

示例10: THD_FUNCTION

THD_FUNCTION(Thread1, arg) {

  (void)arg;

  /*
   * Activate the serial driver 0 using the driver default configuration.
   */
  sdStart(&SD1, NULL);

  /* Activate the ADC driver 1 using its config */
  adcStart(&ADCD1, &config);

  while (chnGetTimeout(&SD1, TIME_INFINITE)) {
    print(start_msg);
    chThdSleepMilliseconds(2000);

    /* Test 1 - 1ch1d, no circular */
    run_test(test_1_msg, 1, 1, false);
    
    /* Test 2 - 1ch8d, no circular */
    run_test(test_2_msg, 1, 8, false);
    
    /* Test 3 - 4chd1, no circular */
    run_test(test_3_msg, 4, 1, false);
    
    /* Test 4 - 4ch8d, no circular */
    run_test(test_4_msg, 4, 8, false);
    
    /* Test 5 - 1ch1d, circular */
    run_test(test_5_msg, 1, 1, true);
    
    /* Test 6 - 1ch8d, circular */
    run_test(test_6_msg, 1, 8, true);
    
    /* Test 7 - 4ch1d, circular */
    run_test(test_7_msg, 4, 1, true);
    
    /* Test 8 - 4ch8d, circular */
    run_test(test_8_msg, 4, 8, true);
    
    /* Test 9 - 1ch1d, synchronous */
    print(test_9_msg);
    cb_arg = 0;
    
    group.num_channels = 1;
    group.circular = false;
    group.end_cb = adc_callback;
    
    cb_expect = 1;
    
    adcConvert(&ADCD1, &group, buffer, 1);
    
    while (ADCD1.state == ADC_ACTIVE) ;
    
    sniprintf(out_string, 128, chn_fmt_string, group.channels[0]);
    print(out_string);
    
    sniprintf(out_string, 128, raw_fmt_string, buffer[0]); 
    print(out_string);
    
    buffer[0] = adcMSP430XAdjustTemp(&group, buffer[0]);
    
    sniprintf(out_string, 128, cooked_fmt_string, buffer[0]); 
    print(out_string);
    
    if (cb_arg == cb_expect) {
      print(success_string);
    }
    else {
      print(fail_string);
    }
  }
}
开发者ID:ChibiOS,项目名称:ChibiOS-Contrib,代码行数:73,代码来源:main.c

示例11: test_fixture_part1

void	test_fixture_part1(void)
{
	test_fixture_start();
	run_test(test_ft_memset);
	run_test(test_ft_bzero);
	run_test(test_ft_memcpy);
	run_test(test_ft_memccpy);
	run_test(test_ft_memmove);
	run_test(test_ft_memchr);
	run_test(test_ft_memcmp);
	run_test(test_ft_strlen);
	run_test(test_ft_strdup);
	run_test(test_ft_strcpy);
	run_test(test_ft_strncpy);
	run_test(test_ft_strcat);
	run_test(test_ft_strncat);
	run_test(test_ft_strlcat);
	run_test(test_ft_strchr);
	run_test(test_ft_strrchr);
	run_test(test_ft_strstr);
	run_test(test_ft_strnstr);
	run_test(test_ft_strcmp);
	run_test(test_ft_strncmp);
	run_test(test_ft_atoi);
	run_test(test_ft_isalpha);
	run_test(test_ft_isdigit);
	run_test(test_ft_isalnum);
	run_test(test_ft_isascii);
	run_test(test_ft_isprint);
	run_test(test_ft_toupper);
	run_test(test_ft_tolower);
	test_fixture_end();
}
开发者ID:lambda2,项目名称:zsh-backup,代码行数:33,代码来源:test_fixture_part1.c

示例12: START_TEST

END_TEST

START_TEST(test_proto2_interrupt)
{
	run_test(0, PROTO_2, 10, 100, setup_asfds_proto2_interrupt);
}
开发者ID:rubenk,项目名称:burp,代码行数:6,代码来源:test_restore.c

示例13: main

// ---- testing ------
//To compile: gcc eigen_decomp.c -lm
//The lm links with the math library so we can use sqrt
int main()
{
    run_test();
	return 0;
}
开发者ID:tsarvey,项目名称:spinwaves,代码行数:8,代码来源:c_version.c

示例14: menu

void menu() {
	small_uint_t cmd;
	int full_duplex;

	printf(&debug, "Free memory: %d bytes\n", mem_available(&pool));

	printf(&debug, "Ethernet: %s",
			eth_get_carrier(&eth) ? "Cable OK" : "No cable");
	if (eth_get_speed(&eth, &full_duplex)) {
		printf(&debug, ", %s", full_duplex ? "Full Duplex" : "Half Duplex");
	}
	printf(&debug, ", %u interrupts\n", eth.intr);

	printf(&debug, "Transmit: %ld packets, %ld collisions, %ld errors\n",
			eth.netif.out_packets, eth.netif.out_collisions,
			eth.netif.out_errors);

	printf(&debug, "Receive: %ld packets, %ld errors, %ld lost\n",
			eth.netif.in_packets, eth.netif.in_errors, eth.netif.in_discards);

	printf(&debug, "\n  1. Transmit 1 packet");
	printf(&debug, "\n  2. Transmit 2 packets");
	printf(&debug, "\n  3. Transmit 8 packets");
	printf(&debug, "\n  4. Run send/receive test");
	printf(&debug, "\n  5. Packet size: %d bytes", packet_size);
	printf(&debug, "\n  6. Local loopback: %s",
			local_loop ? "Enabled" : "Disabled");
	puts(&debug, "\n\n");
	for (;;) {
		/* Ввод команды. */
		puts(&debug, "Command: ");
		while (peekchar (&debug) < 0)
			timer_delay(&timer, 50);
		cmd = getchar(&debug);
		putchar(&debug, '\n');

		if (cmd == '\n' || cmd == '\r')
			break;

		if (cmd == '1') {
			send_packets(1);
			break;
		}
		if (cmd == '2') {
			send_packets(2);
			break;
		}
		if (cmd == '3') {
			send_packets(8);
			break;
		}
		if (cmd == '4') {
			run_test();
			break;
		}
		if (cmd == '5') {
			try_again: printf(&debug, "Enter packet size (1-1518): ");
			packet_size = get_short(packet_size);
			if (packet_size <= 0 || packet_size > 1518) {
				printf(&debug, "Invalid value, try again.");
				goto try_again;
			}
			putchar(&debug, '\n');
			data_pattern = mem_realloc(data_pattern, packet_size);
			if (!data_pattern) {
				printf(&debug, "No memory for data_pattern\n");
				uos_halt(1);
			}
			int i;
			for (i = 0; i < packet_size; i++)
				data_pattern[i] = i;
			if (packet_size >= 6)
				memset(data_pattern, 0xFF, 6);
			if (packet_size >= 12)
				memcpy(data_pattern + 6, eth.netif.ethaddr, 6);
			break;
		}
		if (cmd == '6') {
			local_loop = !local_loop;
			eth_set_loop(&eth, local_loop);
			break;
		}
		if (cmd == CTL('E')) {
			/* Регистры Ethernet. */
			putchar(&debug, '\n');
			eth_debug(&eth, &debug);
			putchar(&debug, '\n');
			continue;
		}
		if (cmd == CTL('T')) {
			/* Список задач uOS. */
			printf(&debug, "\nFree memory: %u bytes\n\n", mem_available(&pool));
			task_print(&debug, 0);
			task_print(&debug, (task_t*) stack_console);
			task_print(&debug, (task_t*) stack_test);
			task_print(&debug, (task_t*) eth.stack);
			putchar(&debug, '\n');
			continue;
		}
	}
//.........这里部分代码省略.........
开发者ID:Yurock172,项目名称:uos-embedded,代码行数:101,代码来源:test-eth.c

示例15: main

int
main(int argc, char *argv[])
{
    int c;
    int test_loops = 1;
    int test_normal = FALSE;
    int test_optimize = FALSE;

    setlocale(LC_ALL, "");

    while ((c = getopt(argc, argv, "cf:h:l:norsx")) != -1) {
	switch (c) {
	case 'c':
	    continuous = TRUE;
	    break;
	case 'f':
	    foot_lines = atoi(optarg);
	    break;
	case 'h':
	    head_lines = atoi(optarg);
	    break;
	case 'l':
	    test_loops = atoi(optarg);
	    assert(test_loops >= 0);
	    break;
	case 'n':
	    test_normal = TRUE;
	    break;
	case 'o':
	    test_optimize = TRUE;
	    break;
	case 'r':
	    reverse_loops = TRUE;
	    break;
	case 's':
	    single_step = TRUE;
	    break;
	case 'x':
	    extend_corner = TRUE;
	    break;
	default:
	    usage();
	}
    }
    if (!test_normal && !test_optimize) {
	test_normal = TRUE;
	test_optimize = TRUE;
    }
#if USE_TRACE
    trace(TRACE_TIMES);
#endif

    CATCHALL(finish);		/* arrange interrupts to terminate */

    (void) initscr();		/* initialize the curses library */
    keypad(stdscr, TRUE);	/* enable keyboard mapping */
    (void) nonl();		/* tell curses not to do NL->CR/NL on output */
    (void) cbreak();		/* take input chars one at a time, no wait for \n */
    (void) noecho();		/* don't echo input */
    scrollok(stdscr, TRUE);

    while (test_loops-- > 0) {
	if (test_normal)
	    run_test(FALSE);
	if (test_optimize)
	    run_test(TRUE);
    }

    cleanup();			/* we're done */
    ExitProgram(EXIT_SUCCESS);
}
开发者ID:Scarletts,项目名称:LiteBSD,代码行数:71,代码来源:hashtest.c


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