コード例 #1
0
void RunSingleBufferOverreadTest(void (*test_func)(uint8_t*, size_t)) {
  // In order to verify that functions are not reading past the end of the
  // src, create data that ends exactly at an unreadable memory boundary.
  size_t pagesize = static_cast<size_t>(sysconf(_SC_PAGE_SIZE));
  uint8_t* memory;
  ASSERT_TRUE(posix_memalign(reinterpret_cast<void**>(&memory), pagesize,
                             2*pagesize) == 0);
  memset(memory, 0x23, 2*pagesize);

  // Make the second page unreadable and unwritable.
  ASSERT_TRUE(mprotect(&memory[pagesize], pagesize, PROT_NONE) == 0);

  for (size_t i = 0; i < pagesize; i++) {
    uint8_t* buf = &memory[pagesize-i];

    test_func(buf, i);
  }
  ASSERT_TRUE(mprotect(&memory[pagesize], pagesize, PROT_READ | PROT_WRITE) == 0);
  free(memory);
}
コード例 #2
0
ファイル: cec2013.c プロジェクト: cran/cec2013
void cec2013(char **extdatadir, int *i, double *X, int *row, int *col, double *f)
{
    int r, c;
    double *x;

	extdata = *extdatadir;

    x = (double *) malloc(*col * sizeof(double));

    for (r = 0; r < *row; r++) {
        R_CheckUserInterrupt();

        for (c = 0; c < *col; c++) {
            x[c] = X[r + *row * c];
        }
        test_func(x, &f[r] , *col, 1, *i);
    }

    free(x);
}
コード例 #3
0
ファイル: xdaemon.c プロジェクト: iawes/daemon
int main(int argc, char *argv[])
{
	int err;
	pthread_t tid;
	struct sigaction sa;
	char *cmd;

	if(NULL == (cmd = strrchr(argv[0], '/')))
		cmd = argv[0];
	else
		cmd ++;
	syslog(LOG_ERR, "main thread id is %u.\n", (unsigned)pthread_self());

//	daemonize(cmd);
	daemon(0, 0);
	if(already_running())
	{
		syslog(LOG_ERR, "xdaemon already running.\n");
		exit(1);
	}
	syslog(LOG_ERR, "main thread 2 id is %u.\n", (unsigned)pthread_self());

//	/*
	sa.sa_handler = SIG_DFL;
	sigemptyset(&sa.sa_mask);
	sa.sa_flags = 0;
	if(sigaction(SIGHUP, &sa, NULL) < 0)
		log_quit("can't restore SIGHUP default");
	sigfillset(&mask);
	if((err = pthread_sigmask(SIG_BLOCK, &mask, NULL)) != 0)
			log_exit(err, "SIG_BLOCK error");

	err = pthread_create(&tid, NULL, thread_func, 0);
	if(err != 0)
		log_exit(err, "can't create thread");

//*/
	test_func();

	exit(0);
}
コード例 #4
0
ファイル: glx-query-drawable.c プロジェクト: blaztinn/piglit
int main(int argc, char **argv) {
	Display *display;
	XVisualInfo *visual;
	Window window;
	GLXContext ctx;
	void (*test_func)(Display*, GLXDrawable);

	parse_args(argc, argv, &test_func);

	display = piglit_get_glx_display();
	visual = piglit_get_glx_visual(display);
	window = piglit_get_glx_window(display, visual);
	ctx = piglit_get_glx_context(display, visual);
	glXMakeCurrent(display, window, ctx);

	/* Must initialize static variables of this function. */
	piglit_glx_get_error(display, NULL);

	test_func(display, window);

	return 0;
}
コード例 #5
0
void RunSrcDstBufferAlignTest(
    size_t max_test_size, void (*test_func)(uint8_t*, uint8_t*, size_t),
    size_t (*set_incr)(size_t)) {
  if (!set_incr) {
    set_incr = SetIncrement;
  }

  // Allocate two large buffers for all of the testing.
  uint8_t* src = new uint8_t[3*max_test_size];
  uint8_t* dst = new uint8_t[3*max_test_size];

  uint8_t* src_align;
  uint8_t* dst_align;
  for (size_t i = 0; i < g_double_aligns_len; i++) {
    size_t incr = 1;
    for (size_t len = 0; len <= max_test_size; len += incr) {
      incr = set_incr(len);

      src_align =
          reinterpret_cast<uint8_t*>(GetAlignedPtr(
              src+FENCEPOST_LENGTH, g_double_aligns[i][0], g_double_aligns[i][1]));
      dst_align =
          reinterpret_cast<uint8_t*>(GetAlignedPtr(
              dst+FENCEPOST_LENGTH, g_double_aligns[i][2], g_double_aligns[i][3]));
      SetFencepost(&dst_align[-FENCEPOST_LENGTH]);
      SetFencepost(&dst_align[len]);

      test_func(src_align, dst_align, len);

      VerifyFencepost(&dst_align[-FENCEPOST_LENGTH]);
      VerifyFencepost(&dst_align[len]);
    }
  }
  delete src;
  delete dst;
}
コード例 #6
0
ファイル: main.cpp プロジェクト: carlonluca/LightLogger
/*------------------------------------------------------------------------------
 |    main
 +-----------------------------------------------------------------------------*/
