Released version 3-2015061300
[notion.git] / test / integration / runtests.lua
blobf9bdfa1009d15345ca90a10df3873cde4130eb9e
1 # on Debian in lua-posix
2 require "posix"
4 function sleep(sec)
5 os.execute("sleep " .. tonumber(sec))
6 end
8 function getTests(testset)
9 return (io.popen("ls " .. testset .. "/*.lua"):lines())
10 end
12 print 'Running tests against ../../notion/notion'
13 print 'Starting Xdummy...'
15 local xpid = posix.fork()
16 if (xpid == 0) then
17 local result,errstr,errno = posix.exec("/bin/sh", "./Xdummy", ":7")
18 print ('Error replacing current process with Xdummy: ' .. errstr);
19 os.exit(1)
20 end
22 sleep(1)
24 print '(Hopefully) started Xdummy.'
26 local testsets = { 'basic_test', 'xinerama', 'xrandr' }
27 local errors = 0
29 for i,testset in ipairs(testsets) do
31 posix.setenv('HOME', testset);
33 os.execute("rm -r " .. testset .. "/.notion/default-session--7")
35 print ('Starting notion in ./' .. testset .. '...')
37 local notionpid = posix.fork()
38 if (notionpid == 0) then
39 local result,errstr,errno = posix.exec("../../notion/notion", "-noerrorlog", "-display", ":7")
40 print ('Error replacing current process with notion: ' .. errstr)
41 os.exit(1)
42 end
44 sleep(2)
46 print 'Running tests...'
48 for test in getTests(testset) do
49 print ('Running test ' .. test)
50 local testoutputpipe = io.popen("cat " .. test .. " | DISPLAY=:7 notionflux")
51 local testoutput = testoutputpipe:read("*a")
52 print 'Evaluating result...'
53 if(testoutput ~= "\"ok\"\n") then
54 print('** ERROR ** ' .. testoutput)
55 errors = errors + 1
56 else
57 print '** OK **'
58 end
59 end
61 print 'Killing notion process...'
62 posix.kill(notionpid)
63 sleep(1)
65 end
67 print 'Killing X process...'
68 posix.kill(xpid)
70 if errors == 0 then
71 print 'OK!'
72 else
73 print (errors .. " errors.")
74 end