diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/appendud.lua | 2 | ||||
-rw-r--r-- | tests/basic.lua | 17 | ||||
-rw-r--r-- | tests/error.lua | 7 | ||||
-rw-r--r-- | tests/finalizer.lua | 4 | ||||
-rw-r--r-- | tests/func_is_string.lua | 13 | ||||
-rw-r--r-- | tests/irayo_closure.lua | 2 | ||||
-rw-r--r-- | tests/launchtest.lua | 4 | ||||
-rw-r--r-- | tests/linda_perf.lua | 7 | ||||
-rw-r--r-- | tests/perftest.lua | 4 | ||||
-rw-r--r-- | tests/pingpong.lua | 8 | ||||
-rw-r--r-- | tests/rupval.lua | 6 | ||||
-rw-r--r-- | tests/tobeclosed.lua | 5 |
12 files changed, 42 insertions, 37 deletions
diff --git a/tests/appendud.lua b/tests/appendud.lua index f6f99c1..2a8c8ce 100644 --- a/tests/appendud.lua +++ b/tests/appendud.lua | |||
@@ -49,7 +49,7 @@ assert(not err) | |||
49 | -- test | 49 | -- test |
50 | -- print("t:join()") | 50 | -- print("t:join()") |
51 | a,b,c = t[1],t[2],t[3] -- Need to explicitly wait for the thread, since 'ipairs()' does not | 51 | a,b,c = t[1],t[2],t[3] -- Need to explicitly wait for the thread, since 'ipairs()' does not |
52 | --a,b,c = t:join() -- Need to explicitly wait for the thread, since 'ipairs()' does not | 52 | --r,a,b,c = t:join() -- Need to explicitly wait for the thread, since 'ipairs()' does not |
53 | -- value the '__index' metamethod (wouldn't it be cool if it did..?) | 53 | -- value the '__index' metamethod (wouldn't it be cool if it did..?) |
54 | 54 | ||
55 | print(a,b,c) | 55 | print(a,b,c) |
diff --git a/tests/basic.lua b/tests/basic.lua index 9aaad97..f393175 100644 --- a/tests/basic.lua +++ b/tests/basic.lua | |||
@@ -507,19 +507,20 @@ local S = lanes.gen("table", { name = 'auto', gc_cb = gc_cb }, | |||
507 | return (unpack or table.unpack)(aux) | 507 | return (unpack or table.unpack)(aux) |
508 | end) | 508 | end) |
509 | 509 | ||
510 | h= S { 12, 13, 14 } -- execution starts, h[1..3] will get the return values | 510 | h = S { 12, 13, 14 } -- execution starts, h[1..3] will get the return values |
511 | -- wait a bit so that the lane has a chance to set its debug name | 511 | -- wait a bit so that the lane has a chance to set its debug name |
512 | SLEEP(0.5) | 512 | SLEEP(0.5) |
513 | print("joining with '" .. h:get_threadname() .. "'") | 513 | print("joining with '" .. h:get_threadname() .. "'") |
514 | local a,b,c,d= h:join() | 514 | local r,a,b,c,d= h:join() |
515 | if h.status == "error" then | 515 | if h.status == "error" then |
516 | print(h:get_threadname(), "error: " , a, b, c, d) | 516 | print(h:get_threadname(), "error: " , r, a, b, c, d) |
517 | else | 517 | else |
518 | print(h:get_threadname(), a,b,c,d) | 518 | print(h:get_threadname(), r,a,b,c,d) |
519 | assert(a==14) | 519 | assert(r == true) |
520 | assert(b==13) | 520 | assert(a == 14) |
521 | assert(c==12) | 521 | assert(b == 13) |
522 | assert(d==nil) | 522 | assert(c == 12) |
523 | assert(d == nil) | ||
523 | end | 524 | end |
524 | 525 | ||
525 | local nameof_type, nameof_name = lanes.nameof(print) | 526 | local nameof_type, nameof_name = lanes.nameof(print) |
diff --git a/tests/error.lua b/tests/error.lua index 28cfff1..76ceea4 100644 --- a/tests/error.lua +++ b/tests/error.lua | |||
@@ -173,8 +173,7 @@ local do_error_catching_test = function(error_reporting_mode_, error_value_, fin | |||
173 | local h = start_lane(error_reporting_mode_, error_value_, finalizer_, finalizer_error_value_) | 173 | local h = start_lane(error_reporting_mode_, error_value_, finalizer_, finalizer_error_value_) |
174 | local ret,err,stack= h:join() -- wait for the lane (no automatic error propagation) | 174 | local ret,err,stack= h:join() -- wait for the lane (no automatic error propagation) |
175 | WR("Processing results for {", error_reporting_mode_, error_value_, finalizer_, finalizer_error_value_, "}") | 175 | WR("Processing results for {", error_reporting_mode_, error_value_, finalizer_, finalizer_error_value_, "}") |
176 | if err then | 176 | if ret == nil then |
177 | assert(ret == nil) | ||
178 | assert(error_reporting_mode_ == "minimal" or type(stack)=="table") -- only true if lane was configured with error_trace_level ~= "minimal" | 177 | assert(error_reporting_mode_ == "minimal" or type(stack)=="table") -- only true if lane was configured with error_trace_level ~= "minimal" |
179 | if err == error_value_ then | 178 | if err == error_value_ then |
180 | WR("Lane regular error: ", err) | 179 | WR("Lane regular error: ", err) |
@@ -198,8 +197,8 @@ local do_error_catching_test = function(error_reporting_mode_, error_value_, fin | |||
198 | end | 197 | end |
199 | end | 198 | end |
200 | else -- no error | 199 | else -- no error |
201 | assert(ret == "success") | 200 | assert(ret == true and err == "success") |
202 | WR("No error in lane: ", ret) | 201 | WR("No error in lane: ", err, ret) |
203 | end | 202 | end |
204 | WR "TEST OK" | 203 | WR "TEST OK" |
205 | end | 204 | end |
diff --git a/tests/finalizer.lua b/tests/finalizer.lua index ac5ce8b..9fa12dc 100644 --- a/tests/finalizer.lua +++ b/tests/finalizer.lua | |||
@@ -77,8 +77,8 @@ local do_test = function(error_) | |||
77 | 77 | ||
78 | local h = lgen(error_) | 78 | local h = lgen(error_) |
79 | 79 | ||
80 | local _,err,stack = h:join() -- wait for the lane (no automatic error propagation) | 80 | local r,err,stack = h:join() -- wait for the lane (no automatic error propagation) |
81 | if err then | 81 | if not r then |
82 | assert(stack, "no stack trace on error, check 'error_trace_level'") | 82 | assert(stack, "no stack trace on error, check 'error_trace_level'") |
83 | io.stderr:write( "Lane error: "..tostring(err).."\n" ) | 83 | io.stderr:write( "Lane error: "..tostring(err).."\n" ) |
84 | io.stderr:write( "\t", table.concat(stack,"\t\n"), "\n" ) | 84 | io.stderr:write( "\t", table.concat(stack,"\t\n"), "\n" ) |
diff --git a/tests/func_is_string.lua b/tests/func_is_string.lua index 5de4c60..3c91603 100644 --- a/tests/func_is_string.lua +++ b/tests/func_is_string.lua | |||
@@ -21,16 +21,17 @@ end | |||
21 | 21 | ||
22 | local options = {globals = { b = 666 }} | 22 | local options = {globals = { b = 666 }} |
23 | 23 | ||
24 | local gen1 = lanes.gen("*", { name = 'auto' }, "return true, dofile('fibonacci.lua')") | 24 | local gen1 = lanes.gen("*", { name = 'auto' }, "return true, error('bob')") |
25 | local gen2 = lanes.gen(options, { name = 'auto' }, "return b") | ||
26 | 25 | ||
27 | fibLane = gen1() | 26 | fibLane = gen1() |
28 | lanes.sleep(0.1) | 27 | lanes.sleep(0.1) |
29 | print(fibLane, fibLane.status) | 28 | print(fibLane, fibLane.status) |
30 | local _status, _err = fibLane:join() | 29 | local _r, _err, _stk = fibLane:join() |
31 | print(_status, _err) | 30 | assert(_r == nil, "got " .. tostring(_r) .. " " .. tostring(_err) .. " " .. tostring(_stk)) |
32 | 31 | ||
33 | retLane1, retLane2 = gen2(), gen2() | 32 | local gen2 = lanes.gen(options, { name = 'auto' }, "return b") |
33 | local retLane1, retLane2 = gen2(), gen2() | ||
34 | 34 | ||
35 | print( retLane1[1], retLane2[1]) | 35 | print( retLane1[1], retLane2[1]) |
36 | print "TEST OK" \ No newline at end of file | 36 | assert(retLane1[1] == 666 and retLane2[1] == 666) |
37 | print "TEST OK" | ||
diff --git a/tests/irayo_closure.lua b/tests/irayo_closure.lua index 705b85e..40c586d 100644 --- a/tests/irayo_closure.lua +++ b/tests/irayo_closure.lua | |||
@@ -5,7 +5,7 @@ | |||
5 | "Another issue I've noticed is trying to pass a table with a function | 5 | "Another issue I've noticed is trying to pass a table with a function |
6 | that uses closures in it as a global variable into a new lane. This | 6 | that uses closures in it as a global variable into a new lane. This |
7 | causes a segmentation fault and it appears to be related to the | 7 | causes a segmentation fault and it appears to be related to the |
8 | luaG_inter_move function near line 835-836 or so in lanes.c, but I | 8 | luaW_inter_move function near line 835-836 or so in lanes.c, but I |
9 | haven't investigated further. | 9 | haven't investigated further. |
10 | e.g. { globals = { data = 1, func = function() useclosurehere() end } }" | 10 | e.g. { globals = { data = 1, func = function() useclosurehere() end } }" |
11 | ]] | 11 | ]] |
diff --git a/tests/launchtest.lua b/tests/launchtest.lua index 57411e1..cdd6ffc 100644 --- a/tests/launchtest.lua +++ b/tests/launchtest.lua | |||
@@ -69,8 +69,8 @@ else | |||
69 | io.stderr:write( N.." lanes launched.\n" ) | 69 | io.stderr:write( N.." lanes launched.\n" ) |
70 | 70 | ||
71 | for i=1,N do | 71 | for i=1,N do |
72 | local rc= t[i]:join() | 72 | local r,rc = t[i]:join() |
73 | assert( rc==i ) | 73 | assert( r == true and rc == i ) |
74 | end | 74 | end |
75 | 75 | ||
76 | io.stderr:write( N.." lanes finished.\n" ) | 76 | io.stderr:write( N.." lanes finished.\n" ) |
diff --git a/tests/linda_perf.lua b/tests/linda_perf.lua index 83b8921..e68d552 100644 --- a/tests/linda_perf.lua +++ b/tests/linda_perf.lua | |||
@@ -56,7 +56,7 @@ local eater = function( l, loop) | |||
56 | -- print "loop is over" | 56 | -- print "loop is over" |
57 | key, val = l:receive( "done") | 57 | key, val = l:receive( "done") |
58 | print("eater: done ("..val..")") | 58 | print("eater: done ("..val..")") |
59 | return true | 59 | return "ate everything" |
60 | end | 60 | end |
61 | 61 | ||
62 | -- ################################################################################################# | 62 | -- ################################################################################################# |
@@ -74,7 +74,7 @@ local gobbler = function( l, loop, batch) | |||
74 | print "loop is over" | 74 | print "loop is over" |
75 | key, val = l:receive( "done") | 75 | key, val = l:receive( "done") |
76 | print("gobbler: done ("..val..")") | 76 | print("gobbler: done ("..val..")") |
77 | return true | 77 | return "gobbled everything" |
78 | end | 78 | end |
79 | 79 | ||
80 | -- ################################################################################################# | 80 | -- ################################################################################################# |
@@ -123,7 +123,8 @@ local function ziva1( preloop, loop, batch) | |||
123 | end | 123 | end |
124 | end | 124 | end |
125 | l:send( "done" ,"are you happy?") | 125 | l:send( "done" ,"are you happy?") |
126 | lane:join() | 126 | local r, ret = lane:join() |
127 | assert(r == true and type(ret) == "string", "got " .. tostring(r) .. " " .. tostring(ret)) | ||
127 | return lanes.now_secs() - t1 | 128 | return lanes.now_secs() - t1 |
128 | end | 129 | end |
129 | 130 | ||
diff --git a/tests/perftest.lua b/tests/perftest.lua index fe43cca..35e164d 100644 --- a/tests/perftest.lua +++ b/tests/perftest.lua | |||
@@ -175,9 +175,9 @@ else | |||
175 | -- Make sure all lanes finished | 175 | -- Make sure all lanes finished |
176 | -- | 176 | -- |
177 | for i=1,N do | 177 | for i=1,N do |
178 | local tmp= t[i]:join() | 178 | local r, tmp = t[i]:join() |
179 | -- this assert will trigger if you change M to values below 1000 in order to solve C stack overflow | 179 | -- this assert will trigger if you change M to values below 1000 in order to solve C stack overflow |
180 | assert( type(tmp)=="table" and tmp[1]==2 and tmp[168]==997 ) | 180 | assert( r == true and type(tmp) == "table" and tmp[1] == 2 and tmp[168] == 997 ) |
181 | end | 181 | end |
182 | end | 182 | end |
183 | 183 | ||
diff --git a/tests/pingpong.lua b/tests/pingpong.lua index 06c0903..1ed5b9a 100644 --- a/tests/pingpong.lua +++ b/tests/pingpong.lua | |||
@@ -21,13 +21,15 @@ local pingpong = function(name, qr, qs, start) | |||
21 | q:send(qs, val) | 21 | q:send(qs, val) |
22 | count = count + 1 | 22 | count = count + 1 |
23 | end | 23 | end |
24 | return true | 24 | return "ping!" |
25 | end | 25 | end |
26 | 26 | ||
27 | -- pingpong("L1", '0', '1', true) | 27 | -- pingpong("L1", '0', '1', true) |
28 | local t1, err1 = lanes.gen("*", { name = 'auto' }, pingpong)("L1", 'a', 'b', true) | 28 | local t1, err1 = lanes.gen("*", { name = 'auto' }, pingpong)("L1", 'a', 'b', true) |
29 | local t2, err2 = lanes.gen("*", { name = 'auto' }, pingpong)("L2", 'b', 'a', false) | 29 | local t2, err2 = lanes.gen("*", { name = 'auto' }, pingpong)("L2", 'b', 'a', false) |
30 | 30 | ||
31 | t1:join() | 31 | local r1, ret1 = t1:join() |
32 | t2:join() | 32 | assert(r1 == true and ret1 == "ping!") |
33 | local r2, ret2 = t2:join() | ||
34 | assert(r2 == true and ret2 == "ping!") | ||
33 | print "TEST OK" | 35 | print "TEST OK" |
diff --git a/tests/rupval.lua b/tests/rupval.lua index ad5ad9d..c6743b3 100644 --- a/tests/rupval.lua +++ b/tests/rupval.lua | |||
@@ -26,17 +26,17 @@ end | |||
26 | local g = lanes.gen( "base", { name = 'auto' }, a) | 26 | local g = lanes.gen( "base", { name = 'auto' }, a) |
27 | 27 | ||
28 | local l = g(7) | 28 | local l = g(7) |
29 | local r = l:join() | 29 | local _, r = l:join() |
30 | assert(r == y) | 30 | assert(r == y) |
31 | print(r) | 31 | print(r) |
32 | 32 | ||
33 | local l = g(8) | 33 | local l = g(8) |
34 | local r = l:join() | 34 | local _, r = l:join() |
35 | assert(r == z) | 35 | assert(r == z) |
36 | print(r) | 36 | print(r) |
37 | 37 | ||
38 | local l = g(9) | 38 | local l = g(9) |
39 | local r = l:join() | 39 | local _, r = l:join() |
40 | assert(r == x) | 40 | assert(r == x) |
41 | print(r) | 41 | print(r) |
42 | 42 | ||
diff --git a/tests/tobeclosed.lua b/tests/tobeclosed.lua index 447b936..fd157e2 100644 --- a/tests/tobeclosed.lua +++ b/tests/tobeclosed.lua | |||
@@ -106,7 +106,7 @@ do | |||
106 | local _count, l_out <close> = l:get("trip") | 106 | local _count, l_out <close> = l:get("trip") |
107 | -- linda from arguments | 107 | -- linda from arguments |
108 | local l_arg <close> = l_arg_ | 108 | local l_arg <close> = l_arg_ |
109 | return true | 109 | return "done" |
110 | end | 110 | end |
111 | 111 | ||
112 | local close_handler_f = function(linda_, err_) | 112 | local close_handler_f = function(linda_, err_) |
@@ -118,7 +118,8 @@ do | |||
118 | l:set("trip", l_in) | 118 | l:set("trip", l_in) |
119 | 119 | ||
120 | do | 120 | do |
121 | lanes.gen("*", { name = 'auto' }, lane_body)(l_in):join() | 121 | local r, ret = lanes.gen("*", { name = 'auto' }, lane_body)(l_in):join() |
122 | assert(r == true and ret == "done") | ||
122 | end | 123 | end |
123 | local _count, _closed = l_in:get("closed") | 124 | local _count, _closed = l_in:get("closed") |
124 | assert(_count == 1 and _closed == 2) | 125 | assert(_count == 1 and _closed == 2) |