Skip to content

bpo-31904: Fix test_getcwd_long_path failures for VxWorks RTOS #20256

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

Merged
merged 4 commits into from
Nov 28, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion Lib/test/test_os.py
Original file line number Diff line number Diff line change
Expand Up @@ -102,7 +102,12 @@ def test_getcwd_long_path(self):
# On Windows, the test can stop when trying to create a path longer
# than MAX_PATH if long paths support is disabled:
# see RtlAreLongPathsEnabled().
min_len = 2000 # characters
#
# On VxWorks, PATH_MAX is defined as 1024 bytes.
if sys.platform == 'vxworks':
min_len = 1000
else:
min_len = 2000 # characters
dirlen = 200 # characters
dirname = 'python_test_dir_'
dirname = dirname + ('a' * (dirlen - len(dirname)))
Expand Down
14 changes: 10 additions & 4 deletions Lib/test/test_posix.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,12 @@ def _supports_sched():
return False
return True

def _supports_shell():
if sys.platform == "vxworks":
return False
else:
return True

requires_sched = unittest.skipUnless(_supports_sched(), 'requires POSIX scheduler API')


Expand Down Expand Up @@ -1028,7 +1034,7 @@ def test_getgrouplist(self):
self.assertIn(group, posix.getgrouplist(user, group))


@unittest.skipUnless(hasattr(os, 'getegid'), "test needs os.getegid()")
@unittest.skipUnless(_supports_shell() and hasattr(os, 'getegid'), "test needs shell support and os.getegid()")
def test_getgroups(self):
with os.popen('id -G 2>/dev/null') as idg:
groups = idg.read().strip()
Expand Down Expand Up @@ -1078,7 +1084,7 @@ def test_chmod_dir_fd(self):
finally:
posix.close(f)

@unittest.skipUnless(os.chown in os.supports_dir_fd, "test needs dir_fd support in os.chown()")
@unittest.skipUnless(hasattr(os, 'chown') and (os.chown in os.supports_dir_fd), "test needs dir_fd support in os.chown()")
def test_chown_dir_fd(self):
support.unlink(support.TESTFN)
support.create_empty_file(support.TESTFN)
Expand Down Expand Up @@ -1166,7 +1172,7 @@ def test_mkdir_dir_fd(self):
posix.close(f)
support.rmtree(support.TESTFN + 'dir')

@unittest.skipUnless((os.mknod in os.supports_dir_fd) and hasattr(stat, 'S_IFIFO'),
@unittest.skipUnless(hasattr(os, 'mknod') and (os.mknod in os.supports_dir_fd) and hasattr(stat, 'S_IFIFO'),
"test requires both stat.S_IFIFO and dir_fd support for os.mknod()")
def test_mknod_dir_fd(self):
# Test using mknodat() to create a FIFO (the only use specified
Expand Down Expand Up @@ -1199,7 +1205,7 @@ def test_open_dir_fd(self):
posix.close(a)
posix.close(b)

@unittest.skipUnless(os.readlink in os.supports_dir_fd, "test needs dir_fd support in os.readlink()")
@unittest.skipUnless(hasattr(os, 'readlink') and (os.readlink in os.supports_dir_fd), "test needs dir_fd support in os.readlink()")
def test_readlink_dir_fd(self):
os.symlink(support.TESTFN, support.TESTFN + 'link')
f = posix.open(posix.getcwd(), posix.O_RDONLY)
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix os module failures for VxWorks RTOS.
2 changes: 2 additions & 0 deletions Modules/posixmodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -12540,6 +12540,8 @@ os_cpu_count_impl(PyObject *module)
ncpu = mpctl(MPC_GETNUMSPUS, NULL, NULL);
#elif defined(HAVE_SYSCONF) && defined(_SC_NPROCESSORS_ONLN)
ncpu = sysconf(_SC_NPROCESSORS_ONLN);
#elif defined(__VXWORKS__)
ncpu = __builtin_popcount(vxCpuEnabledGet());
#elif defined(__DragonFly__) || \
defined(__OpenBSD__) || \
defined(__FreeBSD__) || \
Expand Down