Commit graph

580 commits

Author SHA1 Message Date
Hood Chatham
f4911258a8
gh-127146: Skip test_os.test_mode for Emscripten (#135764)
Temporarily skip test_os.test_mode on Emscripten; this fails consistently
on the buildbot, but not on other test configurations. Reported as #135783 
for follow up.
2025-06-21 06:06:59 +00:00
Victor Stinner
5c25c884b9
gh-126112: Fix test_os.TimerfdTests: use 10 ms resolution (#135681)
Use 10 ms for CLOCK_RES instead of 100 ms to tolerate slow buildbots.
2025-06-19 11:40:40 +02:00
Serhiy Storchaka
2602d8ae98
gh-71339: Use new assertion methods in tests (GH-129046) 2025-05-22 13:17:22 +03:00
R. David Murray
6146295a5b
gh-90548: Make musl test skips smarter (fixes Alpine errors) (#131313)
* Make musl test skips smarter (fixes Alpine errors)

A relatively small number of tests fail when the underlying c library is
provided by musl.  This was originally reported in bpo-46390 by
Christian Heimes.  Among other changes, these tests were marked for
skipping in gh-31947/ef1327e3 as part of bpo-40280 (emscripten support),
but the skips were conditioned on the *platform* being emscripten (or
wasi, skips for which ere added in 9b50585e02).

In gh-131071 Victor Stinner added a linked_to_musl function to enable
skipping a test in test_math that fails under musl, like it does on a
number of other platforms.  This check can successfully detect that
python is running under musl on Alpine, which was the original problem
report in bpo-46390.

This PR replaces Victor's solution with an enhancement to
platform.libc_ver that does the check more cheaply, and also gets the
version number.  The latter is important because the math test being
skipped is due to a bug in musl that has been fixed, but as of this
checkin date has not yet been released.  When it is, the test skip can
be fixed to check for the minimum needed version.

The enhanced version of linked_to_musl is also used to do the skips of
the other tests that generically fail under musl, as opposed to
emscripten or wasi only failures.  This will allow these tests to be
skipped automatically on Alpine.

This PR does *not* enhance libc_ver to support emscripten and wasi, as
I'm not familiar with those platforms; instead it returns a version
triple of (0, 0, 0) for those platforms.  This means the musl tests will
be skipped regardless of musl version, so ideally someone will add
support to libc_ver for these platforms.

* Platform tests and bug fixes.

In adding tests for the new platform code I found a bug in the old code:
if a valid version is passed for version and it is greater than the
version found for an so *and* there is no glibc version, then the
version from the argument was returned.  The code changes here fix
that.

* Add support docs, including for some preexisting is_xxx's.

* Add news item about libc_ver enhancement.

* Prettify platform re expression using re.VERBOSE.
2025-03-19 13:05:09 -04:00
Furkan Onder
8ad4646c67
gh-131263: Skip test_timerfd_negative on NetBSD to prevent system freeze (#131431) 2025-03-19 11:24:09 +00:00
Hood Chatham
789390872b
gh-127146: Skip test_readinto_non_blocking on Emscripten (#129421)
Skips an additional test due to non_blocking not working reliably on Emscripten.
2025-01-29 07:30:42 +08:00
Hood Chatham
8e57877e3f
gh-127146: Update test skips for Emscripten 4.0.1 (#129375)
Updates the Emscripten test skips to reflect recent changes in Emscripten capabilities.
2025-01-28 01:05:21 +00:00
Cody Maloney
1ed4487968
gh-129205: Add os.readinto() API for reading data into a caller provided buffer (#129211)
Add a new OS API which will read data directly into a caller provided
writeable buffer protocol object.

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: Victor Stinner <vstinner@python.org>
2025-01-26 14:21:03 +01:00
Hood Chatham
616692d465
gh-127146: Skip Emscripten tests with pending fixes (#128549)
Marks some additional tests as skipped on Emscripten. Many of these skips can be
reverted when the next Emscripten release is available.
2025-01-07 06:25:29 +08:00
Kumar Aditya
5892853fb7
gh-127949: deprecate asyncio.set_event_loop_policy (#128024)
First step towards deprecating the asyncio policy system.
This deprecates `asyncio.set_event_loop_policy` and will be removed in Python 3.16.
2024-12-18 11:35:29 +05:30
Hood Chatham
1183e4ce2f
gh-127146: Emscripten clean up test suite (#127984)
Removed test skips that are no longer required as a result of Emscripten updates.
2024-12-17 07:48:23 +00:00
Hood Chatham
41f29e5d16
gh-127146: Some expected failures in Emscripten time tests (#127843)
Disables two tests in the test_time suite, and adjusts test_os to reflect 
precision limits in Emscripten.
2024-12-12 09:11:00 +08:00
Malcolm Smith
4ca2c82862
gh-124873: Skip timerfd tests on Android (#127279)
* Revert "[3.13] gh-124873: Tolerate 100 ms in TimerfdTests on Android (GH-127101) (#127105)"

This reverts commit c09366b1fe.

* Skip timerfd tests on Android.

Co-authored-by: Victor Stinner <vstinner@python.org>
2024-11-26 09:46:46 +00:00
Victor Stinner
bab4b0462e
gh-124873: Tolerate 100 ms in TimerfdTests on Android (#127101)
On Android, TimerfdTests of test_os now uses 100 ms accuracy instead
of 10 ms.
2024-11-21 15:53:52 +01:00
Malcolm Smith
c5c9286804
gh-118201: Simplify conv_confname (#126089) 2024-11-19 10:42:19 -05:00
Michał Górny
2c0a21c1aa
gh-126909: Fix running xattr tests on systems with lower limits (#126930)
Modify the extended attribute tests to write fewer and smaller extended
attributes, in order to fit within filesystems with total xattr limit
of 1 KiB (e.g. ext4 with 1 KiB blocks).  Previously, the test would
write over 2 KiB, making it fail with ENOSPC on such systems.
2024-11-18 14:05:55 +01:00
Victor Stinner
4a0d574273
gh-120057: Add os.reload_environ() function (#126268)
Replace the os.environ.refresh() method with a new
os.reload_environ() function.

Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com>
Co-authored-by: Adam Turner <9087854+AA-Turner@users.noreply.github.com>
2024-11-05 08:43:34 +01:00
Alex Waygood
8a2baedc4b
Bump Ruff to 0.6.7 (#124384) 2024-09-23 22:19:35 +00:00
Michał Górny
342e654b8e
gh-124213: Skip tests failing inside systemd-nspawn --suppress-sync=true (#124215)
Add a helper function that checks whether the test suite is running
inside a systemd-nspawn container, and skip the few tests failing
with `--suppress-sync=true` in that case.  The tests are failing because
`--suppress-sync=true` stubs out `fsync()`, `fdatasync()` and `msync()`
calls, and therefore they always return success without checking for
invalid arguments.

Call `os.open(__file__, os.O_RDONLY | os.O_SYNC)` and check the errno to
detect whether `--suppress-sync=true` is actually used, and skip
the tests only in that scenario.
2024-09-20 13:37:49 +00:00
Serhiy Storchaka
1a0c7b9ba4
gh-121905: Consistently use "floating-point" instead of "floating point" (GH-121907) 2024-07-19 08:06:02 +00:00
Victor Stinner
7aff2de62b
gh-120057: Add os.environ.refresh() method (#120059) 2024-06-10 16:34:17 +00:00
Kirill Podoprigora
d5ba4fc9bc
gh-120164: Fix test_os.test_win32_mkdir_700() (#120177)
Don't compare the path to avoid encoding issues.

Co-authored-by: Eryk Sun <eryksun@gmail.com>
2024-06-07 11:14:13 +02:00
Barney Gale
a5fef800d3
GH-89727: Fix FD leak on os.fwalk() generator finalization. (#119766)
Follow-up to 3c890b50. Ensure we `os.close()` open file descriptors when
the `os.fwalk()` generator is finalized.
2024-05-30 03:45:47 +00:00
Barney Gale
3c890b503c
GH-89727: Fix os.fwalk() recursion error on deep trees (#119638)
Implement `os.fwalk()` using a list as a stack to avoid emitting recursion
errors on deeply nested trees.
2024-05-30 03:05:36 +00:00
Steve Dower
94591dca51
gh-118486: Simplify test_win32_mkdir_700 to check the exact ACL (GH-119056) 2024-05-15 11:59:41 +01:00
Steve Dower
82acc5f211
gh-118802: Fix ACL use in test for non-English Windows (GH-118831) 2024-05-09 13:59:18 +01:00
Steve Dower
81939dad77
gh-118486: Support mkdir(mode=0o700) on Windows (GH-118488) 2024-05-02 15:20:43 +01:00
Russell Keith-Magee
21336aa127
gh-118201: Accomodate flaky behavior of os.sysconf on iOS (GH-118453) 2024-04-30 22:31:00 -04:00
Malcolm Smith
1d3225ae05
gh-116622: Test updates for Android (#117299)
- re-enable test_fcntl_64_bit on Linux aarch64, but disable it on all
  Android ABIs
- use support.setswitchinterval in all relevant tests
- skip test_fma_zero_result on Android x86_64
- accept EACCES when calling os.get_terminal_size on Android
2024-04-05 20:57:36 +00:00
Erlend E. Aasland
ea94b3b149
gh-116303: Skip test module dependent tests if test modules are unavailable (#117341) 2024-04-03 15:11:36 +02:00
Malcolm Smith
eefff682f0
gh-108277: Make test_os tolerate 10 ms diff for timerfd on Android emulators (#117223) 2024-03-27 23:11:44 +01:00
Sam Gross
60e105c1c1
gh-113964: Don't prevent new threads until all non-daemon threads exit (#116677)
Starting in Python 3.12, we prevented calling fork() and starting new threads
during interpreter finalization (shutdown). This has led to a number of
regressions and flaky tests. We should not prevent starting new threads
(or `fork()`) until all non-daemon threads exit and finalization starts in
earnest.

This changes the checks to use `_PyInterpreterState_GetFinalizing(interp)`,
which is set immediately before terminating non-daemon threads.
2024-03-19 14:40:20 -04:00
Serhiy Storchaka
aa7bcf284f
gh-116401: Fix blocking os.fwalk() and shutil.rmtree() on opening a named pipe (GH-116421) 2024-03-13 11:40:28 +02:00
Malcolm Smith
872c0714fc
gh-71052: Change Android's sys.platform from "linux" to "android"
Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
2024-03-11 19:25:39 +00:00
Malcolm Smith
2339e7cff7
gh-116057: Use relative recursion limits when testing os.walk() and Path.walk() (#116058)
Replace test.support.set_recursion_limit with test.support.infinite_recursion.
2024-03-10 23:00:33 +01:00
Malcolm Smith
41d5391c55
gh-71052: Add test exclusions to support running the test suite on Android (#115918) 2024-02-29 22:32:50 +01:00
Brian Schubert
90dd653a61
gh-115596: Fix ProgramPriorityTests in test_os permanently changing the process priority (GH-115610) 2024-02-17 16:42:57 +00:00
Dmitry Marakasov
437924465d
Fix ProgramPriorityTests on FreeBSD with high nice value (GH-100145)
It expects priority to be capped with 19, which is the cap for Linux,
but for FreeBSD the cap is 20 and the test fails under the similar
conditions. Tweak the condition to cover FreeBSD as well.
2024-02-17 14:54:47 +00:00
Serhiy Storchaka
652fbf88c4
gh-82626: Emit a warning when bool is used as a file descriptor (GH-111275) 2024-02-05 22:51:11 +02:00
Russell Keith-Magee
391659b3da
gh-114099: Add test exclusions to support running the test suite on iOS (#114889)
Add test annotations required to run the test suite on iOS (PEP 730).

The majority of the change involve annotating tests that use subprocess,
but are skipped on Emscripten/WASI for other reasons, and including
iOS/tvOS/watchOS under the same umbrella as macOS/darwin checks.

`is_apple` and `is_apple_mobile` test helpers have been added to
identify *any* Apple platform, and "any Apple platform except macOS",
respectively.
2024-02-05 01:04:57 +01:00
Soumendra Ganguly
e351ca3c20
gh-85984: Add POSIX pseudo-terminal functions. (GH-102413)
Signed-off-by: Soumendra Ganguly <soumendraganguly@gmail.com>
Co-authored-by: Gregory P. Smith <greg@krypto.org>
Co-authored-by: Petr Viktorin <encukou@gmail.com>
2024-01-29 16:10:28 +00:00
Steve Dower
d91ddff5de
gh-114435: Allow test_stat_inaccessible_file() to have matching ino/dev (GH-114571)
This may occur if Windows allows reading stat information from a file even if the current user does not have access.
2024-01-26 17:33:44 +00:00
Steve Dower
c63c6142f9
gh-114272: Fix or skip tests that fail due to spaces in paths (GH-114451) 2024-01-25 00:38:34 +00:00
Steve Dower
ed066481c7
gh-111877: Fixes stat() handling for inaccessible files on Windows (GH-113716) 2024-01-12 15:27:56 +00:00
Victor Stinner
1d75fa43a2
gh-77046: os.pipe() sets _O_NOINHERIT flag on fds (#113817)
On Windows, set _O_NOINHERIT flag on file descriptors
created by os.pipe() and io.WindowsConsoleIO.

Add test_pipe_spawnl() to test_os.

Co-authored-by: Zackery Spytz <zspytz@gmail.com>
2024-01-10 23:02:17 +01:00
Serhiy Storchaka
c6e953be12
gh-113090: Fix test.support.os_support.can_chmod() on Windows (GH-113091) 2023-12-14 13:27:43 +02:00
Sam Gross
fdee7b7b3e
gh-112532: Require mimalloc in --disable-gil builds (gh-112883) 2023-12-12 09:04:48 +09:00
Serhiy Storchaka
0b06d2482d
gh-111841: Fix os.putenv() and os.unsetenv() with embedded NUL on Windows (GH-111842) 2023-11-10 18:42:14 +02:00
Victor Stinner
244e37b22a
gh-109649: Fix test_os.test_process_cpu_count_affinity() (#111689)
When CPUs are isolated on Linux, os.process_cpu_count() is smaller
than os.cpu_count(). Fix the test for this case.

Example with "isolcpus=5,11 rcu_nocbs=5,11" options passed to a Linux
command line to isolated two logical CPUs:

$ ./python -c 'import os; print(os.process_cpu_count(), "/", os.cpu_count())'
10 / 12
2023-11-03 23:53:18 +00:00
Victor Stinner
7b153d14ef
gh-110697: Use CLOCK_RES in test_os.TimerfdTests (#111529)
More TimerfdTests tests tolerate a difference of 1 ms in measured
elapsed time.
2023-10-30 22:47:59 +00:00