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

add test for easyconfig file permissions #18647

Merged
merged 1 commit into from
Sep 4, 2023
Merged
Changes from all commits
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
24 changes: 24 additions & 0 deletions test/easyconfigs/easyconfigs.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
import os
import re
import shutil
import stat
import sys
import tempfile
from collections import defaultdict
Expand Down Expand Up @@ -1226,6 +1227,29 @@ def check_https_url(http_url):
if failing_checks:
self.fail('\n'.join(failing_checks))

@skip_if_not_pr_to_non_main_branch()
def test_ec_file_permissions(self):
"""Make sure correct access rights are set for easyconfigs."""

failing_checks = []
for ec in self.changed_ecs:
ec_fn = os.path.basename(ec.path)
st = os.stat(ec.path)
read_perms = stat.S_IRUSR | stat.S_IRGRP | stat.S_IROTH
exec_perms = stat.S_IXUSR | stat.S_IXGRP | stat.S_IXOTH
wrong_perms = []
if (st.st_mode & read_perms) != read_perms:
wrong_perms.append("readable (owner, group, other)")
if st.st_mode & exec_perms:
wrong_perms.append("not executable")
if not (st.st_mode & stat.S_IWUSR):
wrong_perms.append("at least owner writable")
if wrong_perms:
failing_checks.append("%s must be %s, is: %s" % (ec_fn, ", ".join(wrong_perms), oct(st.st_mode)))

if failing_checks:
self.fail('\n'.join(failing_checks))

@skip_if_not_pr_to_non_main_branch()
def test_pr_CMAKE_BUILD_TYPE(self):
"""Make sure -DCMAKE_BUILD_TYPE is no longer used (replaced by build_type)"""
Expand Down