This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: test_ioctl may fail when run in background
Type: behavior Stage: resolved
Components: Tests Versions: Python 3.2, Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: flox Nosy List: flox, nirai, r.david.murray, vstinner
Priority: normal Keywords: patch

Created on 2009-12-22 23:39 by flox, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
issue7564_test_ioctl_v2.diff flox, 2010-01-26 18:27 Patch, apply to trunk
Messages (8)
msg96820 - (view) Author: Florent Xicluna (flox) * (Python committer) Date: 2009-12-22 23:39
I got it to fail sometimes on trunk, when run with "-r -uall".

Debian 64bits, Python 2.7a r77004


test_ioctl
test_ioctl (test.test_ioctl.IoctlTests) ... FAIL
test_ioctl_mutate (test.test_ioctl.IoctlTests) ... FAIL
test_ioctl_signed_unsigned_code_param (test.test_ioctl.IoctlTests) ... ok

======================================================================
FAIL: test_ioctl (test.test_ioctl.IoctlTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "./Lib/test/test_ioctl.py", line 27, in test_ioctl
    self.assertTrue(rpgrp in ids, "%s not in %s" % (rpgrp, ids))
AssertionError: 9165 not in (2334, 15696)

======================================================================
FAIL: test_ioctl_mutate (test.test_ioctl.IoctlTests)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "./Lib/test/test_ioctl.py", line 37, in test_ioctl_mutate
    self.assertTrue(rpgrp in ids, "%s not in %s" % (rpgrp, ids))
AssertionError: 9165 not in (2334, 15696)

----------------------------------------------------------------------
Ran 3 tests in 0.001s

FAILED (failures=2)
test test_ioctl failed -- multiple errors occurred
msg97122 - (view) Author: Florent Xicluna (flox) * (Python committer) Date: 2010-01-01 22:43
It fails if the test is run in background, and there's another process
in foreground.

Example 1:

~ $ (./python Lib/test/regrtest.py test_ioctl &) && tail -f /dev/null
test_ioctl
test test_ioctl failed -- multiple errors occurred; run in verbose mode
for details
1 test failed:
    test_ioctl


Example 2 (a shell script):

~ $ cat run_ioctl.sh
#!/bin/sh
./python Lib/test/regrtest.py -v test_ioctl > test_ioctl.log &
tail -f test_ioctl.log
msg98172 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2010-01-23 00:37
test_ioctl() gets the process group ID of the foreground process group on /dev/tty. If Python is in foreground, it's equal to the process group ID (os.getpgrp()) or to the session ID (os.getsid(0)). If Python is in background, yes, the test fail.

test_ioctl_mutate() contains test_ioctl() but also ensure that the input buffer is not modified by the ioctl.

If you would like to run test_ioctl.py in background, you will have to disable these 2 tests: ignore the tests if the process is in background. Detect if a process is in foreground or background is exactly the goal of test_ioctl()...
msg98334 - (view) Author: Florent Xicluna (flox) * (Python committer) Date: 2010-01-26 13:19
Patch to skip the test with the appropriate warning in verbose mode.
msg98337 - (view) Author: Florent Xicluna (flox) * (Python committer) Date: 2010-01-26 14:09
Patch to make the "skip" message visible in normal mode:

test_ioctl
test_ioctl skipped -- Process group 1844 is associated with /dev/tty


And in the summary you have the information:

1 test skipped:
    test_ioctl
1 skip unexpected on linux2:
    test_ioctl
msg98340 - (view) Author: R. David Murray (r.david.murray) * (Python committer) Date: 2010-01-26 15:36
Could the skip message be made a little more explanatory?  I have no idea why "Process group 1844 is associated with /dev/tty" would mean that test_ioctl would need to be skipped.
msg98344 - (view) Author: Florent Xicluna (flox) * (Python committer) Date: 2010-01-26 18:27
A little more explanatory.
msg113293 - (view) Author: Florent Xicluna (flox) * (Python committer) Date: 2010-08-08 18:07
Fixed with revision 83839.
History
Date User Action Args
2022-04-11 14:56:55adminsetgithub: 51813
2010-08-08 18:07:22floxsetstatus: open -> closed
resolution: fixed
messages: + msg113293

stage: patch review -> resolved
2010-03-07 01:22:35floxsetpriority: low -> normal
assignee: flox
versions: - Python 2.6, Python 3.1
2010-01-26 18:27:25floxsetfiles: + issue7564_test_ioctl_v2.diff

messages: + msg98344
2010-01-26 18:26:07floxsetfiles: - issue7564_test_ioctl.diff
2010-01-26 15:36:30r.david.murraysetnosy: + r.david.murray
messages: + msg98340
2010-01-26 14:09:08floxsetfiles: + issue7564_test_ioctl.diff

messages: + msg98337
2010-01-26 14:06:13floxsetfiles: - issue7564_test_ioctl.diff
2010-01-26 13:19:08floxsetfiles: + issue7564_test_ioctl.diff
keywords: + patch
messages: + msg98334

stage: patch review
2010-01-23 00:37:39vstinnersetnosy: + vstinner
messages: + msg98172
2010-01-01 22:43:47floxsettitle: test_ioctl fails when run in background -> test_ioctl may fail when run in background
2010-01-01 22:43:26floxsetpriority: low

title: test_ioctl fails sometimes -> test_ioctl fails when run in background
messages: + msg97122
versions: + Python 2.6, Python 3.1, Python 3.2
2009-12-25 07:23:10niraisetnosy: + nirai
2009-12-22 23:39:14floxcreate