Skip to content
This repository was archived by the owner on Apr 6, 2022. It is now read-only.

Commit 640744b

Browse files
ulfalizergalak
authored andcommitted
check_compliance: Run the dtlib and edtlib test suites in CI
zephyrproject-rtos/zephyr#17660 must go in before this will work. Piggyback a clarification re. ZEPHYR_BASE being None when not running on a Zephyr tree (e.g. when running on the ci-tools repo itself). Signed-off-by: Ulf Magnusson <[email protected]>
1 parent d56f2dd commit 640744b

File tree

1 file changed

+39
-0
lines changed

1 file changed

+39
-0
lines changed

scripts/check_compliance.py

+39
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,9 @@ def git(*args):
4444
return sh.git(*args, _tty_out=False, _cwd=os.getcwd())
4545

4646

47+
# This ends up as None when we're not running in a Zephyr tree
4748
ZEPHYR_BASE = os.environ.get('ZEPHYR_BASE')
49+
4850
# The absolute path of the top-level git directory
4951
GIT_TOP = git("rev-parse", "--show-toplevel").strip()
5052

@@ -454,6 +456,43 @@ def check_no_undef_outside_kconfig(self, kconf):
454456
}
455457

456458

459+
class DeviceTreeCheck(ComplianceTest):
460+
"""
461+
Runs the dtlib and edtlib test suites in scripts/dts/.
462+
"""
463+
_name = "Device tree"
464+
_doc = "https://docs.zephyrproject.org/latest/guides/dts/index.html"
465+
466+
def run(self):
467+
self.prepare(ZEPHYR_BASE)
468+
if not ZEPHYR_BASE:
469+
self.skip("Not a Zephyr tree (ZEPHYR_BASE unset)")
470+
471+
scripts_path = os.path.join(ZEPHYR_BASE, "scripts", "dts")
472+
473+
sys.path.insert(0, scripts_path)
474+
import testdtlib
475+
import testedtlib
476+
477+
# Hack: The test suites expect to be run from the scripts/dts
478+
# directory, because they compare repr() output that contains relative
479+
# paths against an expected string. Temporarily change the working
480+
# directory to scripts/dts/.
481+
#
482+
# Warning: This is not thread-safe, though the test suites run in a
483+
# fraction of a second.
484+
old_dir = os.getcwd()
485+
os.chdir(scripts_path)
486+
try:
487+
testdtlib.run()
488+
testedtlib.run()
489+
except Exception as e:
490+
self.add_failure(str(e))
491+
finally:
492+
# Restore working directory
493+
os.chdir(old_dir)
494+
495+
457496
class Codeowners(ComplianceTest):
458497
"""
459498
Check if added files have an owner.

0 commit comments

Comments
 (0)