unit test introduced:
User should create <test-name>-test.c file in the following manner:
> cat codegen/function/sum-test.c
extern void *resolve_symbol(const char*);
int
run_test() {
int (*sum)(int, int) = resolve_symbol("kfun:sum");
if (sum(2, 3) != 5) return 1;
return 0;
}
and add <test-name> to the TESTS variable in the Makefile
to run tests:
> make clean run
Note: failing tests should return no zero values.
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
#include <dlfcn.h>
|
||||
#include <stdio.h>
|
||||
/**
|
||||
* > llc-mp-3.8 b.out -o b.S
|
||||
* > /opt/local/libexec/llvm-3.8/bin/clang main.c b.S -o sum-test
|
||||
*/
|
||||
|
||||
extern int run_test();
|
||||
|
||||
void * resolve_symbol(char *name) {
|
||||
/* here we can add here some magic to resolve symbols in kotlin native*/
|
||||
return dlsym(RTLD_SELF, name);
|
||||
}
|
||||
|
||||
|
||||
int
|
||||
main() {
|
||||
return run_test();
|
||||
}
|
||||
Reference in New Issue
Block a user