summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
Diffstat (limited to 'test')
-rwxr-xr-xtest/Makefile.am5
-rw-r--r--test/known_failures_Linux.json18
-rw-r--r--test/lua/Makefile.am30
-rw-r--r--test/lua/test_basic_client.lua53
-rw-r--r--test/lua/test_basic_server.lua1
-rw-r--r--test/tests.json26
6 files changed, 120 insertions, 13 deletions
diff --git a/test/Makefile.am b/test/Makefile.am
index 6db171f87..4abb0fd1b 100755
--- a/test/Makefile.am
+++ b/test/Makefile.am
@@ -75,6 +75,11 @@ SUBDIRS += erl
PRECROSS_TARGET += precross-erl
endif
+if WITH_LUA
+SUBDIRS += lua
+PRECROSS_TARGET += precross-lua
+endif
+
#
# generate html for ThriftTest.thrift
#
diff --git a/test/known_failures_Linux.json b/test/known_failures_Linux.json
index be9e945cf..220d03dfa 100644
--- a/test/known_failures_Linux.json
+++ b/test/known_failures_Linux.json
@@ -1,4 +1,5 @@
[
+ "c_glib-lua_binary_buffered-ip",
"cpp-cpp_binary_buffered-ip-ssl",
"cpp-cpp_binary_framed-ip-ssl",
"cpp-cpp_binary_http-domain",
@@ -32,6 +33,7 @@
"cpp-java_compact_http-ip-ssl",
"cpp-java_json_http-ip",
"cpp-java_json_http-ip-ssl",
+ "cpp-lua_binary_buffered-ip",
"cpp-perl_binary_buffered-ip-ssl",
"cpp-perl_binary_framed-ip-ssl",
"cpp-py_binary-accel_framed-ip-ssl",
@@ -52,6 +54,7 @@
"csharp-go_compact_framed-ip-ssl",
"csharp-go_json_buffered-ip-ssl",
"csharp-go_json_framed-ip-ssl",
+ "csharp-lua_binary_buffered-ip",
"csharp-nodejs_binary_buffered-ip-ssl",
"csharp-nodejs_binary_framed-ip-ssl",
"csharp-nodejs_compact_buffered-ip-ssl",
@@ -78,6 +81,7 @@
"erl-cpp_compact_buffered-ip-ssl",
"erl-cpp_compact_framed-ip",
"erl-cpp_compact_framed-ip-ssl",
+ "erl-lua_binary_buffered-ip",
"erl-nodejs_binary_buffered-ip",
"erl-nodejs_compact_buffered-ip",
"erl-perl_binary_buffered-ip-ssl",
@@ -105,6 +109,7 @@
"go-java_compact_http-ip-ssl",
"go-java_json_http-ip",
"go-java_json_http-ip-ssl",
+ "go-lua_binary_buffered-ip",
"go-perl_binary_buffered-ip-ssl",
"go-perl_binary_framed-ip-ssl",
"hs-csharp_binary_framed-ip",
@@ -112,23 +117,32 @@
"hs-csharp_json_framed-ip",
"hs-dart_binary_framed-ip",
"hs-dart_json_framed-ip",
+ "hs-lua_binary_buffered-ip",
"hs-py3_json_buffered-ip",
"hs-py3_json_framed-ip",
"hs-py_json_buffered-ip",
"hs-py_json_framed-ip",
+ "java-lua_binary_buffered-ip",
"java-perl_binary_buffered-ip-ssl",
"java-perl_binary_fastframed-framed-ip-ssl",
"java-perl_binary_framed-ip-ssl",
+ "nodejs-lua_binary_buffered-ip",
"nodejs-perl_binary_buffered-ip-ssl",
"nodejs-perl_binary_framed-ip-ssl",
+ "perl-lua_binary_buffered-ip",
"perl-perl_binary_buffered-ip-ssl",
"perl-perl_binary_framed-ip-ssl",
"perl-php_binary_framed-ip",
"py-cpp_compact_buffered-ip",
+ "py-lua_accel-binary_buffered-ip",
+ "py-lua_binary_buffered-ip",
"py-perl_accel-binary_buffered-ip-ssl",
"py-perl_accel-binary_framed-ip-ssl",
"py-perl_binary_buffered-ip-ssl",
"py-perl_binary_framed-ip-ssl",
+ "py3-lua_binary_buffered-ip",
"py3-perl_binary_buffered-ip-ssl",
- "py3-perl_binary_framed-ip-ssl"
-]
+ "py3-perl_binary_framed-ip-ssl",
+ "rb-lua_accel-binary_buffered-ip",
+ "rb-lua_binary_buffered-ip"
+] \ No newline at end of file
diff --git a/test/lua/Makefile.am b/test/lua/Makefile.am
new file mode 100644
index 000000000..91de535be
--- /dev/null
+++ b/test/lua/Makefile.am
@@ -0,0 +1,30 @@
+#
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements. See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership. The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License. You may obtain a copy of the License at
+#
+# http://www.apache.org/licenses/LICENSE-2.0
+#
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied. See the License for the
+# specific language governing permissions and limitations
+# under the License.
+#
+
+THRIFT = $(top_builddir)/compiler/cpp/thrift
+
+# Remove "MapType =" line to ignore some map bug for now
+stubs: ../ThriftTest.thrift $(THRIFT)
+ $(THRIFT) --gen lua $<
+ $(SED) -i 's/MapType =//g' gen-lua/ThriftTest_ttypes.lua
+
+precross: stubs
+
+clean-local:
+ $(RM) -r gen-lua
diff --git a/test/lua/test_basic_client.lua b/test/lua/test_basic_client.lua
index e7571f939..5e0966fc1 100644
--- a/test/lua/test_basic_client.lua
+++ b/test/lua/test_basic_client.lua
@@ -17,6 +17,8 @@
require('TSocket')
+require('TBufferedTransport')
+require('TFramedTransport')
require('TBinaryProtocol')
require('ThriftTest_ThriftTest')
require('liblualongnumber')
@@ -25,28 +27,56 @@ local client
function teardown()
if client then
- -- Shuts down the server
- client:testVoid()
-
-- close the connection
client:close()
end
end
+function parseArgs(rawArgs)
+ local opt = {
+ protocol='binary',
+ transport='buffered',
+ port='9090',
+ }
+ for i, str in pairs(rawArgs) do
+ if i > 0 then
+ k, v = string.match(str, '--(%w+)=(%w+)')
+ assert(opt[k] ~= nil, 'Unknown argument')
+ opt[k] = v
+ end
+ end
+ return opt
+end
+
function assertEqual(val1, val2, msg)
assert(val1 == val2, msg)
end
-function testBasicClient()
+function testBasicClient(rawArgs)
+ local opt = parseArgs(rawArgs)
local socket = TSocket:new{
- port = 9090
+ port = tonumber(opt.port)
}
assert(socket, 'Failed to create client socket')
socket:setTimeout(5000)
- local protocol = TBinaryProtocol:new{
+ local transports = {
+ buffered = TBufferedTransport,
+ framed = TFramedTransport,
+ }
+ assert(transports[opt.transport] ~= nil)
+ local transport = transports[opt.transport]:new{
trans = socket
}
+
+ local protocols = {
+ binary = TBinaryProtocol,
+ -- compact = TCompactProtocol,
+ }
+ assert(protocols[opt.protocol] ~= nil)
+ local protocol = protocols[opt.protocol]:new{
+ trans = transport
+ }
assert(protocol, 'Failed to create binary protocol')
client = ThriftTestClient:new{
@@ -62,6 +92,10 @@ function testBasicClient()
assertEqual(client:testString('lala'), 'lala', 'Failed testString')
assertEqual(client:testString('wahoo'), 'wahoo', 'Failed testString')
+ -- Bool
+ assertEqual(client:testBool(true), true, 'Failed testBool true')
+ -- assertEqual(client:testBool(false), false, 'Failed testBool false')
+
-- Byte
assertEqual(client:testByte(0x01), 1, 'Failed testByte 1')
assertEqual(client:testByte(0x40), 64, 'Failed testByte 2')
@@ -130,9 +164,8 @@ function testBasicClient()
-- TODO fix client struct equality
--assertEqual(client:testStruct(a), a, 'Failed testStruct')
- -- Call the void function and end the test (handler stops server)
- client:testVoid()
+ -- TODO add list map set exception etc etc
end
-testBasicClient()
-teardown() \ No newline at end of file
+testBasicClient(arg)
+teardown()
diff --git a/test/lua/test_basic_server.lua b/test/lua/test_basic_server.lua
index 96a1ae9e0..fb8f074d4 100644
--- a/test/lua/test_basic_server.lua
+++ b/test/lua/test_basic_server.lua
@@ -28,7 +28,6 @@ TestHandler = ThriftTestIface:new{}
-- Stops the server
function TestHandler:testVoid()
- self.__server:stop()
end
function TestHandler:testString(str)
diff --git a/test/tests.json b/test/tests.json
index 6df5d4160..4bc976804 100644
--- a/test/tests.json
+++ b/test/tests.json
@@ -491,5 +491,31 @@
]
},
"workdir": "../lib/js"
+ },
+ {
+ "name": "lua",
+ "TODO": "Add dll to LUA_CPATH",
+ "env": {
+ "LUA_PATH": ";;gen-lua/?.lua;../../lib/lua/?.lua",
+ "LUA_CPATH": ";;../../lib/lua/.libs/?.so"
+ },
+ "client": {
+ "timeout": 5,
+ "transports": [
+ "buffered",
+ "framed"
+ ],
+ "sockets": [
+ "ip"
+ ],
+ "protocols": [
+ "binary"
+ ],
+ "command": [
+ "lua",
+ "test_basic_client.lua"
+ ]
+ },
+ "workdir": "lua"
}
]