示例#1
0
    def validateRegularFilePath(self, view, path):
        attr = view.getattr(path)

        self.assertTrue(attr.st_size >= 0)

        self.assertTrue(view.open(path, 32768) == None)

        content = view.read(path, 4096, 0)

        self.assertNotEquals(-errno.ENOSYS, content)
        self.assertNotEquals(-errno.ENOENT, content)

        self.assertTrue(content != None)

        logging.debug('Content: ' + str(content))
示例#2
0
    def validateDirectoryPath(self, view, path):
        # path is a directory

        # test rox filer default access
        for file in ['AppRun', '.DirIcon']:
            attr = view.getattr(os.path.join(path, file))

        # TODO implement propper offset handling
        for entry in view.readdir(path, 0):
            self.assertTrue(entry != None)

            # TODO put '.' and '..' in set
            if entry.name == '.':
                continue

            if entry.name == '..':
                continue

            self.validateView(view, path + '/' + entry.name)
示例#3
0
    def validateView(self, view, path):
        attr = view.getattr(path)

        # TODO assert every file belongs to 'me'
        # right now this is the default behaviour
        #self.assertEquals(os.getuid(), attr.st_uid)
        #self.assertEquals(os.getgid(), attr.st_gid)

        self.assertNotEquals(-errno.ENOSYS, attr,
                              msg = 'Expected attributes for path ' + path + ' but was ' + str(attr))
        self.assertNotEquals(-errno.ENOENT, attr,
                              msg = 'Expected attributes for path ' + path + ' but was ' + str(attr))

        if (attr.st_mode & stat.S_IFDIR == stat.S_IFDIR):
            self.validateDirectoryPath(view, path)
        elif (attr.st_mode & stat.S_IFLNK == stat.S_IFLNK):
            self.validateLinkPath(view, path)
        elif (attr.st_mode & stat.S_IFREG == stat.S_IFREG):
            self.validateRegularFilePath(view, path)
        else:
            self.fail('Unknown attributes ' + str(attr))