From 0b7ad6e20562e5561e07f3a34a1544f09b0d0091 Mon Sep 17 00:00:00 2001 From: Pavel Punegov <32519625+PavelPunegov@users.noreply.github.com> Date: Tue, 24 Oct 2017 14:05:13 +0300 Subject: [PATCH] Remove obsolete C test files and Makefiles --- backend.native/tests/Makefile | 48 ------------------- .../tests/codegen/basics/check_type-test.c | 16 ------- .../tests/codegen/object/constructor-test.c | 38 --------------- backend.native/tests/main.c | 30 ------------ .../tests/runtime/basic/hello1-test.c | 11 ----- 5 files changed, 143 deletions(-) delete mode 100644 backend.native/tests/Makefile delete mode 100644 backend.native/tests/codegen/basics/check_type-test.c delete mode 100644 backend.native/tests/codegen/object/constructor-test.c delete mode 100644 backend.native/tests/main.c delete mode 100644 backend.native/tests/runtime/basic/hello1-test.c diff --git a/backend.native/tests/Makefile b/backend.native/tests/Makefile deleted file mode 100644 index 9ad05e228fa..00000000000 --- a/backend.native/tests/Makefile +++ /dev/null @@ -1,48 +0,0 @@ -TESTS := sum \ - sum_foo_bar \ - arithmetic \ - initialization - -BIN_TESTS=$(foreach t, ${TESTS},${t}_test) - -VPATH=codegen/function:codegen/object:${TOP}/runtime/build - -LLC=llc-mp-3.8 -CC=clang-mp-3.8 -JAVA=java - -TOP=../.. -RUNTIME=${TOP}/runtime -BACKEND=${TOP}/backend.native -BACKEND_CLASSES=${TOP}/backend.native/build/classes -KOTLIN_DIST=${BACKEND}/kotlin-ir/dist -KOTLIN_NATIVE_CLASSPATH=${BACKEND_CLASSES}/bc_frontend:${BACKEND_CLASSES}/cli_bc:${BACKEND_CLASSES}/compiler:${BACKEND_CLASSES}/llvmInteropStubs:${BACKEND_CLASSES}/hashInteropStubs:${KOTLIN_DIST}/kotlinc/lib/kotlin-reflect.jar:${KOTLIN_DIST}kotlinc/lib/kotlin-stdlib.jar:${KOTLIN_DIST}/kotlinc/lib/kotlin-compiler.jar:${KOTLIN_DIST}/kotlinc/lib/kotlin-runtime.jar:${TOP}/Interop/Runtime/build/classes/main - - -define PROTO -$(1)_test: $1-test.c $1.S runtime.S main.c - $(CC) -o $$@ $$^ - -${1}_run:${1}_test - ./${1}_test -endef - -$(foreach test,${TESTS},$(eval $(call PROTO,$(test)))) - -all:${BIN_TESTS} - -run:$(foreach test,${TESTS},${test}_run) - -clean: - ${RM} *.o *.S *.BCkt ${BIN_TESTS} - -%.S:%.bc - ${LLC} -o $@ $< - -%.S:%.BCkt - ${LLC} -o $@ $< - - -%.BCkt:%.kt - ${JAVA} -cp ${KOTLIN_NATIVE_CLASSPATH} -Djava.library.path=${BACKEND}/build/nativelibs org.jetbrains.kotlin.cli.bc.K2NativeKt -output $@ -runtime ${RUNTIME}/build/runtime.bc ${RUNTIME}/src/main/kotlin $< - diff --git a/backend.native/tests/codegen/basics/check_type-test.c b/backend.native/tests/codegen/basics/check_type-test.c deleted file mode 100644 index 837879463f6..00000000000 --- a/backend.native/tests/codegen/basics/check_type-test.c +++ /dev/null @@ -1,16 +0,0 @@ -#include - -extern void *resolve_symbol(const char*); - -int -run_test() { - int (*check_type)() = resolve_symbol("kfun:check_type()"); - int (*check_not_type)() = resolve_symbol("kfun:check_not_type()"); - int (*check_interface)() = resolve_symbol("kfun:check_interface()"); - - if (!check_type()) return 1; - if (!check_not_type()) return 1; - if (!check_interface()) return 1; - - return 0; -} diff --git a/backend.native/tests/codegen/object/constructor-test.c b/backend.native/tests/codegen/object/constructor-test.c deleted file mode 100644 index 05809dc36f6..00000000000 --- a/backend.native/tests/codegen/object/constructor-test.c +++ /dev/null @@ -1,38 +0,0 @@ -#include - -extern void *resolve_symbol(const char*); -extern void *AllocInstance(void *, int32_t); - -#define CHECK_OBJ(obj, info) if ((uintptr_t)*(obj) != (uintptr_t)(info)) return 1; -#define MAGIC0 0xdeadbeef -#define MAGIC1 0xcafebabe -#define MAGIC2 0xabadbabe - -int -run_test() { - void *a_type_info = resolve_symbol("ktype:A"); - void *(*a_init)(void *) = resolve_symbol("kfun:A.()"); - void *b_type_info = resolve_symbol("ktype:B"); - void *(*b_init)(void *, int) = resolve_symbol("kfun:B.(Int)"); - int (*b_get_a)(void *) = resolve_symbol("kfun:B.()"); - void *c_type_info = resolve_symbol("ktype:C"); - void *(*c_init)(void *, int, int) = resolve_symbol("kfun:C.(Int;Int)"); - int (*c_get_a)(void *) = resolve_symbol("kfun:C.()"); - - void **a = (void **)AllocInstance(a_type_info, 1); - CHECK_OBJ(a, a_type_info) - - void **b = (void **)AllocInstance(b_type_info, 1); - CHECK_OBJ(b, b_type_info) - void *b_obj = b_init((void *)b, MAGIC0); - CHECK_OBJ(b, b_type_info) - if (b_get_a(b_obj) != MAGIC0) return 1; - - - void **c = (void **)AllocInstance(c_type_info, 1); - CHECK_OBJ(c, c_type_info) - void *c_obj = c_init((void *)c, 0xcafebabe, 0xabadbabe); - CHECK_OBJ(c, c_type_info) - if (c_get_a(c_obj) != MAGIC1) return 1; - return 0; -} diff --git a/backend.native/tests/main.c b/backend.native/tests/main.c deleted file mode 100644 index fe2f5864e5e..00000000000 --- a/backend.native/tests/main.c +++ /dev/null @@ -1,30 +0,0 @@ -#ifdef __linux__ -# define _GNU_SOURCE -#endif -#include -#include -#include - -extern int run_test(); - -void * resolve_symbol(char *name) { - /* here we can add here some magic to resolve symbols in kotlin native*/ - void* symbol = dlsym(RTLD_DEFAULT, name); - - if (!symbol) { - printf("Could not find kotlin symbol '%s': %s\n", name, dlerror()); - exit(1); - } - - return symbol; -} - -extern void InitMemory(); -extern void InitGlobalVariables(); - -int -main() { - InitMemory(); - InitGlobalVariables(); - exit(run_test()); -} diff --git a/backend.native/tests/runtime/basic/hello1-test.c b/backend.native/tests/runtime/basic/hello1-test.c deleted file mode 100644 index d5885bfec38..00000000000 --- a/backend.native/tests/runtime/basic/hello1-test.c +++ /dev/null @@ -1,11 +0,0 @@ -extern void *resolve_symbol(const char*); - -int -run_test() { - void (*main)(void*) = resolve_symbol("kfun:main(Array)"); - - main((void*)0); - - return 0; -} -