aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/test.lua20
1 files changed, 16 insertions, 4 deletions
diff --git a/tests/test.lua b/tests/test.lua
index cf1e573..94338b0 100644
--- a/tests/test.lua
+++ b/tests/test.lua
@@ -36,6 +36,15 @@ assert (lfs.chdir ("this couldn't be an actual directory") == nil, "could change
36-- Changing creating and removing directories 36-- Changing creating and removing directories
37local tmpdir = current..sep.."lfs_tmp_dir" 37local tmpdir = current..sep.."lfs_tmp_dir"
38local tmpfile = tmpdir..sep.."tmp_file" 38local tmpfile = tmpdir..sep.."tmp_file"
39-- Test for existence of a previous lfs_tmp_dir
40-- that may have resulted from an interrupted test execution and remove it
41if lfs.chdir (tmpdir) then
42 assert (lfs.chdir (upper), "could not change to upper directory")
43 assert (os.remove (tmpfile), "could not remove file from previous test")
44 assert (lfs.rmdir (tmpdir), "could not remove directory from previous test")
45end
46
47-- tries to create a directory
39assert (lfs.mkdir (tmpdir), "could not make a new directory") 48assert (lfs.mkdir (tmpdir), "could not make a new directory")
40local attrib, errmsg = lfs.attributes (tmpdir) 49local attrib, errmsg = lfs.attributes (tmpdir)
41if not attrib then 50if not attrib then
@@ -45,17 +54,20 @@ local f = io.open(tmpfile, "w")
45f:close() 54f:close()
46 55
47-- Change access time 56-- Change access time
48local testdate = os.time({ year = 2007, day = 10, month = 2}) 57local testdate = os.time({ year = 2007, day = 10, month = 2, hour=0})
49assert (lfs.touch (tmpfile, testdate)) 58assert (lfs.touch (tmpfile, testdate))
50local new_att = assert (lfs.attributes (tmpfile)) 59local new_att = assert (lfs.attributes (tmpfile))
51assert (new_att.access == testdate, "could not set access time") 60assert (new_att.access == testdate, "could not set access time")
52assert (new_att.modification == testdate, "could not set modification time") 61assert (new_att.modification == testdate, "could not set modification time")
53 62
54-- Change access and modification time 63-- Change access and modification time
55assert (lfs.touch (tmpfile, testdate + 2, testdate + 1)) 64local testdate1 = os.time({ year = 2007, day = 10, month = 2, hour=0})
65local testdate2 = os.time({ year = 2007, day = 11, month = 2, hour=0})
66
67assert (lfs.touch (tmpfile, testdate2, testdate1))
56local new_att = assert (lfs.attributes (tmpfile)) 68local new_att = assert (lfs.attributes (tmpfile))
57assert (new_att.access == testdate + 2, "could not set access time") 69assert (new_att.access == testdate2, "could not set access time")
58assert (new_att.modification == testdate + 1, "could not set modification time") 70assert (new_att.modification == testdate1, "could not set modification time")
59 71
60-- Restore access time to current value 72-- Restore access time to current value
61assert (lfs.touch (tmpfile, attrib.access, attrib.modification)) 73assert (lfs.touch (tmpfile, attrib.access, attrib.modification))