1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
1.2 +++ b/librazor/test.lua Fri Apr 23 19:14:17 2010 +0100
1.3 @@ -0,0 +1,60 @@
1.4 +dofile("/testfile")
1.5 +assert(loadfile("/testfile"))
1.6 +assert(io.input("/testfile"))
1.7 +assert(io.output("/file1"))
1.8 +file = assert(io.open("/file1", "w"))
1.9 +assert(io.input(file))
1.10 +assert(io.output(file))
1.11 +file:write("Hello world\n")
1.12 +file:close()
1.13 +assert(io.input())
1.14 +assert(io.output())
1.15 +for line in assert(io.lines("/file1")) do
1.16 + assert(line == "Hello world")
1.17 +end
1.18 +file, err = io.popen("/testfile", "r")
1.19 +if file == nil then
1.20 + assert(string.find(err, " not supported") == 1)
1.21 +else
1.22 + assert(file:read() == "Abracadabra!")
1.23 + file:close();
1.24 +end
1.25 +assert(os.rename("/file1","/file2"))
1.26 +assert(os.remove("/file2"))
1.27 +assert(posix.mkdir("/testdir"))
1.28 +assert(posix.stat("/testdir"))
1.29 +assert(posix.chdir("/testdir"))
1.30 +assert(posix.getcwd() == "/testdir")
1.31 +assert(posix.mkdir("dir1"))
1.32 +assert(posix.link("/testdir/dir1", "/testdir/link", true))
1.33 +assert(posix.readlink("/testdir/link") == "/testdir/dir1")
1.34 +assert(posix.unlink("/testdir/link"))
1.35 +assert(posix.link("/testfile", "/testdir/magic", false))
1.36 +assert(posix.chmod("/testfile","a+x"))
1.37 +assert(posix.access("/testfile","x"))
1.38 +pid = posix.fork()
1.39 +if pid == 0 then
1.40 + assert(posix.exec("/testfile"))
1.41 +else
1.42 + posix.wait(pid)
1.43 +end
1.44 +assert(posix.chdir("/"))
1.45 +posix.setenv("PATH","/bin:/usr/bin:/testdir",true)
1.46 +pid = posix.fork()
1.47 +if pid == 0 then
1.48 + assert(posix.execp("magic"))
1.49 +else
1.50 + posix.wait(pid)
1.51 +end
1.52 +assert(posix.utime("/testfile"))
1.53 +assert(posix.pathconf("/testdir/magic"))
1.54 +assert(posix.mkfifo("/testdir/fifo"))
1.55 +assert(posix.dir())
1.56 +assert(posix.dir("/testdir"))
1.57 +assert(posix.files())
1.58 +assert(posix.files("/testdir"))
1.59 +for _,f in pairs(posix.glob("/testdir/*")) do
1.60 + assert(string.find(f, "/testdir/") == 1)
1.61 +end
1.62 +assert(posix.rmdir("/testdir/dir1"))
1.63 +assert(posix.chown("/testfile",-1,-1))