issue #157 Long overdue reorg of tests, much more needs to be done, but this is a start

lua54-randomgen
Dibyendu Majumdar 4 years ago
parent 5f286815ed
commit 18ff6c1f36

@ -42,4 +42,4 @@ jobs:
- name: Test
shell: bash
run: cd lua-tests && sh run_tests.sh ${{runner.workspace}}/build/ravi
run: cd tests && sh run_tests.sh ${{runner.workspace}}/build/ravi

@ -19,8 +19,8 @@ script:
- mkdir $TRAVIS_BUILD_DIR/build
- cd $TRAVIS_BUILD_DIR/build && cmake -DCMAKE_BUILD_TYPE=Debug -DLLVM_DIR=$TRAVIS_BUILD_DIR/clang+llvm-6.0.1-x86_64-linux-gnu-ubuntu-16.04/lib/cmake/llvm -G "Unix Makefiles" -DLLVM_JIT=ON ..
- cd $TRAVIS_BUILD_DIR/build && make
- cd $TRAVIS_BUILD_DIR/lua-tests && sh ./run_travis_tests.sh $TRAVIS_BUILD_DIR/build/ravi
- cd $TRAVIS_BUILD_DIR/tests && sh ./run_tests.sh $TRAVIS_BUILD_DIR/build/ravi
- mkdir $TRAVIS_BUILD_DIR/buildmir
- cd $TRAVIS_BUILD_DIR/buildmir && cmake -DCMAKE_BUILD_TYPE=Release -G "Unix Makefiles" -DMIR_JIT=ON ..
- cd $TRAVIS_BUILD_DIR/buildmir && cmake -DCMAKE_BUILD_TYPE=Debug -DLTESTS=ON -DMIR_JIT=ON -G "Unix Makefiles" ..
- cd $TRAVIS_BUILD_DIR/buildmir && make
- cd $TRAVIS_BUILD_DIR/lua-tests && sh ./run_travis_tests.sh $TRAVIS_BUILD_DIR/buildmir/ravi
- cd $TRAVIS_BUILD_DIR/tests && sh ./run_tests.sh $TRAVIS_BUILD_DIR/buildmir/ravi

@ -1,42 +0,0 @@
LUA=$1
if [ "$LUA" = "" ]
then
echo "Please pass path to Lua"
exit 1
fi
# Run the interpreter tests first
$LUA -e"_port=true" all.lua
if [ $? != 0 ]
then
echo "all.lua interpreted failed"
exit 1
fi
# Run tests in JIT mode without support for the line hook
$LUA -e"_port=true; ravi.auto(true,1)" all.lua
if [ $? != 0 ]
then
echo "all.lua compiled without tracehook failed"
exit 1
fi
# Run tests in JIT mode with suppor for the line hook
$LUA -e"_port=true; ravi.tracehook(true); ravi.auto(true,1)" all.lua
if [ $? != 0 ]
then
echo "all.lua compiled with tracehook failed"
exit 1
fi
# Run tests in partial JIT mode, with line hook
$LUA -e"_port=true; ravi.tracehook(true); ravi.auto(true)" all.lua
if [ $? != 0 ]
then
echo "all.lua partially compiled with tracehook failed"
exit 1
fi
cd ../ravi-tests
. ./run_tests.sh "$LUA"
cd -

@ -1,26 +0,0 @@
LUA=$1
if [ "$LUA" = "" ]
then
echo "Please pass path to Lua"
exit 1
fi
# Run the interpreter tests first
$LUA -e"_port=true" all.lua
if [ $? != 0 ]
then
echo "all.lua interpreted failed"
exit 1
fi
# Run tests in JIT mode without support for the line hook
$LUA -e"_port=true; ravi.auto(true)" all.lua
if [ $? != 0 ]
then
echo "all.lua partially compiled with tracehook failed"
exit 1
fi
cd ../ravi-tests
. ./run_tests.sh "$LUA"
cd -

