Remove obsolete C test files and Makefiles
This commit is contained in:
committed by
Pavel Punegov
parent
9400ee6a8e
commit
0b7ad6e205
@@ -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 $<
|
|
||||||
|
|
||||||
@@ -1,16 +0,0 @@
|
|||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
@@ -1,38 +0,0 @@
|
|||||||
#include <stdint.h>
|
|
||||||
|
|
||||||
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.<init>()");
|
|
||||||
void *b_type_info = resolve_symbol("ktype:B");
|
|
||||||
void *(*b_init)(void *, int) = resolve_symbol("kfun:B.<init>(Int)");
|
|
||||||
int (*b_get_a)(void *) = resolve_symbol("kfun:B.<get-a>()");
|
|
||||||
void *c_type_info = resolve_symbol("ktype:C");
|
|
||||||
void *(*c_init)(void *, int, int) = resolve_symbol("kfun:C.<init>(Int;Int)");
|
|
||||||
int (*c_get_a)(void *) = resolve_symbol("kfun:C.<get-a>()");
|
|
||||||
|
|
||||||
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;
|
|
||||||
}
|
|
||||||
@@ -1,30 +0,0 @@
|
|||||||
#ifdef __linux__
|
|
||||||
# define _GNU_SOURCE
|
|
||||||
#endif
|
|
||||||
#include <dlfcn.h>
|
|
||||||
#include <stdlib.h>
|
|
||||||
#include <stdio.h>
|
|
||||||
|
|
||||||
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());
|
|
||||||
}
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
extern void *resolve_symbol(const char*);
|
|
||||||
|
|
||||||
int
|
|
||||||
run_test() {
|
|
||||||
void (*main)(void*) = resolve_symbol("kfun:main(Array<String>)");
|
|
||||||
|
|
||||||
main((void*)0);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
Reference in New Issue
Block a user