Skip to content

Commit

Permalink
Add astsee-related tests (#3)
Browse files Browse the repository at this point in the history
  • Loading branch information
sgizler committed Apr 12, 2024
1 parent 66ee243 commit 8bd340f
Show file tree
Hide file tree
Showing 7 changed files with 99 additions and 1 deletion.
5 changes: 4 additions & 1 deletion .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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: |
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
obj_*
*.swp
.gdb_history
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -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
1 change: 1 addition & 0 deletions submodules/astsee
Submodule astsee added at 0f5bc2
33 changes: 33 additions & 0 deletions t/t_dump_json_astsee.pl
Original file line number Diff line number Diff line change
@@ -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;
24 changes: 24 additions & 0 deletions t/t_gdb_jtree.gdb
Original file line number Diff line number Diff line change
@@ -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
33 changes: 33 additions & 0 deletions t/t_gdb_jtree.pl
Original file line number Diff line number Diff line change
@@ -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;

0 comments on commit 8bd340f

Please sign in to comment.