add start of test_mem_map.c

This commit is contained in:
Jonathon Reinhart 2015-09-07 15:05:55 -04:00
parent 12909e6a4c
commit d4de54601d
3 changed files with 73 additions and 2 deletions

View file

@ -1,13 +1,33 @@
CFLAGS += -L ../../
CFLAGS += -lcmocka -lunicorn CFLAGS += -lcmocka -lunicorn
CFLAGS += -I ../../include
ALL_TESTS = test_x86 test_mem_map
ALL_TESTS = test_x86 .PHONY: all
all: ${ALL_TESTS} all: ${ALL_TESTS}
.PHONY: clean
clean: clean:
rm ${ALL_TESTS} rm ${ALL_TESTS}
.PHONY: test
test: export LD_LIBRARY_PATH=../../
test: ${ALL_TESTS}
@#echo ${ALL_TESTS} | xargs -n1 | xargs -I CMD sh -c ./CMD
@for test in ${ALL_TESTS}; do \
echo -e "\n--------------------------------------------------------------------------------"; \
echo "TEST: $$test"; \
./$$test || break; \
done
test_x86: test_x86.c test_x86: test_x86.c
test_mem_map: test_mem_map.c
${ALL_TESTS}:
gcc ${CFLAGS} -o $@ $^ gcc ${CFLAGS} -o $@ $^

35
test/unit/test_mem_map.c Normal file
View file

@ -0,0 +1,35 @@
#include "unicorn_test.h"
#include <stdio.h>
static int setup(void **state)
{
fprintf(stderr, "~~~ setup() ~~~\n");
uc_engine *uc;
uc_assert_success(uc_open(UC_ARCH_X86, UC_MODE_32, &uc));
*state = uc;
return 0;
}
static int teardown(void **state)
{
uc_engine *uc = *state;
fprintf(stderr, "~~~ teardown() ~~~\n");
uc_assert_success(uc_close(uc));
return 0;
}
static void test_basic(void **state)
{
}
int main(void) {
const struct CMUnitTest tests[] = {
cmocka_unit_test(test_basic),
};
return cmocka_run_group_tests(tests, setup, teardown);
}

16
test/unit/unicorn_test.h Normal file
View file

@ -0,0 +1,16 @@
#ifndef UNICORN_TEST_H
#define UNICORN_TEST_H
#include <stdarg.h>
#include <stddef.h>
#include <setjmp.h>
#include <cmocka.h>
#include <unicorn/unicorn.h>
static void uc_assert_success(uc_err err)
{
assert_int_equal(err, 0);
// uc_strerror(err)
}
#endif /* UNICORN_TEST_H */