* Re: [Devel] [PATCH vz10] selftests/damon: add script dir to sys.path for PYTHONSAFEPATH compatibility [not found] ` <4492431c-87f8-4de6-9221-4e57107113bc@virtuozzo.com> @ 2026-08-19 14:12 ` Konstantin Khorenko 0 siblings, 0 replies; 2+ messages in thread From: Konstantin Khorenko @ 2026-08-19 14:12 UTC (permalink / raw) On 6/26/26 16:28, Pavel Tikhomirov wrote: > On 6/26/26 13:34, Eva Kurchatova wrote: >> The RHEL10 import (commit 9f055df11343) changed the Python shebang from >> '#!/usr/bin/python3 -s' to '#!/usr/bin/python3 -sP'. The -P flag enables >> Python's safe path mode (PYTHONSAFEPATH, added in Python 3.11), which >> prevents prepending the script's directory to sys.path. >> >> This breaks all 7 DAMON Python selftests that import the _damon_sysfs >> helper module located in the same directory: >> >> ModuleNotFoundError: No module named '_damon_sysfs' >> >> Fix this by explicitly adding the script's directory to sys.path before >> importing _damon_sysfs, following the same pattern used in commit >> c3b3eb565bd7 ("tools: ynl: add script dir to sys.path") which fixed the >> identical issue for the YNL tools. >> >> Fixes: 9f055df11343 ("rh10: import RHEL10 kernel-6.12.0-211.16.1.el10") >> Signed-off-by: Eva Kurchatova <eva.kurchatova@virtuozzo.com> > > There is no -sP in mainstream so this test is not meant to be run with those > flags, we should either avoid running this test or just remove the flags. Well, i have to disagree here. Yes, mainstream does not have -sP option at the moment, at the same time they have already accepted the patch c3b3eb565bd7 ("tools: ynl: add script dir to sys.path") which fixes for example tools/net/ynl/pyynl/cli.py (the files was moved later here) which also lacks -sP python option, but still ther argument >>>>>>>> Python options like PYTHONSAFEPATH or -P [1] do not add script directory to PYTHONPATH. ynl depends on this path to build and run. [1] This option is default for Fedora rpmbuild since introduction of https://fedoraproject.org/wiki/Changes/PythonSafePath <<<<<<<< worked fine. So i think that will be a direction in ms. Currently RHEL10 kernel has ~120 files with "python -sP". > >> >> https://virtuozzo.atlassian.net/browse/VSTOR-132453 >> Feature: fix selftests >> >> --- >> tools/testing/selftests/damon/damon_nr_regions.py | 3 +++ >> tools/testing/selftests/damon/damos_apply_interval.py | 3 +++ >> tools/testing/selftests/damon/damos_quota.py | 3 +++ >> tools/testing/selftests/damon/damos_quota_goal.py | 3 +++ >> tools/testing/selftests/damon/damos_tried_regions.py | 3 +++ >> .../selftests/damon/sysfs_update_schemes_tried_regions_hang.py | 3 +++ >> .../damon/sysfs_update_schemes_tried_regions_wss_estimation.py | 3 +++ >> 7 files changed, 21 insertions(+) >> >> diff --git a/tools/testing/selftests/damon/damon_nr_regions.py b/tools/testing/selftests/damon/damon_nr_regions.py >> index cb31cd140d22..8d0a352f7e85 100755 >> --- a/tools/testing/selftests/damon/damon_nr_regions.py >> +++ b/tools/testing/selftests/damon/damon_nr_regions.py >> @@ -1,9 +1,12 @@ >> #! /usr/bin/python3 -sP >> # SPDX-License-Identifier: GPL-2.0 >> >> +import os >> import subprocess >> +import sys >> import time >> >> +sys.path.append(os.path.dirname(os.path.abspath(__file__))) >> import _damon_sysfs >> >> def test_nr_regions(real_nr_regions, min_nr_regions, max_nr_regions): >> diff --git a/tools/testing/selftests/damon/damos_apply_interval.py b/tools/testing/selftests/damon/damos_apply_interval.py >> index e81de3c06a8d..b1d78397bc41 100755 >> --- a/tools/testing/selftests/damon/damos_apply_interval.py >> +++ b/tools/testing/selftests/damon/damos_apply_interval.py >> @@ -1,9 +1,12 @@ >> #! /usr/bin/python3 -sP >> # SPDX-License-Identifier: GPL-2.0 >> >> +import os >> import subprocess >> +import sys >> import time >> >> +sys.path.append(os.path.dirname(os.path.abspath(__file__))) >> import _damon_sysfs >> >> def main(): >> diff --git a/tools/testing/selftests/damon/damos_quota.py b/tools/testing/selftests/damon/damos_quota.py >> index 7498b9472e9f..45b8b17f940a 100755 >> --- a/tools/testing/selftests/damon/damos_quota.py >> +++ b/tools/testing/selftests/damon/damos_quota.py >> @@ -1,9 +1,12 @@ >> #! /usr/bin/python3 -sP >> # SPDX-License-Identifier: GPL-2.0 >> >> +import os >> import subprocess >> +import sys >> import time >> >> +sys.path.append(os.path.dirname(os.path.abspath(__file__))) >> import _damon_sysfs >> >> def main(): >> diff --git a/tools/testing/selftests/damon/damos_quota_goal.py b/tools/testing/selftests/damon/damos_quota_goal.py >> index da43f69ed30d..a2d3abd780ae 100755 >> --- a/tools/testing/selftests/damon/damos_quota_goal.py >> +++ b/tools/testing/selftests/damon/damos_quota_goal.py >> @@ -1,9 +1,12 @@ >> #! /usr/bin/python3 -sP >> # SPDX-License-Identifier: GPL-2.0 >> >> +import os >> import subprocess >> +import sys >> import time >> >> +sys.path.append(os.path.dirname(os.path.abspath(__file__))) >> import _damon_sysfs >> >> def main(): >> diff --git a/tools/testing/selftests/damon/damos_tried_regions.py b/tools/testing/selftests/damon/damos_tried_regions.py >> index 7d1a44dbbe3d..188097475aa4 100755 >> --- a/tools/testing/selftests/damon/damos_tried_regions.py >> +++ b/tools/testing/selftests/damon/damos_tried_regions.py >> @@ -1,9 +1,12 @@ >> #! /usr/bin/python3 -sP >> # SPDX-License-Identifier: GPL-2.0 >> >> +import os >> import subprocess >> +import sys >> import time >> >> +sys.path.append(os.path.dirname(os.path.abspath(__file__))) >> import _damon_sysfs >> >> def main(): >> diff --git a/tools/testing/selftests/damon/sysfs_update_schemes_tried_regions_hang.py b/tools/testing/selftests/damon/sysfs_update_schemes_tried_regions_hang.py >> index 1ae639549f6d..b0710fb371f1 100755 >> --- a/tools/testing/selftests/damon/sysfs_update_schemes_tried_regions_hang.py >> +++ b/tools/testing/selftests/damon/sysfs_update_schemes_tried_regions_hang.py >> @@ -1,9 +1,12 @@ >> #! /usr/bin/python3 -sP >> # SPDX-License-Identifier: GPL-2.0 >> >> +import os >> import subprocess >> +import sys >> import time >> >> +sys.path.append(os.path.dirname(os.path.abspath(__file__))) >> import _damon_sysfs >> >> def main(): >> diff --git a/tools/testing/selftests/damon/sysfs_update_schemes_tried_regions_wss_estimation.py b/tools/testing/selftests/damon/sysfs_update_schemes_tried_regions_wss_estimation.py >> index b7d35ca4c129..cd8d901b8263 100755 >> --- a/tools/testing/selftests/damon/sysfs_update_schemes_tried_regions_wss_estimation.py >> +++ b/tools/testing/selftests/damon/sysfs_update_schemes_tried_regions_wss_estimation.py >> @@ -1,9 +1,12 @@ >> #! /usr/bin/python3 -sP >> # SPDX-License-Identifier: GPL-2.0 >> >> +import os >> import subprocess >> +import sys >> import time >> >> +sys.path.append(os.path.dirname(os.path.abspath(__file__))) >> import _damon_sysfs >> >> def main(): > ^ permalink raw reply [flat|nested] 2+ messages in thread
* [Devel] [PATCH RHEL10 COMMIT] selftests/damon: add script dir to sys.path for PYTHONSAFEPATH compatibility [not found] <20260626113435.2210877-1-eva.kurchatova@virtuozzo.com> [not found] ` <4492431c-87f8-4de6-9221-4e57107113bc@virtuozzo.com> @ 2026-08-19 14:16 ` Konstantin Khorenko 1 sibling, 0 replies; 2+ messages in thread From: Konstantin Khorenko @ 2026-08-19 14:16 UTC (permalink / raw) The commit is pushed to "branch-rh10-6.12.0-211.39.1.16.x.vz10-ovz" and will appear at git at bitbucket.org:openvz/vzkernel.git after rh10-6.12.0-211.39.1.16.6.vz10 ------> commit e6c430f5a2cc31a0244492728ab9af8d0530710a Author: Eva Kurchatova <eva.kurchatova@virtuozzo.com> Date: Fri Jun 26 14:34:27 2026 +0300 selftests/damon: add script dir to sys.path for PYTHONSAFEPATH compatibility The RHEL10 import (commit 9f055df11343) changed the Python shebang from '#!/usr/bin/python3 -s' to '#!/usr/bin/python3 -sP'. The -P flag enables Python's safe path mode (PYTHONSAFEPATH, added in Python 3.11), which prevents prepending the script's directory to sys.path. This breaks all 7 DAMON Python selftests that import the _damon_sysfs helper module located in the same directory: ModuleNotFoundError: No module named '_damon_sysfs' Fix this by explicitly adding the script's directory to sys.path before importing _damon_sysfs, following the same pattern used in commit c3b3eb565bd7 ("tools: ynl: add script dir to sys.path") which fixed the identical issue for the YNL tools. Note: CentOS 10 Stream git does NOT have "-sP" due to some reason [1]. [1] https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-10/-/blob/main/tools/testing/selftests/damon/damon_nr_regions.py Fixes: 9f055df11343 ("rh10: import RHEL10 kernel-6.12.0-211.16.1.el10") https://virtuozzo.atlassian.net/browse/VSTOR-132453 Feature: fix selftests Signed-off-by: Eva Kurchatova <eva.kurchatova@virtuozzo.com> Acked-by: Konstantin Khorenko <khorenko@virtuozzo.com> --- tools/testing/selftests/damon/damon_nr_regions.py | 3 +++ tools/testing/selftests/damon/damos_apply_interval.py | 3 +++ tools/testing/selftests/damon/damos_quota.py | 3 +++ tools/testing/selftests/damon/damos_quota_goal.py | 3 +++ tools/testing/selftests/damon/damos_tried_regions.py | 3 +++ .../testing/selftests/damon/sysfs_update_schemes_tried_regions_hang.py | 3 +++ .../damon/sysfs_update_schemes_tried_regions_wss_estimation.py | 3 +++ 7 files changed, 21 insertions(+) diff --git a/tools/testing/selftests/damon/damon_nr_regions.py b/tools/testing/selftests/damon/damon_nr_regions.py index cb31cd140d220..8d0a352f7e85c 100755 --- a/tools/testing/selftests/damon/damon_nr_regions.py +++ b/tools/testing/selftests/damon/damon_nr_regions.py @@ -1,9 +1,12 @@ #! /usr/bin/python3 -sP # SPDX-License-Identifier: GPL-2.0 +import os import subprocess +import sys import time +sys.path.append(os.path.dirname(os.path.abspath(__file__))) import _damon_sysfs def test_nr_regions(real_nr_regions, min_nr_regions, max_nr_regions): diff --git a/tools/testing/selftests/damon/damos_apply_interval.py b/tools/testing/selftests/damon/damos_apply_interval.py index e81de3c06a8d2..b1d78397bc41d 100755 --- a/tools/testing/selftests/damon/damos_apply_interval.py +++ b/tools/testing/selftests/damon/damos_apply_interval.py @@ -1,9 +1,12 @@ #! /usr/bin/python3 -sP # SPDX-License-Identifier: GPL-2.0 +import os import subprocess +import sys import time +sys.path.append(os.path.dirname(os.path.abspath(__file__))) import _damon_sysfs def main(): diff --git a/tools/testing/selftests/damon/damos_quota.py b/tools/testing/selftests/damon/damos_quota.py index 7498b9472e9f7..45b8b17f940a0 100755 --- a/tools/testing/selftests/damon/damos_quota.py +++ b/tools/testing/selftests/damon/damos_quota.py @@ -1,9 +1,12 @@ #! /usr/bin/python3 -sP # SPDX-License-Identifier: GPL-2.0 +import os import subprocess +import sys import time +sys.path.append(os.path.dirname(os.path.abspath(__file__))) import _damon_sysfs def main(): diff --git a/tools/testing/selftests/damon/damos_quota_goal.py b/tools/testing/selftests/damon/damos_quota_goal.py index da43f69ed30db..a2d3abd780aeb 100755 --- a/tools/testing/selftests/damon/damos_quota_goal.py +++ b/tools/testing/selftests/damon/damos_quota_goal.py @@ -1,9 +1,12 @@ #! /usr/bin/python3 -sP # SPDX-License-Identifier: GPL-2.0 +import os import subprocess +import sys import time +sys.path.append(os.path.dirname(os.path.abspath(__file__))) import _damon_sysfs def main(): diff --git a/tools/testing/selftests/damon/damos_tried_regions.py b/tools/testing/selftests/damon/damos_tried_regions.py index 7d1a44dbbe3df..188097475aa41 100755 --- a/tools/testing/selftests/damon/damos_tried_regions.py +++ b/tools/testing/selftests/damon/damos_tried_regions.py @@ -1,9 +1,12 @@ #! /usr/bin/python3 -sP # SPDX-License-Identifier: GPL-2.0 +import os import subprocess +import sys import time +sys.path.append(os.path.dirname(os.path.abspath(__file__))) import _damon_sysfs def main(): diff --git a/tools/testing/selftests/damon/sysfs_update_schemes_tried_regions_hang.py b/tools/testing/selftests/damon/sysfs_update_schemes_tried_regions_hang.py index 1ae639549f6de..b0710fb371f14 100755 --- a/tools/testing/selftests/damon/sysfs_update_schemes_tried_regions_hang.py +++ b/tools/testing/selftests/damon/sysfs_update_schemes_tried_regions_hang.py @@ -1,9 +1,12 @@ #! /usr/bin/python3 -sP # SPDX-License-Identifier: GPL-2.0 +import os import subprocess +import sys import time +sys.path.append(os.path.dirname(os.path.abspath(__file__))) import _damon_sysfs def main(): diff --git a/tools/testing/selftests/damon/sysfs_update_schemes_tried_regions_wss_estimation.py b/tools/testing/selftests/damon/sysfs_update_schemes_tried_regions_wss_estimation.py index b7d35ca4c129a..cd8d901b8263b 100755 --- a/tools/testing/selftests/damon/sysfs_update_schemes_tried_regions_wss_estimation.py +++ b/tools/testing/selftests/damon/sysfs_update_schemes_tried_regions_wss_estimation.py @@ -1,9 +1,12 @@ #! /usr/bin/python3 -sP # SPDX-License-Identifier: GPL-2.0 +import os import subprocess +import sys import time +sys.path.append(os.path.dirname(os.path.abspath(__file__))) import _damon_sysfs def main(): ^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2026-08-19 14:16 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
[not found] <20260626113435.2210877-1-eva.kurchatova@virtuozzo.com>
[not found] ` <4492431c-87f8-4de6-9221-4e57107113bc@virtuozzo.com>
2026-08-19 14:12 ` [Devel] [PATCH vz10] selftests/damon: add script dir to sys.path for PYTHONSAFEPATH compatibility Konstantin Khorenko
2026-08-19 14:16 ` [Devel] [PATCH RHEL10 COMMIT] " Konstantin Khorenko
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.