classification
Title: android: test_os fails
Type: behavior Stage: resolved
Components: Tests Versions: Python 3.7, Python 3.6
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: xdegaye Nosy List: Alex.Willmer, Chi Hsuan Yen, loewis, martin.panter, python-dev, xdegaye
Priority: normal Keywords: patch

Created on 2016-05-03 15:03 by xdegaye, last changed 2016-11-16 07:37 by xdegaye. This issue is now closed.

Files
File name Uploaded Description Edit
test_output.txt xdegaye, 2016-05-03 15:03 test results
test_urandom_fd_reopened.patch xdegaye, 2016-05-07 16:02 review
test_urandom_fd_reopened_2.patch xdegaye, 2016-11-03 10:43 review
test_urandom_fd_reopened_3.patch xdegaye, 2016-11-05 19:38 review
Messages (10)
msg264736 - (view) Author: Xavier de Gaye (xdegaye) * (Python committer) Date: 2016-05-03 15:03
One test of test_os fails on an android emulator running an x86 system image at API level 21.

See the attached test_output.txt file.
msg265074 - (view) Author: Xavier de Gaye (xdegaye) * (Python committer) Date: 2016-05-07 16:02
On android dup2() returns with an error when both fds are the same:

root@generic_x86:/data/local/tmp # python
Python 3.6.0a0 (default:811ccdee6f87+, May  7 2016, 12:44:06) 
[GCC 4.9 20140827 (prerelease)] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import os
>>> os.dup2(1, 1)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
OSError: [Errno 22] Invalid argument


The attached patch fixes this in test_urandom_fd_reopened.
msg265099 - (view) Author: Martin Panter (martin.panter) * (Python committer) Date: 2016-05-07 22:52
I think this is an Android bug. See specification <http://pubs.opengroup.org/onlinepubs/9699919799/functions/dup2.html>, fix <https://android.googlesource.com/platform/bionic/+/be52e658171edf6651895c40d1563289bafa52f7%5E!/>.

If the change is to go into Python, it would be good to include a comment admitting it is an Android workaround, rather than a general deficiency.
msg265124 - (view) Author: Xavier de Gaye (xdegaye) * (Python committer) Date: 2016-05-08 10:45
Since this seems to be fixed in a version of android that is more recent that API 21, maybe use the value of 'sdk.release' when platform.android_ver() is available after issue #26855 is fixed, with for example, if this is fixed at API 23:

    sdk_release = platform.android_ver()[1]
    if new_fd != fd or not sdk_release or sdk_release >= 23:
msg265127 - (view) Author: Martin Panter (martin.panter) * (Python committer) Date: 2016-05-08 11:05
Yes something like that should do the trick
msg265144 - (view) Author: Chi Hsuan Yen (Chi Hsuan Yen) * Date: 2016-05-08 15:06
My implementation at #26855 returns a tuple of strings like other funcitons, including java_ver() and mac_ver(). Maybe it requires a change.
msg265249 - (view) Author: Xavier de Gaye (xdegaye) * (Python committer) Date: 2016-05-10 14:47
This is fixed at API 23 (Android 6.0) and test_os runs on an android-23-x86 emulator without failures.
msg279984 - (view) Author: Xavier de Gaye (xdegaye) * (Python committer) Date: 2016-11-03 10:43
This new patch takes into account Martin comment in msg265099 and fixes a call to getpwall() as Android does not have getpwall().
msg280124 - (view) Author: Xavier de Gaye (xdegaye) * (Python committer) Date: 2016-11-05 19:38
New patch. Thanks for the review Martin!
msg280920 - (view) Author: Roundup Robot (python-dev) Date: 2016-11-16 07:07
New changeset 80e4cb5888f3 by Xavier de Gaye in branch '3.6':
Issue #26935: Fix broken Android dup2() in test_os
https://hg.python.org/cpython/rev/80e4cb5888f3

New changeset da59b7084dbe by Xavier de Gaye in branch 'default':
Issue #26935: Merge 3.6
https://hg.python.org/cpython/rev/da59b7084dbe
History
Date User Action Args
2016-11-16 07:37:17xdegayesetstatus: open -> closed
dependencies: - android: add platform.android_ver()
resolution: fixed
stage: commit review -> resolved
2016-11-16 07:07:09python-devsetnosy: + python-dev
messages: + msg280920
2016-11-05 19:38:46xdegayesetfiles: + test_urandom_fd_reopened_3.patch

messages: + msg280124
2016-11-03 10:43:39xdegayesetfiles: + test_urandom_fd_reopened_2.patch
versions: + Python 3.7
messages: + msg279984

assignee: xdegaye
stage: patch review -> commit review
2016-05-21 07:06:39xdegayelinkissue26865 dependencies
2016-05-10 14:47:34xdegayesetmessages: + msg265249
2016-05-08 15:06:14Chi Hsuan Yensetnosy: + Chi Hsuan Yen
messages: + msg265144
2016-05-08 11:05:21martin.pantersetdependencies: + android: add platform.android_ver()
messages: + msg265127
components: + Tests, - Library (Lib), Cross-Build
2016-05-08 10:45:19xdegayesetmessages: + msg265124
2016-05-07 22:52:37martin.pantersetnosy: + martin.panter

messages: + msg265099
stage: patch review
2016-05-07 16:02:44xdegayesetfiles: + test_urandom_fd_reopened.patch
keywords: + patch
messages: + msg265074
2016-05-03 15:03:20xdegayecreate