int main(int argc, char** argv)
{
#if defined(QT_QML_LIB) && defined(QT_QUICK_LIB)
   QGuiApplication a(argc, argv);
#endif

#if 0
   QElapsedTimer timer;
   timer.start();

   // Test with lc_logging.
   for (int i = 0; i < 100000; i++)
      log_verbose("Test: %d.", i);
   qDebug("Result lc_logging: %lld.", timer.elapsed());

   // Test with printf.
   timer.restart();
   for (int i = 0; i < 100000; i++) {
      fprintf(stdout, "- DEBUG:%s: Test: %d.\n", lc_current_time().c_str(), i);
      fflush(stdout);
   }
   qDebug("Result printf: %lld.", timer.elapsed());

   // Test with qDebug.
   timer.restart();
   for (int i = 0; i < 100000; i++) {
      qDebug("- DEBUG:%s: Test: %d.\n", lc_current_time().c_str(), i);
      fflush(stderr);
   }
   qDebug("Result qDebug: %lld.", timer.elapsed());
#endif

#ifdef __GNUC__
   LOG_CRITICAL("MyTag", "Oooops!");
#endif

   log_info("Info log.");
   log_info_t("MyTag", "Info log.");
   test_args("Testing %d va_args functions.", 2);

   log_debug("Some message for debugging...");
   log_disabled("A disabled log!!!!!!!!!!! You won't see this.");

   log_critical("Print int: %d.", 5);
   log_critical_t("MyTag", "Print int: %d.", 5);
   log_critical_t("MyTag", "Print with tag only.");

   /*lc_formatted_printf(stdout, LC_LOG_ATTR_UNDERLINE, LC_LOG_COL_MAGENTA,
                     "Underlined %s! ;-)\n", "magenta");*/
   log_formatted(LC_LOG_ATTR_UNDERLINE, LC_LOG_COL_YELLOW, "Formatted text.");
   log_formatted(LC_LOG_COL_YELLOW, "Formatted text with %s.", "param");

#ifndef __ANDROID__
   test_func();
#endif

   // Using streams.
   {
      LC_LogDef logger(NULL, LC_LOG_ATTR_RESET, LC_LOG_COL_BLUE);
      logger.stream() << "Blue log using stream. " << "Params can be added like " << 1234 << ".";

      LC_LogDef l(NULL);
      Q_UNUSED(l);
   }

   {
      LC_Log<LC_Output2Std> logger(LC_LOG_DEBUG);
      logger.stream() << "Debug log with stream.";
   }

   {
      LC_Log<LC_Output2Std> logger(LC_LOG_WARN);
      logger.stream() << "Warning log with stream.";
   }

   {
      LC_Log<LC_Output2Std> logger(LC_LOG_CRITICAL);
      logger.stream() << "Critical log with stream.";
   }

#if defined(QT_QML_LIB) && defined(QT_QUICK_LIB)
   QQuickView view;
   LC_QMLLogger::registerObject(view.rootContext());
   view.setSource(QUrl("qrc:///main.qml"));
#endif

   assert(log_verbose("") == true);
   assert(log_info("") == true);
   assert(log_warn("") == false);
   assert(log_err("") == false);
   assert(log_critical("") == false);

   return 0;
}
コード例 #7
0
ファイル: veritesting_b.c プロジェクト: angr/binaries
int main()
{
    test_func();
}
コード例 #8
0
ファイル: test.c プロジェクト: CNMAT/gsl
int
main (void)
{
  size_t M = 53;
  size_t N = 107;

  gsl_ieee_env_setup ();

  test_func (M, N);
  test_float_func (M, N);
  test_long_double_func (M, N);
  test_ulong_func (M, N);
  test_long_func (M, N);
  test_uint_func (M, N);
  test_int_func (M, N);
  test_ushort_func (M, N);
  test_short_func (M, N);
  test_uchar_func (M, N);
  test_char_func (M, N);
  test_complex_func (M, N);
  test_complex_float_func (M, N);
  test_complex_long_double_func (M, N);

  test_ops (M, N);
  test_float_ops (M, N);
  test_long_double_ops (M, N);
  test_ulong_ops (M, N);
  test_long_ops (M, N);
  test_uint_ops (M, N);
  test_int_ops (M, N);
  test_ushort_ops (M, N);
  test_short_ops (M, N);
  test_uchar_ops (M, N);
  test_char_ops (M, N);

  /* Must use smaller dimensions to prevent approximation of floats in
     float_mul_elements test*/
  
  {
    const size_t P = 8;
    const size_t Q = 12;

    test_complex_ops (P, Q);
    test_complex_float_ops (P, Q);
    test_complex_long_double_ops (P, Q);
  }

  test_text (M, N);
  test_float_text (M, N);
#if HAVE_PRINTF_LONGDOUBLE
  test_long_double_text (M, N);
#endif
  test_ulong_text (M, N);
  test_long_text (M, N);
  test_uint_text (M, N);
  test_int_text (M, N);
  test_ushort_text (M, N);
  test_short_text (M, N);
  test_uchar_text (M, N);
  test_char_text (M, N);
  test_complex_text (M, N);
  test_complex_float_text (M, N);
#if HAVE_PRINTF_LONGDOUBLE
  test_complex_long_double_text (M, N);
#endif

  test_binary (M, N);
  test_float_binary (M, N);
  test_long_double_binary (M, N);
  test_ulong_binary (M, N);
  test_long_binary (M, N);
  test_uint_binary (M, N);
  test_int_binary (M, N);
  test_ushort_binary (M, N);
  test_short_binary (M, N);
  test_uchar_binary (M, N);
  test_char_binary (M, N);
  test_complex_binary (M, N);
  test_complex_float_binary (M, N);
  test_complex_long_double_binary (M, N);

#if GSL_RANGE_CHECK
  gsl_set_error_handler (&my_error_handler);

  test_trap (M, N);
  test_float_trap (M, N);
  test_long_double_trap (M, N);
  test_ulong_trap (M, N);
  test_long_trap (M, N);
  test_uint_trap (M, N);
  test_int_trap (M, N);
  test_ushort_trap (M, N);
  test_short_trap (M, N);
  test_uchar_trap (M, N);
  test_char_trap (M, N);
  test_complex_trap (M, N);
  test_complex_float_trap (M, N);
  test_complex_long_double_trap (M, N);
#endif

  exit (gsl_test_summary ());
}
コード例 #9
0
ファイル: test.c プロジェクト: ampl/gsl
int
main (void)
{
  size_t stride, ostride, N;

  gsl_ieee_env_setup ();

  for (N = 10; N < 1024; N = 2*N + 1) 
    {
      for (stride = 1; stride < 5 ; stride++)
        {
          test_func (stride, N);
          test_float_func (stride, N);
          test_long_double_func (stride, N);
          test_ulong_func (stride, N);
          test_long_func (stride, N);
          test_uint_func (stride, N);
          test_int_func (stride, N);
          test_ushort_func (stride, N);
          test_short_func (stride, N);
          test_uchar_func (stride, N);
          test_char_func (stride, N);

          test_complex_func (stride, N);
          test_complex_float_func (stride, N);
          test_complex_long_double_func (stride, N);

          for (ostride = 1; ostride < 5 ; ostride++)
            {
              test_ops (stride, ostride, N);
              test_float_ops (stride, ostride, N);
              test_long_double_ops (stride, ostride, N);
              test_ulong_ops (stride, ostride, N);
              test_long_ops (stride, ostride, N);
              test_uint_ops (stride, ostride, N);
              test_int_ops (stride, ostride, N);
              test_ushort_ops (stride, ostride, N);
              test_short_ops (stride, ostride, N);
              test_uchar_ops (stride, ostride, N);
              test_char_ops (stride, ostride, N);
              test_complex_ops (stride, ostride, N);
              test_complex_float_ops (stride, ostride, N);
              test_complex_long_double_ops (stride, ostride, N);
            }              

          test_text (stride, N);
          test_float_text (stride, N);
#if HAVE_PRINTF_LONGDOUBLE
          test_long_double_text (stride, N);
#endif
          test_ulong_text (stride, N);
          test_long_text (stride, N);
          test_uint_text (stride, N);
          test_int_text (stride, N);
          test_ushort_text (stride, N);
          test_short_text (stride, N);
          test_uchar_text (stride, N);
          test_char_text (stride, N);

          test_complex_text (stride, N);
          test_complex_float_text (stride, N);
#if HAVE_PRINTF_LONGDOUBLE
          test_complex_long_double_text (stride, N);
#endif

          test_file (stride, N);
          test_float_file (stride, N);
          test_long_double_file (stride, N);
          test_ulong_file (stride, N);
          test_long_file (stride, N);
          test_uint_file (stride, N);
          test_int_file (stride, N);
          test_ushort_file (stride, N);
          test_short_file (stride, N);
          test_uchar_file (stride, N);
          test_char_file (stride, N);
          test_complex_file (stride, N);
          test_complex_float_file (stride, N);
          test_complex_long_double_file (stride, N);
        }
    }

    test_alloc_zero_length ();
    test_float_alloc_zero_length ();
    test_long_double_alloc_zero_length ();
    test_ulong_alloc_zero_length ();
    test_long_alloc_zero_length ();
    test_uint_alloc_zero_length ();
    test_int_alloc_zero_length ();
    test_ushort_alloc_zero_length ();
    test_short_alloc_zero_length ();
    test_uchar_alloc_zero_length ();
    test_char_alloc_zero_length ();

    test_complex_alloc_zero_length ();
    test_complex_float_alloc_zero_length ();
    test_complex_long_double_alloc_zero_length ();

    test_calloc_zero_length ();
    test_float_calloc_zero_length ();
    test_long_double_calloc_zero_length ();
    test_ulong_calloc_zero_length ();
    test_long_calloc_zero_length ();
    test_uint_calloc_zero_length ();
    test_int_calloc_zero_length ();
    test_ushort_calloc_zero_length ();
    test_short_calloc_zero_length ();
    test_uchar_calloc_zero_length ();
    test_char_calloc_zero_length ();

    test_complex_calloc_zero_length ();
    test_complex_float_calloc_zero_length ();
    test_complex_long_double_calloc_zero_length ();

#if GSL_RANGE_CHECK
  gsl_set_error_handler (&my_error_handler);

  for (N = 1; N < 1024; N *=2) 
    {
      for (stride = 1; stride < 5 ; stride++)
        {
          test_trap (stride, N);
          test_float_trap (stride, N);
          test_long_double_trap (stride, N);
          test_ulong_trap (stride, N);
          test_long_trap (stride, N);
          test_uint_trap (stride, N);
          test_int_trap (stride, N);
          test_ushort_trap (stride, N);
          test_short_trap (stride, N);
          test_uchar_trap (stride, N);
          test_char_trap (stride, N);
          test_complex_trap (stride, N);
          test_complex_float_trap (stride, N);
          test_complex_long_double_trap (stride, N);
        }
    }
#endif

  exit (gsl_test_summary ());
}
コード例 #10
0
ファイル: math.c プロジェクト: liuyang1/test
int main() {
    test_func();
    return 0;
}
コード例 #11
0
ファイル: plugins.c プロジェクト: itaka/hurricane
Plugin* plugin_open(const char* filename)
{
	Plugin* plugin;
	Plugin_Info* info;
	Plugin_Event_Table* events;
	void** procs;
	int init_flag = 1;

	//ShowDebug("plugin_open(%s)\n", filename);
	
	// Check if the plugin has been loaded before
	plugin = plugin_head;
	while (plugin) {
		// returns handle to the already loaded plugin
		if( plugin->state && strcmpi(plugin->filename, filename) == 0 ){
			ShowWarning("plugin_open: not loaded (duplicate) : '"CL_WHITE"%s"CL_RESET"'\n", filename);
			return plugin;
		}
		plugin = plugin->next;
	}

	CREATE(plugin, Plugin, 1);
	plugin->state = -1;	// not loaded

	plugin->dll = DLL_OPEN(filename);
	if( !plugin->dll ){
		ShowWarning("plugin_open: not loaded (invalid file) : '"CL_WHITE"%s"CL_RESET"'\n", filename);
		plugin_unload(plugin);
		return NULL;
	}

	// Retrieve plugin information
	plugin->state = 0;	// initialising
	info = (Plugin_Info*)DLL_SYM(plugin->dll, "plugin_info");
	// For high priority plugins (those that are explicitly loaded from the conf file)
	// we'll ignore them even (could be a 3rd party dll file)
	if( !info )
	{// foreign plugin
		//ShowDebug("plugin_open: plugin_info not found\n");
		if( load_priority == 0 )
		{// not requested
			//ShowDebug("plugin_open: not loaded (not requested) : '"CL_WHITE"%s"CL_RESET"'\n", filename);
			plugin_unload(plugin);
			return NULL;
		}
	} else if( !plugin_iscompatible(info->req_version) )
	{// incompatible version
		ShowWarning("plugin_open: not loaded (incompatible version '%s' -> '%s') : '"CL_WHITE"%s"CL_RESET"'\n", info->req_version, PLUGIN_VERSION, filename);
		plugin_unload(plugin);
		return NULL;
	} else if( (info->type != PLUGIN_ALL && info->type != PLUGIN_CORE && info->type != SERVER_TYPE) ||
		(info->type == PLUGIN_CORE && SERVER_TYPE != PLUGIN_LOGIN && SERVER_TYPE != PLUGIN_CHAR && SERVER_TYPE != PLUGIN_MAP) )
	{// not for this server
		//ShowDebug("plugin_open: not loaded (incompatible) : '"CL_WHITE"%s"CL_RESET"'\n", filename);
		plugin_unload(plugin);
		return NULL;
	}

	plugin->info = ( info != NULL ? info : &default_info );
	plugin->filename = aStrdup(filename);

	// Initialise plugin call table (For exporting procedures)
	procs = (void**)DLL_SYM(plugin->dll, "plugin_call_table");
	if( procs )
		*procs = plugin_call_table;
	//else ShowDebug("plugin_open: plugin_call_table not found\n");

	// Register plugin events
	events = (Plugin_Event_Table*)DLL_SYM(plugin->dll, "plugin_event_table");
	if( events ){
		int i = 0;
		//ShowDebug("plugin_open: parsing plugin_event_table\n");
		while( events[i].func_name ){
			if( strcmpi(events[i].event_name, EVENT_PLUGIN_TEST) == 0 ){
				Plugin_Test_Func* test_func;
				test_func = (Plugin_Test_Func*)DLL_SYM(plugin->dll, events[i].func_name);
				//ShowDebug("plugin_open: invoking "EVENT_PLUGIN_TEST" with %s()\n", events[i].func_name);
				if( test_func && test_func() == 0 ){
					// plugin has failed test, disabling
					//ShowDebug("plugin_open: disabled (failed test) : %s\n", filename);
					init_flag = 0;
				}
			} else {
				Plugin_Event_Func* func;
				func = (Plugin_Event_Func*)DLL_SYM(plugin->dll, events[i].func_name);
				if (func)
					register_plugin_event(func, events[i].event_name);
			}
			i++;
		}
	}
	//else ShowDebug("plugin_open: plugin_event_table not found\n");

	plugin->next = plugin_head;
	plugin_head = plugin;

	plugin->state = init_flag;	// fully loaded
	ShowStatus("Done loading plugin '"CL_WHITE"%s"CL_RESET"'\n", (info) ? plugin->info->name : filename);

	return plugin;
}
コード例 #12
0
void *
vg_thread_loop(void *arg)
{
	unsigned char hash_buf[128];
	unsigned char *eckey_buf;
	unsigned char hash1[32];

	int i, c, len, output_interval;
	int hash_len;

	const BN_ULONG rekey_max = 10000000;
	BN_ULONG npoints, rekey_at, nbatch;

	vg_context_t *vcp = (vg_context_t *) arg;
	EC_KEY *pkey = NULL;
	const EC_GROUP *pgroup;
	const EC_POINT *pgen;
	const int ptarraysize = 256;
	EC_POINT *ppnt[ptarraysize];
	EC_POINT *pbatchinc;

	vg_test_func_t test_func = vcp->vc_test;
	vg_exec_context_t ctx;
	vg_exec_context_t *vxcp;

	struct timeval tvstart;


	memset(&ctx, 0, sizeof(ctx));
	vxcp = &ctx;

	vg_exec_context_init(vcp, &ctx);

	pkey = vxcp->vxc_key;
	pgroup = EC_KEY_get0_group(pkey);
	pgen = EC_GROUP_get0_generator(pgroup);

	for (i = 0; i < ptarraysize; i++) {
		ppnt[i] = EC_POINT_new(pgroup);
		if (!ppnt[i]) {
			fprintf(stderr, "ERROR: out of memory?\n");
			exit(1);
		}
	}
	pbatchinc = EC_POINT_new(pgroup);
	if (!pbatchinc) {
		fprintf(stderr, "ERROR: out of memory?\n");
		exit(1);
	}

	BN_set_word(&vxcp->vxc_bntmp, ptarraysize);
	EC_POINT_mul(pgroup, pbatchinc, &vxcp->vxc_bntmp, NULL, NULL,
		     vxcp->vxc_bnctx);
	EC_POINT_make_affine(pgroup, pbatchinc, vxcp->vxc_bnctx);

	npoints = 0;
	rekey_at = 0;
	nbatch = 0;
	vxcp->vxc_key = pkey;
	vxcp->vxc_binres[0] = vcp->vc_addrtype;
	c = 0;
	output_interval = 1000;
	gettimeofday(&tvstart, NULL);

	if (vcp->vc_format == VCF_SCRIPT) {
		hash_buf[ 0] = 0x51;  // OP_1
		hash_buf[ 1] = 0x41;  // pubkey length
		// gap for pubkey
		hash_buf[67] = 0x51;  // OP_1
		hash_buf[68] = 0xae;  // OP_CHECKMULTISIG
		eckey_buf = hash_buf + 2;
		hash_len = 69;

	} else {
		eckey_buf = hash_buf;
		hash_len = 65;
	}

	while (!vcp->vc_halt) {
		if (++npoints >= rekey_at) {
			vg_exec_context_upgrade_lock(vxcp);
			/* Generate a new random private key */
			EC_KEY_generate_key(pkey);
			npoints = 0;

			/* Determine rekey interval */
			EC_GROUP_get_order(pgroup, &vxcp->vxc_bntmp,
					   vxcp->vxc_bnctx);
			BN_sub(&vxcp->vxc_bntmp2,
			       &vxcp->vxc_bntmp,
			       EC_KEY_get0_private_key(pkey));
			rekey_at = BN_get_word(&vxcp->vxc_bntmp2);
			if ((rekey_at == BN_MASK2) || (rekey_at > rekey_max))
				rekey_at = rekey_max;
			assert(rekey_at > 0);

			EC_POINT_copy(ppnt[0], EC_KEY_get0_public_key(pkey));
			vg_exec_context_downgrade_lock(vxcp);

			npoints++;
			vxcp->vxc_delta = 0;

			if (vcp->vc_pubkey_base)
				EC_POINT_add(pgroup,
					     ppnt[0],
					     ppnt[0],
					     vcp->vc_pubkey_base,
					     vxcp->vxc_bnctx);

			for (nbatch = 1;
			     (nbatch < ptarraysize) && (npoints < rekey_at);
			     nbatch++, npoints++) {
				EC_POINT_add(pgroup,
					     ppnt[nbatch],
					     ppnt[nbatch-1],
					     pgen, vxcp->vxc_bnctx);
			}

		} else {
			/*
			 * Common case
			 *
			 * EC_POINT_add() can skip a few multiplies if
			 * one or both inputs are affine (Z_is_one).
			 * This is the case for every point in ppnt, as
			 * well as pbatchinc.
			 */
			assert(nbatch == ptarraysize);
			for (nbatch = 0;
			     (nbatch < ptarraysize) && (npoints < rekey_at);
			     nbatch++, npoints++) {
				EC_POINT_add(pgroup,
					     ppnt[nbatch],
					     ppnt[nbatch],
					     pbatchinc,
					     vxcp->vxc_bnctx);
			}
		}

		/*
		 * The single most expensive operation performed in this
		 * loop is modular inversion of ppnt->Z.  There is an
		 * algorithm implemented in OpenSSL to do batched inversion
		 * that only does one actual BN_mod_inverse(), and saves
		 * a _lot_ of time.
		 *
		 * To take advantage of this, we batch up a few points,
		 * and feed them to EC_POINTs_make_affine() below.
		 */

		EC_POINTs_make_affine(pgroup, nbatch, ppnt, vxcp->vxc_bnctx);

		for (i = 0; i < nbatch; i++, vxcp->vxc_delta++) {
			/* Hash the public key */
			len = EC_POINT_point2oct(pgroup, ppnt[i],
						 POINT_CONVERSION_UNCOMPRESSED,
						 eckey_buf,
						 65,
						 vxcp->vxc_bnctx);
			assert(len == 65);

			SHA256(hash_buf, hash_len, hash1);
			RIPEMD160(hash1, sizeof(hash1), &vxcp->vxc_binres[1]);

			switch (test_func(vxcp)) {
			case 1:
				npoints = 0;
				rekey_at = 0;
				i = nbatch;
				break;
			case 2:
				goto out;
			default:
				break;
			}
		}

		c += i;
		if (c >= output_interval) {
			output_interval = vg_output_timing(vcp, c, &tvstart);
			if (output_interval > 250000)
				output_interval = 250000;
			c = 0;
		}

		vg_exec_context_yield(vxcp);
	}

out:
	vg_exec_context_del(&ctx);
	vg_context_thread_exit(vcp);

	for (i = 0; i < ptarraysize; i++)
		if (ppnt[i])
			EC_POINT_free(ppnt[i]);
	if (pbatchinc)
		EC_POINT_free(pbatchinc);
	return NULL;
}
コード例 #13
0
ファイル: test.c プロジェクト: CNMAT/CNMAT-Externs
int
main (void)
{
  gsl_ieee_env_setup ();

  test_func ();
  test_float_func ();
  test_long_double_func ();
  test_ulong_func ();
  test_long_func ();
  test_uint_func ();
  test_int_func ();
  test_ushort_func ();
  test_short_func ();
  test_uchar_func ();
  test_char_func ();
  test_complex_func ();
  test_complex_float_func ();
  test_complex_long_double_func ();

  test_text ();
  test_float_text ();
#if HAVE_PRINTF_LONGDOUBLE
  test_long_double_text ();
#endif
  test_ulong_text ();
  test_long_text ();
  test_uint_text ();
  test_int_text ();
  test_ushort_text ();
  test_short_text ();
  test_uchar_text ();
  test_char_text ();
  test_complex_text ();
  test_complex_float_text ();
#if HAVE_PRINTF_LONGDOUBLE
  test_complex_long_double_text ();
#endif

  test_binary ();
  test_float_binary ();
  test_long_double_binary ();
  test_ulong_binary ();
  test_long_binary ();
  test_uint_binary ();
  test_int_binary ();
  test_ushort_binary ();
  test_short_binary ();
  test_uchar_binary ();
  test_char_binary ();
  test_complex_binary ();
  test_complex_float_binary ();
  test_complex_long_double_binary ();

  gsl_set_error_handler (&my_error_handler);

  test_trap ();
  test_float_trap ();
  test_long_double_trap ();
  test_ulong_trap ();
  test_long_trap ();
  test_uint_trap ();
  test_int_trap ();
  test_ushort_trap ();
  test_short_trap ();
  test_uchar_trap ();
  test_char_trap ();
  test_complex_trap ();
  test_complex_float_trap ();
  test_complex_long_double_trap ();

  exit (gsl_test_summary ());
}
コード例 #14
0
ファイル: sleep.c プロジェクト: august782/klee
int main(int argc, char **argv) {
  test_func();
}
コード例 #15
0
ファイル: TestQueryParserLogic.c プロジェクト: apache/lucy
void
TestQPLogic_Run_IMP(TestQueryParserLogic *self, TestBatchRunner *runner) {
    TestBatchRunner_Plan(runner, (TestBatch*)self, 258);

    uint32_t i;
    Folder        *folder     = S_create_index();
    IndexSearcher *searcher   = IxSearcher_new((Obj*)folder);
    QueryParser   *or_parser  = QParser_new(IxSearcher_Get_Schema(searcher),
                                            NULL, NULL, NULL);
    String        *AND        = SSTR_WRAP_C("AND");
    QueryParser   *and_parser = QParser_new(IxSearcher_Get_Schema(searcher),
                                            NULL, AND, NULL);
    QParser_Set_Heed_Colons(or_parser, true);
    QParser_Set_Heed_Colons(and_parser, true);

    // Run logical tests with default boolop of OR.
    for (i = 0; logical_test_funcs[i] != NULL; i++) {
        LUCY_TestQPLogic_Logical_Test_t test_func = logical_test_funcs[i];
        TestQueryParser *test_case_obj = test_func(BOOLOP_OR);
        TestQueryParserIVARS *test_case = TestQP_IVARS(test_case_obj);
        Query *tree     = QParser_Tree(or_parser, test_case->query_string);
        Query *parsed   = QParser_Parse(or_parser, test_case->query_string);
        Hits  *hits     = IxSearcher_Hits(searcher, (Obj*)parsed, 0, 10, NULL);
        char  *qstr     = Str_To_Utf8(test_case->query_string);

        TEST_TRUE(runner, Query_Equals(tree, (Obj*)test_case->tree),
                  "tree() OR   %s", qstr);
        TEST_INT_EQ(runner, Hits_Total_Hits(hits), test_case->num_hits,
                    "hits: OR   %s", qstr);
        free(qstr);
        DECREF(hits);
        DECREF(parsed);
        DECREF(tree);
        DECREF(test_case_obj);
    }

    // Run logical tests with default boolop of AND.
    for (i = 0; logical_test_funcs[i] != NULL; i++) {
        LUCY_TestQPLogic_Logical_Test_t test_func = logical_test_funcs[i];
        TestQueryParser *test_case_obj = test_func(BOOLOP_AND);
        TestQueryParserIVARS *test_case = TestQP_IVARS(test_case_obj);
        Query *tree     = QParser_Tree(and_parser, test_case->query_string);
        Query *parsed   = QParser_Parse(and_parser, test_case->query_string);
        Hits  *hits     = IxSearcher_Hits(searcher, (Obj*)parsed, 0, 10, NULL);
        char  *qstr     = Str_To_Utf8(test_case->query_string);

        TEST_TRUE(runner, Query_Equals(tree, (Obj*)test_case->tree),
                  "tree() AND   %s", qstr);
        TEST_INT_EQ(runner, Hits_Total_Hits(hits), test_case->num_hits,
                    "hits: AND   %s", qstr);
        free(qstr);
        DECREF(hits);
        DECREF(parsed);
        DECREF(tree);
        DECREF(test_case_obj);
    }

    // Run tests for QParser_Prune().
    for (i = 0; prune_test_funcs[i] != NULL; i++) {
        LUCY_TestQPLogic_Prune_Test_t test_func = prune_test_funcs[i];
        TestQueryParser *test_case_obj = test_func();
        TestQueryParserIVARS *test_case = TestQP_IVARS(test_case_obj);
        String *qstring = test_case->tree
                          ? Query_To_String(test_case->tree)
                          : Str_new_from_trusted_utf8("(NULL)", 6);
        char  *qstr = Str_To_Utf8(qstring);
        Query *tree = test_case->tree;
        Query *wanted = test_case->expanded;
        Query *pruned   = QParser_Prune(or_parser, tree);
        Query *expanded;
        Hits  *hits;

        TEST_TRUE(runner, Query_Equals(pruned, (Obj*)wanted),
                  "prune()   %s", qstr);
        expanded = QParser_Expand(or_parser, pruned);
        hits = IxSearcher_Hits(searcher, (Obj*)expanded, 0, 10, NULL);
        TEST_INT_EQ(runner, Hits_Total_Hits(hits), test_case->num_hits,
                    "hits:    %s", qstr);

        free(qstr);
        DECREF(hits);
        DECREF(expanded);
        DECREF(pruned);
        DECREF(qstring);
        DECREF(test_case_obj);
    }

    DECREF(and_parser);
    DECREF(or_parser);
    DECREF(searcher);
    DECREF(folder);
}
コード例 #16
0
ファイル: binder2nd.pass.cpp プロジェクト: llvm-mirror/libcxx
test() : std::binder2nd<test_func>(test_func(3), 4.5) {}
コード例 #17
0
int main()
{
  int a[N];
  int i;
  
#pragma acc parallel loop copy(a)
  for(i = 0; i < N; i++){
    a[i] = i;
  }

  //check
  for(i = 0; i < N; i++){
    if(a[i] != i) return 1;
  }


#pragma acc parallel loop copyin(a)
  for(i = 0; i < N; i++){
    a[i] = i + 1;
  }

  //check
  for(i = 0; i < N; i++){
    if(a[i] != i) return 2;
  }


#pragma acc parallel loop copyout(a)
  for(i = 0; i < N; i++){
    a[i] = i + 2;
  }

  //check
  for(i = 0; i < N; i++){
    if(a[i] != i + 2) return 3;
  }


#pragma acc parallel loop create(a)
  for(i = 0; i < N; i++){
    a[i] = i + 3;
  }

  //check
  for(i = 0; i < N; i++){
    if(a[i] != i + 2) return 4;
  }


  int ret;
  for(i = 0; i < N; i++) a[i] = 0;
  ret = test_func(a, 0);
  if(ret != 0){
    return 5;
  }


  for(i = 0; i < N; i++) a[i] = 0;
#pragma acc data copy(a)
  ret = test_func(a, 1);

  if(ret != 0){
    return 6;
  }


  for(i = 0; i < N; i++) a[i] = 0;
#pragma acc data copy(a)
#pragma acc host_data use_device(a)
  test_func2(a);
  //check
  for(i = 0; i < N; i++){
    if(a[i] != i * 3) return 7;
  }

  printf("PASS\n");
  return 0;
}
コード例 #18
0
ファイル: test_rapidxml.cpp プロジェクト: BillXu/simple_win
int _tmain(int argc, _TCHAR* argv[])
{
	test_func();
	system("pause");
	return 0;
}
コード例 #19
0
ファイル: bproc_test.c プロジェクト: dwrudis/clustermatic
/* XXX it would really be good to have a built-in I/O forwarder so
 * that we can make sure the output from this test program looks
 * somewhat reasonable.  It's also the sure-fire way to make sure that
 * we know what's really going on. */
static
int test_run_arr(int nprocs, int arr, int flags,
		 int (*test_func)(int, struct bproc_test_info_t *)) {
    int pid,a,r,i;
    int pfd[2];
    int status;

    struct bproc_test_info_t ti;

    if (nnodes == -1) {
	fprintf(stderr, "bproc_test: call bproc_test_init() first!\n");
	exit(1);
    }

    /* Assign nodes to this arrangement */
    ti.nprocs  = nprocs;
    ti.arr     = arr;
    ti.scratch = 0;
    for (i=0; i < nprocs; i++) {
	if (proc_arr(arr, i) == proc_fe)
	    ti.node[i] = BPROC_NODE_MASTER;
	else if (proc_arr(arr, i) == proc_inv)
	    ti.node[i] = node_inv;
	else {
	    a = proc_arr(arr, i);
	    if (a >= proc_sl_d)
		a -= proc_sl_d - proc_sl;
	    a -= proc_sl;

	    if (a >= nnodes)
		return 2;
	    ti.node[i] = nodes[a];
	}
    }

    /* Setup the first (parent) process */
    pid = bproc_rfork(ti.node[0]);
    if (pid < 0) {
	fprintf(stderr, "bproc_rfork(%d)=%d; errno=%d (%s)\n",
		ti.node[0], pid, errno, bproc_strerror(errno));
	return 3;
    }
    if (pid > 0) {
	if (waitpid(pid, &status, 0) != pid) {
	    fprintf(stderr, "Failed to wait on proc 0: %s\n", strerror(errno));
	    return 1;
	}
	if (!WIFEXITED(status)) {
	    printf(" abnormal exit");
	    return 1;
	} else if (WEXITSTATUS(status) != 0) {
	    printf(" exit_status=%d", WEXITSTATUS(status));
	    return 1;
	} else {
	    return 0;
	}
    }

    /* PROC 0: PARENT */
    ti.pid[0] = getpid();

    if (flags & bproc_test_no_auto_create)
	exit(test_func(0, &ti));	

    /* Create cihld processes */
    for (i=1; i < nprocs; i++) {
	a = proc_arr(arr,i);
	pipe(pfd);
	pid = fork();
	if (pid < 0) {
	    perror("fork");
	    exit(100);
	}
	if (pid == 0) {
	    close(pfd[0]);
	    if (pfd[1] != STDOUT_FILENO) {
		dup2(pfd[1], STDOUT_FILENO);
		close(pfd[1]);
	    }

	    /* We need the cruddy built-in I/O forwarding here because
	     * we use it to inform the parent about the PID *after*
	     * moving.  The side-effect of doing it this way is that
	     * we know that child process is on the node where it
	     * should be before going on. */
	    if (ti.node[i] != ti.node[0]) {
		if (bproc_move(ti.node[i]))
		    exit(101);
	    }

	    /* PROC i: CHILD */
	    if (proc_isdetach(a)) {
		/* Detach self from parent by forking again. */
		pid = fork();
		if (pid < 0)
		    exit(102);
		if (pid > 0)
		    exit(0);
		/* child continues and does stuff */
	    }
	    /* Tell parent about PID */
	    ti.pid[i] = getpid();
	    if (write(STDOUT_FILENO, &ti.pid[i], sizeof(ti.pid[i]))
		!= sizeof(ti.pid[i])) {
		exit(103);
	    }
	    close(STDOUT_FILENO);

	    /* Do the test */
	    exit(test_func(i, &ti));
	}
	/* PROC 0: PARENT */
	close(pfd[1]);
	r = read_all(pfd[0], &ti.pid[i], sizeof(ti.pid[i]));
	if (r != sizeof(ti.pid[i])) {
	    fprintf(stderr, "Failed to get PID from child %d\n", i);
	    exit(104);
	}
	close(pfd[0]);

	if (proc_isdetach(a)) {
	    int status;
	    /* Wait for intermediate process to exit */
	    if (waitpid(pid, &status, 0) != pid)
		exit(105);
	    if (!WIFEXITED(status) || WEXITSTATUS(status) != 0)
		exit(106);
	}
    }

    exit(test_func(0, &ti));
}
コード例 #20
0
void
TestQPLogic_run_tests()
{
    u32_t i;
    TestBatch   *batch = Test_new_batch("TestQueryParserLogic", 178, NULL);
    Folder      *folder       = S_create_index();
    Searcher    *searcher     = Searcher_new((Obj*)folder);
    QueryParser *or_parser    = QParser_new(Searcher_Get_Schema(searcher), 
        NULL, NULL, NULL);
    static  ZombieCharBuf AND = ZCB_LITERAL("AND");
    QueryParser *and_parser   = QParser_new(Searcher_Get_Schema(searcher), 
        NULL, (CharBuf*)&AND, NULL);
    QParser_Set_Heed_Colons(or_parser, true);
    QParser_Set_Heed_Colons(and_parser, true);

    PLAN(batch);

    /* Run logical tests with default boolop of OR. */
    for (i = 0; logical_test_funcs[i] != NULL; i++) {
        kino_TestQPLogic_logical_test_t test_func = logical_test_funcs[i];
        TestQueryParser *test_case = test_func(BOOLOP_OR);
        Query *tree     = QParser_Tree(or_parser, test_case->query_string);
        Query *parsed   = QParser_Parse(or_parser, test_case->query_string);
        Hits  *hits     = Searcher_Hits(searcher, (Obj*)parsed, 0, 10, NULL);

        ASSERT_TRUE(batch, Query_Equals(tree, (Obj*)test_case->tree),
            "tree() OR   %s", test_case->query_string->ptr);
        ASSERT_INT_EQ(batch, Hits_Total_Hits(hits), test_case->num_hits,
            "hits: OR   %s", test_case->query_string->ptr);
        DECREF(hits);
        DECREF(parsed);
        DECREF(tree);
        DECREF(test_case);
    }

    /* Run logical tests with default boolop of AND. */
    for (i = 0; logical_test_funcs[i] != NULL; i++) {
        kino_TestQPLogic_logical_test_t test_func = logical_test_funcs[i];
        TestQueryParser *test_case = test_func(BOOLOP_AND);
        Query *tree     = QParser_Tree(and_parser, test_case->query_string);
        Query *parsed   = QParser_Parse(and_parser, test_case->query_string);
        Hits  *hits     = Searcher_Hits(searcher, (Obj*)parsed, 0, 10, NULL);

        ASSERT_TRUE(batch, Query_Equals(tree, (Obj*)test_case->tree),
            "tree() AND   %s", test_case->query_string->ptr);
        ASSERT_INT_EQ(batch, Hits_Total_Hits(hits), test_case->num_hits,
            "hits: AND   %s", test_case->query_string->ptr);
        DECREF(hits);
        DECREF(parsed);
        DECREF(tree);
        DECREF(test_case);
    }

    /* Run tests for QParser_Prune(). */
    for (i = 0; prune_test_funcs[i] != NULL; i++) {
        kino_TestQPLogic_prune_test_t test_func = prune_test_funcs[i];
        TestQueryParser *test_case = test_func();
        CharBuf *qstring = test_case->tree 
                         ? Obj_To_String(test_case->tree)
                         : CB_new_from_trusted_utf8("(NULL)", 6);
        Query *tree = test_case->tree;
        Query *wanted = test_case->expanded;
        Query *pruned   = QParser_Prune(or_parser, tree);
        Query *expanded;
        Hits  *hits;

        ASSERT_TRUE(batch, Query_Equals(pruned, (Obj*)wanted),
            "prune()   %s", qstring->ptr);
        expanded = QParser_Expand(or_parser, pruned);
        hits = Searcher_Hits(searcher, (Obj*)expanded, 0, 10, NULL);
        ASSERT_INT_EQ(batch, Hits_Total_Hits(hits), test_case->num_hits,
            "hits:    %s", qstring->ptr);

        DECREF(hits);
        DECREF(expanded);
        DECREF(pruned);
        DECREF(qstring);
        DECREF(test_case);
    }

    DECREF(and_parser);
    DECREF(or_parser);
    DECREF(searcher);
    DECREF(folder);
    batch->destroy(batch);
}
コード例 #21
0
ファイル: c_client.c プロジェクト: 3112517927/otp
int main(int argc, char **argv)
#endif
{
    struct hostent *hp;
    erlang_pid pid;
    MyTimeval start, stop;
    int i, fd, ires, tres;
    IC_Env *env;
    int tries = 0;
    char *this_node_name = NULL;
    char *peer_node = NULL;
    char *peer_process_name = NULL;
    char *cookie = NULL;
    char host[HOSTNAMESZ + 1];
    TestFunc test_func = NULL;
    TestCase *test_case;
    char *test_case_name = NULL;
    
#ifdef __WIN32__
    WORD wVersionRequested;
    WSADATA wsaData;
    
    wVersionRequested = MAKEWORD(2, 0);
    
    if (WSAStartup(wVersionRequested, &wsaData) != 0) {
	fprintf(stderr, "Could not load winsock2 v2.0 compatible DLL");
	exit(1);
    }
#endif
    
    progname = argv[0];
    host[HOSTNAMESZ] = '\0';
    if (gethostname(host, HOSTNAMESZ) < 0) {
	fprintf(stderr, "Can't find own hostname\n");
	done(1);
    } 
    if ((hp = gethostbyname(host)) == 0) {
	fprintf(stderr, "Can't get ip address for host %s\n", host);
	done(1);
    }
    for (i = 1; i < argc; i++) {
	if (cmp_str(argv[i], "-help")) {
	    usage();
	    done(0);
	} else if (cmp_str(argv[i], "-this-node-name")) {
	    i++;
	    this_node_name = argv[i];
	} else if (cmp_str(argv[i], "-peer-node")) {
	    i++;
	    peer_node = argv[i];
	} else if (cmp_str(argv[i], "-peer-process-name")) {
	    i++;
	    peer_process_name = argv[i];
	} else if (cmp_str(argv[i], "-cookie")) {
	    i++;
	    cookie = argv[i];
	} else if (cmp_str(argv[i], "-test-case")) {
	    i++;
	    test_case_name = argv[i];
	} else {
	    fprintf(stderr, "Error : invalid argument \"%s\"\n", argv[i]);
	    usage();
	    done(1);
	}
    }

    if (this_node_name == NULL || peer_node == NULL || test_case_name == NULL 
	|| peer_process_name == NULL || cookie == NULL) {
	fprintf(stderr, "Error: missing option\n");
	usage();
	done(1);
    }

    test_case = test_cases;
    while (test_case->func) {
	if (cmp_str(test_case->name, test_case_name)) {
	    test_func = test_case->func;
	    break;
	}
	test_case++;
    }
    if (test_func == NULL) {
	fprintf(stderr, "Error: illegal test case: \"%s\"\n", test_case_name);
	done(1);
    }
    
    /* Behead hostname at first dot */
    for (i=0; host[i] != '\0'; i++) {
	if (host[i] == '.') { host[i] = '\0'; break; }
    }
    sprintf(this_node, "%s@%s", this_node_name, host);
    fprintf(stderr, "c_client: this node: \"%s\"\n", this_node);
    fprintf(stderr, "c_client: peer node: \"%s\"\n", peer_node);
    fprintf(stderr, "c_client: test case: \"%s\"\n", test_case_name);

    fprintf(stderr, "c_client: starting\n");

    /* initialize erl_interface */
    erl_init(NULL, 0);

    for (tries = 0; tries < MAXTRIES; tries++) {

	/* connect to erlang node */ 

    	ires = erl_connect_xinit(host, this_node_name, this_node, 
				 (struct in_addr *)*hp->h_addr_list, 
				 cookie, 0);

	fprintf(stderr, "c_client: erl_connect_xinit(): %d\n", ires);
    
	fd = erl_connect(peer_node);
	fprintf(stderr, "c_client: erl_connect(): %d\n", fd);
    
	if (fd >= 0) 
	    break;
	fprintf(stderr, "c_client: cannot connect, retrying\n");
    }
    if (fd < 0) {
	fprintf(stderr, "c_client: cannot connect, exiting\n");
	done(1);
    }
    env = CORBA_Environment_alloc(INBUFSZ, OUTBUFSZ);
    env->_fd = fd; 
    strcpy(env->_regname, peer_process_name);
    env->_to_pid = NULL;
    env->_from_pid = &pid;
    
    strcpy(pid.node, this_node);
    pid.num = fd;
    pid.serial = 0;
    pid.creation = 0;

    my_gettimeofday(&start);
    tres = test_func(env);	/* Call test case */
    my_gettimeofday(&stop);
    showtime(&start, &stop);
    erl_close_connection(fd);

    printf("c_client: env->_inbuf before : %d\n", INBUFSZ);
    printf("c_client: env->_outbuf before : %d\n", OUTBUFSZ);
    printf("c_client: env->_inbuf after : %d\n", env->_inbufsz);
    printf("c_client: env->_outbuf after : %d\n", env->_outbufsz);

    CORBA_free(env->_inbuf);
    CORBA_free(env->_outbuf);
    CORBA_free(env);
    done(tres);
}
コード例 #22
0
ファイル: TestQueryParserSyntax.c プロジェクト: kidaa/lucy
static void
test_query_parser_syntax(TestBatchRunner *runner) {
    if (!RegexTokenizer_is_available()) {
        for (uint32_t i = 0; leaf_test_funcs[i] != NULL; i++) {
            SKIP(runner, 3, "RegexTokenizer not available");
        }

        for (uint32_t i = 0; syntax_test_funcs[i] != NULL; i++) {
            SKIP(runner, 2, "RegexTokenizer not available");
        }

        return;
    }

    Folder        *index    = build_index();
    IndexSearcher *searcher = IxSearcher_new((Obj*)index);
    QueryParser   *qparser  = QParser_new(IxSearcher_Get_Schema(searcher),
                                          NULL, NULL, NULL);
    QParser_Set_Heed_Colons(qparser, true);

    for (uint32_t i = 0; leaf_test_funcs[i] != NULL; i++) {
        LUCY_TestQPSyntax_Test_t test_func = leaf_test_funcs[i];
        TestQueryParser *test_case = test_func();
        TestQueryParserIVARS *ivars = TestQP_IVARS(test_case);
        Query *tree     = QParser_Tree(qparser, ivars->query_string);
        Query *expanded = QParser_Expand_Leaf(qparser, ivars->tree);
        Query *parsed   = QParser_Parse(qparser, ivars->query_string);
        Hits  *hits     = IxSearcher_Hits(searcher, (Obj*)parsed, 0, 10, NULL);

        TEST_TRUE(runner, Query_Equals(tree, (Obj*)ivars->tree),
                  "tree()    %s", Str_Get_Ptr8(ivars->query_string));
        TEST_TRUE(runner, Query_Equals(expanded, (Obj*)ivars->expanded),
                  "expand_leaf()    %s", Str_Get_Ptr8(ivars->query_string));
        TEST_INT_EQ(runner, Hits_Total_Hits(hits), ivars->num_hits,
                    "hits:    %s", Str_Get_Ptr8(ivars->query_string));
        DECREF(hits);
        DECREF(parsed);
        DECREF(expanded);
        DECREF(tree);
        DECREF(test_case);
    }

    for (uint32_t i = 0; syntax_test_funcs[i] != NULL; i++) {
        LUCY_TestQPSyntax_Test_t test_func = syntax_test_funcs[i];
        TestQueryParser *test_case = test_func();
        TestQueryParserIVARS *ivars = TestQP_IVARS(test_case);
        Query *tree   = QParser_Tree(qparser, ivars->query_string);
        Query *parsed = QParser_Parse(qparser, ivars->query_string);
        Hits  *hits   = IxSearcher_Hits(searcher, (Obj*)parsed, 0, 10, NULL);

        TEST_TRUE(runner, Query_Equals(tree, (Obj*)ivars->tree),
                  "tree()    %s", Str_Get_Ptr8(ivars->query_string));
        TEST_INT_EQ(runner, Hits_Total_Hits(hits), ivars->num_hits,
                    "hits:    %s", Str_Get_Ptr8(ivars->query_string));
        DECREF(hits);
        DECREF(parsed);
        DECREF(tree);
        DECREF(test_case);
    }

    DECREF(searcher);
    DECREF(qparser);
    DECREF(index);
}
コード例 #23
0
ファイル: util.c プロジェクト: rgs1/libsmall
SMALL_EXPORT void run_test(const char *test_desc, void (*test_func) (void))
{
  info("Running %s", test_desc);
  test_func();
}
コード例 #24
0
ファイル: bt_detect2.c プロジェクト: jvoyatz/rageAgainstVM
JNIEXPORT jint JNICALL Java_com_btdetector2_NativeWrapper_is_1synch_1proc_1switch
  (JNIEnv * je, jclass jc)
{
    // a function pointer to our test code
    test_func_t     test_func;

    // a pointer to some code that we will patch
    uint32_t *  patch;

    // a useful swap pointer
    uint32_t *  caret;

		int i=0;
		double sum=0;
		struct timespec tsi, tsf;
		double elaps_ns, elaps_s;


    // we need some memory for our run-time-generated function.
    // w+x rights in order to be able to patch the code
    // 16 * 4,  // Space for 16 instructions. (More than enough.)
    uint32_t *  code = mmap(
            NULL,
            16 * 4,  // Space for 64 instructions. (More than enough.)
            PROT_READ | PROT_WRITE | PROT_EXEC,
            MAP_PRIVATE | MAP_ANONYMOUS,
            -1,
            0);

    if (code == MAP_FAILED) {
        printf("Could not mmap a memory buffer with the proper permissions.\n");
        return -1;
    }

    // Set test_func to point to the writable code block
    test_func = (test_func_t) code;

    // initialize test_func with f1 code
		write_code(&caret, &code, &patch, &f2);

    // Synchronize the cache.
    // __clear_cache((char*)code, (char*)caret);

		sum=0;
		for (i=0; i<10; i++) {

			// patch code with f1, synch I-cache and run the function
			patch_code_other(&caret, &patch, &f1);
			test_func();

			// patch code with f2, synch I-cache and run the function
			patch_code_other(&caret, &patch, &f2);
			test_func();
		}

	if (strcmp(switch_str, expected) == 0) {
		// printf("\n is Emulator! \n");
		return 1;
	}
	else {
		// printf("\n is Device! \n");
		return 0;
	}
}
コード例 #25
0
ファイル: bind2nd.pass.cpp プロジェクト: themiwi/libcxx
int main()
{
    assert(std::bind2nd(test_func(1), 5)(10) == 5.);
}
コード例 #26
0
    double t=1e-3;
    int tri[]={
		0,1,4,
		4, 1, 2,
		3, 4, 2,
		3, 0, 4
	};
	const int nValence=4;
	int polyfanid[nValence]={0,1,2,3};
	const int nodeid = 4;
    shell.init(0, 4, pVertex, tri, nv_per_elm, polyfanid, nValence, t);
	//return 1;

    startFastTimer(timerid);
	const int stride = sizeof(Vector3d);
    for (int i=0; i<N; i++){
		const int j=0;
        const double z = 1.0*i/N;
        pVertex[4].z = z;
        shell.computeForce(0, pVertex, stride, mtl, F, ppJacobian);
        printf("Loop %3d, Force is %8lg %8lg %8lg\n", i, F[j].x, F[j].y, F[j].z);
    }
    stopFastTimer(timerid);
    reportTimeDifference(timerid, "Shell elm run time:");
