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_getdents.py

Revision 5563, 1.2 KB (checked in by nitin, 5 years ago)

Fixed size issue for getdents; Modified the corresponding Unit test.

Line 
1import lind_test_server
2
3from lind_fs_constants import *
4
5lind_test_server._blank_fs_init()
6
7# Let's add a few directories to the system and see if it works...
8lind_test_server.mkdir_syscall('/bar',S_IRWXA)
9lind_test_server.mkdir_syscall('/bar/baz',S_IRWXA)
10lind_test_server.mkdir_syscall('/bar/bap',0)
11
12# Create a new file...
13fd = lind_test_server.open_syscall('/bar/bam',O_CREAT,0)
14lind_test_server.close_syscall(fd)
15
16# Read the root directory...
17rootfd = lind_test_server.open_syscall('/',0,0)
18val = lind_test_server.getdents_syscall(rootfd, 100)
19assert (val==[(3, 'bar', DT_DIR, 24), (1, '..', DT_DIR, 24),\
20  (1, '.', DT_DIR, 24)]), "Found: %s"%(str(val))
21
22# Read the /bar directory...
23barfd = lind_test_server.open_syscall('/bar',0,0)
24
25# The buffer size is given small, only few entries are read.
26val = lind_test_server.getdents_syscall(barfd, 80)
27assert (val == [(6, 'bam', DT_REG, 24), (4, 'baz', DT_DIR, 24),\
28  (5, 'bap', DT_DIR, 24)]), "Found: %s"%(str(val))
29
30# Again call on the same FD, should continue parsing the /bar directory.
31val = lind_test_server.getdents_syscall(barfd, 80)
32assert (val == [(1, '..', DT_DIR, 24), (3, '.', DT_DIR, 24)]),\
33  "Found: %s"%(str(val))
34
35lind_test_server.close_syscall(rootfd)
36lind_test_server.close_syscall(barfd)
Note: See TracBrowser for help on using the browser.