aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/LuaSL
diff options
context:
space:
mode:
Diffstat (limited to '')
-rwxr-xr-xLuaSL/luaprocTest.sh14
-rw-r--r--LuaSL/testLua/luaprocTest0.lua39
-rw-r--r--LuaSL/testLua/luaprocTest1.lua41
-rw-r--r--LuaSL/testLua/luaprocTest2.lua80
4 files changed, 174 insertions, 0 deletions
diff --git a/LuaSL/luaprocTest.sh b/LuaSL/luaprocTest.sh
new file mode 100755
index 0000000..98f37f5
--- /dev/null
+++ b/LuaSL/luaprocTest.sh
@@ -0,0 +1,14 @@
1#! /bin/bash
2
3cd testLua
4
5LUA_SOPATH="../../libraries/luaproc/" lua luaprocTest0.lua
6
7time LUA_SOPATH="../../libraries/luaproc/" lua luaprocTest1.lua
8
9time LUA_SOPATH="../../libraries/luaproc/" luajit luaprocTest1.lua
10
11time LUA_SOPATH="../../libraries/luaproc/" lua luaprocTest2.lua
12
13time LUA_SOPATH="../../libraries/luaproc/" luajit luaprocTest2.lua
14
diff --git a/LuaSL/testLua/luaprocTest0.lua b/LuaSL/testLua/luaprocTest0.lua
new file mode 100644
index 0000000..5868d6f
--- /dev/null
+++ b/LuaSL/testLua/luaprocTest0.lua
@@ -0,0 +1,39 @@
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
29require "luaproc"
30
31luaproc.createworker()
32
33luaproc.newproc( [=[
34 luaproc.newchannel( "testchannel" )
35 luaproc.newproc( "luaproc.send( 'testchannel', 'luaproc is working fine!' )" )
36 luaproc.newproc( "print( luaproc.receive( 'testchannel' ))" )
37]=] )
38
39luaproc.exit()
diff --git a/LuaSL/testLua/luaprocTest1.lua b/LuaSL/testLua/luaprocTest1.lua
new file mode 100644
index 0000000..3fe4811
--- /dev/null
+++ b/LuaSL/testLua/luaprocTest1.lua
@@ -0,0 +1,41 @@
1require "luaproc"
2
3result, error_msg = luaproc.createworker()
4if not result then print(error_msg) end
5result, error_msg = luaproc.createworker()
6if not result then print(error_msg) end
7result, error_msg = luaproc.createworker()
8if not result then print(error_msg) end
9result, error_msg = luaproc.createworker()
10if not result then print(error_msg) end
11
12result, error_msg = luaproc.newproc( [=[
13
14 local count = 0
15
16-- Hmm, luajit 2 beta 9 crashes at about 8140, lua can go up to 50000 at least.
17 for i = 1, 8000 do
18 local channel = "channel" .. i
19-- local proc = 'print(luaproc.receive("channel' .. i .. '") .. " " .. ' .. i ..')'
20 local proc = 'luaproc.receive("' .. channel .. '")'
21
22-- print(channel .. "\n" .. proc)
23 result, error_msg = luaproc.newchannel(channel)
24 if not result then print(error_msg) end
25 result, error_msg = luaproc.newproc(proc)
26 if not result then print(error_msg) else count = count + 1 end
27 end
28
29 print("Started " .. count .. " Lua threads")
30
31 if 0 ~= count then
32 for i = 1, count do
33 result, error_msg = luaproc.send("channel" .. i, 'luaproc is working fine! ' .. i)
34 if not result then print(error_msg .. " " .. i) end
35 end
36 end
37]=] )
38if not result then print(error_msg .. " for main proc") end
39
40luaproc.exit()
41
diff --git a/LuaSL/testLua/luaprocTest2.lua b/LuaSL/testLua/luaprocTest2.lua
new file mode 100644
index 0000000..7814e42
--- /dev/null
+++ b/LuaSL/testLua/luaprocTest2.lua
@@ -0,0 +1,80 @@
1require "luaproc"
2
3result, error_msg = luaproc.createworker()
4if not result then print(error_msg) end
5result, error_msg = luaproc.createworker()
6if not result then print(error_msg) end
7result, error_msg = luaproc.createworker()
8if not result then print(error_msg) end
9result, error_msg = luaproc.createworker()
10if not result then print(error_msg) end
11
12count = 0
13
14for i = 1, 10 do
15 local proc = [=[
16 require "string"
17 local channel = "channel%d"
18 local message
19
20 result, error_msg = luaproc.newchannel(channel)
21 if not result then print(error_msg) end
22 repeat
23 message = luaproc.receive(channel)
24 local x, y = string.find(message, "@")
25 if not x then
26 x, y = string.find(message, "@")
27 x, y = string.find(message, "@")
28 x, y = string.find(message, "@")
29 x, y = string.find(message, "@")
30 x, y = string.find(message, "@")
31 x, y = string.find(message, "@")
32 x, y = string.find(message, "@")
33 x, y = string.find(message, "@")
34 end
35 until "quit" == message
36 ]=]
37
38 proc = string.format(proc, i)
39-- print(proc)
40 result, error_msg = luaproc.newproc(proc)
41 if not result then print(error_msg) else count = count + 1 end
42end
43
44print("Started " .. count .. " Lua threads.")
45
46mainProc = [=[
47 local count = %d
48 local messages = 0
49 local length = 0
50 local message = "This is a test message. 56789 12"
51
52 if 0 ~= count then
53 for k = 0, 16 do
54 for j = 0, 199 do
55 for i = 1, count do
56 result, error_msg = luaproc.send("channel" .. i, message)
57 if not result then print(error_msg .. " " .. i) else
58 messages = messages + 1
59 length = length + #message
60 end
61 end
62 end
63 message = message .. message
64 end
65
66 for i = 1, count do
67 result, error_msg = luaproc.send("channel" .. i, "quit")
68 if not result then print(error_msg .. " " .. i) end
69 end
70 end
71
72 print("Sent " .. messages .. " messages totalling " .. length .. " bytes. The largest message was " .. #message .. " bytes.")
73]=]
74
75mainProc = string.format(mainProc, count)
76result, error_msg = luaproc.newproc(mainProc)
77if not result then print(error_msg) end
78
79luaproc.exit()
80