From 44e18bf3bca1b72091aee14b7edbf18858e2ec13 Mon Sep 17 00:00:00 2001 From: Jan Matyas Date: Sun, 27 Dec 2020 14:02:51 +0100 Subject: [PATCH 01/39] Dummy action - test Change-Id: I2284f153af3094272bdb2d7045897f35644832b7 --- .github/workflows/riscv-openocd-ci.yml | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 .github/workflows/riscv-openocd-ci.yml diff --git a/.github/workflows/riscv-openocd-ci.yml b/.github/workflows/riscv-openocd-ci.yml new file mode 100644 index 0000000000..204638e577 --- /dev/null +++ b/.github/workflows/riscv-openocd-ci.yml @@ -0,0 +1,15 @@ +name: riscv-openocd-ci +on: [push] +jobs: + run-riscv-tests: + runs-on: ubuntu-2004 + steps: + - name: Dummy step 1 + run: true + - name: Dummy step 2 + run: ls -l + - name: Checkout OpenOCD + uses: actions/checkout@v2 + - name: Dummy step 3 + run: ls -l + From 39b1b40cf4fbf607faba50bed639301cd5d73a21 Mon Sep 17 00:00:00 2001 From: Jan Matyas Date: Sun, 27 Dec 2020 14:08:52 +0100 Subject: [PATCH 02/39] WIP 2 Change-Id: Ie9e11db6aa59376027f239e4c1a4f71a84334a25 --- .github/workflows/riscv-openocd-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/riscv-openocd-ci.yml b/.github/workflows/riscv-openocd-ci.yml index 204638e577..198be1597b 100644 --- a/.github/workflows/riscv-openocd-ci.yml +++ b/.github/workflows/riscv-openocd-ci.yml @@ -2,7 +2,7 @@ name: riscv-openocd-ci on: [push] jobs: run-riscv-tests: - runs-on: ubuntu-2004 + runs-on: ubuntu-20.04 steps: - name: Dummy step 1 run: true From 0434774610badb5998c643f371eba1b7c28dff2d Mon Sep 17 00:00:00 2001 From: Jan Matyas Date: Sun, 27 Dec 2020 14:18:35 +0100 Subject: [PATCH 03/39] WIP 3 Change-Id: Ia78859f85a1b03bdd1987923571754156dedf2d2 --- .github/workflows/riscv-openocd-ci.yml | 11 +- riscv-openocd-ci/build_openocd.py | 93 ++++++++++++ riscv-openocd-ci/build_spike.py | 77 ++++++++++ riscv-openocd-ci/utils/__init__.py | 0 .../utils/__pycache__/__init__.cpython-37.pyc | Bin 0 -> 139 bytes .../utils/__pycache__/utils.cpython-37.pyc | Bin 0 -> 4449 bytes riscv-openocd-ci/utils/utils.py | 143 ++++++++++++++++++ 7 files changed, 317 insertions(+), 7 deletions(-) create mode 100644 riscv-openocd-ci/build_openocd.py create mode 100644 riscv-openocd-ci/build_spike.py create mode 100644 riscv-openocd-ci/utils/__init__.py create mode 100644 riscv-openocd-ci/utils/__pycache__/__init__.cpython-37.pyc create mode 100644 riscv-openocd-ci/utils/__pycache__/utils.cpython-37.pyc create mode 100644 riscv-openocd-ci/utils/utils.py diff --git a/.github/workflows/riscv-openocd-ci.yml b/.github/workflows/riscv-openocd-ci.yml index 198be1597b..d647d9396d 100644 --- a/.github/workflows/riscv-openocd-ci.yml +++ b/.github/workflows/riscv-openocd-ci.yml @@ -4,12 +4,9 @@ jobs: run-riscv-tests: runs-on: ubuntu-20.04 steps: - - name: Dummy step 1 - run: true - - name: Dummy step 2 - run: ls -l - name: Checkout OpenOCD uses: actions/checkout@v2 - - name: Dummy step 3 - run: ls -l - + - name: Build OpenOCD + run: | + cd riscv-openocd-ci + python3 build_openocd.py --src-dir ../ --install-dir install/ diff --git a/riscv-openocd-ci/build_openocd.py b/riscv-openocd-ci/build_openocd.py new file mode 100644 index 0000000000..973151f133 --- /dev/null +++ b/riscv-openocd-ci/build_openocd.py @@ -0,0 +1,93 @@ + + +import logging +from logging import info +from multiprocessing import cpu_count +import os +import sys +from utils.utils import MeasureTime, ChangeWorkdir, run_cmd, info_box, git_apply_patch, git_revision_info, \ + check_file_exists, check_dir_exists + + +def parse_args(): + import argparse + parser = argparse.ArgumentParser("Build OpenOCD from local (checked-out) source") + parser.add_argument("--src-dir", required=True, help="Directory where OpenOCD source code is located") + parser.add_argument("--install-dir", required=True, help="Directory where to install OpenOCD after the build") + parser.add_argument("--coverage", action="store_true", default=False, + help="Compile OpenOCD with support for code coverage collection (using gcov)") + return parser.parse_args() + + +def print_openocd_rev(src_dir): + rev = git_revision_info(src_dir) + info_box("OpenOCD revision") + info("Commit ID: {}".format(rev["hash"])) + info("Subject: {}".format(rev["subject"])) + info("Author: {}".format(rev["author"])) + info("Author date: {}".format(rev["author_date"])) + info("Commit date: {}".format(rev["commit_date"])) + + +def build_openocd(src_dir, install_dir, with_coverage=False): + check_dir_exists(src_dir) + with ChangeWorkdir(src_dir): + info_box("Bootstrapping OpenOCD ...") + run_cmd(["bash", "./bootstrap"]) + info_box("Configuring OpenOCD ...") + configure_args = [ + "--enable-remote-bitbang", + "--enable-jtag_vpi", + "--enable-ftdi", + "--prefix=" + install_dir + ] + if with_coverage: + configure_args += [ + "CFLAGS=-O0 --coverage -fprofile-arcs -ftest-coverage", + "CXXFLAGS=-O0 --coverage -fprofile-arcs -ftest-coverage", + "LDFLAGS=-fprofile-arcs -lgcov" + ] + run_cmd(["bash", "./configure"] + configure_args) + if with_coverage: + # Need to patch OpenOCD source so that coverage is collected even if OpenOCD + # gets terminated by a signal. + patch_file = os.path.join(script_dir, "patches", "openocd_gcov_flush.patch") + git_apply_patch(patch_file, src_dir) + info_box("Building OpenOCD ...") + run_cmd(["make", "clean"]) # safety + run_cmd(["make", "-j" + str(cpu_count())]) + info_box("Installing OpenOCD ...") + run_cmd(["make", "install"]) + info_box("Finished build of OpenOCD. ") + + +def check_openocd_runs(install_dir): + openocd_binary = os.path.join(install_dir, "bin", "openocd") + check_file_exists(openocd_binary) + info("Checking that OpenOCD runs ...") + run_cmd([openocd_binary, "--version"]) + + +def main(): + args = parse_args() + + # use absolute paths + args.src_dir = os.path.abspath(args.src_dir) + args.install_dir = os.path.abspath(args.install_dir) + + print_openocd_rev(args.src_dir) + build_openocd(args.src_dir, args.install_dir, with_coverage=args.coverage) + check_openocd_runs(args.install_dir) + + return 0 + + +script_dir = None + +if __name__ == '__main__': + logging.getLogger().setLevel(logging.INFO) + script_name = os.path.basename(__file__) + script_dir = os.path.abspath(os.path.dirname(__file__)) + with MeasureTime("Script " + script_name): + retcode = main() + sys.exit(retcode) diff --git a/riscv-openocd-ci/build_spike.py b/riscv-openocd-ci/build_spike.py new file mode 100644 index 0000000000..5544e9ab30 --- /dev/null +++ b/riscv-openocd-ci/build_spike.py @@ -0,0 +1,77 @@ + +from utils.utils import MeasureTime, ChangeWorkdir, run_cmd, info_box +import logging +from logging import info +from multiprocessing import cpu_count +import os +import sys + + +def parse_args(): + import argparse + parser = argparse.ArgumentParser("Build Spike (RISC-V ISA Simulator) from local (checked-out) source code") + parser.add_argument("--src-dir", required=True, help="Directory where OpenOCD source code is located") + parser.add_argument("--install-dir", required=True, help="Directory where to install OpenOCD after the build") + return parser.parse_args() + + +def build_spike(src_dir, install_dir, with_coverage=False): + assert os.path.isdir(src_dir) + with ChangeWorkdir(src_dir): + info_box("Bootstrapping OpenOCD ...") + run_cmd(["bash", "./bootstrap"]) + info_box("Configuring OpenOCD ...") + configure_args = [ + "--enable-remote-bitbang", + "--enable-jtag_vpi", + "--enable-ftdi", + "--prefix=" + install_dir + ] + if with_coverage: + configure_args += [ + "CFLAGS=-O0 --coverage -fprofile-arcs -ftest-coverage", + "CXXFLAGS=-O0 --coverage -fprofile-arcs -ftest-coverage", + "LDFLAGS=-fprofile-arcs -lgcov" + ] + run_cmd(["bash", "./configure"] + configure_args) + if with_coverage: + # Need to patch OpenOCD source so that coverage is collected even if OpenOCD + # gets terminated by a signal. + patch_file = os.path.join(script_dir, "patches", "openocd_gcov_flush.patch") + git_apply_patch(patch_file, src_dir) + info_box("Building OpenOCD ...") + run_cmd(["make", "clean"]) # safety + run_cmd(["make", "-j" + str(cpu_count())]) + info_box("Installing OpenOCD ...") + run_cmd(["make", "install"]) + info_box("Finished build of OpenOCD. ") + + +def check_spike_runs(install_dir): + spike_binary = os.path.join(install_dir, "bin", "spike") + assert os.path.isfile(spike_binary) + run_cmd([spike_binary, "--version"]) + + +def main(): + args = parse_args() + + # use absolute paths + args.src_dir = os.path.abspath(args.src_dir) + args.install_dir = os.path.abspath(args.install_dir) + + build_spike(args.src_dir, args.install_dir) + check_spike_runs(args.install_dir) + + return 0 + + +script_dir = None + +if __name__ == '__main__': + logging.getLogger().setLevel(logging.INFO) + script_name = os.path.basename(__file__) + script_dir = os.path.abspath(os.path.dirname(__file__)) + with MeasureTime("Script " + script_name): + retcode = main() + sys.exit(retcode) diff --git a/riscv-openocd-ci/utils/__init__.py b/riscv-openocd-ci/utils/__init__.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/riscv-openocd-ci/utils/__pycache__/__init__.cpython-37.pyc b/riscv-openocd-ci/utils/__pycache__/__init__.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..e739a02b02a375de5afe01f9c469bedb0c89a409 GIT binary patch literal 139 zcmZ?b<>g`k0^`^h@gVv!h=2h`Aj1KOi&=m~3PUi1CZpd2KczG$ M)edCZXCP((0R5pLZvX%Q literal 0 HcmV?d00001 diff --git a/riscv-openocd-ci/utils/__pycache__/utils.cpython-37.pyc b/riscv-openocd-ci/utils/__pycache__/utils.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..0ab69bb208630220beb2673afc92836b98f79b70 GIT binary patch literal 4449 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 W&Uk0l_kFjs Date: Sun, 27 Dec 2020 14:23:59 +0100 Subject: [PATCH 04/39] WIP 4 Change-Id: If693a13490b425d5be8c8187773df5f39602d1d6 --- .github/workflows/riscv-openocd-ci.yml | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/.github/workflows/riscv-openocd-ci.yml b/.github/workflows/riscv-openocd-ci.yml index d647d9396d..0ad1160eef 100644 --- a/.github/workflows/riscv-openocd-ci.yml +++ b/.github/workflows/riscv-openocd-ci.yml @@ -1,11 +1,18 @@ name: riscv-openocd-ci on: [push] + jobs: + run-riscv-tests: runs-on: ubuntu-20.04 steps: + - name: Checkout OpenOCD uses: actions/checkout@v2 + + - name: Install required pkgs + run: sudo apt install libtool pkg-config autoconf automake libusb-1.0 libftdi1 + - name: Build OpenOCD run: | cd riscv-openocd-ci From 9f1e21961e55404c6dce046e3c6d0011fd098b50 Mon Sep 17 00:00:00 2001 From: Jan Matyas Date: Sun, 27 Dec 2020 14:31:48 +0100 Subject: [PATCH 05/39] WIP 5 Change-Id: Ie7be8f078d5abd9012018f6d8b391208f33b2cd0 --- .github/workflows/riscv-openocd-ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/riscv-openocd-ci.yml b/.github/workflows/riscv-openocd-ci.yml index 0ad1160eef..b96b6bcab4 100644 --- a/.github/workflows/riscv-openocd-ci.yml +++ b/.github/workflows/riscv-openocd-ci.yml @@ -4,14 +4,14 @@ on: [push] jobs: run-riscv-tests: - runs-on: ubuntu-20.04 + runs-on: ubuntu-18.04 steps: - name: Checkout OpenOCD uses: actions/checkout@v2 - name: Install required pkgs - run: sudo apt install libtool pkg-config autoconf automake libusb-1.0 libftdi1 + run: sudo apt-get install libtool pkg-config autoconf automake libusb-1.0 libftdi1 - name: Build OpenOCD run: | From 30eb095763aaedbe93802e5821fbd0b09b20fe49 Mon Sep 17 00:00:00 2001 From: Jan Matyas Date: Sun, 27 Dec 2020 15:39:24 +0100 Subject: [PATCH 06/39] WIP 6 Change-Id: I5899542d9d8a8379957956a53373211c301a1036 --- .github/workflows/riscv-openocd-ci.yml | 20 ++++++-- riscv-openocd-ci/build_spike.py | 48 ++++++------------ .../utils/__pycache__/__init__.cpython-37.pyc | Bin 139 -> 158 bytes .../utils/__pycache__/utils.cpython-37.pyc | Bin 4449 -> 4504 bytes riscv-openocd-ci/utils/utils.py | 6 ++- 5 files changed, 36 insertions(+), 38 deletions(-) diff --git a/.github/workflows/riscv-openocd-ci.yml b/.github/workflows/riscv-openocd-ci.yml index b96b6bcab4..7de7e6a596 100644 --- a/.github/workflows/riscv-openocd-ci.yml +++ b/.github/workflows/riscv-openocd-ci.yml @@ -7,13 +7,25 @@ jobs: runs-on: ubuntu-18.04 steps: + - name: Install required pkgs + run: sudo apt-get install libtool pkg-config autoconf automake libusb-1.0 libftdi1 gcov lcov device-tree-compiler + - name: Checkout OpenOCD uses: actions/checkout@v2 - - name: Install required pkgs - run: sudo apt-get install libtool pkg-config autoconf automake libusb-1.0 libftdi1 - - name: Build OpenOCD run: | cd riscv-openocd-ci - python3 build_openocd.py --src-dir ../ --install-dir install/ + python3 build_openocd.py --src-dir ../ --install-dir work/install/ --coverage + + - name: Checkout Spike + run: | + cd riscv-openocd-ci + mkdir work + cd work + git clone https://github.com/riscv/riscv-isa-sim.git --recursive + + - name: Build Spike + run: | + cd riscv-openocd-ci + python3 build_spike.py --src-dir work/riscv-isa-sim --install-dir work/install/ \ No newline at end of file diff --git a/riscv-openocd-ci/build_spike.py b/riscv-openocd-ci/build_spike.py index 5544e9ab30..b79e3c02fd 100644 --- a/riscv-openocd-ci/build_spike.py +++ b/riscv-openocd-ci/build_spike.py @@ -1,5 +1,5 @@ -from utils.utils import MeasureTime, ChangeWorkdir, run_cmd, info_box +from utils.utils import MeasureTime, ChangeWorkdir, run_cmd, info_box, check_dir_exists, check_file_exists import logging from logging import info from multiprocessing import cpu_count @@ -10,47 +10,31 @@ def parse_args(): import argparse parser = argparse.ArgumentParser("Build Spike (RISC-V ISA Simulator) from local (checked-out) source code") - parser.add_argument("--src-dir", required=True, help="Directory where OpenOCD source code is located") - parser.add_argument("--install-dir", required=True, help="Directory where to install OpenOCD after the build") + parser.add_argument("--src-dir", required=True, help="Directory where Spike source code is located") + parser.add_argument("--install-dir", required=True, help="Directory where to install Spike after the build") return parser.parse_args() -def build_spike(src_dir, install_dir, with_coverage=False): - assert os.path.isdir(src_dir) - with ChangeWorkdir(src_dir): - info_box("Bootstrapping OpenOCD ...") - run_cmd(["bash", "./bootstrap"]) - info_box("Configuring OpenOCD ...") - configure_args = [ - "--enable-remote-bitbang", - "--enable-jtag_vpi", - "--enable-ftdi", - "--prefix=" + install_dir - ] - if with_coverage: - configure_args += [ - "CFLAGS=-O0 --coverage -fprofile-arcs -ftest-coverage", - "CXXFLAGS=-O0 --coverage -fprofile-arcs -ftest-coverage", - "LDFLAGS=-fprofile-arcs -lgcov" - ] - run_cmd(["bash", "./configure"] + configure_args) - if with_coverage: - # Need to patch OpenOCD source so that coverage is collected even if OpenOCD - # gets terminated by a signal. - patch_file = os.path.join(script_dir, "patches", "openocd_gcov_flush.patch") - git_apply_patch(patch_file, src_dir) - info_box("Building OpenOCD ...") +def build_spike(src_dir, install_dir): + check_dir_exists(src_dir) + build_dir = os.path.join(src_dir, "build") + os.mkdir(build_dir) + with ChangeWorkdir(build_dir): + info_box("Configuring Spike ...") + run_cmd(["bash", "../configure", "--prefix=" + install_dir]) + info_box("Building Spike ...") run_cmd(["make", "clean"]) # safety run_cmd(["make", "-j" + str(cpu_count())]) - info_box("Installing OpenOCD ...") + info_box("Installing Spike ...") run_cmd(["make", "install"]) - info_box("Finished build of OpenOCD. ") + info_box("Finished Spike build. ") def check_spike_runs(install_dir): spike_binary = os.path.join(install_dir, "bin", "spike") - assert os.path.isfile(spike_binary) - run_cmd([spike_binary, "--version"]) + check_file_exists(spike_binary) + info("Checking that Spike runs") + run_cmd([spike_binary, "--help"], display_stderr=False) def main(): diff --git a/riscv-openocd-ci/utils/__pycache__/__init__.cpython-37.pyc b/riscv-openocd-ci/utils/__pycache__/__init__.cpython-37.pyc index e739a02b02a375de5afe01f9c469bedb0c89a409..f556d3cc5bbba868f7f18e7001680e74b40eed72 100644 GIT binary patch delta 76 zcmeBXoX5!J#LLUY00fR56S*wS-1Rf^b5r%p64Q$k^Gfv7GfVV~GK-VTbn^>R^YW8Z Rbkp*SveAT+Gbg600sv7$80`Q6 delta 57 zcmbQo*v-i0#LLUY00hRd6S*vvP4qMJb5r%p64Q$k^GfuKGK-VTbn^>R^YW8Zbdxjn LlQWGbR;mI3r{WP2 diff --git a/riscv-openocd-ci/utils/__pycache__/utils.cpython-37.pyc b/riscv-openocd-ci/utils/__pycache__/utils.cpython-37.pyc index 0ab69bb208630220beb2673afc92836b98f79b70..2ea1f73f15301a2523f2c124e5c9cb2e42922c76 100644 GIT binary patch delta 1148 zcmZ8g&u`R56!zF&d)E6S8x#`4k_57)se_gUDYQw{6~Dq3swxRmXjKckb=S_ukX91@ujb0IroANN&0{~Ge8N6ns%^xbuy(_5gWpYR?I@{1Bw9DBaWCw~t)RLd z!?ph{wW44CV5b>N~SfFoe9k$Ko3uDUoayu*kHR^@z zk2XM{biNTy~+rLdz(1PO#uIcek95lOrC-lsXsGGnExx#14U*M)FA!x{{vm(9@GbxXG zd7p1t6buzPoIN)56}b)$C^A@-tJ$aQBl$WzaZuI154T+dC}mYynh^;^Jy*x@d8fjz z$ji>fbDk~w-(3w`iD&u!WFrPIH~2OKKMB2DEADinL>U-4OJr3d);$hkFKz}AKwZ9a z4wo=Hv2UepLFoOBW9j#}S0o3U5Us5lRpsX;Lc^>(OTDG8iYX z>{}q6!A01_Aym(yCPmW4-DU6Zf6EM~$bBFc&Bo=k{L~mFFKE0MJ}dvs-Pwp2GQiHC}Ad_xFRRKii+JFJYZ`d8VGPIhb zW`NHLR%Ky$Y!sGozJ)_r2-rUcH(&{`a76w+R3A~5Oyf?PX>FjyDE$%nX{kI*+V4;p z38LvJGd78%5AMWhEH_+xd3kNQ(O8qWOLJcS6D$0)ML|#mR&dbIDPX<1h`bKiOOoE=* zx4zk*%tYb~E59G@W#2O~u(Pt@FS(V=^?9f_!wPtTbGhud+@|j|%8plYyj`z;h=W4R zVpY9o6)1Yf(SPMg)0cm6h*ofmpdlK{Vq!_$(DA$4uTI^Nm`x6=vXQ`3$+FQ!F3`=; zgDXj|AYlzF>j)yn4e4V^0uD4?0@s#@tNS%>)m*0WO|!(RzVoy`TytroaJV0+Cu zKh6Ui@KUPS*GuMvk`Gx~#smzN>d?5>>io@9g zuFASL#O4x?r-$+p?#yf~#s};nv!w!;1{(;XR1kvKvJ?t$W(LGr ze3+RYjr3so!bR5!Bdxw1F8B}`?XTUahi+sz{?d{c#tKDl)PW`W@$G=m0=&l2m`Yo jH#yS$cq)KT0^8_NJ$SZrd#5R-Ol1t2lBU$9Zkj& Date: Sun, 27 Dec 2020 15:42:52 +0100 Subject: [PATCH 07/39] WIP 7 Change-Id: Ibb5d783b101ab1ad264b72dcc5fac455393b4614 --- riscv-openocd-ci/.gitignore | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 riscv-openocd-ci/.gitignore diff --git a/riscv-openocd-ci/.gitignore b/riscv-openocd-ci/.gitignore new file mode 100644 index 0000000000..4f6f9ccc43 --- /dev/null +++ b/riscv-openocd-ci/.gitignore @@ -0,0 +1,2 @@ +**/*.pyc +work From 92d7331d9b1e6b4fea3d7ed138902f15c7142da1 Mon Sep 17 00:00:00 2001 From: Jan Matyas Date: Sun, 27 Dec 2020 15:46:52 +0100 Subject: [PATCH 08/39] WIP 8 Change-Id: If55fb5c7ae44b7cdfc2817e2aaea168cbf64d600 --- .github/workflows/riscv-openocd-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/riscv-openocd-ci.yml b/.github/workflows/riscv-openocd-ci.yml index 7de7e6a596..6ecb879b28 100644 --- a/.github/workflows/riscv-openocd-ci.yml +++ b/.github/workflows/riscv-openocd-ci.yml @@ -8,7 +8,7 @@ jobs: steps: - name: Install required pkgs - run: sudo apt-get install libtool pkg-config autoconf automake libusb-1.0 libftdi1 gcov lcov device-tree-compiler + run: sudo apt-get install libtool pkg-config autoconf automake libusb-1.0 libftdi1 lcov device-tree-compiler - name: Checkout OpenOCD uses: actions/checkout@v2 From 59c3ab73453ac05b5030b932fa226e7be3cc6bf4 Mon Sep 17 00:00:00 2001 From: Jan Matyas Date: Sun, 27 Dec 2020 15:52:55 +0100 Subject: [PATCH 09/39] WIP 8 Change-Id: I6fb408d8c5ad471ab0beb0e1906e6b8b059e16ad --- riscv-openocd-ci/.gitignore | 2 -- 1 file changed, 2 deletions(-) delete mode 100644 riscv-openocd-ci/.gitignore diff --git a/riscv-openocd-ci/.gitignore b/riscv-openocd-ci/.gitignore deleted file mode 100644 index 4f6f9ccc43..0000000000 --- a/riscv-openocd-ci/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -**/*.pyc -work From 765a0fd81c1403fbc5baedb4df995375286ca16f Mon Sep 17 00:00:00 2001 From: Jan Matyas Date: Sun, 27 Dec 2020 15:56:00 +0100 Subject: [PATCH 10/39] WIP 9 Change-Id: I8ab40e1a0aa3586acec1b83abfb46168a6b56dc1 --- riscv-openocd-ci/patches/openocd_gcov_flush.patch | 15 +++++++++++++++ 1 file changed, 15 insertions(+) create mode 100644 riscv-openocd-ci/patches/openocd_gcov_flush.patch diff --git a/riscv-openocd-ci/patches/openocd_gcov_flush.patch b/riscv-openocd-ci/patches/openocd_gcov_flush.patch new file mode 100644 index 0000000000..2476b17ca8 --- /dev/null +++ b/riscv-openocd-ci/patches/openocd_gcov_flush.patch @@ -0,0 +1,15 @@ +diff --git a/src/server/server.c b/src/server/server.c +index 4e970fa8f..43bd9fb2e 100644 +--- a/src/server/server.c ++++ b/src/server/server.c +@@ -725,6 +725,10 @@ void server_free(void) + + void exit_on_signal(int sig) + { ++ /* dump coverage before being killed by the signal ++ * (otherwise gcov's *.gcda files would not be created) */ ++ void __gcov_flush(void); ++ __gcov_flush(); + #ifndef _WIN32 + /* bring back default system handler and kill yourself */ + signal(sig, SIG_DFL); From 2aadff85f4b71c2e247674cb4af07697d40767f0 Mon Sep 17 00:00:00 2001 From: Jan Matyas Date: Sun, 27 Dec 2020 15:58:26 +0100 Subject: [PATCH 11/39] WIP 10 Change-Id: Ib3ad13acf19c1a3b626f12066a175eaa0cb1b345 --- .github/workflows/riscv-openocd-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/riscv-openocd-ci.yml b/.github/workflows/riscv-openocd-ci.yml index 6ecb879b28..9540c8f8e5 100644 --- a/.github/workflows/riscv-openocd-ci.yml +++ b/.github/workflows/riscv-openocd-ci.yml @@ -21,7 +21,7 @@ jobs: - name: Checkout Spike run: | cd riscv-openocd-ci - mkdir work + mkdir -p work cd work git clone https://github.com/riscv/riscv-isa-sim.git --recursive From d267c914c5631d1ff293418d1924e571b8930983 Mon Sep 17 00:00:00 2001 From: Jan Matyas Date: Sun, 27 Dec 2020 16:31:06 +0100 Subject: [PATCH 12/39] WIP 11 Change-Id: I9d2f2674f1c42a94c5d7b701c1b3423dd4a4cb70 --- .github/workflows/riscv-openocd-ci.yml | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/.github/workflows/riscv-openocd-ci.yml b/.github/workflows/riscv-openocd-ci.yml index 9540c8f8e5..4ff643b052 100644 --- a/.github/workflows/riscv-openocd-ci.yml +++ b/.github/workflows/riscv-openocd-ci.yml @@ -28,4 +28,19 @@ jobs: - name: Build Spike run: | cd riscv-openocd-ci - python3 build_spike.py --src-dir work/riscv-isa-sim --install-dir work/install/ \ No newline at end of file + python3 build_spike.py --src-dir work/riscv-isa-sim --install-dir work/install/ + + - name: Download RISC-V toolchain + # TODO + run: | + cd riscv-openocd-ci/work + https://buildbot.embecosm.com/job/riscv32-gcc-ubuntu1804/25/artifact/riscv32-embecosm-gcc-ubuntu1804-20201108.tar.gz + tar -C install -xvf riscv32-embecosm-gcc-ubuntu1804-20201108.tar.gz --strip-components=1 + cd install/bin + find . -name 'riscv32-*' | while read F; do ln -s $F $(echo $F | sed -e 's/riscv32/riscv64/'); done + + - name: Checkout RISC-V tests + # TODO + run: | + cd riscv-openocd-ci/work + git clone https://github.com/riscv/riscv-isa-sim.git --recursive \ No newline at end of file From 965dfd5833ec6fc80dba794dda7b75b2ebf7fe5e Mon Sep 17 00:00:00 2001 From: Jan Matyas Date: Sun, 27 Dec 2020 16:42:22 +0100 Subject: [PATCH 13/39] WIP 12 Change-Id: I474348fff3a319665b5ff519bc024d11f2e67e00 --- .github/workflows/riscv-openocd-ci.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/riscv-openocd-ci.yml b/.github/workflows/riscv-openocd-ci.yml index 4ff643b052..e3db155051 100644 --- a/.github/workflows/riscv-openocd-ci.yml +++ b/.github/workflows/riscv-openocd-ci.yml @@ -34,7 +34,7 @@ jobs: # TODO run: | cd riscv-openocd-ci/work - https://buildbot.embecosm.com/job/riscv32-gcc-ubuntu1804/25/artifact/riscv32-embecosm-gcc-ubuntu1804-20201108.tar.gz + wget "https://buildbot.embecosm.com/job/riscv32-gcc-ubuntu1804/25/artifact/riscv32-embecosm-gcc-ubuntu1804-20201108.tar.gz" tar -C install -xvf riscv32-embecosm-gcc-ubuntu1804-20201108.tar.gz --strip-components=1 cd install/bin find . -name 'riscv32-*' | while read F; do ln -s $F $(echo $F | sed -e 's/riscv32/riscv64/'); done From a7ac1431de6d1b2e854268ae2ae55261acff762a Mon Sep 17 00:00:00 2001 From: Jan Matyas Date: Sun, 27 Dec 2020 16:52:12 +0100 Subject: [PATCH 14/39] WIP 13 Change-Id: Ifb9049667c44685a98eb57f640280ad107671226 --- .github/workflows/riscv-openocd-ci.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/riscv-openocd-ci.yml b/.github/workflows/riscv-openocd-ci.yml index e3db155051..b7188be933 100644 --- a/.github/workflows/riscv-openocd-ci.yml +++ b/.github/workflows/riscv-openocd-ci.yml @@ -34,7 +34,7 @@ jobs: # TODO run: | cd riscv-openocd-ci/work - wget "https://buildbot.embecosm.com/job/riscv32-gcc-ubuntu1804/25/artifact/riscv32-embecosm-gcc-ubuntu1804-20201108.tar.gz" + wget --progress dot:mega "https://buildbot.embecosm.com/job/riscv32-gcc-ubuntu1804/25/artifact/riscv32-embecosm-gcc-ubuntu1804-20201108.tar.gz" tar -C install -xvf riscv32-embecosm-gcc-ubuntu1804-20201108.tar.gz --strip-components=1 cd install/bin find . -name 'riscv32-*' | while read F; do ln -s $F $(echo $F | sed -e 's/riscv32/riscv64/'); done @@ -43,4 +43,4 @@ jobs: # TODO run: | cd riscv-openocd-ci/work - git clone https://github.com/riscv/riscv-isa-sim.git --recursive \ No newline at end of file + git clone https://github.com/riscv/riscv-tests.git --recursive \ No newline at end of file From cd695372f34002e4229940654220151113535cf3 Mon Sep 17 00:00:00 2001 From: Jan Matyas Date: Sun, 27 Dec 2020 17:13:20 +0100 Subject: [PATCH 15/39] WIP 13 Change-Id: I87862efae6f852792539a64df3de8ab0c6a1405b --- .github/workflows/riscv-openocd-ci.yml | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) diff --git a/.github/workflows/riscv-openocd-ci.yml b/.github/workflows/riscv-openocd-ci.yml index b7188be933..b797d6af4c 100644 --- a/.github/workflows/riscv-openocd-ci.yml +++ b/.github/workflows/riscv-openocd-ci.yml @@ -39,8 +39,20 @@ jobs: cd install/bin find . -name 'riscv32-*' | while read F; do ln -s $F $(echo $F | sed -e 's/riscv32/riscv64/'); done - - name: Checkout RISC-V tests + - name: Checkout riscv-tests # TODO run: | cd riscv-openocd-ci/work - git clone https://github.com/riscv/riscv-tests.git --recursive \ No newline at end of file + git clone https://github.com/riscv/riscv-tests.git --recursive + + - name: Run riscv-tests/debug + # TODO: make all + run: | + cd riscv-openocd-ci/work/riscv-tests/debug + make -k || true + + - name: Archive logs from the tests + uses: actions/upload-artifact@v2 + with: + name: test-logs + path: riscv-openocd-ci/work/riscv-tests/debug/logs \ No newline at end of file From 5f2bd9143b0234cdf785a85f3c19eb7759a64678 Mon Sep 17 00:00:00 2001 From: Jan Matyas Date: Sun, 27 Dec 2020 17:24:32 +0100 Subject: [PATCH 16/39] WIP 14 Change-Id: I009680e80daa3b4abe852934aafe2c7440acaf8d --- .github/workflows/riscv-openocd-ci.yml | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.github/workflows/riscv-openocd-ci.yml b/.github/workflows/riscv-openocd-ci.yml index b797d6af4c..b621c7396a 100644 --- a/.github/workflows/riscv-openocd-ci.yml +++ b/.github/workflows/riscv-openocd-ci.yml @@ -8,7 +8,9 @@ jobs: steps: - name: Install required pkgs - run: sudo apt-get install libtool pkg-config autoconf automake libusb-1.0 libftdi1 lcov device-tree-compiler + run: | + sudo apt-get install libtool pkg-config autoconf automake libusb-1.0 libftdi1 lcov device-tree-compiler + sudo python3 -m pip install pexpect - name: Checkout OpenOCD uses: actions/checkout@v2 From 964bc88f59a4a7805984262489cadd2d87cbdfe7 Mon Sep 17 00:00:00 2001 From: Jan Matyas Date: Sun, 27 Dec 2020 17:42:05 +0100 Subject: [PATCH 17/39] WIP 15 Change-Id: Iad59e7d2fd671cfa5c77ef1af9f3a5dbc7e571af --- .github/workflows/riscv-openocd-ci.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/riscv-openocd-ci.yml b/.github/workflows/riscv-openocd-ci.yml index b621c7396a..993cc0df4a 100644 --- a/.github/workflows/riscv-openocd-ci.yml +++ b/.github/workflows/riscv-openocd-ci.yml @@ -41,6 +41,9 @@ jobs: cd install/bin find . -name 'riscv32-*' | while read F; do ln -s $F $(echo $F | sed -e 's/riscv32/riscv64/'); done + - name: Update PATH + run: echo "`pwd`/riscv-openocd-ci/work/install/bin" >> $GITHUB_PATH + - name: Checkout riscv-tests # TODO run: | From c864d96f489c7c5fbdb4db55e60de2cb07848f87 Mon Sep 17 00:00:00 2001 From: Jan Matyas Date: Sun, 27 Dec 2020 19:22:03 +0100 Subject: [PATCH 18/39] WIP 16 Change-Id: Id5f1e1afacdd51af43caf69b2e74b51cdfd388bf --- .github/workflows/riscv-openocd-ci.yml | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/.github/workflows/riscv-openocd-ci.yml b/.github/workflows/riscv-openocd-ci.yml index 993cc0df4a..2502aff288 100644 --- a/.github/workflows/riscv-openocd-ci.yml +++ b/.github/workflows/riscv-openocd-ci.yml @@ -41,8 +41,10 @@ jobs: cd install/bin find . -name 'riscv32-*' | while read F; do ln -s $F $(echo $F | sed -e 's/riscv32/riscv64/'); done - - name: Update PATH - run: echo "`pwd`/riscv-openocd-ci/work/install/bin" >> $GITHUB_PATH + - name: Update env. variables + run: | + echo "`pwd`/riscv-openocd-ci/work/install/bin" >> $GITHUB_PATH + echo "RISCV=`pwd`/riscv-openocd-ci/work/install/bin" >> $GITHUB_ENV - name: Checkout riscv-tests # TODO From 3d158a1e5004303fc6aed8b640514f5210401c42 Mon Sep 17 00:00:00 2001 From: Jan Matyas Date: Sun, 27 Dec 2020 19:54:30 +0100 Subject: [PATCH 19/39] WIP 17 Change-Id: I8d44f6f07520f89c965f6fdf738ad7501ba910b7 --- .github/workflows/riscv-openocd-ci.yml | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/.github/workflows/riscv-openocd-ci.yml b/.github/workflows/riscv-openocd-ci.yml index 2502aff288..b977631bf2 100644 --- a/.github/workflows/riscv-openocd-ci.yml +++ b/.github/workflows/riscv-openocd-ci.yml @@ -41,17 +41,16 @@ jobs: cd install/bin find . -name 'riscv32-*' | while read F; do ln -s $F $(echo $F | sed -e 's/riscv32/riscv64/'); done - - name: Update env. variables - run: | - echo "`pwd`/riscv-openocd-ci/work/install/bin" >> $GITHUB_PATH - echo "RISCV=`pwd`/riscv-openocd-ci/work/install/bin" >> $GITHUB_ENV - - name: Checkout riscv-tests - # TODO run: | cd riscv-openocd-ci/work git clone https://github.com/riscv/riscv-tests.git --recursive + - name: Update env. variables + run: | + echo "`pwd`/riscv-openocd-ci/work/install/bin" >> $GITHUB_PATH + echo "RISCV=`pwd`/riscv-openocd-ci/work/install" >> $GITHUB_ENV + - name: Run riscv-tests/debug # TODO: make all run: | From d2b82547115b67b09407f8d8d99f8351cfc5c62f Mon Sep 17 00:00:00 2001 From: Jan Matyas Date: Mon, 28 Dec 2020 00:04:45 +0100 Subject: [PATCH 20/39] WIP 18 Change-Id: If21c1aef1e6d5399464a1be01f1e1f62738e82dd --- .github/workflows/riscv-openocd-ci.yml | 11 +- riscv-openocd-ci/build_spike.py | 11 ++ riscv-openocd-ci/process_test_results.py | 136 +++++++++++++++++++++++ 3 files changed, 156 insertions(+), 2 deletions(-) create mode 100644 riscv-openocd-ci/process_test_results.py diff --git a/.github/workflows/riscv-openocd-ci.yml b/.github/workflows/riscv-openocd-ci.yml index b977631bf2..ca5b75f19e 100644 --- a/.github/workflows/riscv-openocd-ci.yml +++ b/.github/workflows/riscv-openocd-ci.yml @@ -57,8 +57,15 @@ jobs: cd riscv-openocd-ci/work/riscv-tests/debug make -k || true + - name: Process test results + run: | + cd riscv-openocd-ci + python3 process_test_results.py --log-dir work/riscv-tests/debug/logs --output-dir work/results + - name: Archive logs from the tests + # store logs also on failure + if: ${{ always() }} uses: actions/upload-artifact@v2 with: - name: test-logs - path: riscv-openocd-ci/work/riscv-tests/debug/logs \ No newline at end of file + name: test-results + path: riscv-openocd-ci/work/results \ No newline at end of file diff --git a/riscv-openocd-ci/build_spike.py b/riscv-openocd-ci/build_spike.py index b79e3c02fd..4d18fcee9d 100644 --- a/riscv-openocd-ci/build_spike.py +++ b/riscv-openocd-ci/build_spike.py @@ -15,6 +15,16 @@ def parse_args(): return parser.parse_args() +def print_spike_rev(src_dir): + rev = git_revision_info(src_dir) + info_box("Spike revision") + info("Commit ID: {}".format(rev["hash"])) + info("Subject: {}".format(rev["subject"])) + info("Author: {}".format(rev["author"])) + info("Author date: {}".format(rev["author_date"])) + info("Commit date: {}".format(rev["commit_date"])) + + def build_spike(src_dir, install_dir): check_dir_exists(src_dir) build_dir = os.path.join(src_dir, "build") @@ -44,6 +54,7 @@ def main(): args.src_dir = os.path.abspath(args.src_dir) args.install_dir = os.path.abspath(args.install_dir) + print_spike_rev(args.src_dir) build_spike(args.src_dir, args.install_dir) check_spike_runs(args.install_dir) diff --git a/riscv-openocd-ci/process_test_results.py b/riscv-openocd-ci/process_test_results.py new file mode 100644 index 0000000000..caa60c5b88 --- /dev/null +++ b/riscv-openocd-ci/process_test_results.py @@ -0,0 +1,136 @@ + + +import logging +from logging import info +from multiprocessing import cpu_count +import os +import re +import shutil +import sys +from utils.utils import MeasureTime, ChangeWorkdir, run_cmd, info_box, git_apply_patch, git_revision_info, \ + check_file_exists, check_dir_exists + +KNOWN_RESULTS = ["pass", "fail", "not_applicable", "exception"] +SUMMARY_FILE = "test_summary.txt" + + +def parse_args(): + import argparse + parser = argparse.ArgumentParser("Process logs from riscv-tests/debug") + parser.add_argument("--log-dir", required=True, help="Directory where logs from RISC-V debug tests are stored") + parser.add_argument("--output-dir", required=True, help="Directory where put post-processed logs") + return parser.parse_args() + + +def process_test_logs(log_dir, output_dir): + from glob import glob + check_dir_exists(log_dir) + os.makedirs(output_dir, exist_ok=True) + + # process log files + file_pattern = os.path.join(log_dir, "*.log") + res = [] + for lf in sorted(glob(file_pattern)): + target, result = process_one_log(lf) + copy_one_log(lf, result, output_dir) + res += [(lf, target, result)] + + any_failed = aggregate_results(res) + return any_failed + + +def process_one_log(log_file): + check_file_exists(log_file) + target = None + result = None + for line in open(log_file, "r"): + target_match = re.match(r"^Target: (\S+)$", line) + if target_match is not None: + target = target_match.group(1) + result_match = re.match(r"^Result: (\S+)$", line) + if result_match is not None: + result = result_match.group(1) + if result not in KNOWN_RESULTS: + msg = ("Unknown test result '{}' in file {}. Expected one of: {}" + .format(result, log_file, KNOWN_RESULTS)) + raise RuntimeError(msg) + + if target is None: + raise RuntimeError("Could not find target name in log file {}".format(log_file)) + if result is None: + raise RuntimeError("Could not find test result in log file {}".format(log_file)) + + return target, result + + +def copy_one_log(log_file, result, output_dir): + # copy the log to an output sub-folder based on the result + target_dir = os.path.join(output_dir, result) + os.makedirs(target_dir, exist_ok=True) + assert os.path.isdir(target_dir) + shutil.copy2(log_file, target_dir) + + +def aggregate_results(res): + + outcomes = { + "Passed tests" : "pass", + "Not applicable tests": "not_applicable", + "Failed tests": "fail", + "Tests ended with exception": "exception", + } + + for caption, filter in outcomes.items(): + info_box(caption) + tests_filtered = [lf for lf, _, r in res if r == filter] + for lf in tests_filtered: + name = os.path.splitext(os.path.basename(lf))[0] + info(name) + if not tests_filtered: + info("(none)") + + target_names = set([t for (_, t, _) in res]) + + info_box("Summary") + + def _print_row(target, total, num_pass, num_na, num_fail, num_exc): + info("{:<25} {:<10} {:<10} {:<10} {:<10} {:<10}".format(target, total, num_pass, num_na, num_fail, num_exc)) + + _print_row("Target", "# tests", "Pass", "Not_appl.", "Fail", "Exception") + _print_row("-----", "-----", "-----", "-----", "-----", "-----") + sum_pass = sum_na = sum_fail = sum_exc = 0 + for tn in target_names: + t_pass = sum([1 for _, t, r in res if t == tn and r == "pass"]) + t_na = sum([1 for _, t, r in res if t == tn and r == "not_applicable"]) + t_fail = sum([1 for _, t, r in res if t == tn and r == "fail"]) + t_exc = sum([1 for _, t, r in res if t == tn and r == "exception"]) + t_sum = sum([1 for _, t, _ in res if t == tn]) + assert t_sum == t_pass + t_na + t_fail + t_exc + _print_row(tn, t_sum, t_pass, t_na, t_fail, t_exc) + sum_pass += t_pass + sum_na += t_na + sum_fail += t_fail + sum_exc += t_exc + assert len(res) == sum_pass + sum_na + sum_fail + sum_exc + _print_row("-----", "-----", "-----", "-----", "-----", "-----") + _print_row("All targets:", len(res), sum_pass, sum_na, sum_fail, sum_exc) + _print_row("-----", "-----", "-----", "-----", "-----", "-----") + + any_failed = (sum_fail + sum_exc) > 0 + return any_failed + + +def main(): + args = parse_args() + + # use absolute paths + args.log_dir = os.path.abspath(args.log_dir) + args.output_dir = os.path.abspath(args.output_dir) + + any_failed = process_test_logs(args.log_dir, args.output_dir) + return 1 if any_failed else 0 + + +if __name__ == '__main__': + logging.getLogger().setLevel(logging.INFO) + sys.exit(main()) From 80ef744f3986c2caecc9a6c5b4ded70f3a0297fe Mon Sep 17 00:00:00 2001 From: Jan Matyas Date: Mon, 28 Dec 2020 00:07:58 +0100 Subject: [PATCH 21/39] WIP 19 Change-Id: I2b03fb9d52bf89d8362e056b75ecdc89f2839285 --- riscv-openocd-ci/build_spike.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/riscv-openocd-ci/build_spike.py b/riscv-openocd-ci/build_spike.py index 4d18fcee9d..8abe255d6c 100644 --- a/riscv-openocd-ci/build_spike.py +++ b/riscv-openocd-ci/build_spike.py @@ -1,5 +1,6 @@ -from utils.utils import MeasureTime, ChangeWorkdir, run_cmd, info_box, check_dir_exists, check_file_exists +from utils.utils import MeasureTime, ChangeWorkdir, run_cmd, info_box, \ + check_dir_exists, check_file_exists, git_revision_info import logging from logging import info from multiprocessing import cpu_count From 260a9f0404c10627e80496912579786d2613e710 Mon Sep 17 00:00:00 2001 From: Jan Matyas Date: Mon, 28 Dec 2020 00:17:28 +0100 Subject: [PATCH 22/39] WIP 20 Change-Id: I596436d3a4ad3aafec1fb2407f354d7058e54b0f --- .github/workflows/riscv-openocd-ci.yml | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) diff --git a/.github/workflows/riscv-openocd-ci.yml b/.github/workflows/riscv-openocd-ci.yml index ca5b75f19e..dfdf984049 100644 --- a/.github/workflows/riscv-openocd-ci.yml +++ b/.github/workflows/riscv-openocd-ci.yml @@ -53,6 +53,7 @@ jobs: - name: Run riscv-tests/debug # TODO: make all + id: run_tests run: | cd riscv-openocd-ci/work/riscv-tests/debug make -k || true @@ -62,10 +63,19 @@ jobs: cd riscv-openocd-ci python3 process_test_results.py --log-dir work/riscv-tests/debug/logs --output-dir work/results - - name: Archive logs from the tests - # store logs also on failure - if: ${{ always() }} + - name: Store test results + if: steps.run_tests.outputs.exit_code == 0 uses: actions/upload-artifact@v2 with: name: test-results - path: riscv-openocd-ci/work/results \ No newline at end of file + path: riscv-openocd-ci/work/results + + - name: Collect code coverage + if: steps.run_tests.outputs.exit_code == 0 + run: true + # TODO + + - name: Store code coverage + if: steps.run_tests.outputs.exit_code == 0 + run: true + # TODO \ No newline at end of file From 355735d41440ecff08594f38df01ecc186595676 Mon Sep 17 00:00:00 2001 From: Jan Matyas Date: Mon, 28 Dec 2020 12:09:16 +0100 Subject: [PATCH 23/39] WIP 21 Change-Id: Ib9079218fca66e73082a41a13b1afe9f46864c86 --- .github/workflows/riscv-openocd-ci.yml | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/.github/workflows/riscv-openocd-ci.yml b/.github/workflows/riscv-openocd-ci.yml index dfdf984049..0947e81b9b 100644 --- a/.github/workflows/riscv-openocd-ci.yml +++ b/.github/workflows/riscv-openocd-ci.yml @@ -61,21 +61,27 @@ jobs: - name: Process test results run: | cd riscv-openocd-ci - python3 process_test_results.py --log-dir work/riscv-tests/debug/logs --output-dir work/results + python3 process_test_results.py --log-dir work/riscv-tests/debug/logs --output-dir work/results/logs - name: Store test results if: steps.run_tests.outputs.exit_code == 0 uses: actions/upload-artifact@v2 with: name: test-results - path: riscv-openocd-ci/work/results + path: riscv-openocd-ci/work/results/logs - - name: Collect code coverage + - name: Collect OpenOCD code coverage + id: collect_cov if: steps.run_tests.outputs.exit_code == 0 - run: true - # TODO + run: | + cd riscv-openocd-ci + lcov --capture --directory work/riscv-openocd --output-file work/openocd-coverage.info + genhtml work/openocd-coverage.info --output-directory work/results/openocd-coverage - - name: Store code coverage - if: steps.run_tests.outputs.exit_code == 0 - run: true + - name: Store OpenOCD code coverage + if: steps.collect_cov.outputs.exit_code == 0 + uses: actions/upload-artifact@v2 + with: + name: openocd-coverage + path: riscv-openocd-ci/work/results/openocd-coverage # TODO \ No newline at end of file From 02598149c44808d7c366746278ba13df57c516c1 Mon Sep 17 00:00:00 2001 From: Jan Matyas Date: Mon, 28 Dec 2020 14:26:24 +0100 Subject: [PATCH 24/39] WIP 22 Change-Id: If789a81830ac9765d0d750bb94d9ca438728da6b --- .github/workflows/riscv-openocd-ci.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.github/workflows/riscv-openocd-ci.yml b/.github/workflows/riscv-openocd-ci.yml index 0947e81b9b..ac4e034241 100644 --- a/.github/workflows/riscv-openocd-ci.yml +++ b/.github/workflows/riscv-openocd-ci.yml @@ -75,8 +75,13 @@ jobs: if: steps.run_tests.outputs.exit_code == 0 run: | cd riscv-openocd-ci + echo "1" + ls -l + echo "2" lcov --capture --directory work/riscv-openocd --output-file work/openocd-coverage.info + echo "3" genhtml work/openocd-coverage.info --output-directory work/results/openocd-coverage + echo "4" - name: Store OpenOCD code coverage if: steps.collect_cov.outputs.exit_code == 0 From eb7a7d406d7ff138bd68379b0338b16119685b74 Mon Sep 17 00:00:00 2001 From: Jan Matyas Date: Mon, 28 Dec 2020 15:10:21 +0100 Subject: [PATCH 25/39] WIP 23 Change-Id: I9151791484b7e8115e3cf81a7940ff64434cadb5 --- .github/workflows/riscv-openocd-ci.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/riscv-openocd-ci.yml b/.github/workflows/riscv-openocd-ci.yml index ac4e034241..4d4ea209b6 100644 --- a/.github/workflows/riscv-openocd-ci.yml +++ b/.github/workflows/riscv-openocd-ci.yml @@ -74,13 +74,13 @@ jobs: id: collect_cov if: steps.run_tests.outputs.exit_code == 0 run: | - cd riscv-openocd-ci + cd riscv-openocd-ci/work/riscv-openocd echo "1" ls -l echo "2" - lcov --capture --directory work/riscv-openocd --output-file work/openocd-coverage.info + lcov --capture --directory . --output-file openocd-coverage.info echo "3" - genhtml work/openocd-coverage.info --output-directory work/results/openocd-coverage + genhtml openocd-coverage.info --output-directory ../results/openocd-coverage echo "4" - name: Store OpenOCD code coverage From 1811218559e8830792714921f08b4ceada8b6b90 Mon Sep 17 00:00:00 2001 From: Jan Matyas Date: Mon, 28 Dec 2020 15:44:16 +0100 Subject: [PATCH 26/39] WIP 24 Change-Id: If394d74b409616ba70a2eb672e313e2837549871 --- .github/workflows/riscv-openocd-ci.yml | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/.github/workflows/riscv-openocd-ci.yml b/.github/workflows/riscv-openocd-ci.yml index 4d4ea209b6..d65f889ba5 100644 --- a/.github/workflows/riscv-openocd-ci.yml +++ b/.github/workflows/riscv-openocd-ci.yml @@ -74,14 +74,8 @@ jobs: id: collect_cov if: steps.run_tests.outputs.exit_code == 0 run: | - cd riscv-openocd-ci/work/riscv-openocd - echo "1" - ls -l - echo "2" - lcov --capture --directory . --output-file openocd-coverage.info - echo "3" - genhtml openocd-coverage.info --output-directory ../results/openocd-coverage - echo "4" + lcov --capture --directory . --output-file riscv-openocd-ci/work/openocd-coverage.info + genhtml riscv-openocd-ci/work/openocd-coverage.info --output-directory riscv-openocd-ci/work/results/openocd-coverage - name: Store OpenOCD code coverage if: steps.collect_cov.outputs.exit_code == 0 @@ -89,4 +83,3 @@ jobs: with: name: openocd-coverage path: riscv-openocd-ci/work/results/openocd-coverage - # TODO \ No newline at end of file From d3bd5a982055de02135bd228ce861be47f89adb8 Mon Sep 17 00:00:00 2001 From: Jan Matyas Date: Tue, 29 Dec 2020 11:16:04 +0100 Subject: [PATCH 27/39] WIP 25 Change-Id: Ib5d3915d67e203a9049fd371bc483d8495938ed5 --- .github/workflows/riscv-openocd-ci.yml | 130 ++++++++++++------------- riscv-openocd-ci/build_openocd.sh | 30 ++++++ 2 files changed, 94 insertions(+), 66 deletions(-) create mode 100644 riscv-openocd-ci/build_openocd.sh diff --git a/.github/workflows/riscv-openocd-ci.yml b/.github/workflows/riscv-openocd-ci.yml index d65f889ba5..4840d6092e 100644 --- a/.github/workflows/riscv-openocd-ci.yml +++ b/.github/workflows/riscv-openocd-ci.yml @@ -16,70 +16,68 @@ jobs: uses: actions/checkout@v2 - name: Build OpenOCD - run: | - cd riscv-openocd-ci - python3 build_openocd.py --src-dir ../ --install-dir work/install/ --coverage - - - name: Checkout Spike - run: | - cd riscv-openocd-ci - mkdir -p work - cd work - git clone https://github.com/riscv/riscv-isa-sim.git --recursive - - - name: Build Spike - run: | - cd riscv-openocd-ci - python3 build_spike.py --src-dir work/riscv-isa-sim --install-dir work/install/ - - - name: Download RISC-V toolchain - # TODO - run: | - cd riscv-openocd-ci/work - wget --progress dot:mega "https://buildbot.embecosm.com/job/riscv32-gcc-ubuntu1804/25/artifact/riscv32-embecosm-gcc-ubuntu1804-20201108.tar.gz" - tar -C install -xvf riscv32-embecosm-gcc-ubuntu1804-20201108.tar.gz --strip-components=1 - cd install/bin - find . -name 'riscv32-*' | while read F; do ln -s $F $(echo $F | sed -e 's/riscv32/riscv64/'); done - - - name: Checkout riscv-tests - run: | - cd riscv-openocd-ci/work - git clone https://github.com/riscv/riscv-tests.git --recursive - - - name: Update env. variables - run: | - echo "`pwd`/riscv-openocd-ci/work/install/bin" >> $GITHUB_PATH - echo "RISCV=`pwd`/riscv-openocd-ci/work/install" >> $GITHUB_ENV - - - name: Run riscv-tests/debug - # TODO: make all - id: run_tests - run: | - cd riscv-openocd-ci/work/riscv-tests/debug - make -k || true - - - name: Process test results - run: | - cd riscv-openocd-ci - python3 process_test_results.py --log-dir work/riscv-tests/debug/logs --output-dir work/results/logs - - - name: Store test results - if: steps.run_tests.outputs.exit_code == 0 - uses: actions/upload-artifact@v2 - with: - name: test-results - path: riscv-openocd-ci/work/results/logs - - - name: Collect OpenOCD code coverage - id: collect_cov - if: steps.run_tests.outputs.exit_code == 0 - run: | - lcov --capture --directory . --output-file riscv-openocd-ci/work/openocd-coverage.info - genhtml riscv-openocd-ci/work/openocd-coverage.info --output-directory riscv-openocd-ci/work/results/openocd-coverage + run: bash riscv-openocd-ci/build_openocd.sh - - name: Store OpenOCD code coverage - if: steps.collect_cov.outputs.exit_code == 0 - uses: actions/upload-artifact@v2 - with: - name: openocd-coverage - path: riscv-openocd-ci/work/results/openocd-coverage +# - name: Checkout Spike +# run: | +# cd riscv-openocd-ci +# mkdir -p work +# cd work +# git clone https://github.com/riscv/riscv-isa-sim.git --recursive +# +# - name: Build Spike +# run: | +# cd riscv-openocd-ci +# python3 build_spike.py --src-dir work/riscv-isa-sim --install-dir work/install/ +# +# - name: Download RISC-V toolchain +# # TODO +# run: | +# cd riscv-openocd-ci/work +# wget --progress dot:mega "https://buildbot.embecosm.com/job/riscv32-gcc-ubuntu1804/25/artifact/riscv32-embecosm-gcc-ubuntu1804-20201108.tar.gz" +# tar -C install -xvf riscv32-embecosm-gcc-ubuntu1804-20201108.tar.gz --strip-components=1 +# cd install/bin +# find . -name 'riscv32-*' | while read F; do ln -s $F $(echo $F | sed -e 's/riscv32/riscv64/'); done +# +# - name: Checkout riscv-tests +# run: | +# cd riscv-openocd-ci/work +# git clone https://github.com/riscv/riscv-tests.git --recursive +# +# - name: Update env. variables +# run: | +# echo "`pwd`/riscv-openocd-ci/work/install/bin" >> $GITHUB_PATH +# echo "RISCV=`pwd`/riscv-openocd-ci/work/install" >> $GITHUB_ENV +# +# - name: Run riscv-tests/debug +# # TODO: make all +# id: run_tests +# run: | +# cd riscv-openocd-ci/work/riscv-tests/debug +# make -k || true +# +# - name: Process test results +# run: | +# cd riscv-openocd-ci +# python3 process_test_results.py --log-dir work/riscv-tests/debug/logs --output-dir work/results/logs +# +# - name: Store test results +# if: steps.run_tests.outputs.exit_code == 0 +# uses: actions/upload-artifact@v2 +# with: +# name: test-results +# path: riscv-openocd-ci/work/results/logs +# +# - name: Collect OpenOCD code coverage +# id: collect_cov +# if: steps.run_tests.outputs.exit_code == 0 +# run: | +# lcov --capture --directory . --output-file riscv-openocd-ci/work/openocd-coverage.info +# genhtml riscv-openocd-ci/work/openocd-coverage.info --output-directory riscv-openocd-ci/work/results/openocd-coverage +# +# - name: Store OpenOCD code coverage +# if: steps.collect_cov.outputs.exit_code == 0 +# uses: actions/upload-artifact@v2 +# with: +# name: openocd-coverage +# path: riscv-openocd-ci/work/results/openocd-coverage diff --git a/riscv-openocd-ci/build_openocd.sh b/riscv-openocd-ci/build_openocd.sh new file mode 100644 index 0000000000..f368fa674a --- /dev/null +++ b/riscv-openocd-ci/build_openocd.sh @@ -0,0 +1,30 @@ +#!/bin/bash + +INSTALL_DIR=`pwd`/riscv-openocd-ci/work/install + +# Fail on first error. +set -e + +# Assuming OpenOCD source is already checked-out in the CWD. + +./bootstrap + +# Enable most frequently used JTAG drivers. +# Allow for code coverage collection. +./configure \ + --enable-remote-bitbang \ + --enable-jtag_vpi \ + --enable-ftdi \ + --prefix=$INSTALL_DIR \ + CFLAGS="-O0 --coverage -fprofile-arcs -ftest-coverage" \ + CXXFLAGS="-O0 --coverage -fprofile-arcs -ftest-coverage" \ + LDFLAGS="-fprofile-arcs -lgcov" + +# Patch OpenOCD so that coverage is recorded also when terminated +# by a signal. +git apply riscv-openocd-ci/patches/openocd_gcov_flush.patch + +# Build and install OpenOCD +make clean # safety +make -j`nproc` +make install From bfe3ff127378f0d2b48e953801b9ecd7cc392a7d Mon Sep 17 00:00:00 2001 From: Jan Matyas Date: Tue, 29 Dec 2020 11:31:20 +0100 Subject: [PATCH 28/39] WIP 26 Change-Id: I795da1fdcd095c418696a8a998b02a3f329f4512 --- .github/workflows/riscv-openocd-ci.yml | 10 +++------- riscv-openocd-ci/build_openocd.sh | 3 +++ riscv-openocd-ci/build_spike.sh | 23 +++++++++++++++++++++++ 3 files changed, 29 insertions(+), 7 deletions(-) create mode 100644 riscv-openocd-ci/build_spike.sh diff --git a/.github/workflows/riscv-openocd-ci.yml b/.github/workflows/riscv-openocd-ci.yml index 4840d6092e..a2c9129985 100644 --- a/.github/workflows/riscv-openocd-ci.yml +++ b/.github/workflows/riscv-openocd-ci.yml @@ -18,13 +18,9 @@ jobs: - name: Build OpenOCD run: bash riscv-openocd-ci/build_openocd.sh -# - name: Checkout Spike -# run: | -# cd riscv-openocd-ci -# mkdir -p work -# cd work -# git clone https://github.com/riscv/riscv-isa-sim.git --recursive -# + - name: Checkout & build Spike + run: bash riscv-openocd-ci/build_spike.sh + # - name: Build Spike # run: | # cd riscv-openocd-ci diff --git a/riscv-openocd-ci/build_openocd.sh b/riscv-openocd-ci/build_openocd.sh index f368fa674a..d8882ee781 100644 --- a/riscv-openocd-ci/build_openocd.sh +++ b/riscv-openocd-ci/build_openocd.sh @@ -28,3 +28,6 @@ git apply riscv-openocd-ci/patches/openocd_gcov_flush.patch make clean # safety make -j`nproc` make install + +# Check that OpenOCD runs +$INSTALL_DIR/bin/openocd --version \ No newline at end of file diff --git a/riscv-openocd-ci/build_spike.sh b/riscv-openocd-ci/build_spike.sh new file mode 100644 index 0000000000..c1de4276b3 --- /dev/null +++ b/riscv-openocd-ci/build_spike.sh @@ -0,0 +1,23 @@ +#!/bin/bash + +CHECKOUT_DIR=`pwd`/riscv-openocd-ci/work/riscv-isa-sim +INSTALL_DIR=`pwd`/riscv-openocd-ci/work/install + +# Fail on first error. +set -e + +# Checkout Spike. +mkdir -p "$CHECKOUT_DIR" +cd "$CHECKOUT_DIR" +git clone --recursive https://github.com/riscv/riscv-isa-sim.git . + +# Build Spike +mkdir build +cd build +bash ../configure --prefix=$INSTALL_DIR +make clean # safety +make -j`nproc` +make install + +# Check that Spike runs +$INSTALL_DIR/bin/spike --help From 99d102c4072bc83d6573d0a2def76ca4b552960c Mon Sep 17 00:00:00 2001 From: Jan Matyas Date: Tue, 29 Dec 2020 13:03:54 +0100 Subject: [PATCH 29/39] WIP 27 Change-Id: I806f916e0f2d735799a70b781cff683c5560b6a1 --- .github/workflows/riscv-openocd-ci.yml | 93 ++++++++++---------------- riscv-openocd-ci/.gitignore | 1 + riscv-openocd-ci/build_openocd.sh | 7 +- riscv-openocd-ci/build_spike.sh | 3 + riscv-openocd-ci/download_toolchain.sh | 30 +++++++++ riscv-openocd-ci/run_tests.sh | 20 ++++++ 6 files changed, 96 insertions(+), 58 deletions(-) create mode 100644 riscv-openocd-ci/.gitignore create mode 100644 riscv-openocd-ci/download_toolchain.sh create mode 100644 riscv-openocd-ci/run_tests.sh diff --git a/.github/workflows/riscv-openocd-ci.yml b/.github/workflows/riscv-openocd-ci.yml index a2c9129985..4249f353d6 100644 --- a/.github/workflows/riscv-openocd-ci.yml +++ b/.github/workflows/riscv-openocd-ci.yml @@ -21,59 +21,40 @@ jobs: - name: Checkout & build Spike run: bash riscv-openocd-ci/build_spike.sh -# - name: Build Spike -# run: | -# cd riscv-openocd-ci -# python3 build_spike.py --src-dir work/riscv-isa-sim --install-dir work/install/ -# -# - name: Download RISC-V toolchain -# # TODO -# run: | -# cd riscv-openocd-ci/work -# wget --progress dot:mega "https://buildbot.embecosm.com/job/riscv32-gcc-ubuntu1804/25/artifact/riscv32-embecosm-gcc-ubuntu1804-20201108.tar.gz" -# tar -C install -xvf riscv32-embecosm-gcc-ubuntu1804-20201108.tar.gz --strip-components=1 -# cd install/bin -# find . -name 'riscv32-*' | while read F; do ln -s $F $(echo $F | sed -e 's/riscv32/riscv64/'); done -# -# - name: Checkout riscv-tests -# run: | -# cd riscv-openocd-ci/work -# git clone https://github.com/riscv/riscv-tests.git --recursive -# -# - name: Update env. variables -# run: | -# echo "`pwd`/riscv-openocd-ci/work/install/bin" >> $GITHUB_PATH -# echo "RISCV=`pwd`/riscv-openocd-ci/work/install" >> $GITHUB_ENV -# -# - name: Run riscv-tests/debug -# # TODO: make all -# id: run_tests -# run: | -# cd riscv-openocd-ci/work/riscv-tests/debug -# make -k || true -# -# - name: Process test results -# run: | -# cd riscv-openocd-ci -# python3 process_test_results.py --log-dir work/riscv-tests/debug/logs --output-dir work/results/logs -# -# - name: Store test results -# if: steps.run_tests.outputs.exit_code == 0 -# uses: actions/upload-artifact@v2 -# with: -# name: test-results -# path: riscv-openocd-ci/work/results/logs -# -# - name: Collect OpenOCD code coverage -# id: collect_cov -# if: steps.run_tests.outputs.exit_code == 0 -# run: | -# lcov --capture --directory . --output-file riscv-openocd-ci/work/openocd-coverage.info -# genhtml riscv-openocd-ci/work/openocd-coverage.info --output-directory riscv-openocd-ci/work/results/openocd-coverage -# -# - name: Store OpenOCD code coverage -# if: steps.collect_cov.outputs.exit_code == 0 -# uses: actions/upload-artifact@v2 -# with: -# name: openocd-coverage -# path: riscv-openocd-ci/work/results/openocd-coverage + - name: Download RISC-V toolchain + run: bash riscv-openocd-ci/download_toolchain.sh + + - name: Update env. variables + # change RISCV and PATH vars for subsequent steps + run: | + echo "`pwd`/riscv-openocd-ci/work/install/bin" >> $GITHUB_PATH + echo "RISCV=`pwd`/riscv-openocd-ci/work/install" >> $GITHUB_ENV + + - name: Checkout & run riscv-tests + run: bash riscv-openocd-ci/run_tests.sh + + - name: Process test results + run: | + cd riscv-openocd-ci + python3 process_test_results.py --log-dir work/riscv-tests/debug/logs --output-dir work/results/logs + + - name: Store test results + if: steps.run_tests.outputs.exit_code == 0 + uses: actions/upload-artifact@v2 + with: + name: test-results + path: riscv-openocd-ci/work/results/logs + + - name: Collect OpenOCD code coverage + id: collect_cov + if: steps.run_tests.outputs.exit_code == 0 + run: | + lcov --capture --directory . --output-file riscv-openocd-ci/work/openocd-coverage.info + genhtml riscv-openocd-ci/work/openocd-coverage.info --output-directory riscv-openocd-ci/work/results/openocd-coverage + + - name: Store OpenOCD code coverage + if: steps.collect_cov.outputs.exit_code == 0 + uses: actions/upload-artifact@v2 + with: + name: openocd-coverage + path: riscv-openocd-ci/work/results/openocd-coverage diff --git a/riscv-openocd-ci/.gitignore b/riscv-openocd-ci/.gitignore new file mode 100644 index 0000000000..b8f99f5be5 --- /dev/null +++ b/riscv-openocd-ci/.gitignore @@ -0,0 +1 @@ +work diff --git a/riscv-openocd-ci/build_openocd.sh b/riscv-openocd-ci/build_openocd.sh index d8882ee781..eeb3908d24 100644 --- a/riscv-openocd-ci/build_openocd.sh +++ b/riscv-openocd-ci/build_openocd.sh @@ -5,7 +5,10 @@ INSTALL_DIR=`pwd`/riscv-openocd-ci/work/install # Fail on first error. set -e -# Assuming OpenOCD source is already checked-out in the CWD. +# Echo commands. +set -o xtrace + +# Assuming OpenOCD source is already checked-out in the current workdir. ./bootstrap @@ -30,4 +33,4 @@ make -j`nproc` make install # Check that OpenOCD runs -$INSTALL_DIR/bin/openocd --version \ No newline at end of file +$INSTALL_DIR/bin/openocd --version diff --git a/riscv-openocd-ci/build_spike.sh b/riscv-openocd-ci/build_spike.sh index c1de4276b3..148d6e8ca5 100644 --- a/riscv-openocd-ci/build_spike.sh +++ b/riscv-openocd-ci/build_spike.sh @@ -6,6 +6,9 @@ INSTALL_DIR=`pwd`/riscv-openocd-ci/work/install # Fail on first error. set -e +# Echo commands. +set -o xtrace + # Checkout Spike. mkdir -p "$CHECKOUT_DIR" cd "$CHECKOUT_DIR" diff --git a/riscv-openocd-ci/download_toolchain.sh b/riscv-openocd-ci/download_toolchain.sh new file mode 100644 index 0000000000..ff87023301 --- /dev/null +++ b/riscv-openocd-ci/download_toolchain.sh @@ -0,0 +1,30 @@ +#!/bin/bash + +TOOLCHAIN_URL="https://buildbot.embecosm.com/job/riscv32-gcc-ubuntu1804/25/artifact/riscv32-embecosm-gcc-ubuntu1804-20201108.tar.gz" +ARCHIVE_NAME=${TOOLCHAIN_URL##*/} +DOWNLOAD_DIR=`pwd`/riscv-openocd-ci/work +INSTALL_DIR=`pwd`/riscv-openocd-ci/work/install + +# Fail on first error. +set -e + +# Echo commands. +set -o xtrace + +# Download the toolchain. +# Use a pre-built toolchain binaries provided by Embecosm: https://buildbot.embecosm.com/ +mkdir -p "$DOWNLOAD_DIR" +cd "$DOWNLOAD_DIR" +wget --progress dot:mega "$TOOLCHAIN_URL" + +# Extract +mkdir -p "$INSTALL_DIR" +cd "$INSTALL_DIR" +tar xvf "$DOWNLOAD_DIR/$ARCHIVE_NAME" --strip-components=1 + +# Make symlinks: riscv64-* --> riscv32-* +cd "$INSTALL_DIR/bin" +find . -name 'riscv32-*' | while read F; do ln -s $F $(echo $F | sed -e 's/riscv32/riscv64/'); done + +# Check that the compiler runs +./riscv64-unknown-elf-gcc --version diff --git a/riscv-openocd-ci/run_tests.sh b/riscv-openocd-ci/run_tests.sh new file mode 100644 index 0000000000..f7b308df67 --- /dev/null +++ b/riscv-openocd-ci/run_tests.sh @@ -0,0 +1,20 @@ +#!/bin/bash + +CHECKOUT_DIR=`pwd`/riscv-openocd-ci/work/riscv-isa-sim + +# Fail on first error. +set -e + +# Echo commands. +set -o xtrace + +# Checkout riscv-tests. +mkdir -p "$CHECKOUT_DIR" +cd "$CHECKOUT_DIR" +git clone --recursive https://github.com/riscv/riscv-tests . + +# Run the debug tests. +# Do not stop even if there is a failed test. +cd debug +make -k || true + From 99e710bb3eb3e3047b96566ba60d59b2657278b7 Mon Sep 17 00:00:00 2001 From: Jan Matyas Date: Tue, 29 Dec 2020 13:18:20 +0100 Subject: [PATCH 30/39] WIP 28 Change-Id: I352e2a233e69c4b16f287d6262e28491946321c0 --- riscv-openocd-ci/run_tests.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/riscv-openocd-ci/run_tests.sh b/riscv-openocd-ci/run_tests.sh index f7b308df67..323b8b8fe3 100644 --- a/riscv-openocd-ci/run_tests.sh +++ b/riscv-openocd-ci/run_tests.sh @@ -1,6 +1,6 @@ #!/bin/bash -CHECKOUT_DIR=`pwd`/riscv-openocd-ci/work/riscv-isa-sim +CHECKOUT_DIR=`pwd`/riscv-openocd-ci/work/riscv-tests # Fail on first error. set -e From eeb8262f7856370d804ec57de5996db016a5de91 Mon Sep 17 00:00:00 2001 From: Jan Matyas Date: Tue, 29 Dec 2020 15:21:13 +0100 Subject: [PATCH 31/39] WIP 29 Change-Id: I568dd942fac003a4af526e4eccd0f3f7b48449d1 --- .github/workflows/riscv-openocd-ci.yml | 2 +- riscv-openocd-ci/process_test_results.py | 94 ++++++++---- riscv-openocd-ci/run_tests.sh | 5 +- riscv-openocd-ci/utils/__init__.py | 0 .../utils/__pycache__/__init__.cpython-37.pyc | Bin 158 -> 0 bytes .../utils/__pycache__/utils.cpython-37.pyc | Bin 4504 -> 0 bytes riscv-openocd-ci/utils/utils.py | 145 ------------------ 7 files changed, 66 insertions(+), 180 deletions(-) delete mode 100644 riscv-openocd-ci/utils/__init__.py delete mode 100644 riscv-openocd-ci/utils/__pycache__/__init__.cpython-37.pyc delete mode 100644 riscv-openocd-ci/utils/__pycache__/utils.cpython-37.pyc delete mode 100644 riscv-openocd-ci/utils/utils.py diff --git a/.github/workflows/riscv-openocd-ci.yml b/.github/workflows/riscv-openocd-ci.yml index 4249f353d6..32271d6bde 100644 --- a/.github/workflows/riscv-openocd-ci.yml +++ b/.github/workflows/riscv-openocd-ci.yml @@ -25,7 +25,7 @@ jobs: run: bash riscv-openocd-ci/download_toolchain.sh - name: Update env. variables - # change RISCV and PATH vars for subsequent steps + # Change RISCV and PATH env variables for subsequent steps. run: | echo "`pwd`/riscv-openocd-ci/work/install/bin" >> $GITHUB_PATH echo "RISCV=`pwd`/riscv-openocd-ci/work/install" >> $GITHUB_ENV diff --git a/riscv-openocd-ci/process_test_results.py b/riscv-openocd-ci/process_test_results.py index caa60c5b88..3e183e26d0 100644 --- a/riscv-openocd-ci/process_test_results.py +++ b/riscv-openocd-ci/process_test_results.py @@ -1,5 +1,5 @@ - +from glob import glob import logging from logging import info from multiprocessing import cpu_count @@ -7,14 +7,22 @@ import re import shutil import sys -from utils.utils import MeasureTime, ChangeWorkdir, run_cmd, info_box, git_apply_patch, git_revision_info, \ - check_file_exists, check_dir_exists KNOWN_RESULTS = ["pass", "fail", "not_applicable", "exception"] -SUMMARY_FILE = "test_summary.txt" + + +def info_box(msg): + """Display an emphasized message - print an ASCII box around it. """ + box = " +==" + ("=" * len(msg)) + "==+" + info("") + info(box) + info(" | " + msg + " |") + info(box) + info("") def parse_args(): + """Process command-line arguments. """ import argparse parser = argparse.ArgumentParser("Process logs from riscv-tests/debug") parser.add_argument("--log-dir", required=True, help="Directory where logs from RISC-V debug tests are stored") @@ -23,26 +31,35 @@ def parse_args(): def process_test_logs(log_dir, output_dir): - from glob import glob - check_dir_exists(log_dir) + """Process all logs from the testing. """ + + assert os.path.isdir(log_dir) os.makedirs(output_dir, exist_ok=True) # process log files file_pattern = os.path.join(log_dir, "*.log") - res = [] - for lf in sorted(glob(file_pattern)): + log_files = sorted(glob(file_pattern)) + + if not len(log_files): + # Did not find any *.log. + # Either the tests did not start at all or a wrong log directory was specified. + raise RuntimeError("No log files (*.log) in directory {}".format(log_dir)) + + tests = [] + for lf in log_files: target, result = process_one_log(lf) copy_one_log(lf, result, output_dir) - res += [(lf, target, result)] + tests += [{"log": lf, "target": target, "result": result}] - any_failed = aggregate_results(res) - return any_failed + return tests def process_one_log(log_file): - check_file_exists(log_file) + """Parse a single log file, extract required pieces from it. """ + assert os.path.isfile(log_file) target = None result = None + # Find target name and the test result in the log file for line in open(log_file, "r"): target_match = re.match(r"^Target: (\S+)$", line) if target_match is not None: @@ -64,32 +81,43 @@ def process_one_log(log_file): def copy_one_log(log_file, result, output_dir): - # copy the log to an output sub-folder based on the result + """Copy the log to a sub-folder based on the result. """ target_dir = os.path.join(output_dir, result) os.makedirs(target_dir, exist_ok=True) assert os.path.isdir(target_dir) shutil.copy2(log_file, target_dir) -def aggregate_results(res): +def print_aggregated_results(tests): + """Print the tests grouped by the result. Print also pass/fail/... counts.""" + + def _filter_tests(tests, target=None, result=None): + tests_out = tests + if target is not None: + tests_out = filter(lambda t: t["target"] == target, tests_out) + if result is not None: + tests_out = filter(lambda t: t["result"] == result, tests_out) + return list(tests_out) + # Print lists of passed/failed/... tests outcomes = { - "Passed tests" : "pass", + "Passed tests": "pass", "Not applicable tests": "not_applicable", "Failed tests": "fail", "Tests ended with exception": "exception", } - - for caption, filter in outcomes.items(): + for caption, result in outcomes.items(): info_box(caption) - tests_filtered = [lf for lf, _, r in res if r == filter] - for lf in tests_filtered: - name = os.path.splitext(os.path.basename(lf))[0] + tests_filtered = _filter_tests(tests, result=result) + for t in tests_filtered: + name = os.path.splitext(os.path.basename(t["log"]))[0] info(name) if not tests_filtered: info("(none)") - target_names = set([t for (_, t, _) in res]) + target_names = sorted(set([t["target"] for t in tests])) + + # Print summary - passed/failed/... counts, for each target and total info_box("Summary") @@ -100,20 +128,20 @@ def _print_row(target, total, num_pass, num_na, num_fail, num_exc): _print_row("-----", "-----", "-----", "-----", "-----", "-----") sum_pass = sum_na = sum_fail = sum_exc = 0 for tn in target_names: - t_pass = sum([1 for _, t, r in res if t == tn and r == "pass"]) - t_na = sum([1 for _, t, r in res if t == tn and r == "not_applicable"]) - t_fail = sum([1 for _, t, r in res if t == tn and r == "fail"]) - t_exc = sum([1 for _, t, r in res if t == tn and r == "exception"]) - t_sum = sum([1 for _, t, _ in res if t == tn]) - assert t_sum == t_pass + t_na + t_fail + t_exc + t_pass = len(_filter_tests(tests, target=tn, result="pass")) + t_na = len(_filter_tests(tests, target=tn, result="not_applicable")) + t_fail = len(_filter_tests(tests, target=tn, result="fail")) + t_exc = len(_filter_tests(tests, target=tn, result="exception")) + t_sum = len(_filter_tests(tests, target=tn)) + assert t_sum == t_pass + t_na + t_fail + t_exc # self-check _print_row(tn, t_sum, t_pass, t_na, t_fail, t_exc) sum_pass += t_pass sum_na += t_na sum_fail += t_fail sum_exc += t_exc - assert len(res) == sum_pass + sum_na + sum_fail + sum_exc + assert len(tests) == sum_pass + sum_na + sum_fail + sum_exc # self-check _print_row("-----", "-----", "-----", "-----", "-----", "-----") - _print_row("All targets:", len(res), sum_pass, sum_na, sum_fail, sum_exc) + _print_row("All targets:", len(tests), sum_pass, sum_na, sum_fail, sum_exc) _print_row("-----", "-----", "-----", "-----", "-----", "-----") any_failed = (sum_fail + sum_exc) > 0 @@ -123,11 +151,15 @@ def _print_row(target, total, num_pass, num_na, num_fail, num_exc): def main(): args = parse_args() - # use absolute paths + # Use absolute paths. args.log_dir = os.path.abspath(args.log_dir) args.output_dir = os.path.abspath(args.output_dir) - any_failed = process_test_logs(args.log_dir, args.output_dir) + # Process the log files and print results. + tests = process_test_logs(args.log_dir, args.output_dir) + any_failed = print_aggregated_results(tests) + + # The overall exit code. return 1 if any_failed else 0 diff --git a/riscv-openocd-ci/run_tests.sh b/riscv-openocd-ci/run_tests.sh index 323b8b8fe3..bc52069a12 100644 --- a/riscv-openocd-ci/run_tests.sh +++ b/riscv-openocd-ci/run_tests.sh @@ -14,7 +14,6 @@ cd "$CHECKOUT_DIR" git clone --recursive https://github.com/riscv/riscv-tests . # Run the debug tests. -# Do not stop even if there is a failed test. +# Do not stop even on a failed test. cd debug -make -k || true - +make -k all || true diff --git a/riscv-openocd-ci/utils/__init__.py b/riscv-openocd-ci/utils/__init__.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/riscv-openocd-ci/utils/__pycache__/__init__.cpython-37.pyc b/riscv-openocd-ci/utils/__pycache__/__init__.cpython-37.pyc deleted file mode 100644 index f556d3cc5bbba868f7f18e7001680e74b40eed72..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 158 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 diff --git a/riscv-openocd-ci/utils/utils.py b/riscv-openocd-ci/utils/utils.py deleted file mode 100644 index afa6ac5208..0000000000 --- a/riscv-openocd-ci/utils/utils.py +++ /dev/null @@ -1,145 +0,0 @@ -from contextlib import contextmanager -from datetime import timedelta -from logging import info -import os -import shutil -import subprocess -import sys -import time - - -def info_box(msg): - box = " +==" + ("=" * len(msg)) + "==+" - info("") - info(box) - info(" | " + msg + " |") - info(box) - info("") - - -@contextmanager -def _stdout_manager(display_stdout=False, stdout_to_file=None, stdout_capture=False): - assert sum([bool(display_stdout), bool(stdout_to_file), bool(stdout_capture)]) <= 1, \ - "Can't direct stdout to multiple places at the same time" - f = None - try: - if display_stdout: - # inherit stdout from parent - yield None - elif stdout_to_file: - # log stdout to file - f = open(stdout_to_file, "w") - yield f - elif stdout_capture: - # capture stdout for further processing - yield subprocess.PIPE - else: - # drop stdout - yield subprocess.DEVNULL - finally: - if f: - f.close() - - -def run_cmd(args, cwd=None, timeout=None, display_stdout=True, stdout_to_file=None, - stdout_capture=False, suppress_info=False, display_stderr=True): - from subprocess import check_call - if cwd is None: - cwd = os.getcwd() - with _stdout_manager(display_stdout=display_stdout, - stdout_to_file=stdout_to_file, - stdout_capture=stdout_capture) as stdout: - - if not suppress_info: - info("Running cmd: {}".format(args)) - info(" cwd: {}".format(cwd)) - if stdout_to_file: - info(" log file: {}".format(stdout_to_file)) - return subprocess.run(args, check=True, cwd=cwd, stdout=stdout, - stderr=None if display_stderr else subprocess.DEVNULL, - timeout=timeout, encoding="utf-8") - - -def git_apply_patch(patch_file, target_dir): - check_file_exists(patch_file) - check_dir_exists(target_dir) - patch_file = os.path.abspath(patch_file) - with ChangeWorkdir(target_dir): - run_cmd(["git", "apply", patch_file]) - - -def require_python_ver(major, minor, patch): - if sys.version_info < (major, minor, patch): - raise RuntimeError("Python {}.{}.{} or newer is required.".format(major, minor, patch)) - - -def require_module(mod_name, hint=None): - import importlib - try: - importlib.import_module(mod_name) - except ImportError: - msg = "Python module '{}' is required.".format(mod_name) - if hint: - msg += " Hint: " + hint - raise RuntimeError(msg) - - -def require_in_path(tool_name): - if shutil.which(tool_name) is None: - raise RuntimeError("Did not find '{}' in your system PATH.".format(tool_name)) - - -def git_revision_info(repo_dir): - def _git_show(format): - proc = run_cmd(["git", "show", "-s", "--format=" + format], display_stdout=False, stdout_capture=True) - return proc.stdout.strip() - - check_dir_exists(repo_dir) - with ChangeWorkdir(repo_dir): - return { - "hash": _git_show("%H"), - "subject": _git_show("%s"), - "author": _git_show("%an"), - "author_date": _git_show("%ai"), - "commit_date": _git_show("%ci") - } - - -def check_file_exists(f): - if not os.path.exists(f): - raise RuntimeError("File does not exist: {}".format(f)) - if not os.path.isfile(f): - raise RuntimeError("Not a file: {}".format(f)) - - -def check_dir_exists(d): - if not os.path.exists(d): - raise RuntimeError("Directory does not exist: {}".format(f)) - if not os.path.isdir(d): - raise RuntimeError("Not a directory: {}".format(f)) - - -class MeasureTime(object): - def __init__(self, description): - self.description = description - - def __enter__(self): - self.start = time.time() - - def __exit__(self, exc_type, exc_value, exc_traceback): - # print the duration into the log - duration_secs = time.time() - self.start - duration_secs = int(duration_secs) # drop usec - result = "completed" if exc_type is None else "FAILED" - delta = timedelta(seconds=duration_secs) - info("{} {}, duration: {}".format(self.description, result, delta)) - - -@contextmanager -def ChangeWorkdir(path): - old_wd = os.getcwd() - os.chdir(path) - try: - yield - finally: - os.chdir(old_wd) From f3e904b95b8794c0547a2334860d7c8c663250ee Mon Sep 17 00:00:00 2001 From: Jan Matyas Date: Tue, 29 Dec 2020 17:11:36 +0100 Subject: [PATCH 32/39] WIP 30 Change-Id: I1990b3953cb43536f3368490374f1ab2c1a821e7 --- riscv-openocd-ci/process_test_results.py | 10 +++++++--- riscv-openocd-ci/run_tests.sh | 2 +- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/riscv-openocd-ci/process_test_results.py b/riscv-openocd-ci/process_test_results.py index 3e183e26d0..d5949b0eb9 100644 --- a/riscv-openocd-ci/process_test_results.py +++ b/riscv-openocd-ci/process_test_results.py @@ -1,8 +1,7 @@ from glob import glob import logging -from logging import info -from multiprocessing import cpu_count +from logging import info, error import os import re import shutil @@ -160,7 +159,12 @@ def main(): any_failed = print_aggregated_results(tests) # The overall exit code. - return 1 if any_failed else 0 + exit_code = 1 if any_failed else 0 + if any_failed: + error("Encountered failed test(s). Exiting with non-zero return code.") + else: + info("Success - no failed tests encountered.") + return exit_code if __name__ == '__main__': diff --git a/riscv-openocd-ci/run_tests.sh b/riscv-openocd-ci/run_tests.sh index bc52069a12..bdb9dd80ed 100644 --- a/riscv-openocd-ci/run_tests.sh +++ b/riscv-openocd-ci/run_tests.sh @@ -16,4 +16,4 @@ git clone --recursive https://github.com/riscv/riscv-tests . # Run the debug tests. # Do not stop even on a failed test. cd debug -make -k all || true +make -k -j`nproc` all || true From 8071af50d5e56749de89a1cef494800212fcd63c Mon Sep 17 00:00:00 2001 From: Jan Matyas Date: Tue, 29 Dec 2020 17:22:34 +0100 Subject: [PATCH 33/39] WIP 31 Change-Id: Ic539ea713aed024b9c5a4fb5c4a513181f70b2e3 --- .github/workflows/riscv-openocd-ci.yml | 1 + riscv-openocd-ci/process_test_results.py | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/riscv-openocd-ci.yml b/.github/workflows/riscv-openocd-ci.yml index 32271d6bde..905a770fd6 100644 --- a/.github/workflows/riscv-openocd-ci.yml +++ b/.github/workflows/riscv-openocd-ci.yml @@ -31,6 +31,7 @@ jobs: echo "RISCV=`pwd`/riscv-openocd-ci/work/install" >> $GITHUB_ENV - name: Checkout & run riscv-tests + id: run_tests run: bash riscv-openocd-ci/run_tests.sh - name: Process test results diff --git a/riscv-openocd-ci/process_test_results.py b/riscv-openocd-ci/process_test_results.py index d5949b0eb9..f34e9b6c14 100644 --- a/riscv-openocd-ci/process_test_results.py +++ b/riscv-openocd-ci/process_test_results.py @@ -161,7 +161,7 @@ def main(): # The overall exit code. exit_code = 1 if any_failed else 0 if any_failed: - error("Encountered failed test(s). Exiting with non-zero return code.") + error("Encountered failed test(s). Exiting with non-zero code.") else: info("Success - no failed tests encountered.") return exit_code From fbad0eba9b44cd939f511a55f24b6c411e601ce1 Mon Sep 17 00:00:00 2001 From: Jan Matyas Date: Tue, 29 Dec 2020 17:36:35 +0100 Subject: [PATCH 34/39] WIP 31 - overschedule Change-Id: I5011da97d2a278836e67f06cc58f45dd32ccc502 --- riscv-openocd-ci/run_tests.sh | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/riscv-openocd-ci/run_tests.sh b/riscv-openocd-ci/run_tests.sh index bdb9dd80ed..f8532a44ae 100644 --- a/riscv-openocd-ci/run_tests.sh +++ b/riscv-openocd-ci/run_tests.sh @@ -16,4 +16,6 @@ git clone --recursive https://github.com/riscv/riscv-tests . # Run the debug tests. # Do not stop even on a failed test. cd debug -make -k -j`nproc` all || true +NPROC=`nproc` +NPROC2=$(( $NPROC * 2 )) +make -k -j$NPROC2 all || true From 09839c0c8519c907974abfaeb3b6564a46c4206a Mon Sep 17 00:00:00 2001 From: Jan Matyas Date: Tue, 29 Dec 2020 17:53:26 +0100 Subject: [PATCH 35/39] WIP 31 - overschedule all Change-Id: I1e950a92256084654f6f27880732ea5f6302b041 --- riscv-openocd-ci/build_openocd.sh | 3 ++- riscv-openocd-ci/build_spike.sh | 3 ++- riscv-openocd-ci/run_tests.sh | 5 ++--- 3 files changed, 6 insertions(+), 5 deletions(-) diff --git a/riscv-openocd-ci/build_openocd.sh b/riscv-openocd-ci/build_openocd.sh index eeb3908d24..fcf20fb1f5 100644 --- a/riscv-openocd-ci/build_openocd.sh +++ b/riscv-openocd-ci/build_openocd.sh @@ -29,7 +29,8 @@ git apply riscv-openocd-ci/patches/openocd_gcov_flush.patch # Build and install OpenOCD make clean # safety -make -j`nproc` +JOBS=$(($(nproc) + 2)) +make -j$JOBS make install # Check that OpenOCD runs diff --git a/riscv-openocd-ci/build_spike.sh b/riscv-openocd-ci/build_spike.sh index 148d6e8ca5..962f4bb361 100644 --- a/riscv-openocd-ci/build_spike.sh +++ b/riscv-openocd-ci/build_spike.sh @@ -19,7 +19,8 @@ mkdir build cd build bash ../configure --prefix=$INSTALL_DIR make clean # safety -make -j`nproc` +JOBS=$(($(nproc) + 2)) +make -j$JOBS make install # Check that Spike runs diff --git a/riscv-openocd-ci/run_tests.sh b/riscv-openocd-ci/run_tests.sh index f8532a44ae..eef07698bf 100644 --- a/riscv-openocd-ci/run_tests.sh +++ b/riscv-openocd-ci/run_tests.sh @@ -16,6 +16,5 @@ git clone --recursive https://github.com/riscv/riscv-tests . # Run the debug tests. # Do not stop even on a failed test. cd debug -NPROC=`nproc` -NPROC2=$(( $NPROC * 2 )) -make -k -j$NPROC2 all || true +JOBS=$(($(nproc) + 2)) +make -k -j$JOBS all || true From 5a890e14c8e8cfd85b1072eb7c6782d957e65264 Mon Sep 17 00:00:00 2001 From: Jan Matyas Date: Tue, 29 Dec 2020 18:34:11 +0100 Subject: [PATCH 36/39] WIP 32 Change-Id: I4a46a800f3460532d11bd9914a3e765c35fa72ca --- riscv-openocd-ci/build_openocd.py | 93 ------------------------------- riscv-openocd-ci/build_openocd.sh | 3 +- riscv-openocd-ci/build_spike.py | 73 ------------------------ riscv-openocd-ci/build_spike.sh | 3 +- riscv-openocd-ci/run_tests.sh | 1 + 5 files changed, 3 insertions(+), 170 deletions(-) delete mode 100644 riscv-openocd-ci/build_openocd.py delete mode 100644 riscv-openocd-ci/build_spike.py diff --git a/riscv-openocd-ci/build_openocd.py b/riscv-openocd-ci/build_openocd.py deleted file mode 100644 index 973151f133..0000000000 --- a/riscv-openocd-ci/build_openocd.py +++ /dev/null @@ -1,93 +0,0 @@ - - -import logging -from logging import info -from multiprocessing import cpu_count -import os -import sys -from utils.utils import MeasureTime, ChangeWorkdir, run_cmd, info_box, git_apply_patch, git_revision_info, \ - check_file_exists, check_dir_exists - - -def parse_args(): - import argparse - parser = argparse.ArgumentParser("Build OpenOCD from local (checked-out) source") - parser.add_argument("--src-dir", required=True, help="Directory where OpenOCD source code is located") - parser.add_argument("--install-dir", required=True, help="Directory where to install OpenOCD after the build") - parser.add_argument("--coverage", action="store_true", default=False, - help="Compile OpenOCD with support for code coverage collection (using gcov)") - return parser.parse_args() - - -def print_openocd_rev(src_dir): - rev = git_revision_info(src_dir) - info_box("OpenOCD revision") - info("Commit ID: {}".format(rev["hash"])) - info("Subject: {}".format(rev["subject"])) - info("Author: {}".format(rev["author"])) - info("Author date: {}".format(rev["author_date"])) - info("Commit date: {}".format(rev["commit_date"])) - - -def build_openocd(src_dir, install_dir, with_coverage=False): - check_dir_exists(src_dir) - with ChangeWorkdir(src_dir): - info_box("Bootstrapping OpenOCD ...") - run_cmd(["bash", "./bootstrap"]) - info_box("Configuring OpenOCD ...") - configure_args = [ - "--enable-remote-bitbang", - "--enable-jtag_vpi", - "--enable-ftdi", - "--prefix=" + install_dir - ] - if with_coverage: - configure_args += [ - "CFLAGS=-O0 --coverage -fprofile-arcs -ftest-coverage", - "CXXFLAGS=-O0 --coverage -fprofile-arcs -ftest-coverage", - "LDFLAGS=-fprofile-arcs -lgcov" - ] - run_cmd(["bash", "./configure"] + configure_args) - if with_coverage: - # Need to patch OpenOCD source so that coverage is collected even if OpenOCD - # gets terminated by a signal. - patch_file = os.path.join(script_dir, "patches", "openocd_gcov_flush.patch") - git_apply_patch(patch_file, src_dir) - info_box("Building OpenOCD ...") - run_cmd(["make", "clean"]) # safety - run_cmd(["make", "-j" + str(cpu_count())]) - info_box("Installing OpenOCD ...") - run_cmd(["make", "install"]) - info_box("Finished build of OpenOCD. ") - - -def check_openocd_runs(install_dir): - openocd_binary = os.path.join(install_dir, "bin", "openocd") - check_file_exists(openocd_binary) - info("Checking that OpenOCD runs ...") - run_cmd([openocd_binary, "--version"]) - - -def main(): - args = parse_args() - - # use absolute paths - args.src_dir = os.path.abspath(args.src_dir) - args.install_dir = os.path.abspath(args.install_dir) - - print_openocd_rev(args.src_dir) - build_openocd(args.src_dir, args.install_dir, with_coverage=args.coverage) - check_openocd_runs(args.install_dir) - - return 0 - - -script_dir = None - -if __name__ == '__main__': - logging.getLogger().setLevel(logging.INFO) - script_name = os.path.basename(__file__) - script_dir = os.path.abspath(os.path.dirname(__file__)) - with MeasureTime("Script " + script_name): - retcode = main() - sys.exit(retcode) diff --git a/riscv-openocd-ci/build_openocd.sh b/riscv-openocd-ci/build_openocd.sh index fcf20fb1f5..eeb3908d24 100644 --- a/riscv-openocd-ci/build_openocd.sh +++ b/riscv-openocd-ci/build_openocd.sh @@ -29,8 +29,7 @@ git apply riscv-openocd-ci/patches/openocd_gcov_flush.patch # Build and install OpenOCD make clean # safety -JOBS=$(($(nproc) + 2)) -make -j$JOBS +make -j`nproc` make install # Check that OpenOCD runs diff --git a/riscv-openocd-ci/build_spike.py b/riscv-openocd-ci/build_spike.py deleted file mode 100644 index 8abe255d6c..0000000000 --- a/riscv-openocd-ci/build_spike.py +++ /dev/null @@ -1,73 +0,0 @@ - -from utils.utils import MeasureTime, ChangeWorkdir, run_cmd, info_box, \ - check_dir_exists, check_file_exists, git_revision_info -import logging -from logging import info -from multiprocessing import cpu_count -import os -import sys - - -def parse_args(): - import argparse - parser = argparse.ArgumentParser("Build Spike (RISC-V ISA Simulator) from local (checked-out) source code") - parser.add_argument("--src-dir", required=True, help="Directory where Spike source code is located") - parser.add_argument("--install-dir", required=True, help="Directory where to install Spike after the build") - return parser.parse_args() - - -def print_spike_rev(src_dir): - rev = git_revision_info(src_dir) - info_box("Spike revision") - info("Commit ID: {}".format(rev["hash"])) - info("Subject: {}".format(rev["subject"])) - info("Author: {}".format(rev["author"])) - info("Author date: {}".format(rev["author_date"])) - info("Commit date: {}".format(rev["commit_date"])) - - -def build_spike(src_dir, install_dir): - check_dir_exists(src_dir) - build_dir = os.path.join(src_dir, "build") - os.mkdir(build_dir) - with ChangeWorkdir(build_dir): - info_box("Configuring Spike ...") - run_cmd(["bash", "../configure", "--prefix=" + install_dir]) - info_box("Building Spike ...") - run_cmd(["make", "clean"]) # safety - run_cmd(["make", "-j" + str(cpu_count())]) - info_box("Installing Spike ...") - run_cmd(["make", "install"]) - info_box("Finished Spike build. ") - - -def check_spike_runs(install_dir): - spike_binary = os.path.join(install_dir, "bin", "spike") - check_file_exists(spike_binary) - info("Checking that Spike runs") - run_cmd([spike_binary, "--help"], display_stderr=False) - - -def main(): - args = parse_args() - - # use absolute paths - args.src_dir = os.path.abspath(args.src_dir) - args.install_dir = os.path.abspath(args.install_dir) - - print_spike_rev(args.src_dir) - build_spike(args.src_dir, args.install_dir) - check_spike_runs(args.install_dir) - - return 0 - - -script_dir = None - -if __name__ == '__main__': - logging.getLogger().setLevel(logging.INFO) - script_name = os.path.basename(__file__) - script_dir = os.path.abspath(os.path.dirname(__file__)) - with MeasureTime("Script " + script_name): - retcode = main() - sys.exit(retcode) diff --git a/riscv-openocd-ci/build_spike.sh b/riscv-openocd-ci/build_spike.sh index 962f4bb361..148d6e8ca5 100644 --- a/riscv-openocd-ci/build_spike.sh +++ b/riscv-openocd-ci/build_spike.sh @@ -19,8 +19,7 @@ mkdir build cd build bash ../configure --prefix=$INSTALL_DIR make clean # safety -JOBS=$(($(nproc) + 2)) -make -j$JOBS +make -j`nproc` make install # Check that Spike runs diff --git a/riscv-openocd-ci/run_tests.sh b/riscv-openocd-ci/run_tests.sh index eef07698bf..72d5005e72 100644 --- a/riscv-openocd-ci/run_tests.sh +++ b/riscv-openocd-ci/run_tests.sh @@ -15,6 +15,7 @@ git clone --recursive https://github.com/riscv/riscv-tests . # Run the debug tests. # Do not stop even on a failed test. +# Use slightly more jobs than CPUs. Observed that this still speeds up the testing. cd debug JOBS=$(($(nproc) + 2)) make -k -j$JOBS all || true From fbf71ded4e8245b2cad887257e298fc65b554fb9 Mon Sep 17 00:00:00 2001 From: Jan Matyas Date: Wed, 30 Dec 2020 11:15:47 +0100 Subject: [PATCH 37/39] WIP 33 - added README Change-Id: I13afd733f75de93c76951eff07edd9a78de11221 --- riscv-openocd-ci/README.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 riscv-openocd-ci/README.md diff --git a/riscv-openocd-ci/README.md b/riscv-openocd-ci/README.md new file mode 100644 index 0000000000..1894a636a2 --- /dev/null +++ b/riscv-openocd-ci/README.md @@ -0,0 +1,20 @@ +# CI for riscv-openocd + +This directory contains a set of scripts that automatically +run [riscv-tests/debug](https://github.com/riscv/riscv-tests/tree/master/debug) +against riscv-openocd. + +The scripts are intended to be called automatically by Github +Actions as means of testing & continuous integration for riscv-openocd. + +The scripts perform these actions: + +- Build OpenOCD from source +- Checkout and build Spike (RISC-V ISA simulator) from source +- Download a pre-built RISC-V toolchain +- Use these components together to run + [riscv-tests/debug](https://github.com/riscv/riscv-tests/tree/master/debug) +- Process the test results +- Collect code coverage for OpenOCD + +See [.github/workflows](.github/workflows) for an example of how this is used in practice. From 113f79e3b8ffab2c8dc780a58db8b27e5be05e21 Mon Sep 17 00:00:00 2001 From: Jan Matyas Date: Wed, 30 Dec 2020 11:20:38 +0100 Subject: [PATCH 38/39] WIP 34 Change-Id: I493e73f368f0eaa591b6b9fc8d6397c3f6346875 --- .github/workflows/riscv-openocd-ci.yml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.github/workflows/riscv-openocd-ci.yml b/.github/workflows/riscv-openocd-ci.yml index 905a770fd6..e9c1c7e7d9 100644 --- a/.github/workflows/riscv-openocd-ci.yml +++ b/.github/workflows/riscv-openocd-ci.yml @@ -40,6 +40,7 @@ jobs: python3 process_test_results.py --log-dir work/riscv-tests/debug/logs --output-dir work/results/logs - name: Store test results + # Run if tests were executed. if: steps.run_tests.outputs.exit_code == 0 uses: actions/upload-artifact@v2 with: @@ -48,12 +49,14 @@ jobs: - name: Collect OpenOCD code coverage id: collect_cov + # Run if tests were executed. if: steps.run_tests.outputs.exit_code == 0 run: | lcov --capture --directory . --output-file riscv-openocd-ci/work/openocd-coverage.info genhtml riscv-openocd-ci/work/openocd-coverage.info --output-directory riscv-openocd-ci/work/results/openocd-coverage - name: Store OpenOCD code coverage + # Run if coverage was collected. if: steps.collect_cov.outputs.exit_code == 0 uses: actions/upload-artifact@v2 with: From 2c90682902524dabe6277da1b765ae550024ae41 Mon Sep 17 00:00:00 2001 From: Jan Matyas Date: Wed, 30 Dec 2020 11:25:51 +0100 Subject: [PATCH 39/39] WIP 25 Change-Id: I75e376f038f7496abb93f63eccef3d846c985199 --- riscv-openocd-ci/README.md | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/riscv-openocd-ci/README.md b/riscv-openocd-ci/README.md index 1894a636a2..88c114e67d 100644 --- a/riscv-openocd-ci/README.md +++ b/riscv-openocd-ci/README.md @@ -5,7 +5,7 @@ run [riscv-tests/debug](https://github.com/riscv/riscv-tests/tree/master/debug) against riscv-openocd. The scripts are intended to be called automatically by Github -Actions as means of testing & continuous integration for riscv-openocd. +Actions as a means of testing & continuous integration for riscv-openocd. The scripts perform these actions: @@ -17,4 +17,5 @@ The scripts perform these actions: - Process the test results - Collect code coverage for OpenOCD -See [.github/workflows](.github/workflows) for an example of how this is used in practice. +See [.github/workflows](../.github/workflows) for an example of how this is +used in practice.