@ -1,34 +0,0 @@
This folder contains various performance and unit tests.
Language tests
--------------
* basics.lua - some simple tests
* ravi_tests1.ravi - contains most of the Ravi specific tests
* ravi_tests3.ravi - additional tests
* ravi_errors.ravi - contains tests for error conditions
* bitwise_tests.lua - modified Lua 5.3 tests to exercise JIT on bitwise operations
Performance tests
-----------------
Following are simple loop tests:
* fornum_test1.lua
* fornum_test2.lua
* fornum_test2.ravi - with optional types
* fornum_test3.lua
Matrix multiplication test:
* matmul1.lua - matrix multiplication (Lua compatible)
* matmul1.ravi - matrix multiplication (ravi version with static typing)
* matmul1_ravi.lua - matrix multiplication (ravi version with static typing)
Following performance tests were obtained from the `The Computer Programming Language Benchmarks Game <http://benchmarksgame.alioth.debian.org/>`_. Original author is `Mike Pall <http://luajit.org/>`_.
* fannkuchen.lua
* fannkuchen.ravi - with optional types
* mandel1.ravi - modified so that it can be JIT compiled
* mandel1.lua - can be JIT compiled but also compatible with Lua
See ``run_tests.sh`` for how to run these tests.

@ -1,31 +0,0 @@
-- test 40
function x(t) return t; end
function f()
local tt: integer[] = {1}
local ss: number[] = { 55.5 }
tt = x(tt)
ss = x(ss)
end
assert(ravi.compile(x))
assert(ravi.compile(f))
assert(pcall(f))
function f()
local tt: integer[] = {1}
tt = x({})
end
--ravi.dumplua(f)
print'+'
assert(ravi.compile(f))
assert(not pcall(f))
print'+'
function f()
local tt: integer[] = {1}
local ss: number[] = { 55.5 }
ss = x(tt)
end
print'+'
assert(ravi.compile(f))
assert(not pcall(f))
print("test 40 OK")

@ -1,38 +0,0 @@
-- Print anything - including nested tables
local function table_print (tt, indent, done)
done = done or {}
indent = indent or 0
if type(tt) == "table" then
for key, value in pairs (tt) do
io.write(string.rep (" ", indent)) -- indent it
if type (value) == "table" and not done [value] then
done [value] = true
io.write(string.format("[%s] => table\n", tostring (key)));
io.write(string.rep (" ", indent+4)) -- indent it
io.write("(\n");
table_print (value, indent + 7, done)
io.write(string.rep (" ", indent+4)) -- indent it
io.write(")\n");
else
io.write(string.format("[%s] => %s\n",
tostring (key), tostring(value)))
end
end
else
io.write(tostring(tt) .. "\n")
end
end
local somecode = [[
extern int adder(int a, int b);
int adder(int a, int b)
{
return a+b;
}
]]
local symbols = dmrc.getsymbols(somecode)
table_print(symbols)

@ -1,20 +0,0 @@
local testfunc = [[
struct lua_State;
extern int puts(const char *);
extern int TestFunc(struct lua_State *L);
int TestFunc(struct lua_State *L)
{
puts("hello world!\n");
return 0;
}
]]
local ctx = llvm.context()
local m = ctx:newmodule()
m:compileC(testfunc)
local f = m:getfunction("TestFunc")
local callable = f:compile()
callable()

