mirror of
https://github.com/yuzu-emu/unicorn
synced 2024-11-24 13:48:14 +00:00
add start of test_mem_map.c
This commit is contained in:
parent
12909e6a4c
commit
d4de54601d
3 changed files with 73 additions and 2 deletions
|
@ -1,13 +1,33 @@
|
|||
|
||||
CFLAGS += -L ../../
|
||||
CFLAGS += -lcmocka -lunicorn
|
||||
CFLAGS += -I ../../include
|
||||
|
||||
ALL_TESTS = test_x86 test_mem_map
|
||||
|
||||
ALL_TESTS = test_x86
|
||||
|
||||
.PHONY: all
|
||||
all: ${ALL_TESTS}
|
||||
|
||||
.PHONY: clean
|
||||
clean:
|
||||
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_mem_map: test_mem_map.c
|
||||
|
||||
${ALL_TESTS}:
|
||||
gcc ${CFLAGS} -o $@ $^
|
||||
|
||||
|
||||
|
||||
|
|
35
test/unit/test_mem_map.c
Normal file
35
test/unit/test_mem_map.c
Normal 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
16
test/unit/unicorn_test.h
Normal 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 */
|
Loading…
Reference in a new issue