aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/LuaSL/testLua
diff options
context:
space:
mode:
Diffstat (limited to 'LuaSL/testLua')
-rw-r--r--LuaSL/testLua/luaprocTest0.lua7
-rw-r--r--LuaSL/testLua/luaprocTest0_C.lua37
-rw-r--r--LuaSL/testLua/luaprocTest1_C.lua28
-rw-r--r--LuaSL/testLua/luaprocTest2_C.lua65
4 files changed, 136 insertions, 1 deletions
diff --git a/LuaSL/testLua/luaprocTest0.lua b/LuaSL/testLua/luaprocTest0.lua
index 5868d6f..94a1d20 100644
--- a/LuaSL/testLua/luaprocTest0.lua
+++ b/LuaSL/testLua/luaprocTest0.lua
@@ -33,7 +33,12 @@ luaproc.createworker()
33luaproc.newproc( [=[ 33luaproc.newproc( [=[
34 luaproc.newchannel( "testchannel" ) 34 luaproc.newchannel( "testchannel" )
35 luaproc.newproc( "luaproc.send( 'testchannel', 'luaproc is working fine!' )" ) 35 luaproc.newproc( "luaproc.send( 'testchannel', 'luaproc is working fine!' )" )
36 luaproc.newproc( "print( luaproc.receive( 'testchannel' ))" ) 36 luaproc.newproc( "print(luaproc.receive( 'testchannel'))" )
37 print("End of parent proc")
37]=] ) 38]=] )
38 39
40print("About to luaproc.exit()!");
39luaproc.exit() 41luaproc.exit()
42print("Should have exited after the luaproc.exit()!");
43
44
diff --git a/LuaSL/testLua/luaprocTest0_C.lua b/LuaSL/testLua/luaprocTest0_C.lua
new file mode 100644
index 0000000..0dd6078
--- /dev/null
+++ b/LuaSL/testLua/luaprocTest0_C.lua
@@ -0,0 +1,37 @@
1----------------------------------------------------
2--
3-- Copyright 2008 Alexandre Skyrme, Noemi Rodriguez, Roberto Ierusalimschy
4--
5-- Permission is hereby granted, free of charge, to any person obtaining a copy
6-- of this software and associated documentation files (the "Software"), to deal
7-- in the Software without restriction, including without limitation the rights
8-- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9-- copies of the Software, and to permit persons to whom the Software is
10-- furnished to do so, subject to the following conditions:
11--
12-- The above copyright notice and this permission notice shall be included in
13-- all copies or substantial portions of the Software.
14--
15-- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16-- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17-- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18-- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19-- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20-- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21-- THE SOFTWARE.
22--
23-----------------------------------------------------
24--
25-- test.lua
26--
27-----------------------------------------------------
28
29luaproc.newproc( [=[
30 luaproc.newchannel( "testchannel" )
31 luaproc.newproc( "luaproc.send( 'testchannel', 'luaproc is working fine!' )" )
32 luaproc.newproc( "print(luaproc.receive( 'testchannel'))" )
33 print("End of parent proc")
34]=] )
35
36print("About to exit.");
37
diff --git a/LuaSL/testLua/luaprocTest1_C.lua b/LuaSL/testLua/luaprocTest1_C.lua
new file mode 100644
index 0000000..61cb461
--- /dev/null
+++ b/LuaSL/testLua/luaprocTest1_C.lua
@@ -0,0 +1,28 @@
1result, error_msg = luaproc.newproc( [=[
2
3 local count = 0
4
5-- Hmm, luajit 2 beta 9 crashes at about 8140, lua can go up to 50000 at least.
6 for i = 1, 8000 do
7 local channel = "channel" .. i
8-- local proc = 'print(luaproc.receive("channel' .. i .. '") .. " " .. ' .. i ..')'
9 local proc = 'luaproc.receive("' .. channel .. '")'
10
11-- print(channel .. "\n" .. proc)
12 result, error_msg = luaproc.newchannel(channel)
13 if not result then print(error_msg) end
14 result, error_msg = luaproc.newproc(proc)
15 if not result then print(error_msg) else count = count + 1 end
16 end
17
18 print("Started " .. count .. " Lua threads")
19
20 if 0 ~= count then
21 for i = 1, count do
22 result, error_msg = luaproc.send("channel" .. i, 'luaproc is working fine! ' .. i)
23 if not result then print(error_msg .. " " .. i) end
24 end
25 end
26]=] )
27if not result then print(error_msg .. " for main proc") end
28
diff --git a/LuaSL/testLua/luaprocTest2_C.lua b/LuaSL/testLua/luaprocTest2_C.lua
new file mode 100644
index 0000000..e1a5a83
--- /dev/null
+++ b/LuaSL/testLua/luaprocTest2_C.lua
@@ -0,0 +1,65 @@
1count = 0
2
3proc = [=[
4 require "string"
5 local channel = "channel%d"
6 local message
7
8 result, error_msg = luaproc.newchannel(channel)
9 if not result then print(error_msg) end
10 repeat
11 message = luaproc.receive(channel)
12 local x, y = string.find(message, "@")
13 if not x then
14 x, y = string.find(message, "@")
15 x, y = string.find(message, "@")
16 x, y = string.find(message, "@")
17 x, y = string.find(message, "@")
18 x, y = string.find(message, "@")
19 x, y = string.find(message, "@")
20 x, y = string.find(message, "@")
21 x, y = string.find(message, "@")
22 end
23 until "quit" == message
24]=]
25
26mainProc = [=[
27 local count = %d
28 local messages = 0
29 local length = 0
30 local message = "This is a test message. 56789 12"
31
32 if 0 ~= count then
33 for k = 0, 16 do
34 for j = 0, 199 do
35 for i = 1, count do
36 result, error_msg = luaproc.send("channel" .. i, message)
37 if not result then print(error_msg .. " " .. i) else
38 messages = messages + 1
39 length = length + #message
40 end
41 end
42 end
43 message = message .. message
44 end
45
46 for i = 1, count do
47 result, error_msg = luaproc.send("channel" .. i, "quit")
48 if not result then print(error_msg .. " " .. i) end
49 end
50 end
51
52 print("Sent " .. messages .. " messages totalling " .. length .. " bytes. The largest message was " .. #message .. " bytes.")
53]=]
54
55for i = 1, 10 do
56 result, error_msg = luaproc.newproc(string.format(proc, i))
57 if not result then print(error_msg) else count = count + 1 end
58end
59
60print("Started " .. count .. " Lua threads.")
61
62result, error_msg = luaproc.newproc(string.format(mainProc, count))
63if not result then print(error_msg) end
64
65