Skip to content

Commit

Permalink
scripts: ci: Fix for compliance with multi-user machine
Browse files Browse the repository at this point in the history
If in a server multiple users are running compliance then it throws
errors as the filename "Kconfig.modules" and "Kconfig.dts" is owned by
someone else.

Fix this by creating a randomized Kconfig file and delete after use.

Signed-off-by: Krishna T <[email protected]>
  • Loading branch information
Krishna T authored and carlescufi committed Oct 26, 2023
1 parent 55918e7 commit 85e3a4c
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions scripts/ci/check_compliance.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import tempfile
import traceback
import shlex
import shutil

from yamllint import config, linter

Expand Down Expand Up @@ -356,6 +357,8 @@ def parse_kconfig(self):
if not os.path.exists(kconfig_path):
self.error(kconfig_path + " not found")

kconfiglib_dir = tempfile.mkdtemp(prefix="kconfiglib_")

sys.path.insert(0, kconfig_path)
# Import globally so that e.g. kconfiglib.Symbol can be referenced in
# tests
Expand All @@ -370,7 +373,7 @@ def parse_kconfig(self):
os.environ["ARCH_DIR"] = "arch/"
os.environ["BOARD_DIR"] = "boards/*/*"
os.environ["ARCH"] = "*"
os.environ["KCONFIG_BINARY_DIR"] = tempfile.gettempdir()
os.environ["KCONFIG_BINARY_DIR"] = kconfiglib_dir
os.environ['DEVICETREE_CONF'] = "dummy"
os.environ['TOOLCHAIN_HAS_NEWLIB'] = "y"

Expand All @@ -379,10 +382,9 @@ def parse_kconfig(self):
os.environ["GENERATED_DTS_BOARD_CONF"] = "dummy"

# For multi repo support
self.get_modules(os.path.join(tempfile.gettempdir(), "Kconfig.modules"))

self.get_modules(os.path.join(kconfiglib_dir, "Kconfig.modules"))
# For Kconfig.dts support
self.get_kconfig_dts(os.path.join(tempfile.gettempdir(), "Kconfig.dts"))
self.get_kconfig_dts(os.path.join(kconfiglib_dir, "Kconfig.dts"))

# Tells Kconfiglib to generate warnings for all references to undefined
# symbols within Kconfig files
Expand All @@ -397,6 +399,9 @@ def parse_kconfig(self):
except kconfiglib.KconfigError as e:
self.failure(str(e))
raise EndTest
finally:
# Clean up the temporary directory
shutil.rmtree(kconfiglib_dir)

def get_defined_syms(self, kconf):
# Returns a set() with the names of all defined Kconfig symbols (with no
Expand Down

0 comments on commit 85e3a4c

Please sign in to comment.