示例#1
0
文件: test.c 项目: esheldon/misc
int main(int argc, char** argv) {
    wlog("testing creating, get, set and iteration\n");
    test_create_and_access();
    wlog("testing realloc resize clear and freedata\n");
    test_realloc_resize();
    wlog("testing push pop and extend\n");
    test_pushpop();
    wlog("testing sort\n");
    test_sort();
    wlog("testing basic type long\n");
    test_long();
    wlog("testing pointer\n");
    test_ptr();
}
示例#2
0
int main(int argc, char **argv)
{
	debug_init(stdout);
	save_fx(fx_orig);
	memcpy(&fx_orig[240], scratch_orig, 4*sizeof(long));
	memcpy(&fx_orig[256], taint_orig, 8*sizeof(long));
	offset = (long)taintmem_test - (long)mem_test;
	codeexec(NULL, 0, (long *)regs_orig);

	init_threads();

	test_reg2(taint_copy_reg32_to_reg32, ref_copy_reg32_to_reg32);
	test_reg2(taint_copy_reg16_to_reg16, ref_copy_reg16_to_reg16);
	test_reg2(taint_copy_reg8_to_reg8, ref_copy_reg8_to_reg8);

	test_mem(taint_copy_mem32_to_reg32, ref_copy_mem32_to_reg32);
	test_mem(taint_copy_mem16_to_reg16, ref_copy_mem16_to_reg16);
	test_mem(taint_copy_mem8_to_reg8, ref_copy_mem8_to_reg8);

	test_mem(taint_copy_reg32_to_mem32, ref_copy_reg32_to_mem32);
	test_mem(taint_copy_reg16_to_mem16, ref_copy_reg16_to_mem16);
	test_mem(taint_copy_reg8_to_mem8, ref_copy_reg8_to_mem8);

	test_stackop(taint_copy_push_reg32, ref_copy_push_reg32);
	test_stackop(taint_copy_push_reg16, ref_copy_push_reg16);

	test_mem(taint_copy_push_mem32, ref_copy_push_mem32);
	test_mem(taint_copy_push_mem16, ref_copy_push_mem16);

	test_stackop(taint_copy_pop_reg32, ref_copy_pop_reg32);
	test_stackop(taint_copy_pop_reg16, ref_copy_pop_reg16);

	test_mem(taint_copy_pop_mem32, ref_copy_pop_mem32);
	test_mem(taint_copy_pop_mem16, ref_copy_pop_mem16);

	test_addr(taint_copy_eax_to_addr32, ref_copy_eax_to_addr32);
	test_addr(taint_copy_ax_to_addr16, ref_copy_ax_to_addr16);
	test_addr(taint_copy_al_to_addr8, ref_copy_al_to_addr8);

	test_addr(taint_copy_addr32_to_eax, ref_copy_addr32_to_eax);
	test_addr(taint_copy_addr16_to_ax, ref_copy_addr16_to_ax);
	test_addr(taint_copy_addr8_to_al, ref_copy_addr8_to_al);

	test_impl(taint_copy_eax_to_str32, ref_copy_eax_to_str32);
	test_impl(taint_copy_ax_to_str16, ref_copy_ax_to_str16);
	test_impl(taint_copy_al_to_str8, ref_copy_al_to_str8);

	test_impl(taint_copy_str32_to_eax, ref_copy_str32_to_eax);
	test_impl(taint_copy_str16_to_ax, ref_copy_str16_to_ax);
	test_impl(taint_copy_str8_to_al, ref_copy_str8_to_al);

	test_impl(taint_copy_str32_to_str32, ref_copy_str32_to_str32);
	test_impl(taint_copy_str16_to_str16, ref_copy_str16_to_str16);
	test_impl(taint_copy_str8_to_str8, ref_copy_str8_to_str8);

	test_reg(taint_erase_reg32, ref_erase_reg32);
	test_reg(taint_erase_reg16, ref_erase_reg16);
	test_reg(taint_erase_reg8, ref_erase_reg8);

	test_mem(taint_erase_mem32, ref_erase_mem32);
	test_mem(taint_erase_mem16, ref_erase_mem16);
	test_mem(taint_erase_mem8, ref_erase_mem8);

	test_reg(taint_erase_hireg16, ref_erase_hireg16);

	test_impl(taint_erase_push32, ref_erase_push32);
	test_impl(taint_erase_push16, ref_erase_push16);

	test_reg2(taint_or_reg32_to_reg32, ref_or_reg32_to_reg32);
	test_reg2(taint_or_reg16_to_reg16, ref_or_reg16_to_reg16);
	test_reg2(taint_or_reg8_to_reg8, ref_or_reg8_to_reg8);

	test_mem(taint_or_reg32_to_mem32, ref_or_reg32_to_mem32);
	test_mem(taint_or_reg16_to_mem16, ref_or_reg16_to_mem16);
	test_mem(taint_or_reg8_to_mem8, ref_or_reg8_to_mem8);

	test_mem(taint_or_mem32_to_reg32, ref_or_mem32_to_reg32);
	test_mem(taint_or_mem16_to_reg16, ref_or_mem16_to_reg16);
	test_mem(taint_or_mem8_to_reg8, ref_or_mem8_to_reg8);

	test_mem(taint_xor_reg32_to_mem32, ref_xor_reg32_to_mem32);
	test_mem(taint_xor_reg16_to_mem16, ref_xor_reg16_to_mem16);
	test_mem(taint_xor_reg8_to_mem8, ref_xor_reg8_to_mem8);

	test_mem(taint_xor_mem32_to_reg32, ref_xor_mem32_to_reg32);
	test_mem(taint_xor_mem16_to_reg16, ref_xor_mem16_to_reg16);
	test_mem(taint_xor_mem8_to_reg8, ref_xor_mem8_to_reg8);

	test_reg2(taint_swap_reg32_reg32, ref_swap_reg32_reg32);
	test_reg2(taint_swap_reg16_reg16, ref_swap_reg16_reg16);
	test_reg2(taint_swap_reg8_reg8, ref_swap_reg8_reg8);

	test_mem(taint_swap_reg32_mem32, ref_swap_reg32_mem32);
	test_mem(taint_swap_reg16_mem16, ref_swap_reg16_mem16);
	test_mem(taint_swap_reg8_mem8, ref_swap_reg8_mem8);

	test_reg2(taint_copy_reg16_to_reg32, ref_copy_reg16_to_reg32);
	test_reg2(taint_copy_reg8_to_reg32, ref_copy_reg8_to_reg32);
	test_reg2(taint_copy_reg8_to_reg16, ref_copy_reg8_to_reg16);

	test_mem(taint_copy_mem16_to_reg32, ref_copy_mem16_to_reg32);
	test_mem(taint_copy_mem8_to_reg32, ref_copy_mem8_to_reg32);
	test_mem(taint_copy_mem8_to_reg16, ref_copy_mem8_to_reg16);

	test_impl2(taint_erase_eax_edx, ref_erase_eax_edx);
	test_impl2(taint_erase_ax_dx, ref_erase_ax_dx);
	test_impl2(taint_erase_eax, ref_erase_eax);
	test_impl2(taint_erase_ax, ref_erase_ax);
	test_impl2(taint_erase_al, ref_erase_al);

	test_pushpop(taint_copy_popa32, ref_copy_popa32, (long)mem_test);
	test_pushpop(taint_copy_popa16, ref_copy_popa16, (long)mem_test);

	test_pushpop(taint_copy_pusha32, ref_copy_pusha32, 32+(long)mem_test);
	test_pushpop(taint_copy_pusha16, ref_copy_pusha16, 32+(long)mem_test);

	test_impl(taint_leave32, ref_leave32);
	test_impl(taint_leave16, ref_leave16);

	test_cmpxchg(taint_cmpxchg8_pre, taint_cmpxchg8_post, ref_cmpxchg8);
	test_cmpxchg(taint_cmpxchg16_pre, taint_cmpxchg16_post, ref_cmpxchg16);
	test_cmpxchg(taint_cmpxchg32_pre, taint_cmpxchg32_post, ref_cmpxchg32);
	test_cmpxchg(taint_cmpxchg8b_pre, taint_cmpxchg8b_post, ref_cmpxchg8b);

	mrm_generator(test_lea);

	exit(err);
}