コード例 #1
0
ファイル: tst-addsub.c プロジェクト: 119/aircam-openwrt
int
main (int argc, char **argv)
{
  mp_size_t alloc_size, max_size, size, i, cumul_size;
  mp_ptr s1, s2, dx, dy;
  int s1_align, s2_align, d_align;
  long pass, n_passes;
  mp_limb_t cx, cy;

  max_size = SIZE;
  n_passes = 1000000;

  argc--; argv++;
  if (argc)
    {
      max_size = atol (*argv);
      argc--; argv++;
    }

  alloc_size = max_size + 32;
  s1 = malloc (alloc_size * BYTES_PER_MP_LIMB);
  s2 = malloc (alloc_size * BYTES_PER_MP_LIMB);
  dx = malloc (alloc_size * BYTES_PER_MP_LIMB);
  dy = malloc (alloc_size * BYTES_PER_MP_LIMB);

  cumul_size = 0;
  for (pass = 0; pass < n_passes; pass++)
    {
      size = random () % max_size + 1;

      cumul_size += size;
      if (cumul_size >= 1000000)
	{
	  cumul_size -= 1000000;
	  printf ("\r%ld", pass); fflush (stdout);
	}
      s1_align = random () % 32;
      s2_align = random () % 32;
      d_align = random () % 32;

      mpn_random2 (s1 + s1_align, size);
      mpn_random2 (s2 + s2_align, size);

      for (i = 0; i < alloc_size; i++)
	dx[i] = dy[i] = i + 0x9876500;

      cx = TESTCALL (dx + d_align, s1 + s1_align, s2 + s2_align, size);
      cy = REFCALL (dy + d_align, s1 + s1_align, s2 + s2_align, size);

      if (cx != cy || mpn_cmp (dx, dy, alloc_size) != 0)
	abort ();
    }

  printf ("%ld passes OK\n", n_passes);
  exit (0);
}
コード例 #2
0
STATUS DdmTestConsole::Enable(Message *pMsg) {

	Tracef("DdmTestConsole::Enable()\n");
	
	NetMsgListen* pListenMsg = new NetMsgListen(10, 40, 20, 200, PORT_NEPTUNE);
	Send(pListenMsg, NULL, REPLYCALLBACK(DdmTestConsole, ListenReplyHandler));

	SessionMan = new TestSessionManager();
	CommandMan = new ConsoleCommandManager();
	HandleMan = new HandleManager();
	
	// Add the commands
	CommandMan->AddCommand("help\0", "This command\0", this, TESTCALL(this, DisplayHelp));		
	CommandMan->AddCommand("list\0", "List available tests\0", this, TESTCALL(this, DisplayList));			
	CommandMan->AddCommand("run\0", "Run the given test - run [TestName] [TestArgs]\0", this, TESTCALL(this, RunTest));
	CommandMan->AddCommand("ps\0", "Display processes (with mask if requested) - ps [running/finished/error/#]\0", this, TESTCALL(this, DisplayHandles));
	CommandMan->AddCommand("output\0", "Set output to this terminal - output [process #] [0=off, 1=on]\0", this, TESTCALL(this, SetHandle));
	CommandMan->AddCommand("exit\0", "Close this console session", this, TESTCALL(this, CloseSession));
	
	Reply(pMsg, OK);
	return OK;

}