@ -1,143 +0,0 @@
main <fannkuchen.ravi:0,0> (39 instructions at 0x1c5d5c0)
0+ params, 13 slots, 1 upvalue, 6 locals, 12 constants, 1 function
1 [67] CLOSURE 0 0 ; 0x1c5d880
2 [69] GETTABUP 1 0 -1 ; _ENV "tonumber"
3 [69] GETTABUP 2 0 -2 ; _ENV "arg"
4 [69] TEST 2 0
5 [69] JMP 0 2 ; to 8
6 [69] GETTABUP 2 0 -2 ; _ENV "arg"
7 [69] GETTABLE 2 2 -3 ; 1
8 [69] CALL 1 2 2
9 [69] TEST 1 1
10 [69] JMP 0 1 ; to 12
11 [69] LOADK 1 -3 ; 1
12 [70] GETTABUP 2 0 -4 ; _ENV "os"
13 [70] GETTABLE 2 2 -5 ; "time"
14 [70] CALL 2 1 2
15 [71] MOVE 3 0
16 [71] MOVE 4 1
17 [71] CALL 3 2 3
18 [72] GETTABUP 5 0 -4 ; _ENV "os"
19 [72] GETTABLE 5 5 -5 ; "time"
20 [72] CALL 5 1 2
21 [73] GETTABUP 6 0 -6 ; _ENV "io"
22 [73] GETTABLE 6 6 -7 ; "write"
23 [73] MOVE 7 3
24 [73] LOADK 8 -8 ; "\nPfannkuchen("
25 [73] MOVE 9 1
26 [73] LOADK 10 -9 ; ") = "
27 [73] MOVE 11 4
28 [73] LOADK 12 -10 ; "\n"
29 [73] CALL 6 7 1
30 [74] GETTABUP 6 0 -6 ; _ENV "io"
31 [74] GETTABLE 6 6 -7 ; "write"
32 [74] LOADK 7 -11 ; "elapsed time in secs "
33 [74] GETTABUP 8 0 -4 ; _ENV "os"
34 [74] GETTABLE 8 8 -12 ; "difftime"
35 [74] MOVE 9 5
36 [74] MOVE 10 2
37 [74] CALL 8 3 0
38 [74] CALL 6 0 1
39 [74] RETURN 0 1
function <fannkuchen.ravi:5,67> (98 instructions at 0x1c5d880)
1 param, 20 slots, 0 upvalues, 31 locals, 7 constants, 0 functions
1 [6] LOADK 1 -1 ; 11
2 [7] NEWARRAYI 2
3 [7] NEWARRAYI 3
4 [7] NEWARRAYI 4
5 [7] LOADK 5 -2 ; 1
6 [7] LOADK 6 -3 ; 0
7 [7] LOADK 7 -3 ; 0
8 [8] LOADK 8 -2 ; 1
9 [8] MOVE 9 1
10 [8] LOADK 10 -2 ; 1
11 [8] FORPREP 8 3 ; to 15
12 [9] SETTABLE_AI 2 -12 -12
13 [10] SETTABLE_AI 3 -12 -12
14 [11] SETTABLE_AI 4 -12 -12
15 [8] FORLOOP 8 -4 ; to 12
16 [15] GETTABLE_AI 8 2 -2
17 [16] EQ 1 8 -2 ; - 1
18 [16] JMP 0 35 ; to 54
19 [17] LOADK 9 -4 ; 2
20 [17] MOVE 10 1
21 [17] LOADK 11 -2 ; 1
22 [17] FORPREP 9 2 ; to 25
23 [18] GETTABLE_AI 13 2 -13
24 [18] SETTABLE_AI 3 -13 -14
25 [17] FORLOOP 9 -3 ; to 23
26 [20] LOADK 9 -2 ; 1
27 [22] GETTABLE_AI 10 3 -9
28 [23] EQ 0 10 -2 ; - 1
29 [23] JMP 0 6 ; to 36
30 [24] MULII 11 -6 -10
31 [24] ADDII 7 -8 -12
32 [25] LT 0 6 9
33 [25] JMP 0 20 ; to 54
34 [26] MOVEI 6 9
35 [27] JMP 0 18 ; to 54
36 [30] SETTABLE_AI 3 -9 -9
37 [31] LE 0 -5 8 ; 4 -
38 [31] JMP 0 10 ; to 49
39 [32] LOADK 11 -4 ; 2
40 [32] SUBII 12 -9 -2
41 [34] GETTABLE_AI 13 3 -13
42 [34] GETTABLE_AI 14 3 -12
43 [34] SETTABLE_AI 3 -13 -15
44 [34] SETTABLE_AI 3 -12 -14
45 [35] ADDIN 11 -12 1
46 [36] SUBII 12 -13 -2
47 [37] LE 0 12 11
48 [37] JMP 0 -8 ; to 41
49 [39] MOVEI 8 10
50 [40] ADDIN 9 -10 1
51 [41] LOADBOOL 11 0 0
52 [41] TEST 11 0
53 [41] JMP 0 -27 ; to 27
54 [44] EQ 0 5 -2 ; - 1
55 [44] JMP 0 6 ; to 62
56 [45] GETTABLE_AI 9 2 -2
57 [45] GETTABLE_AI 10 2 -4
58 [45] SETTABLE_AI 2 -2 -11
59 [45] SETTABLE_AI 2 -4 -10
60 [45] LOADK 5 -6 ; -1
61 [45] JMP 0 33 ; to 95
62 [47] GETTABLE_AI 9 2 -7
63 [47] GETTABLE_AI 10 2 -4
64 [47] SETTABLE_AI 2 -7 -11
65 [47] SETTABLE_AI 2 -4 -10
66 [47] LOADK 5 -2 ; 1
67 [48] LOADK 9 -7 ; 3
68 [48] MOVE 10 1
69 [48] LOADK 11 -2 ; 1
70 [48] FORPREP 9 23 ; to 94
71 [49] GETTABLE_AI 13 4 -13
72 [50] EQ 1 13 -2 ; - 1
73 [50] JMP 0 3 ; to 77
74 [51] SUBII 14 -14 -2
75 [51] SETTABLE_AI 4 -13 -15
76 [51] JMP 0 18 ; to 95
77 [54] EQ 0 12 1
78 [54] JMP 0 3 ; to 82
79 [55] MOVE 14 7
80 [55] MOVE 15 6
81 [55] RETURN 14 3
82 [57] SETTABLE_AI 4 -13 -13
83 [59] GETTABLE_AI 14 2 -2
84 [60] LOADK 15 -2 ; 1
85 [60] MOVE 16 12
86 [60] LOADK 17 -2 ; 1
87 [60] FORPREP 15 3 ; to 91
88 [61] ADDIN 19 -19 1
89 [61] GETTABLE_AI 19 2 -20
90 [61] SETTABLE_AI 2 -19 -20
91 [60] FORLOOP 15 -4 ; to 88
92 [63] ADDIN 15 -13 1
93 [63] SETTABLE_AI 2 -16 -15
94 [48] FORLOOP 9 -24 ; to 71
95 [66] LOADBOOL 9 0 0
96 [66] TEST 9 0
97 [66] JMP 0 -82 ; to 16
98 [67] RETURN 0 1

@ -1,107 +0,0 @@
main <mandel.ravi:0,0> (104 instructions at 0x1c665c0)
0+ params, 35 slots, 1 upvalue, 38 locals, 24 constants, 0 functions
1 [5] GETTABUP 0 0 -1 ; _ENV "arg"
2 [5] TEST 0 0
3 [5] JMP 0 4 ; to 8
4 [5] GETTABUP 0 0 -1 ; _ENV "arg"
5 [5] GETTABLE 0 0 -2 ; 1
6 [5] TEST 0 1
7 [5] JMP 0 1 ; to 9
8 [5] LOADK 0 -3 ; 100
9 [6] GETTABUP 1 0 -4 ; _ENV "tonumber"
10 [6] MOVE 2 0
11 [6] CALL 1 2 2
12 [6] TOINT 1
13 [7] MOVE 2 1
14 [7] DIVFI 3 -5 -2
15 [8] LOADK 4 -6 ; 50
16 [8] LOADK 5 -7 ; 4.0
17 [9] GETTABUP 6 0 -8 ; _ENV "io"
18 [9] GETTABLE 6 6 -9 ; "write"
19 [9] GETTABUP 7 0 -10 ; _ENV "string"
20 [9] GETTABLE 7 7 -11 ; "char"
21 [11] MOVE 8 6
22 [11] LOADK 9 -12 ; "P4\n"
23 [11] MOVE 10 1
24 [11] LOADK 11 -13 ; " "
25 [11] MOVE 12 2
26 [11] LOADK 13 -14 ; "\n"
27 [11] CALL 8 6 1
28 [12] GETTABUP 8 0 -16 ; _ENV "os"
29 [12] GETTABLE 8 8 -17 ; "time"
30 [12] CALL 8 1 2
31 [12] SETTABUP 0 -15 8 ; _ENV "t1"
32 [13] LOADK 8 -18 ; 0
33 [13] SUBII 9 -3 -2
34 [13] LOADK 10 -2 ; 1
35 [13] FORPREP 8 58 ; to 94
36 [14] MULFI 12 -5 -12
37 [14] DIVFI 12 -13 -3
38 [14] SUBFI 12 -13 -2
39 [15] LOADK 13 -18 ; 0
40 [15] SUBII 14 -2 -2
41 [15] LOADK 15 -19 ; 8
42 [15] FORPREP 13 50 ; to 93
43 [16] LOADK 17 -18 ; 0
44 [17] ADDIN 18 -17 7
45 [18] LOADNIL 19 0
46 [18] LOADIZ 19
47 [19] LT 0 18 1
48 [19] JMP 0 2 ; to 51
49 [20] MOVEI 19 18
50 [20] JMP 0 1 ; to 52
51 [22] SUBII 19 -2 -2
52 [24] MOVE 20 16
53 [24] MOVE 21 19
54 [24] LOADK 22 -2 ; 1
55 [24] FORPREP 20 24 ; to 80
56 [25] ADDII 17 -18 -18
57 [26] LOADK 24 -21 ; 0.0
58 [26] LOADK 25 -21 ; 0.0
59 [26] LOADK 26 -21 ; 0.0
60 [26] LOADK 27 -21 ; 0.0
61 [27] MULFI 28 -4 -24
62 [27] SUBFF 28 -29 -22
63 [28] LOADK 29 -2 ; 1
64 [28] MOVE 30 4
65 [28] LOADK 31 -2 ; 1
66 [28] FORPREP 29 12 ; to 79
67 [29] MULFF 33 -25 -26
68 [30] SUBFF 34 -27 -28
69 [30] ADDFF 24 -35 -29
70 [31] ADDFF 34 -34 -34
71 [31] ADDFF 25 -35 -13
72 [32] MULFF 26 -25 -25
73 [33] MULFF 27 -26 -26
74 [34] ADDFF 34 -27 -28
75 [34] LT 0 5 34
76 [34] JMP 0 2 ; to 79
77 [35] ADDIN 17 -18 1
78 [35] JMP 0 1 ; to 80
79 [28] FORLOOP 29 -13 ; to 67
80 [24] FORLOOP 20 -25 ; to 56
81 [40] LE 0 1 18
82 [40] JMP 0 7 ; to 90
83 [41] MOVE 20 1
84 [41] MOVE 21 18
85 [41] LOADK 22 -2 ; 1
86 [41] FORPREP 20 2 ; to 89
87 [41] ADDII 24 -18 -18
88 [41] ADDIN 17 -25 1
89 [41] FORLOOP 20 -3 ; to 87
90 [44] GETTABUP 20 0 -23 ; _ENV "print"
91 [44] MOVE 21 17
92 [44] CALL 20 2 1
93 [15] FORLOOP 13 -51 ; to 43
94 [13] FORLOOP 8 -59 ; to 36
95 [47] GETTABUP 8 0 -16 ; _ENV "os"
96 [47] GETTABLE 8 8 -17 ; "time"
97 [47] CALL 8 1 2
98 [47] SETTABUP 0 -24 8 ; _ENV "t2"
99 [48] GETTABUP 8 0 -23 ; _ENV "print"
100 [48] GETTABUP 9 0 -24 ; _ENV "t2"
101 [48] GETTABUP 10 0 -15 ; _ENV "t1"
102 [48] SUB 9 9 10
103 [48] CALL 8 2 1
104 [48] RETURN 0 1

@ -1,25 +0,0 @@
-- This is a copy of snippet from
-- calls.lua
local function rais(n, f)
--local x = n == 0 and error()
--rais(n-1)
print("called")
if n == 0 then f()
else rais(n-1, f)
end
print("normal exit")
end
ravi.dumplua(rais)
ravi.compile(rais)
function caller(n)
if n > 0 then
pcall(rais,n,error)
caller(n-1)
end
end
ravi.compile(caller)
caller(10)
print("OK")

@ -1,99 +0,0 @@
LUA=$1
if [ "$LUA" = "" ]
then
echo "Please pass path to Lua"
exit 1
fi
$LUA fornum_test1.lua
if [ $? != 0 ]
then
echo "fornum_test1 failed"
exit 1
fi
$LUA fornum_test2.ravi
if [ $? != 0 ]
then
echo "fornum_test2 failed"
exit 1
fi
$LUA mandel1.ravi
if [ $? != 0 ]
then
echo "mandel1 failed"
exit 1
fi
$LUA fannkuchen.ravi
if [ $? != 0 ]
then
echo "fannkuchen failed"
exit 1
fi
$LUA matmul1.ravi
if [ $? != 0 ]
then
echo "matmul1 failed"
exit 1
fi
$LUA basics.lua
if [ $? != 0 ]
then
echo "basics failed"
exit 1
fi
$LUA ravi_tests1.ravi
if [ $? != 0 ]
then
echo "ravi_tests1 failed"
exit 1
fi
$LUA fornum_test3.lua
if [ $? != 0 ]
then
echo "fornum_test3 failed"
exit 1
fi
$LUA bitwise_tests.lua
if [ $? != 0 ]
then
echo "bitwise failed"
exit 1
fi
$LUA ravi_errors.ravi
if [ $? != 0 ]
then
echo "ravi_errors failed"
exit 1
fi
$LUA -e"ravi.auto(true,1)" ravi_errors.ravi
if [ $? != 0 ]
then
echo "ravi_errors failed"
exit 1
fi
echo "======================================="
$LUA gaussian2.lua
if [ $? != 0 ]
then
echo "gaussian2 failed"
exit 1
fi
$LUA -e"ravi.auto(true,1)" gaussian2.lua
if [ $? != 0 ]
then
echo "gaussian2 failed"
exit 1
fi

