aboutsummaryrefslogtreecommitdiff
path: root/ci-tests
diff options
context:
space:
mode:
authorAndrew Waterman <andrew@sifive.com>2022-09-23 16:06:21 -0700
committerAndrew Waterman <andrew@sifive.com>2022-09-23 16:06:21 -0700
commitd17b1767885000ed829eee9e985ae4a680f13377 (patch)
tree47f1877d85860754e942f2a73c8cd031c3e36861 /ci-tests
parent7668b414bb84798f2f57bbd1d9708b72b091c362 (diff)
downloadriscv-isa-sim-d17b1767885000ed829eee9e985ae4a680f13377.zip
riscv-isa-sim-d17b1767885000ed829eee9e985ae4a680f13377.tar.gz
riscv-isa-sim-d17b1767885000ed829eee9e985ae4a680f13377.tar.bz2
Actually run a program in CI
To avoid long CI times, keep the program in binary form. To avoid storing binary files in this repository, store the binaries as an asset on a github release.
Diffstat (limited to 'ci-tests')
-rwxr-xr-xci-tests/create-ci-binary-tarball20
-rw-r--r--ci-tests/hello.c23
-rwxr-xr-xci-tests/test-spike8
3 files changed, 51 insertions, 0 deletions
diff --git a/ci-tests/create-ci-binary-tarball b/ci-tests/create-ci-binary-tarball
new file mode 100755
index 0000000..b4fa545
--- /dev/null
+++ b/ci-tests/create-ci-binary-tarball
@@ -0,0 +1,20 @@
+#!/bin/bash
+set -e
+
+rm -rf build
+
+mkdir -p build/pk && cd "$_"
+`git rev-parse --show-toplevel`/../riscv-pk/configure --host=riscv64-unknown-elf
+make -j4
+cd -
+
+mkdir -p build/hello && cd "$_"
+riscv64-unknown-elf-gcc -O2 -o hello `git rev-parse --show-toplevel`/ci-tests/hello.c
+cd -
+
+mv build/pk/pk .
+mv build/hello/hello .
+
+tar -cf spike-ci.tar pk hello
+
+rm pk hello
diff --git a/ci-tests/hello.c b/ci-tests/hello.c
new file mode 100644
index 0000000..cf10e80
--- /dev/null
+++ b/ci-tests/hello.c
@@ -0,0 +1,23 @@
+#include <stdio.h>
+
+int main()
+{
+ // As a simple benchmark, estimate pi
+ int n = 16384, misses = 0;
+
+ for (int i = 0; i < n; i++) {
+
+ for (int j = 0; j < n; j++) {
+ int x = i - (n / 2);
+ int y = j - (n / 2);
+
+ misses += (x * x + y * y >= (n / 2) * (n / 2));
+ }
+ }
+
+ double pi = 4.0 * (n * n - misses) / (n * n);
+
+ printf("Hello, world! Pi is approximately %f.\n", pi);
+
+ return 0;
+}
diff --git a/ci-tests/test-spike b/ci-tests/test-spike
index 2da04ff..fa9bbdd 100755
--- a/ci-tests/test-spike
+++ b/ci-tests/test-spike
@@ -12,3 +12,11 @@ make install
# check that help message prints without error
install/bin/spike -h
+
+
+# run a program and check for correct output
+mkdir run
+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."