Exemple #1
0
main ()
{
  test_fetch_add ();
  test_fetch_sub ();
  test_fetch_and ();
  test_fetch_nand ();
  test_fetch_xor ();
  test_fetch_or ();

  test_add_fetch ();
  test_sub_fetch ();
  test_and_fetch ();
  test_nand_fetch ();
  test_xor_fetch ();
  test_or_fetch ();

  test_add ();
  test_sub ();
  test_and ();
  test_nand ();
  test_xor ();
  test_or ();

  return 0;
}
/*
 * A single random test
 * - pick two existing bits x and y
 * - select between OR and XOR randomly
 */
static void random_test(void) {
  bit_t x, y;

  x = random_bit();
  y = random_bit();
  if (random() & 0x8000) {
    test_or(x, y);
  } else {
    test_xor(x, y);
  }
}
/*
 * Test all pairwise combinations of existing terms
 */
static void test_all_pairs(void) {
  uint32_t n;
  bit_t x, y;

  n = max+1;
  for (x = 0; x<n; x++) {
    if (! fresh[x]) {
      for (y=0; y<n; y++) {
	if (! fresh[y]) {
	  test_or(x, y);
	  test_xor(x, y);
	}
      }
    }
  }
}
Exemple #4
0
int
main ()
{
  test_fetch_add ();
  test_fetch_sub ();
  test_fetch_and ();
  test_fetch_xor ();
  test_fetch_or ();

  test_add ();
  test_sub ();
  test_and ();
  test_xor ();
  test_or ();

  return 0;
}
Exemple #5
0
int main(int argc, char **argv) {
	printf("-- TEST BEGIN\n");

	test_addu();
	test_addiu();
	test_and();
	test_andi();
	test_daddu();
	test_daddiu();
	test_dsll();
	test_dsll32();
	test_dsllv();
	test_dsra();
	test_dsra32();
	test_dsrav();
	test_dsrl();
	test_dsrl32();
	test_dsrlv();
	test_dsubu();
	test_lui();
	test_movn();
	test_movz();
	test_nor();
	test_or();
	test_ori();
	test_sll();
	test_sllv();
	test_slt();
	test_slti();
	test_sltiu();
	test_sltu();
	test_sra();
	test_srav();
	test_srl();
	test_srlv();
	test_subu();
	test_xor();
	test_xori();

	printf("-- TEST END\n");

	return 0;
}
Exemple #6
0
int main(int argc, char **argv) {
	const char *needle = "^hi";
	const char *haystack_1 = "patata";
	const char *haystack_2 = "hillow";
	if (argc>3) {
		needle = argv[1];
		haystack_1 = argv[2];
		haystack_2 = argv[3];
	} else printf ("Using default values\n");
	RRegex *rx = r_regex_new (needle, "");
	if (rx) {
		int res = r_regex_exec (rx, haystack_1, 0, 0, 0);
		printf ("result (%s) = %d\n", haystack_1, res);
		res = r_regex_exec (rx, haystack_2, 0, 0, 0);
		printf ("result (%s) = %d\n", haystack_2, res);
		r_regex_free (rx);
	} else printf ("oops, cannot compile regexp\n");
	test_or();
	return 0;
}
int main()
{
	union mips_instruction inst;
	struct virtual_mem_region* memory = NULL;
	struct context ctx;

	// I-type
	test_addi(inst, memory, ctx);
	test_addiu(inst, memory, ctx);
	test_andi(inst, memory, ctx);
	test_ori(inst, memory, ctx);
	test_xori(inst, memory, ctx);
	test_lui(inst, memory, ctx);
	test_slti(inst, memory, ctx);
	test_sltiu(inst, memory, ctx);
	test_sw(inst, memory, ctx);
	test_lw(inst, memory, ctx);
	test_sb(inst, memory, ctx);
	test_lb(inst, memory, ctx);
	test_beq(inst, memory, ctx);
	test_bne(inst, memory, ctx);
	test_bgez(inst, memory, ctx);
	test_bgtz(inst, memory, ctx);
	test_blez(inst, memory, ctx);
	test_bltz(inst, memory, ctx);

	// R-type
	test_add(inst, memory, ctx);
	test_addu(inst, memory, ctx);
	test_sub(inst, memory, ctx);
	test_subu(inst, memory, ctx);
	test_and(inst, memory, ctx);
	test_or(inst, memory, ctx);
	test_xor(inst, memory, ctx);
	test_slt(inst, memory, ctx);
	test_sltu(inst, memory, ctx);

	printf("\nAll tests completed successfully!\n");
	return 0;
}
Exemple #8
-1
/*
 * Test all combinations of x and y
 */
static void multi_test(bit_t x, bit_t y) {
  test_or(x, y);
  test_or(bit_not(x), y);
  test_or(x, bit_not(y));
  test_or(bit_not(x), bit_not(y));

  test_or(y, x);
  test_or(y, bit_not(x));
  test_or(bit_not(y), x);
  test_or(bit_not(y), bit_not(x));

  test_xor(x, y);
  test_xor(bit_not(x), y);
  test_xor(x, bit_not(y));
  test_xor(bit_not(x), bit_not(y));

  test_xor(y, x);
  test_xor(bit_not(y), x);
  test_xor(y, bit_not(x));
  test_xor(bit_not(y), bit_not(x));
}