diff options
| author | Benoit Germain <benoit.germain@ubisoft.com> | 2024-04-16 18:06:02 +0200 |
|---|---|---|
| committer | Benoit Germain <benoit.germain@ubisoft.com> | 2024-04-16 18:06:02 +0200 |
| commit | bbb4f99918d00308b52af3289c29624bfeb0066b (patch) | |
| tree | aebfba19ae4bb2bddc2beaa18f80a64d254b4ae6 /tests | |
| parent | d6f5a7795360e3c2a6fc2d424904b6daa1f2accd (diff) | |
| download | lanes-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.lua | 42 | ||||
| -rw-r--r-- | tests/cancel.lua | 22 | ||||
| -rw-r--r-- | tests/linda_perf.lua | 14 |
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 ) |
| 64 | end | 64 | end |
| 65 | 65 | ||
| 66 | --############################################################## | 66 | -- ################################################################################################## |
| 67 | --############################################################## | 67 | -- ################################################################################################## |
| 68 | --############################################################## | 68 | -- ################################################################################################## |
| 69 | 69 | ||
| 70 | PRINT( "\n\n", "---=== Tasking (basic) ===---", "\n\n") | 70 | PRINT( "\n\n", "---=== Tasking (basic) ===---", "\n\n") |
| 71 | 71 | ||
| @@ -112,9 +112,9 @@ assert( lane1.status == "done" ) | |||
| 112 | lane1, lane2 = nil | 112 | lane1, lane2 = nil |
| 113 | collectgarbage() | 113 | collectgarbage() |
| 114 | 114 | ||
| 115 | --############################################################## | 115 | -- ################################################################################################## |
| 116 | --############################################################## | 116 | -- ################################################################################################## |
| 117 | --############################################################## | 117 | -- ################################################################################################## |
| 118 | 118 | ||
| 119 | PRINT( "\n\n", "---=== Tasking (cancelling) ===---", "\n\n") | 119 | PRINT( "\n\n", "---=== Tasking (cancelling) ===---", "\n\n") |
| 120 | 120 | ||
| @@ -201,9 +201,9 @@ repeat until wait_receive_batched_lane.status == "cancelled" | |||
| 201 | print "wait_receive_batched_lane is cancelled" | 201 | print "wait_receive_batched_lane is cancelled" |
| 202 | --################################################]] | 202 | --################################################]] |
| 203 | 203 | ||
| 204 | --############################################################## | 204 | -- ################################################################################################## |
| 205 | --############################################################## | 205 | -- ################################################################################################## |
| 206 | --############################################################## | 206 | -- ################################################################################################## |
| 207 | 207 | ||
| 208 | PRINT( "\n\n", "---=== Communications ===---", "\n\n") | 208 | PRINT( "\n\n", "---=== Communications ===---", "\n\n") |
| 209 | 209 | ||
| @@ -285,9 +285,9 @@ collectgarbage() | |||
| 285 | WR("waiting 1s") | 285 | WR("waiting 1s") |
| 286 | linda:receive( 1, "wait") | 286 | linda:receive( 1, "wait") |
| 287 | 287 | ||
| 288 | --############################################################## | 288 | -- ################################################################################################## |
| 289 | --############################################################## | 289 | -- ################################################################################################## |
| 290 | --############################################################## | 290 | -- ################################################################################################## |
| 291 | 291 | ||
| 292 | PRINT( "\n\n", "---=== Stdlib naming ===---", "\n\n") | 292 | PRINT( "\n\n", "---=== Stdlib naming ===---", "\n\n") |
| 293 | 293 | ||
| @@ -341,9 +341,9 @@ end | |||
| 341 | WR("collectgarbage") | 341 | WR("collectgarbage") |
| 342 | collectgarbage() | 342 | collectgarbage() |
| 343 | 343 | ||
| 344 | --############################################################## | 344 | -- ################################################################################################## |
| 345 | --############################################################## | 345 | -- ################################################################################################## |
| 346 | --############################################################## | 346 | -- ################################################################################################## |
| 347 | 347 | ||
| 348 | PRINT( "\n\n", "---=== Comms criss cross ===---", "\n\n") | 348 | PRINT( "\n\n", "---=== Comms criss cross ===---", "\n\n") |
| 349 | 349 | ||
| @@ -374,9 +374,9 @@ WR("collectgarbage") | |||
| 374 | a, b = nil | 374 | a, b = nil |
| 375 | collectgarbage() | 375 | collectgarbage() |
| 376 | 376 | ||
| 377 | --############################################################## | 377 | -- ################################################################################################## |
| 378 | --############################################################## | 378 | -- ################################################################################################## |
| 379 | --############################################################## | 379 | -- ################################################################################################## |
| 380 | 380 | ||
| 381 | PRINT( "\n\n", "---=== Receive & send of code ===---", "\n\n") | 381 | PRINT( "\n\n", "---=== Receive & send of code ===---", "\n\n") |
| 382 | 382 | ||
| @@ -436,9 +436,9 @@ assert( s2==":)" ) | |||
| 436 | local k,ok2= linda:receive( "up" ) | 436 | local k,ok2= linda:receive( "up" ) |
| 437 | assert( ok2 == "ok2" ) | 437 | assert( ok2 == "ok2" ) |
| 438 | 438 | ||
| 439 | --############################################################## | 439 | -- ################################################################################################## |
| 440 | --############################################################## | 440 | -- ################################################################################################## |
| 441 | --############################################################## | 441 | -- ################################################################################################## |
| 442 | 442 | ||
| 443 | PRINT( "\n\n", "---=== :join test ===---", "\n\n") | 443 | PRINT( "\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 |
| 6 | end | 6 | end |
| 7 | 7 | ||
| 8 | --#################################################################### | 8 | -- ################################################################################################## |
| 9 | 9 | ||
| 10 | local lanes = require "lanes" .configure{ with_timers = false} | 10 | local 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 |
| 14 | linda:set( "val", 33.0) | 14 | linda:set( "val", 33.0) |
| 15 | 15 | ||
| 16 | --#################################################################### | 16 | -- ################################################################################################## |
| 17 | |||
| 17 | if not next(which_tests) or which_tests.genlock then | 18 | if 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" |
| 44 | end | 45 | end |
| 45 | --#################################################################### | 46 | |
| 47 | -- ################################################################################################## | ||
| 46 | 48 | ||
| 47 | local waitCancellation = function( h, expected_status) | 49 | local 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 |
| 128 | end | 130 | end |
| 129 | 131 | ||
| 130 | --#################################################################### | 132 | -- ################################################################################################## |
| 131 | --#################################################################### | 133 | -- ################################################################################################## |
| 132 | 134 | ||
| 133 | if not next(which_tests) or which_tests.linda then | 135 | if 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") |
| 150 | end | 152 | end |
| 151 | 153 | ||
| 154 | -- ################################################################################################## | ||
| 155 | |||
| 152 | if not next(which_tests) or which_tests.soft then | 156 | if 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") |
| 172 | end | 176 | end |
| 173 | 177 | ||
| 178 | -- ################################################################################################## | ||
| 179 | |||
| 174 | if not next(which_tests) or which_tests.hook then | 180 | if 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") |
| 187 | end | 193 | end |
| 188 | 194 | ||
| 195 | -- ################################################################################################## | ||
| 196 | |||
| 189 | if not next(which_tests) or which_tests.hard then | 197 | if 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") |
| 204 | end | 212 | end |
| 205 | 213 | ||
| 214 | -- ################################################################################################## | ||
| 215 | |||
| 206 | if not next(which_tests) or which_tests.hard_unprotected then | 216 | if 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") |
| 221 | end | 231 | end |
| 222 | 232 | ||
| 223 | --#################################################################### | 233 | -- ################################################################################################## |
| 224 | 234 | ||
| 225 | local unknown_test, val = next(remaining_tests) | 235 | local unknown_test, val = next(remaining_tests) |
| 226 | assert(not unknown_test, tostring(unknown_test) .. " test is unknown") | 236 | assert(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 |
| 18 | end | 18 | end |
| 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 |
| 23 | local eater = function( l, loop) | 23 | local eater = function( l, loop) |
| @@ -34,7 +34,7 @@ local eater = function( l, loop) | |||
| 34 | print("eater: done ("..val..")") | 34 | print("eater: done ("..val..")") |
| 35 | end | 35 | end |
| 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 |
| 40 | local gobbler = function( l, loop, batch) | 40 | local 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..")") |
| 52 | end | 52 | end |
| 53 | 53 | ||
| 54 | --################################################################################################## | 54 | -- ################################################################################################# |
| 55 | 55 | ||
| 56 | local lane_eater_gen = lanes.gen( "*", {priority = 3}, eater) | 56 | local lane_eater_gen = lanes.gen( "*", {priority = 3}, eater) |
| 57 | local lane_gobbler_gen = lanes.gen( "*", {priority = 3}, gobbler) | 57 | local 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 |
| 62 | local function ziva( preloop, loop, batch) | 62 | local 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 |
| 103 | end | 103 | end |
| 104 | 104 | ||
| 105 | --################################################################################################## | 105 | -- ################################################################################################# |
| 106 | 106 | ||
| 107 | TEST1 = TEST1 or 1000 | 107 | TEST1 = TEST1 or 1000 |
| 108 | PREFILL1 = PREFILL1 or 10000 | 108 | PREFILL1 = 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") |
| 131 | end | 131 | end |
| 132 | 132 | ||
| 133 | --################################################################################################## | 133 | -- ################################################################################################# |
| 134 | 134 | ||
| 135 | -- sequential write/read (no parallelization involved) | 135 | -- sequential write/read (no parallelization involved) |
| 136 | local function ziva2( preloop, loop, batch) | 136 | local 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 |
| 179 | end | 179 | end |
| 180 | 180 | ||
| 181 | --################################################################################################## | 181 | -- ################################################################################################# |
| 182 | 182 | ||
| 183 | TEST2 = TEST2 or 1000 | 183 | TEST2 = TEST2 or 1000 |
| 184 | PREFILL2 = PREFILL2 or 0 | 184 | PREFILL2 = PREFILL2 or 0 |