*/
    return 1;
}
static int ntest = test_func();


コード例 #27
0
void main(void)
{
	u32 cnt = 0;

	Init_Device();	  //use code generate by silicon tool.

	TI0 = 1; 			//make uart0 in send enable status
//-----------------------------------------
	event_init();
//-----------------------------------------add a timer event for printf
#if 0
{
   	timer_ev_unit_st xdata unit;
	timer_event_init();
	unit.event = EVENT_ID_TIMER_DEBUG;
	unit.time = TRIG_TIME;
	unit.callback = func_for_debug;
	timer_event_add(&unit);
}
#endif
//-----------------------------------------




	report_handler_init();

//	while(cnt++<65536);
//	config_sensor();

	test_func();

 	Usb_Init();
	
	Interrupts_Init();	   //open relative interrupt.

   	//g_panel_point.ID = 0;
 	//g_panel_point.x  = 0;
	//g_panel_point.y  = 0;

	while (1)
	{
		event_process();
		
		if(g_work_style == WORK_STYLE_PREVIEW)
		{
			get_frame_data();
			//while(EP_STATUS[1] != 0);
			send_debug_info_to_host(REPORT_ID_IN_DBGINFO);
		}
		else if(g_work_style == WORK_STYLE_CAL)
		{
		 
		}
		else if(g_work_style == WORK_STYLE_NOMAL)
		{ /*
		 	g_panel_point.x +=200;
			g_panel_point.y +=100;

			g_panel_point.x %= 1600;
			g_panel_point.y %= 900;

			fill_hid_packet(&g_panel_point,1); 
			send_debug_info_to_host(REPORT_ID_IN_MTOUCH);	
		   */
		}
		

	}

}
コード例 #28
0
ファイル: binder1st.pass.cpp プロジェクト: 32bitmicro/libcxx
test() : std::binder1st<test_func>(test_func(2), 30) {}
コード例 #29
0
void run_test(const char *test_name, void (*test_func)(void)) {
  printf("Running %s...\n", test_name);
  test_func();
}
コード例 #30
0
void
TestQPLogic_run_tests() {
    uint32_t i;
    TestBatch     *batch      = TestBatch_new(258);
    Folder        *folder     = S_create_index();
    IndexSearcher *searcher   = IxSearcher_new((Obj*)folder);
    QueryParser   *or_parser  = QParser_new(IxSearcher_Get_Schema(searcher),
                                            NULL, NULL, NULL);
    ZombieCharBuf *AND        = ZCB_WRAP_STR("AND", 3);
    QueryParser   *and_parser = QParser_new(IxSearcher_Get_Schema(searcher),
                                            NULL, (CharBuf*)AND, NULL);
    QParser_Set_Heed_Colons(or_parser, true);
    QParser_Set_Heed_Colons(and_parser, true);

    TestBatch_Plan(batch);

    // Run logical tests with default boolop of OR.
    for (i = 0; logical_test_funcs[i] != NULL; i++) {
        Lucy_TestQPLogic_Logical_Test_t test_func = logical_test_funcs[i];
        TestQueryParser *test_case = test_func(BOOLOP_OR);
        Query *tree     = QParser_Tree(or_parser, test_case->query_string);
        Query *parsed   = QParser_Parse(or_parser, test_case->query_string);
        Hits  *hits     = IxSearcher_Hits(searcher, (Obj*)parsed, 0, 10, NULL);

        TEST_TRUE(batch, Query_Equals(tree, (Obj*)test_case->tree),
                  "tree() OR   %s", (char*)CB_Get_Ptr8(test_case->query_string));
        TEST_INT_EQ(batch, Hits_Total_Hits(hits), test_case->num_hits,
                    "hits: OR   %s", (char*)CB_Get_Ptr8(test_case->query_string));
        DECREF(hits);
        DECREF(parsed);
        DECREF(tree);
        DECREF(test_case);
    }

    // Run logical tests with default boolop of AND.
    for (i = 0; logical_test_funcs[i] != NULL; i++) {
        Lucy_TestQPLogic_Logical_Test_t test_func = logical_test_funcs[i];
        TestQueryParser *test_case = test_func(BOOLOP_AND);
        Query *tree     = QParser_Tree(and_parser, test_case->query_string);
        Query *parsed   = QParser_Parse(and_parser, test_case->query_string);
        Hits  *hits     = IxSearcher_Hits(searcher, (Obj*)parsed, 0, 10, NULL);

        TEST_TRUE(batch, Query_Equals(tree, (Obj*)test_case->tree),
                  "tree() AND   %s", (char*)CB_Get_Ptr8(test_case->query_string));
        TEST_INT_EQ(batch, Hits_Total_Hits(hits), test_case->num_hits,
                    "hits: AND   %s", (char*)CB_Get_Ptr8(test_case->query_string));
        DECREF(hits);
        DECREF(parsed);
        DECREF(tree);
        DECREF(test_case);
    }

    // Run tests for QParser_Prune().
    for (i = 0; prune_test_funcs[i] != NULL; i++) {
        Lucy_TestQPLogic_Prune_Test_t test_func = prune_test_funcs[i];
        TestQueryParser *test_case = test_func();
        CharBuf *qstring = test_case->tree
                           ? Query_To_String(test_case->tree)
                           : CB_new_from_trusted_utf8("(NULL)", 6);
        Query *tree = test_case->tree;
        Query *wanted = test_case->expanded;
        Query *pruned   = QParser_Prune(or_parser, tree);
        Query *expanded;
        Hits  *hits;

        TEST_TRUE(batch, Query_Equals(pruned, (Obj*)wanted),
                  "prune()   %s", (char*)CB_Get_Ptr8(qstring));
        expanded = QParser_Expand(or_parser, pruned);
        hits = IxSearcher_Hits(searcher, (Obj*)expanded, 0, 10, NULL);
        TEST_INT_EQ(batch, Hits_Total_Hits(hits), test_case->num_hits,
                    "hits:    %s", (char*)CB_Get_Ptr8(qstring));

        DECREF(hits);
        DECREF(expanded);
        DECREF(pruned);
        DECREF(qstring);
        DECREF(test_case);
    }

    DECREF(and_parser);
    DECREF(or_parser);
    DECREF(searcher);
    DECREF(folder);
    DECREF(batch);
}