[New-bugs-announce] [issue22094] test_ossaudiodev fails unnecessarily

Akira Li report at bugs.python.org
Mon Jul 28 12:29:20 CEST 2014


New submission from Akira Li:

$ ./python -mtest -uaudio test_ossaudiodev
[1/1] test_ossaudiodev
test test_ossaudiodev failed -- Traceback (most recent call last):
  File "./Lib/test/test_ossaudiodev.py", line 148, in test_playback
    self.play_sound_file(*sound_info)
  File "./Lib/test/test_ossaudiodev.py", line 89, in play_sound_file
    (elapsed_time, expected_time))
AssertionError: False is not true : elapsed time (0.0590214729309082) > 10% off of expected time (3.5127309036445333)

1 test failed:
    test_ossaudiodev

The failure is caused by dsp.write(data) that doesn't write all data
on my machine.  If it is replaced with dsp.writeall(data) then the test
passes.

The docs [1] say that dsp.write() should write all data by default:

  oss_audio_device.write(data)
  Write the Python string data to the audio device and return the
  number of bytes written. If the audio device is in blocking mode
  (the default), the entire string is always written

[1] https://docs.python.org/3.4/library/ossaudiodev.html


The comments in Modules/ossaudiodev.c suggest that dsp.write(data) should
write *all* data unless dsp.nonblock() is called:

    /* Open with O_NONBLOCK to avoid hanging on devices that only allow
       one open at a time.  This does *not* affect later I/O; OSS
       provides a special ioctl() for non-blocking read/write, which is
       exposed via oss_nonblock() below. */
    fd = _Py_open(devicename, imode|O_NONBLOCK);
    ...
    /* And (try to) put it back in blocking mode so we get the
       expected write() semantics. */
    if (fcntl(fd, F_SETFL, 0) == -1) {
        close(fd);
        PyErr_SetFromErrnoWithFilename(PyExc_IOError, devicename);
        return NULL;
    }

----------
components: Tests
messages: 224159
nosy: akira
priority: normal
severity: normal
status: open
title: test_ossaudiodev fails unnecessarily
type: behavior
versions: Python 3.4

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue22094>
_______________________________________


More information about the New-bugs-announce mailing list