diff options
-rw-r--r-- | CHANGES | 4 | ||||
-rw-r--r-- | Makefile | 6 | ||||
-rw-r--r-- | tests/appendud.lua | 6 | ||||
-rw-r--r-- | tests/errhangtest.lua | 13 | ||||
-rw-r--r-- | tests/irayo_closure.lua | 10 |
5 files changed, 31 insertions, 8 deletions
@@ -3,6 +3,10 @@ CHANGES: | |||
3 | 3 | ||
4 | CHANGE X: | 4 | CHANGE X: |
5 | 5 | ||
6 | CHANGE 26 BGe 14-Feb-2011: | ||
7 | Fixed application hang-up because keeper state was not released in case of errors thrown by | ||
8 | inter-state data copy for unsupported types | ||
9 | |||
6 | CHANGE 25 BGe 12-Feb-2011: | 10 | CHANGE 25 BGe 12-Feb-2011: |
7 | Changed idfunc signature and contract to clarify that fact it is not lua-callable | 11 | Changed idfunc signature and contract to clarify that fact it is not lua-callable |
8 | and to be able to require the module it was exported from in the target lanes | 12 | and to be able to require the module it was exported from in the target lanes |
@@ -71,8 +71,9 @@ rock: | |||
71 | #--- Testing --- | 71 | #--- Testing --- |
72 | # | 72 | # |
73 | test: | 73 | test: |
74 | $(MAKE) errhangtest | ||
74 | $(MAKE) irayo_recursive | 75 | $(MAKE) irayo_recursive |
75 | # $(MAKE) irayo_closure | 76 | $(MAKE) irayo_closure |
76 | $(MAKE) basic | 77 | $(MAKE) basic |
77 | $(MAKE) fifo | 78 | $(MAKE) fifo |
78 | $(MAKE) keeper | 79 | $(MAKE) keeper |
@@ -141,6 +142,9 @@ irayo_closure: tests/irayo_closure.lua $(_TARGET_SO) | |||
141 | finalizer: tests/finalizer.lua $(_TARGET_SO) | 142 | finalizer: tests/finalizer.lua $(_TARGET_SO) |
142 | $(_PREFIX) $(LUA) $< | 143 | $(_PREFIX) $(LUA) $< |
143 | 144 | ||
145 | errhangtest: tests/errhangtest.lua $(_TARGET_SO) | ||
146 | $(_PREFIX) $(LUA) $< | ||
147 | |||
144 | error-test: tests/error.lua $(_TARGET_SO) | 148 | error-test: tests/error.lua $(_TARGET_SO) |
145 | $(_PREFIX) $(LUA) $< | 149 | $(_PREFIX) $(LUA) $< |
146 | 150 | ||
diff --git a/tests/appendud.lua b/tests/appendud.lua index afea0e9..65d0798 100644 --- a/tests/appendud.lua +++ b/tests/appendud.lua | |||
@@ -31,18 +31,18 @@ local _ud = { | |||
31 | 31 | ||
32 | 32 | ||
33 | function appendud(tab, ud) | 33 | function appendud(tab, ud) |
34 | io.stderr:write "Starting" | 34 | io.stderr:write "Starting" |
35 | tab:beginupdate() set_finalizer( function() tab:endupdate() end ) | 35 | tab:beginupdate() set_finalizer( function() tab:endupdate() end ) |
36 | ud:lock() set_finalizer( function() ud:unlock() end ) | 36 | ud:lock() set_finalizer( function() ud:unlock() end ) |
37 | for i = 1,#ud do | 37 | for i = 1,#ud do |
38 | tab[#tab+1] = ud[i] | 38 | tab[#tab+1] = ud[i] |
39 | end | 39 | end |
40 | io.stderr:write "Ending" | 40 | io.stderr:write "Ending" |
41 | return tab -- need to return 'tab' since we're running in a separate thread | 41 | return tab -- need to return 'tab' since we're running in a separate thread |
42 | -- ('tab' is passed over lanes by value, not by reference) | 42 | -- ('tab' is passed over lanes by value, not by reference) |
43 | end | 43 | end |
44 | 44 | ||
45 | local t,err= lanes.gen( appendud )( _tab, _ud ) -- create & launch a thread | 45 | local t,err= lanes.gen( "io", appendud )( _tab, _ud ) -- create & launch a thread |
46 | assert(t) | 46 | assert(t) |
47 | assert(not err) | 47 | assert(not err) |
48 | 48 | ||
diff --git a/tests/errhangtest.lua b/tests/errhangtest.lua new file mode 100644 index 0000000..ddc1bfb --- /dev/null +++ b/tests/errhangtest.lua | |||
@@ -0,0 +1,13 @@ | |||
1 | lanes = require('lanes') | ||
2 | |||
3 | local linda = lanes.linda() | ||
4 | |||
5 | local coro = coroutine.create(function() end) | ||
6 | |||
7 | -- we are not allowed to send coroutines through a lanes | ||
8 | -- however, this should raise an error, not hang the program... | ||
9 | print( pcall(linda.send,linda, 'test', "oh boy")) | ||
10 | print( pcall(linda.send,linda, 'test', coro)) | ||
11 | res = linda:receive('test') | ||
12 | print( res) | ||
13 | -- linda:send( 'test', coro) | ||
diff --git a/tests/irayo_closure.lua b/tests/irayo_closure.lua index faf08fd..3a82302 100644 --- a/tests/irayo_closure.lua +++ b/tests/irayo_closure.lua | |||
@@ -20,11 +20,13 @@ local function testrun() | |||
20 | return true | 20 | return true |
21 | end | 21 | end |
22 | 22 | ||
23 | -- Should also work without these lines, but currently doesn't (bug in Lanes, | 23 | -- When some function dereferences a global key, the asssociated global in the source state |
24 | -- a function thrown over isn't connected to receiving lane's globals) | 24 | -- isn't sent over the target lane |
25 | -- therefore, the necessary functions must either be pulled as upvalues (hence locals) | ||
26 | -- or the globals must exist in the target lanes because the modules have been required there | ||
25 | -- | 27 | -- |
26 | --local print=print | 28 | local print=print |
27 | --local assert=assert | 29 | local assert=assert |
28 | 30 | ||
29 | local function useclosurehere() | 31 | local function useclosurehere() |
30 | assert( print ) | 32 | assert( print ) |