Merge pull request #1818 from dibdot/lxc_fix
[project/luci.git] / libs / luci-lib-nixio / axTLS / www / lua / test_main.lua
1 cgilua.htmlheader()
2 cgilua.put[[
3 <html>
4 <head><title>Script Lua Test</title></head>
5
6 <body>
7 cgi = {
8 ]]
9
10 for i,v in pairs (cgi) do
11         if type(v) == "table" then
12                 local vv = "{"
13                 for a,b in pairs(v) do
14                         vv = string.format ("%s%s = %s<br>\n", vv, a, tostring(b))
15                 end
16                 v = vv.."}"
17         end
18         cgilua.put (string.format ("%s = %s<br>\n", i, tostring(v)))
19 end
20 cgilua.put "}<br>\n"
21 cgilua.put ("Remote address: "..cgilua.servervariable"REMOTE_ADDR")
22 cgilua.put "<br>\n"
23 cgilua.put ("Is persistent = "..tostring (SAPI.Info.ispersistent).."<br>\n")
24 cgilua.put ("ap="..tostring(ap).."<br>\n")
25 cgilua.put ("lfcgi="..tostring(lfcgi).."<br>\n")
26
27 -- Checking Virtual Environment
28 local my_output = cgilua.put
29 cgilua.put = nil
30 local status, err = pcall (function ()
31         assert (cgilua.put == nil, "cannot change cgilua.put value")
32 end)
33 cgilua.put = my_output
34 assert (status == true, err)
35
36 -- Checking require
37 local status, err = pcall (function () require"unknown_module" end)
38 assert (status == false, "<tt>unknown_module</tt> loaded!")
39 -- assert (package == nil, "Access to <tt>package</tt> table allowed!")
40
41 cgilua.put[[
42 <p>
43 </body>
44 </html>
45 ]]
46 cgilua = nil