Opened 15 years ago

Closed 11 years ago

#3354 closed bug (fixed)

f.seekable() fails in python test_fileio.py

Reported by: scottmc Owned by: axeld
Priority: normal Milestone: R1
Component: - General Version: R1/Development
Keywords: Cc:
Blocked By: Blocking:
Platform: All

Description

Perhaps related to #3028? Python regression test test_fileio.py fails :

~/develop/python/Lib/test> python test_fileio.py
testAttributes (__main__.AutoFileTests) ... ok
testErrors (__main__.AutoFileTests) ... ok
testMethods (__main__.AutoFileTests) ... ok
testOpendir (__main__.AutoFileTests) ... ok
testReadinto (__main__.AutoFileTests) ... ok
testRepr (__main__.AutoFileTests) ... ok
testSeekTell (__main__.AutoFileTests) ... ok
testWeakRefs (__main__.AutoFileTests) ... ok
testAbles (__main__.OtherFileTests) ... FAIL
testAppend (__main__.OtherFileTests) ... ok
testBadModeArgument (__main__.OtherFileTests) ... ok
testInvalidFd (__main__.OtherFileTests) ... ok
testInvalidInit (__main__.OtherFileTests) ... ok
testModeStrings (__main__.OtherFileTests) ... ok
testTruncateOnWindows (__main__.OtherFileTests) ... ok
testUnicodeOpen (__main__.OtherFileTests) ... ok
testWarnings (__main__.OtherFileTests) ... ok

======================================================================
FAIL: testAbles (__main__.OtherFileTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "test_fileio.py", line 156, in testAbles
    self.assertEquals(f.seekable(), False)
AssertionError: True != False

----------------------------------------------------------------------
Ran 17 tests in 0.157s

FAILED (failures=1)
Traceback (most recent call last):
  File "test_fileio.py", line 268, in <module>
    test_main()
  File "test_fileio.py", line 262, in test_main
    run_unittest(AutoFileTests, OtherFileTests)
  File "/boot/common/lib/python2.7/test/test_support.py", line 710, in run_unittest
    _run_suite(suite)
  File "/boot/common/lib/python2.7/test/test_support.py", line 693, in _run_suite
    raise TestFailed(err)
test.test_support.TestFailed: Traceback (most recent call last):
  File "test_fileio.py", line 156, in testAbles
    self.assertEquals(f.seekable(), False)
AssertionError: True != False

~/develop/python/Lib/test> 

Change History (9)

comment:1 by scottmc, 15 years ago

This still fails on hrev32818.
With python included you can run this test from:
/boot/common/lib/python2.6/test> python test_fileio.py

comment:2 by scottmc, 13 years ago

this still fails as of hrev38817.

comment:3 by scottmc, 13 years ago

Version: R1/pre-alpha1R1/Development

still with us in hrev42190.

comment:4 by scottmc, 12 years ago

Here's the part of the test that is failing. Adding a patch to add a case for 'haiku' not in sys.platform lets the test pass. Question is, would this be the correct solution, that is, should /dev/tty be seekable on Haiku?

def testAbles(self):
        try:
            f = _FileIO(TESTFN, "w")
            self.assertEquals(f.readable(), False)
            self.assertEquals(f.writable(), True)
            self.assertEquals(f.seekable(), True)
            f.close()

            f = _FileIO(TESTFN, "r")
            self.assertEquals(f.readable(), True)
            self.assertEquals(f.writable(), False)
            self.assertEquals(f.seekable(), True)
            f.close()

            f = _FileIO(TESTFN, "a+")
            self.assertEquals(f.readable(), True)
            self.assertEquals(f.writable(), True)
            self.assertEquals(f.seekable(), True)
            self.assertEquals(f.isatty(), False)
            f.close()

            if sys.platform != "win32":
                try:
                    f = _FileIO("/dev/tty", "a")
                except EnvironmentError:
                    # When run in a cron job there just aren't any
                    # ttys, so skip the test.  This also handles other
                    # OS'es that don't support /dev/tty.
                    pass
                else:
                    f = _FileIO("/dev/tty", "a")
                    self.assertEquals(f.readable(), False)
                    self.assertEquals(f.writable(), True)
                    if sys.platform != "darwin" and \
                       'bsd' not in sys.platform and \
                       not sys.platform.startswith('sunos'):
                        # Somehow /dev/tty appears seekable on some BSDs
                        self.assertEquals(f.seekable(), False)
                    self.assertEquals(f.isatty(), True)
                    f.close()
        finally:
            os.unlink(TESTFN)

comment:5 by bonefish, 12 years ago

OK, so apparently our TTY appears to be seekable. So how does the seekable() method determine that?

comment:6 by korli, 12 years ago

The seekable() method seems to use something like "lseek(fd, 0, SEEK_CUR)". /dev/tty is a character device as set up by devfs, and seeking on them seems fine for our VFS.

Opengroup doesn't say that a TTY isn't seekable. I would say, add a case for haiku in the python test.

in reply to:  6 comment:7 by bonefish, 12 years ago

Replying to korli:

The seekable() method seems to use something like "lseek(fd, 0, SEEK_CUR)". /dev/tty is a character device as set up by devfs, and seeking on them seems fine for our VFS.

The only reason for this is that there's no easy way for the VFS to find out whether the underlying node is seekable or not. Otherwise we'd have generated an error in this case, since obviously seeking a TTY doesn't make much sense. Maybe we should introduce a node flag for this purpose or some other way to announce non-seekability.

Opengroup doesn't say that a TTY isn't seekable. I would say, add a case for haiku in the python test.

+1 for the time being.

comment:8 by scottmc, 11 years ago

This is now passing in hrev45107, with python-2.6.8. What change in Haiku fixed this I wonder?

comment:9 by scottmc, 11 years ago

Resolution: fixed
Status: newclosed

This passes now, so closing.

Note: See TracTickets for help on using tickets.