Please note that the CVS and issue trackers have moved to GitHub. These Trac pages are no longer kept up-to-date.

root/seattle/branches/nacl_repy/seattlelib/tests/ut_lind_fs_file_link_unlink.py

Revision 5140, 1.2 KB (checked in by justinc, 6 years ago)

removed circular imports and created a new Python testing mechanism called
lind_test_server. This removes the need for wrappers, etc.

Line 
1import lind_test_server
2
3from lind_fs_constants import *
4
5# Let's add a few files, etc. to the system and see if it works...
6lind_test_server._blank_fs_init()
7
8myfd = lind_test_server.open_syscall('/foo',O_CREAT | O_EXCL | O_WRONLY,S_IRWXA)
9
10# write should succeed
11assert(lind_test_server.write_syscall(myfd,'hi') == 2)
12
13stat_result = lind_test_server.stat_syscall('/foo')
14
15# ensure the file has size 2
16assert(stat_result[7] == 2)
17
18# ensure the link count is 1
19assert(stat_result[3] == 1)
20
21             
22# create a file with no perms...
23lind_test_server.link_syscall('/foo','/foo2')
24
25stat_result = lind_test_server.stat_syscall('/foo')
26stat_result2 = lind_test_server.stat_syscall('/foo2')
27
28# ensure they are the same now...
29assert(stat_result2 == stat_result)
30
31# and that the link count is 2
32assert(stat_result[3] == 2)
33
34
35# let's unlink one now...
36
37lind_test_server.unlink_syscall('/foo')
38
39
40stat_result = lind_test_server.stat_syscall('/foo2')
41
42# ensure the link count is 1
43assert(stat_result[3] == 1)
44
45# file is gone...
46try:
47  stat_result = lind_test_server.stat_syscall('/foo')
48except:
49  pass
50else:
51  print "stat worked after unlinked!!!"
52
53
54lind_test_server.unlink_syscall('/foo2')
Note: See TracBrowser for help on using the browser.