diff -r 000000000000 -r d35581ea0c67 librazor/test.lua --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/librazor/test.lua Thu Aug 13 07:08:45 2009 +0100 @@ -0,0 +1,60 @@ +dofile("/testfile") +assert(loadfile("/testfile")) +assert(io.input("/testfile")) +assert(io.output("/file1")) +file = assert(io.open("/file1", "w")) +assert(io.input(file)) +assert(io.output(file)) +file:write("Hello world\n") +file:close() +assert(io.input()) +assert(io.output()) +for line in assert(io.lines("/file1")) do + assert(line == "Hello world") +end +file, err = io.popen("/testfile", "r") +if file == nil then + assert(string.find(err, " not supported") == 1) +else + assert(file:read() == "Abracadabra!") + file:close(); +end +assert(os.rename("/file1","/file2")) +assert(os.remove("/file2")) +assert(posix.mkdir("/testdir")) +assert(posix.stat("/testdir")) +assert(posix.chdir("/testdir")) +assert(posix.getcwd() == "/testdir") +assert(posix.mkdir("dir1")) +assert(posix.link("/testdir/dir1", "/testdir/link", true)) +assert(posix.readlink("/testdir/link") == "/testdir/dir1") +assert(posix.unlink("/testdir/link")) +assert(posix.link("/testfile", "/testdir/magic", false)) +assert(posix.chmod("/testfile","a+x")) +assert(posix.access("/testfile","x")) +pid = posix.fork() +if pid == 0 then + assert(posix.exec("/testfile")) +else + posix.wait(pid) +end +assert(posix.chdir("/")) +posix.setenv("PATH","/bin:/usr/bin:/testdir",true) +pid = posix.fork() +if pid == 0 then + assert(posix.execp("magic")) +else + posix.wait(pid) +end +assert(posix.utime("/testfile")) +assert(posix.pathconf("/testdir/magic")) +assert(posix.mkfifo("/testdir/fifo")) +assert(posix.dir()) +assert(posix.dir("/testdir")) +assert(posix.files()) +assert(posix.files("/testdir")) +for _,f in pairs(posix.glob("/testdir/*")) do + assert(string.find(f, "/testdir/") == 1) +end +assert(posix.rmdir("/testdir/dir1")) +assert(posix.chown("/testfile",-1,-1))