Skip to content

Commit

Permalink
Add test for EC file permissions (#18647)
Browse files Browse the repository at this point in the history
  • Loading branch information
Flamefire authored Sep 4, 2023
1 parent 4fb424a commit 8c6a7da
Showing 1 changed file with 24 additions and 0 deletions.
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

0 comments on commit 8c6a7da

Please sign in to comment.