From 9ad871546f9fcdb94c8041069bfcfacc3e8c0327 Mon Sep 17 00:00:00 2001 From: Szymon Gizler Date: Tue, 26 Mar 2024 14:03:43 +0100 Subject: [PATCH] Add astsee-related tests --- .github/workflows/build.yml | 5 ++++- .gitignore | 1 + .gitmodules | 3 +++ submodules/astsee | 1 + t/t_dump_json_astsee.pl | 33 +++++++++++++++++++++++++++++++++ t/t_gdb_jtree.gdb | 24 ++++++++++++++++++++++++ t/t_gdb_jtree.pl | 33 +++++++++++++++++++++++++++++++++ 7 files changed, 99 insertions(+), 1 deletion(-) create mode 160000 submodules/astsee create mode 100755 t/t_dump_json_astsee.pl create mode 100644 t/t_gdb_jtree.gdb create mode 100755 t/t_gdb_jtree.pl diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index e7c5691..882a99d 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -60,7 +60,10 @@ jobs: - name: Install packages for tests env: CI_BUILD_STAGE_NAME: test - run: cd submodules/verilator && bash ci/ci-install.bash + run: | + cd submodules/verilator && bash ci/ci-install.bash + PIP_BREAK_SYSTEM_PACKAGES=1 sudo pip install --upgrade pip + PIP_BREAK_SYSTEM_PACKAGES=1 sudo pip install ../astsee - name: Test run: | diff --git a/.gitignore b/.gitignore index 664bfb0..3152087 100644 --- a/.gitignore +++ b/.gitignore @@ -1,2 +1,3 @@ obj_* *.swp +.gdb_history diff --git a/.gitmodules b/.gitmodules index 47a749e..b09d287 100644 --- a/.gitmodules +++ b/.gitmodules @@ -31,3 +31,6 @@ [submodule "submodules/Cores-VeeR-EH1"] path = submodules/Cores-VeeR-EH1 url = https://github.com/chipsalliance/Cores-VeeR-EH1.git +[submodule "submodules/astsee"] + path = submodules/astsee + url = https://github.com/antmicro/astsee.git diff --git a/submodules/astsee b/submodules/astsee new file mode 160000 index 0000000..0f5bc2c --- /dev/null +++ b/submodules/astsee @@ -0,0 +1 @@ +Subproject commit 0f5bc2c5cd54d201baf8f7608acf25bcc8dfe6c9 diff --git a/t/t_dump_json_astsee.pl b/t/t_dump_json_astsee.pl new file mode 100755 index 0000000..595861c --- /dev/null +++ b/t/t_dump_json_astsee.pl @@ -0,0 +1,33 @@ +#!/usr/bin/env perl +if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); die; } +# DESCRIPTION: Verilator: Verilog Test driver/expect definition +# +# Copyright 2003 by Wilson Snyder. This program is free software; you +# can redistribute it and/or modify it under the terms of either the GNU +# Lesser General Public License Version 3 or the Perl Artistic License +# Version 2.0. +# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0 + +# test whether json dumps don't "crash" astsee + +scenarios(vlt => 1); + +{ + my $cmd = qq{astsee_verilator -h >/dev/null 2>&1}; + print "\t$cmd\n" if $::Debug; + system($cmd) and do { skip("No astsee installed\n"); return 1 } +} + +top_filename("$ENV{VERILATOR_ROOT}/test_regress/t/t_dump.v"); + +lint( + v_flags => ["--lint-only --dump-tree-json"], + ); + + +run(cmd => ["cd $Self->{obj_dir} && astsee_verilator *001*.json > astsee.log"], + logfile => "$Self->{obj_dir}/astsee.log"); + +ok(1); + +1; diff --git a/t/t_gdb_jtree.gdb b/t/t_gdb_jtree.gdb new file mode 100644 index 0000000..034c65e --- /dev/null +++ b/t/t_gdb_jtree.gdb @@ -0,0 +1,24 @@ +# Copyright 2024 by Wilson Snyder. This program is free software; you +# can redistribute it and/or modify it under the terms of either the GNU +# Lesser General Public License Version 3 or the Perl Artistic License +# Version 2.0. +# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0 + +watch v3Global.m_rootp +run +python +try: gdb.execute("jtree v3Global.m_rootp") +except Exception: exit(1) +try: gdb.execute("jtree v3Global.m_rootp v3Global.m_rootp") +except Exception: exit(1) + +# stash and use stashed dump +try: gdb.execute("jstash v3Global.m_rootp") +except Exception: exit(1) +# we assume that stash will end up in $1 (we can't use gdb.history_count() since it is not available in older gdb) +try: gdb.execute("jtree $1") +except Exception: exit(1) +try: gdb.execute("jtree $1 v3Global.m_rootp") +except Exception: exit(1) +end +quit 0 diff --git a/t/t_gdb_jtree.pl b/t/t_gdb_jtree.pl new file mode 100755 index 0000000..6282cfb --- /dev/null +++ b/t/t_gdb_jtree.pl @@ -0,0 +1,33 @@ +#!/usr/bin/env perl +if (!$::Driver) { use FindBin; exec("$FindBin::Bin/bootstrap.pl", @ARGV, $0); die; } +# DESCRIPTION: Verilator: Verilog Test driver/expect definition +# +# Copyright 2003 by Wilson Snyder. This program is free software; you +# can redistribute it and/or modify it under the terms of either the GNU +# Lesser General Public License Version 3 or the Perl Artistic License +# Version 2.0. +# SPDX-License-Identifier: LGPL-3.0-only OR Artistic-2.0 + +# test whether jtree gdb command doesn't crash + +scenarios(vlt => 1); + +{ + my $cmd = qq{astsee_verilator -h >/dev/null 2>&1}; + print "\t$cmd\n" if $::Debug; + system($cmd) and do { skip("No astsee installed\n"); return 1 } +} + +setenv("VERILATOR_GDB", "gdb --return-child-result" + . ($::Debug ? " --batch" : " --batch-silent --quiet") + . ' -init-eval-command "set auto-load no"' + . " --command $ENV{VERILATOR_ROOT}/src/.gdbinit" + . " --command $Self->{t_dir}/t_gdb_jtree.gdb"); + +top_filename("t/t_dump.v"); + +lint(v_flags => ["--gdb", "--debug"]); + +ok(1); + +1;