Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

android: test_pipes fails #71105

Closed
xdegaye mannequin opened this issue May 3, 2016 · 10 comments
Closed

android: test_pipes fails #71105

xdegaye mannequin opened this issue May 3, 2016 · 10 comments
Labels
build The build process and cross-build stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error

Comments

@xdegaye
Copy link
Mannequin

xdegaye mannequin commented May 3, 2016

BPO 26918
Nosy @xdegaye, @serhiy-storchaka, @moreati
Files
  • no_tr_skipped.patch
  • emulator_system_bin.txt: list of emulator commands
  • no_tr_skipped_2.patch
  • replace_tr.patch: replace tr with a python command
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2016-05-05.08:00:25.777>
    created_at = <Date 2016-05-03.09:13:44.906>
    labels = ['type-bug', 'library', 'build']
    title = 'android: test_pipes fails'
    updated_at = <Date 2016-05-05.15:22:48.204>
    user = 'https://github.com/xdegaye'

    bugs.python.org fields:

    activity = <Date 2016-05-05.15:22:48.204>
    actor = 'xdegaye'
    assignee = 'none'
    closed = True
    closed_date = <Date 2016-05-05.08:00:25.777>
    closer = 'serhiy.storchaka'
    components = ['Library (Lib)', 'Cross-Build']
    creation = <Date 2016-05-03.09:13:44.906>
    creator = 'xdegaye'
    dependencies = []
    files = ['42722', '42731', '42732', '42733']
    hgrepos = []
    issue_num = 26918
    keywords = ['patch']
    message_count = 10.0
    messages = ['264702', '264855', '264860', '264882', '264883', '264886', '264887', '264888', '264906', '264908']
    nosy_count = 4.0
    nosy_names = ['xdegaye', 'python-dev', 'serhiy.storchaka', 'Alex.Willmer']
    pr_nums = []
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'behavior'
    url = 'https://bugs.python.org/issue26918'
    versions = ['Python 3.6']

    @xdegaye
    Copy link
    Mannequin Author

    xdegaye mannequin commented May 3, 2016

    test_pipes fails on an android emulator running an x86 system image at API level 21.

    root@generic_x86:/data/local/tmp # python -m test -v test_pipes
    == CPython 3.6.0a0 (default:f4c6dab59cd8+, May 3 2016, 10:42:45) [GCC 4.9 20140827 (prerelease)]
    == Linux-3.4.67+-i686-with-libc little-endian
    == hash algorithm: fnv 32bit
    == /data/local/tmp/test_python_1927
    Testing with flags: sys.flags(debug=0, inspect=0, interactive=0, optimize=0, dont_write_bytecode=0,
    no_user_site=0, no_site=0, ignore_environment=0, verbose=0, bytes_warning=0, quiet=0, hash_randomiza
    tion=1, isolated=0)
    Run tests sequentially
    0:00:00 [1/1] test_pipes
    testBadAppendOptions (test.test_pipes.SimplePipeTests) ... ok
    testBadOpenMode (test.test_pipes.SimplePipeTests) ... ok
    testBadPrependOptions (test.test_pipes.SimplePipeTests) ... ok
    testClone (test.test_pipes.SimplePipeTests) ... ok
    testEmptyPipeline1 (test.test_pipes.SimplePipeTests) ... ok
    testEmptyPipeline2 (test.test_pipes.SimplePipeTests) ... ok
    testEmptyPipeline3 (test.test_pipes.SimplePipeTests) ... ok
    testReadOpenSink (test.test_pipes.SimplePipeTests) ... ok
    testRepr (test.test_pipes.SimplePipeTests) ... ok
    testSetDebug (test.test_pipes.SimplePipeTests) ... ok
    testSimplePipe1 (test.test_pipes.SimplePipeTests) ... /system/bin/sh: tr: not found
    FAIL
    testSimplePipe2 (test.test_pipes.SimplePipeTests) ... sh: tr: not found
    FAIL
    testSimplePipe3 (test.test_pipes.SimplePipeTests) ... /system/bin/sh: tr: not found
    FAIL
    testWriteOpenSource (test.test_pipes.SimplePipeTests) ... ok

    ======================================================================
    FAIL: testSimplePipe1 (test.test_pipes.SimplePipeTests)
    ----------------------------------------------------------------------

    Traceback (most recent call last):
      File "/sdcard/org.bitbucket.pyona/lib/python3.6/test/test_pipes.py", line 27, in testSimplePipe1
        self.assertEqual(f.read(), 'HELLO WORLD #1')
    AssertionError: '' != 'HELLO WORLD #1'
    + HELLO WORLD #1

    ======================================================================
    FAIL: testSimplePipe2 (test.test_pipes.SimplePipeTests)
    ----------------------------------------------------------------------

    Traceback (most recent call last):
      File "/sdcard/org.bitbucket.pyona/lib/python3.6/test/test_pipes.py", line 36, in testSimplePipe2
        self.assertEqual(f.read(), 'HELLO WORLD #2')
    AssertionError: '' != 'HELLO WORLD #2'
    + HELLO WORLD #2

    ======================================================================
    FAIL: testSimplePipe3 (test.test_pipes.SimplePipeTests)
    ----------------------------------------------------------------------

    Traceback (most recent call last):
      File "/sdcard/org.bitbucket.pyona/lib/python3.6/test/test_pipes.py", line 45, in testSimplePipe3
        self.assertEqual(f.read(), 'HELLO WORLD #2')
    AssertionError: '' != 'HELLO WORLD #2'
    + HELLO WORLD #2

    Ran 14 tests in 0.039s

    FAILED (failures=3)
    test test_pipes failed
    1 test failed:
    test_pipes
    Total duration: 0:00:01

    @xdegaye xdegaye mannequin added stdlib Python modules in the Lib dir build The build process and cross-build type-bug An unexpected behavior, bug, or error labels May 3, 2016
    @xdegaye
    Copy link
    Mannequin Author

    xdegaye mannequin commented May 4, 2016

    The attached patch fixes this.

    @serhiy-storchaka
    Copy link
    Member

    serhiy-storchaka commented May 4, 2016

    Is tr not available on Android?! I would suggest to use sed instead, but I afraid sed is not available too. What commands are available at all?

    @xdegaye
    Copy link
    Mannequin Author

    xdegaye mannequin commented May 5, 2016

    Here is the list of commands at /system/bin on the emulator.

    @xdegaye
    Copy link
    Mannequin Author

    xdegaye mannequin commented May 5, 2016

    Thanks for the review Serhiy. New patch attached.

    @python-dev
    Copy link
    Mannequin

    python-dev mannequin commented May 5, 2016

    New changeset 3bad4b0f7612 by Serhiy Storchaka in branch 'default':
    Issue bpo-26918: Skipped some tests in test_pipes on Android.
    https://hg.python.org/cpython/rev/3bad4b0f7612

    @serhiy-storchaka
    Copy link
    Member

    serhiy-storchaka commented May 5, 2016

    LGTM. Thanks Xavier.

    It looks to me that there are no useful commands that can be used for testing on Android. We could use md5 or grep, but this would require rewriting tests too much for small benefit. It is better to skip tests.

    @xdegaye
    Copy link
    Mannequin Author

    xdegaye mannequin commented May 5, 2016

    Ooops too late. Here is a new patch that replaces the tr command and allows all the tests of test_pipes to run successfully on android.

    @serhiy-storchaka
    Copy link
    Member

    serhiy-storchaka commented May 5, 2016

    The equivalent of used "tr" command is .upper(), not .swapcase().

    Instead of the loop

        for s in sys.stdin.read(): sys.stdout.write(s.upper())

    you can write just

    sys.stdout.write(sys.stdin.read().upper())
    

    But actually the loop is needed for testing purpose.

        while True:
            b = sys.stdin.buffer.read(1)
            if not b:
                break
            sys.stdout.buffer.write(b.upper())

    And sys.executable should be escaped for the case of spaces or other special symbols in the path.

    All this complicates tests too much. I prefer to skip some tests on Android.

    @xdegaye
    Copy link
    Mannequin Author

    xdegaye mannequin commented May 5, 2016

    I agree with not complicating tests too much.

    For the record, the pipes test suite coverage is very low and the code paths that lead to invocations of os.popen() in the pipes module are not tested when those three tests are skipped.

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    build The build process and cross-build stdlib Python modules in the Lib dir type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant