From 8ad96fda2fc043a8646e037eb4ca44ef96b7979e Mon Sep 17 00:00:00 2001 From: Marek Materzok Date: Tue, 2 Apr 2024 16:06:43 +0200 Subject: [PATCH 1/2] Cache cocotb-config --- test/regression/cocotb/cocotb-config | 20 ++++++++++++++++++++ test/regression/test_regression.py | 5 ++++- 2 files changed, 24 insertions(+), 1 deletion(-) create mode 100755 test/regression/cocotb/cocotb-config diff --git a/test/regression/cocotb/cocotb-config b/test/regression/cocotb/cocotb-config new file mode 100755 index 000000000..232b51b7a --- /dev/null +++ b/test/regression/cocotb/cocotb-config @@ -0,0 +1,20 @@ +#!/bin/bash + +if [ ! -f "cocotb-config.cache" ]; then + cocotb-config --python-bin >> cocotb-config.cache + cocotb-config --prefix >> cocotb-config.cache + cocotb-config --makefiles >> cocotb-config.cache + cocotb-config --lib-dir >> cocotb-config.cache + cocotb-config --libpython >> cocotb-config.cache +fi + +case $1 in + "--python-bin") N=1 ;; + "--prefix") N=2 ;; + "--makefiles") N=3 ;; + "--lib-dir") N=4 ;; + "--libpython") N=5 ;; +esac + +sed "${N}q;d" cocotb-config.cache + diff --git a/test/regression/test_regression.py b/test/regression/test_regression.py index 88fc538f1..b28329ec5 100644 --- a/test/regression/test_regression.py +++ b/test/regression/test_regression.py @@ -73,7 +73,10 @@ def regression_body_with_cocotb(test_name: str, traces: bool): if traces: arglist += ["TRACES=1"] - res = subprocess.run(arglist) + my_env = dict(os.environ) + my_env["PATH"] = os.path.join(os.getcwd(), "test/regression/cocotb") + ":" + my_env["PATH"] + + res = subprocess.run(arglist, env=my_env) assert res.returncode == 0 From 8d2b39d70734a4af56a0dbbcd9e2d11169452675 Mon Sep 17 00:00:00 2001 From: Marek Materzok Date: Tue, 2 Apr 2024 16:22:11 +0200 Subject: [PATCH 2/2] Fix self-reference issue --- test/regression/cocotb/cocotb-config | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/test/regression/cocotb/cocotb-config b/test/regression/cocotb/cocotb-config index 232b51b7a..a0c674f1c 100755 --- a/test/regression/cocotb/cocotb-config +++ b/test/regression/cocotb/cocotb-config @@ -1,11 +1,13 @@ #!/bin/bash +COCOTB_CONFIG=`which -a cocotb-config | tail -n 1` + if [ ! -f "cocotb-config.cache" ]; then - cocotb-config --python-bin >> cocotb-config.cache - cocotb-config --prefix >> cocotb-config.cache - cocotb-config --makefiles >> cocotb-config.cache - cocotb-config --lib-dir >> cocotb-config.cache - cocotb-config --libpython >> cocotb-config.cache + $COCOTB_CONFIG --python-bin >> cocotb-config.cache + $COCOTB_CONFIG --prefix >> cocotb-config.cache + $COCOTB_CONFIG --makefiles >> cocotb-config.cache + $COCOTB_CONFIG --lib-dir >> cocotb-config.cache + $COCOTB_CONFIG --libpython >> cocotb-config.cache fi case $1 in