summaryrefslogtreecommitdiff
path: root/gtest/script
diff options
context:
space:
mode:
Diffstat (limited to 'gtest/script')
-rw-r--r--gtest/script/exec_with_context.lua19
-rw-r--r--gtest/script/get_header.lua25
-rw-r--r--gtest/script/get_other.lua14
3 files changed, 58 insertions, 0 deletions
diff --git a/gtest/script/exec_with_context.lua b/gtest/script/exec_with_context.lua
new file mode 100644
index 0000000..f7464ba
--- /dev/null
+++ b/gtest/script/exec_with_context.lua
@@ -0,0 +1,19 @@
+local data = TEST.data
+local context = TEST.context
+
+if not context.count then
+ context.count = 1
+else
+ context.count = context.count + 1
+end
+
+if not context.message then
+ context.message = "This is first called"
+else
+ context.message = "This is not first called"
+end
+
+local ud = TEST.get.get_userdata()
+local str = string.format("userdata:%s, context.count:%d, context.message:%s", ud, context.count, context.message)
+
+return string.len( str ), str
diff --git a/gtest/script/get_header.lua b/gtest/script/get_header.lua
new file mode 100644
index 0000000..104ddd0
--- /dev/null
+++ b/gtest/script/get_header.lua
@@ -0,0 +1,25 @@
+local data = TSG.data
+
+local req_header = nil
+local header = TSG.req.get_header()
+for k, v in pairs(header) do
+ if not req_header then
+ req_header = string.format( "%s:%s", k, v)
+ else
+ req_header = string.format( "%s,%s:%s",req_header, k, v)
+ end
+end
+
+local rsp_header = nil
+header = TSG.rsp.get_header()
+for k, v in pairs(header) do
+ if not req_header then
+ rsp_header = string.format("%s:%s", k, v)
+ else
+ rsp_header = string.format("%s,%s:%s", rsp_header, k, v)
+ end
+end
+
+local ret = string.format( "req_header:%s; rsp_header:%s", req_header, rsp_header)
+-- print(ret)
+return string.len(ret), ret \ No newline at end of file
diff --git a/gtest/script/get_other.lua b/gtest/script/get_other.lua
new file mode 100644
index 0000000..02c1fa7
--- /dev/null
+++ b/gtest/script/get_other.lua
@@ -0,0 +1,14 @@
+local data = TSG.data
+local result = "true"
+if not TSG.get.get_result() then
+ result = "false"
+end
+
+local flag = "not nil"
+if not TSG.get.get_nil() then
+ flag = "is nil"
+end
+
+local str = string.format("result:%s, time:%d, %s", result, TSG.get.get_time(), flag)
+
+return string.len(str), str \ No newline at end of file