aboutsummaryrefslogtreecommitdiff
path: root/ci-tests
diff options
context:
space:
mode:
authorJerry Zhao <jerryz123@berkeley.edu>2022-12-15 17:07:20 -0800
committerJerry Zhao <jerryz123@berkeley.edu>2022-12-16 10:11:28 -0800
commit46e6be48e90b9ce7b597d1bf16a68019590b4234 (patch)
tree96d991b495a267141987497248e2a3e483dd4bd7 /ci-tests
parent67219b20a33093c136d57697a7b90ea08e10d5d2 (diff)
downloadriscv-isa-sim-46e6be48e90b9ce7b597d1bf16a68019590b4234.zip
riscv-isa-sim-46e6be48e90b9ce7b597d1bf16a68019590b4234.tar.gz
riscv-isa-sim-46e6be48e90b9ce7b597d1bf16a68019590b4234.tar.bz2
Add github actions test that installed headers are usable
Diffstat (limited to 'ci-tests')
-rwxr-xr-xci-tests/test-spike4
-rw-r--r--ci-tests/testlib.c54
2 files changed, 58 insertions, 0 deletions
diff --git a/ci-tests/test-spike b/ci-tests/test-spike
index bf2290b..bafedc8 100755
--- a/ci-tests/test-spike
+++ b/ci-tests/test-spike
@@ -20,3 +20,7 @@ cd run
wget https://github.com/riscv-software-src/riscv-isa-sim/releases/download/dummy-tag-for-ci-storage/spike-ci.tar
tar xf spike-ci.tar
time ../install/bin/spike --isa=rv64gc pk hello | grep "Hello, world! Pi is approximately 3.141588."
+
+# check that including sim.h in an external project works
+g++ -std=c++17 -I../install/include -L../install/lib $DIR/testlib.c -lriscv -o test-libriscv
+LD_LIBRARY_PATH=../install/lib ./test-libriscv | grep "Hello, world! Pi is approximately 3.141588."
diff --git a/ci-tests/testlib.c b/ci-tests/testlib.c
new file mode 100644
index 0000000..3d2d18d
--- /dev/null
+++ b/ci-tests/testlib.c
@@ -0,0 +1,54 @@
+#include <riscv/sim.h>
+
+// Copied from spike main.
+// TODO: This should really be provided in libriscv
+static std::vector<std::pair<reg_t, mem_t*>> make_mems(const std::vector<mem_cfg_t> &layout)
+{
+ std::vector<std::pair<reg_t, mem_t*>> mems;
+ mems.reserve(layout.size());
+ for (const auto &cfg : layout) {
+ mems.push_back(std::make_pair(cfg.base, new mem_t(cfg.size)));
+ }
+ return mems;
+}
+
+int main()
+{
+ std::vector<mem_cfg_t> mem_cfg { mem_cfg_t(0x80000000, 0x10000000) };
+ std::vector<int> hartids = {0};
+ cfg_t cfg(std::make_pair(0, 0),
+ nullptr,
+ "rv64gcv",
+ "MSU",
+ "vlen:128,elen:64",
+ endianness_little,
+ 16,
+ mem_cfg,
+ hartids,
+ false);
+ std::vector<std::pair<reg_t, abstract_device_t*>> plugin_devices;
+ std::vector<std::string> htif_args {"pk", "hello"};
+ debug_module_config_t dm_config = {
+ .progbufsize = 2,
+ .max_sba_data_width = 0,
+ .require_authentication = false,
+ .abstract_rti = 0,
+ .support_hasel = true,
+ .support_abstract_csr_access = true,
+ .support_abstract_fpr_access = true,
+ .support_haltgroups = true,
+ .support_impebreak = true
+ };
+ std::vector<std::pair<reg_t, mem_t*>> mems = make_mems(cfg.mem_layout());
+ sim_t sim(&cfg, false,
+ mems,
+ plugin_devices,
+ htif_args,
+ dm_config,
+ nullptr,
+ true,
+ nullptr,
+ false,
+ nullptr);
+ sim.run();
+}