aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorBenoit Germain <benoit.germain@ubisoft.com>2024-04-16 18:06:02 +0200
committerBenoit Germain <benoit.germain@ubisoft.com>2024-04-16 18:06:02 +0200
commitbbb4f99918d00308b52af3289c29624bfeb0066b (patch)
treeaebfba19ae4bb2bddc2beaa18f80a64d254b4ae6 /tests
parentd6f5a7795360e3c2a6fc2d424904b6daa1f2accd (diff)
downloadlanes-bbb4f99918d00308b52af3289c29624bfeb0066b.tar.gz
lanes-bbb4f99918d00308b52af3289c29624bfeb0066b.tar.bz2
lanes-bbb4f99918d00308b52af3289c29624bfeb0066b.zip
some dead code elimination and other trifles
Diffstat (limited to 'tests')
-rw-r--r--tests/basic.lua42
-rw-r--r--tests/cancel.lua22
-rw-r--r--tests/linda_perf.lua14
3 files changed, 44 insertions, 34 deletions
diff --git a/tests/basic.lua b/tests/basic.lua
index 4b4fae6..1cf37e6 100644
--- a/tests/basic.lua
+++ b/tests/basic.lua
@@ -63,9 +63,9 @@ tables_match= function( a, b )
63 return subtable( a, b ) and subtable( b, a ) 63 return subtable( a, b ) and subtable( b, a )
64end 64end
65 65
66--############################################################## 66-- ##################################################################################################
67--############################################################## 67-- ##################################################################################################
68--############################################################## 68-- ##################################################################################################
69 69
70PRINT( "\n\n", "---=== Tasking (basic) ===---", "\n\n") 70PRINT( "\n\n", "---=== Tasking (basic) ===---", "\n\n")
71 71
@@ -112,9 +112,9 @@ assert( lane1.status == "done" )
112lane1, lane2 = nil 112lane1, lane2 = nil
113collectgarbage() 113collectgarbage()
114 114
115--############################################################## 115-- ##################################################################################################
116--############################################################## 116-- ##################################################################################################
117--############################################################## 117-- ##################################################################################################
118 118
119PRINT( "\n\n", "---=== Tasking (cancelling) ===---", "\n\n") 119PRINT( "\n\n", "---=== Tasking (cancelling) ===---", "\n\n")
120 120
@@ -201,9 +201,9 @@ repeat until wait_receive_batched_lane.status == "cancelled"
201print "wait_receive_batched_lane is cancelled" 201print "wait_receive_batched_lane is cancelled"
202--################################################]] 202--################################################]]
203 203
204--############################################################## 204-- ##################################################################################################
205--############################################################## 205-- ##################################################################################################
206--############################################################## 206-- ##################################################################################################
207 207
208PRINT( "\n\n", "---=== Communications ===---", "\n\n") 208PRINT( "\n\n", "---=== Communications ===---", "\n\n")
209 209
@@ -285,9 +285,9 @@ collectgarbage()
285WR("waiting 1s") 285WR("waiting 1s")
286linda:receive( 1, "wait") 286linda:receive( 1, "wait")
287 287
288--############################################################## 288-- ##################################################################################################
289--############################################################## 289-- ##################################################################################################
290--############################################################## 290-- ##################################################################################################
291 291
292PRINT( "\n\n", "---=== Stdlib naming ===---", "\n\n") 292PRINT( "\n\n", "---=== Stdlib naming ===---", "\n\n")
293 293
@@ -341,9 +341,9 @@ end
341WR("collectgarbage") 341WR("collectgarbage")
342collectgarbage() 342collectgarbage()
343 343
344--############################################################## 344-- ##################################################################################################
345--############################################################## 345-- ##################################################################################################
346--############################################################## 346-- ##################################################################################################
347 347
348PRINT( "\n\n", "---=== Comms criss cross ===---", "\n\n") 348PRINT( "\n\n", "---=== Comms criss cross ===---", "\n\n")
349 349
@@ -374,9 +374,9 @@ WR("collectgarbage")
374a, b = nil 374a, b = nil
375collectgarbage() 375collectgarbage()
376 376
377--############################################################## 377-- ##################################################################################################
378--############################################################## 378-- ##################################################################################################
379--############################################################## 379-- ##################################################################################################
380 380
381PRINT( "\n\n", "---=== Receive & send of code ===---", "\n\n") 381PRINT( "\n\n", "---=== Receive & send of code ===---", "\n\n")
382 382
@@ -436,9 +436,9 @@ assert( s2==":)" )
436local k,ok2= linda:receive( "up" ) 436local k,ok2= linda:receive( "up" )
437assert( ok2 == "ok2" ) 437assert( ok2 == "ok2" )
438 438
439--############################################################## 439-- ##################################################################################################
440--############################################################## 440-- ##################################################################################################
441--############################################################## 441-- ##################################################################################################
442 442
443PRINT( "\n\n", "---=== :join test ===---", "\n\n") 443PRINT( "\n\n", "---=== :join test ===---", "\n\n")
444 444
diff --git a/tests/cancel.lua b/tests/cancel.lua
index c22103f..5bd569f 100644
--- a/tests/cancel.lua
+++ b/tests/cancel.lua
@@ -5,7 +5,7 @@ for k,v in ipairs{...} do
5 remaining_tests[v] = true 5 remaining_tests[v] = true
6end 6end
7 7
8--#################################################################### 8-- ##################################################################################################
9 9
10local lanes = require "lanes" .configure{ with_timers = false} 10local lanes = require "lanes" .configure{ with_timers = false}
11 11
@@ -13,7 +13,8 @@ local linda = lanes.linda()
13-- a numeric value to read 13-- a numeric value to read
14linda:set( "val", 33.0) 14linda:set( "val", 33.0)
15 15
16--#################################################################### 16-- ##################################################################################################
17
17if not next(which_tests) or which_tests.genlock then 18if not next(which_tests) or which_tests.genlock then
18 remaining_tests.genlock = nil 19 remaining_tests.genlock = nil
19 print "\n\n####################################################################\nbegin genlock & genatomic cancel test\n" 20 print "\n\n####################################################################\nbegin genlock & genatomic cancel test\n"
@@ -42,7 +43,8 @@ if not next(which_tests) or which_tests.genlock then
42 43
43 print "test OK" 44 print "test OK"
44end 45end
45--#################################################################### 46
47-- ##################################################################################################
46 48
47local waitCancellation = function( h, expected_status) 49local waitCancellation = function( h, expected_status)
48 local l = lanes.linda() 50 local l = lanes.linda()
@@ -127,8 +129,8 @@ local protectedBody = function( ...)
127 end 129 end
128end 130end
129 131
130--#################################################################### 132-- ##################################################################################################
131--#################################################################### 133-- ##################################################################################################
132 134
133if not next(which_tests) or which_tests.linda then 135if not next(which_tests) or which_tests.linda then
134 remaining_tests.linda = nil 136 remaining_tests.linda = nil
@@ -149,6 +151,8 @@ if not next(which_tests) or which_tests.linda then
149 linda:cancel( "none") 151 linda:cancel( "none")
150end 152end
151 153
154-- ##################################################################################################
155
152if not next(which_tests) or which_tests.soft then 156if not next(which_tests) or which_tests.soft then
153 remaining_tests.soft = nil 157 remaining_tests.soft = nil
154 print "\n\n####################################################################\nbegin soft cancel test\n" 158 print "\n\n####################################################################\nbegin soft cancel test\n"
@@ -171,6 +175,8 @@ if not next(which_tests) or which_tests.soft then
171 waitCancellation( h, "done") 175 waitCancellation( h, "done")
172end 176end
173 177
178-- ##################################################################################################
179
174if not next(which_tests) or which_tests.hook then 180if not next(which_tests) or which_tests.hook then
175 remaining_tests.hook = nil 181 remaining_tests.hook = nil
176 print "\n\n####################################################################\nbegin hook cancel test\n" 182 print "\n\n####################################################################\nbegin hook cancel test\n"
@@ -186,6 +192,8 @@ if not next(which_tests) or which_tests.hook then
186 waitCancellation( h, "cancelled") 192 waitCancellation( h, "cancelled")
187end 193end
188 194
195-- ##################################################################################################
196
189if not next(which_tests) or which_tests.hard then 197if not next(which_tests) or which_tests.hard then
190 remaining_tests.hard = nil 198 remaining_tests.hard = nil
191 print "\n\n####################################################################\nbegin hard cancel test\n" 199 print "\n\n####################################################################\nbegin hard cancel test\n"
@@ -203,6 +211,8 @@ if not next(which_tests) or which_tests.hard then
203 waitCancellation( h, "cancelled") 211 waitCancellation( h, "cancelled")
204end 212end
205 213
214-- ##################################################################################################
215
206if not next(which_tests) or which_tests.hard_unprotected then 216if not next(which_tests) or which_tests.hard_unprotected then
207 remaining_tests.hard_unprotected = nil 217 remaining_tests.hard_unprotected = nil
208 print "\n\n####################################################################\nbegin hard cancel test with unprotected lane body\n" 218 print "\n\n####################################################################\nbegin hard cancel test with unprotected lane body\n"
@@ -220,7 +230,7 @@ if not next(which_tests) or which_tests.hard_unprotected then
220 waitCancellation( h, "cancelled") 230 waitCancellation( h, "cancelled")
221end 231end
222 232
223--#################################################################### 233-- ##################################################################################################
224 234
225local unknown_test, val = next(remaining_tests) 235local unknown_test, val = next(remaining_tests)
226assert(not unknown_test, tostring(unknown_test) .. " test is unknown") 236assert(not unknown_test, tostring(unknown_test) .. " test is unknown")
diff --git a/tests/linda_perf.lua b/tests/linda_perf.lua
index 61b8f05..6b79c1f 100644
--- a/tests/linda_perf.lua
+++ b/tests/linda_perf.lua
@@ -17,7 +17,7 @@ local finalizer = function(err, stk)
17 end 17 end
18end 18end
19 19
20--################################################################################################## 20-- #################################################################################################
21 21
22-- this lane eats items in the linda one by one 22-- this lane eats items in the linda one by one
23local eater = function( l, loop) 23local eater = function( l, loop)
@@ -34,7 +34,7 @@ local eater = function( l, loop)
34 print("eater: done ("..val..")") 34 print("eater: done ("..val..")")
35end 35end
36 36
37--################################################################################################## 37-- #################################################################################################
38 38
39-- this lane eats items in the linda in batches 39-- this lane eats items in the linda in batches
40local gobbler = function( l, loop, batch) 40local gobbler = function( l, loop, batch)
@@ -51,12 +51,12 @@ local gobbler = function( l, loop, batch)
51 print("gobbler: done ("..val..")") 51 print("gobbler: done ("..val..")")
52end 52end
53 53
54--################################################################################################## 54-- #################################################################################################
55 55
56local lane_eater_gen = lanes.gen( "*", {priority = 3}, eater) 56local lane_eater_gen = lanes.gen( "*", {priority = 3}, eater)
57local lane_gobbler_gen = lanes.gen( "*", {priority = 3}, gobbler) 57local lane_gobbler_gen = lanes.gen( "*", {priority = 3}, gobbler)
58 58
59--################################################################################################## 59-- #################################################################################################
60 60
61-- main thread writes data while a lane reads it 61-- main thread writes data while a lane reads it
62local function ziva( preloop, loop, batch) 62local function ziva( preloop, loop, batch)
@@ -102,7 +102,7 @@ local function ziva( preloop, loop, batch)
102 return lanes.now_secs() - t1 102 return lanes.now_secs() - t1
103end 103end
104 104
105--################################################################################################## 105-- #################################################################################################
106 106
107TEST1 = TEST1 or 1000 107TEST1 = TEST1 or 1000
108PREFILL1 = PREFILL1 or 10000 108PREFILL1 = PREFILL1 or 10000
@@ -130,7 +130,7 @@ for i, v in ipairs( tests1) do
130 print("DURATION = " .. ziva( pre, loop, batch) .. "\n") 130 print("DURATION = " .. ziva( pre, loop, batch) .. "\n")
131end 131end
132 132
133--################################################################################################## 133-- #################################################################################################
134 134
135-- sequential write/read (no parallelization involved) 135-- sequential write/read (no parallelization involved)
136local function ziva2( preloop, loop, batch) 136local function ziva2( preloop, loop, batch)
@@ -178,7 +178,7 @@ local function ziva2( preloop, loop, batch)
178 return lanes.now_secs() - t1 178 return lanes.now_secs() - t1
179end 179end
180 180
181--################################################################################################## 181-- #################################################################################################
182 182
183TEST2 = TEST2 or 1000 183TEST2 = TEST2 or 1000
184PREFILL2 = PREFILL2 or 0 184PREFILL2 = PREFILL2 or 0