@ -0,0 +1,34 @@
This folder contains various performance and unit tests.
Language tests
--------------
* language/basics.lua - some simple tests
* language/ravi_tests1.ravi - contains most of the Ravi specific tests
* language/ravi_tests3.ravi - additional tests
* language/ravi_errors.ravi - contains tests for error conditions
* language/bitwise_tests.lua - modified Lua 5.3 tests to exercise JIT on bitwise operations
Performance tests
-----------------
Following are simple loop tests:
* performance/fornum_test1.lua
* performance/fornum_test2.lua
* performance/fornum_test2.ravi - with optional types
* performance/fornum_test3.lua
Matrix multiplication test:
* performance/matmul1.lua - matrix multiplication (Lua compatible)
* performance/matmul1.ravi - matrix multiplication (ravi version with static typing)
* performance/matmul1_ravi.lua - matrix multiplication (ravi version with static typing)
Following performance tests were obtained from the `The Computer Programming Language Benchmarks Game <http://benchmarksgame.alioth.debian.org/>`_. Original author is `Mike Pall <http://luajit.org/>`_.
* performance/fannkuchen.lua
* performance/fannkuchen.ravi - with optional types
* performance/mandel1.ravi - modified so that it can be JIT compiled
* performance/mandel1.lua - can be JIT compiled but also compatible with Lua
See ``run_tests.sh`` for how to run these tests.

Some files were not shown because too many files have changed in this diff Show More

Loading…
Cancel
Save