|
1 | 1 | #!/bin/bash |
2 | 2 | set -e |
3 | 3 |
|
4 | | -DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" |
| 4 | +ROOT=`git rev-parse --show-toplevel` |
| 5 | +NPROCS="$(nproc 2> /dev/null || sysctl -n hw.ncpu)" |
| 6 | +HERE=`pwd` |
| 7 | +CI="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )" |
| 8 | +INSTALL=$HERE/install |
| 9 | +BUILD=$HERE/build |
| 10 | +RUN=$HERE/run |
5 | 11 |
|
6 | | -cd build |
| 12 | +# build pk |
| 13 | +rm -rf $BUILD/pk |
| 14 | +mkdir $BUILD/pk |
| 15 | +cd $BUILD/pk |
| 16 | +git clone https://github.com/riscv-software-src/riscv-pk.git |
| 17 | +riscv-pk/configure --host=riscv64-linux-gnu --prefix=$INSTALL |
| 18 | +make -j$NPROCS |
| 19 | +make install |
7 | 20 |
|
8 | | -# run a program and check for correct output |
9 | | -mkdir run |
10 | | -cd run |
11 | | -wget https://github.com/riscv-software-src/riscv-isa-sim/releases/download/dummy-tag-for-ci-storage/spike-ci.tar |
12 | | -tar xf spike-ci.tar |
13 | | -time ../install/bin/spike --isa=rv64gc pk hello | grep "Hello, world! Pi is approximately 3.141588." |
14 | | -../install/bin/spike --log-commits --isa=rv64gc pk atomics 2> /dev/null | grep "First atomic counter is 1000, second is 100" |
| 21 | +# build tests |
| 22 | +rm -rf $RUN |
| 23 | +mkdir $RUN |
| 24 | +cd $RUN |
| 25 | +riscv64-linux-gnu-gcc -static -O2 -o hello $CI/hello.c |
| 26 | +riscv64-linux-gnu-gcc -static -O2 -o dummy-slliuw $CI/dummy-slliuw.c |
| 27 | +riscv64-linux-gnu-gcc -static -O2 -o customcsr $CI/customcsr.c |
| 28 | +riscv64-linux-gnu-gcc -static -O2 -o atomics $CI/atomics.c |
15 | 29 |
|
16 | 30 | # check that including sim.h in an external project works |
17 | | -g++ -std=c++2a -I../install/include -L../install/lib $DIR/testlib.cc -lriscv -o test-libriscv |
18 | | -g++ -std=c++2a -I../install/include -L../install/lib $DIR/test-customext.cc -lriscv -o test-customext |
19 | | -g++ -std=c++2a -I../install/include -L../install/lib $DIR/custom-csr.cc -lriscv -o test-custom-csr |
| 31 | +g++ -std=c++2a -I$INSTALL/include -L$INSTALL/lib $CI/testlib.cc -lriscv -o test-libriscv |
| 32 | +g++ -std=c++2a -I$INSTALL/include -L$INSTALL/lib $CI/test-customext.cc -lriscv -o test-customext |
| 33 | +g++ -std=c++2a -I$INSTALL/include -L$INSTALL/lib $CI/custom-csr.cc -lriscv -o test-custom-csr |
20 | 34 |
|
21 | 35 | # check that all installed headers are functional |
22 | | -g++ -std=c++2a -I../install/include -L../install/lib $DIR/testlib.cc -lriscv -o /dev/null -include ../install-hdrs-list.h |
| 36 | +g++ -std=c++2a -I$INSTALL/include -L$INSTALL/lib $CI/testlib.cc -lriscv -o /dev/null -include $BUILD/spike/install-hdrs-list.h |
23 | 37 |
|
24 | | -LD_LIBRARY_PATH=../install/lib ./test-libriscv pk hello| grep "Hello, world! Pi is approximately 3.141588." |
25 | | -LD_LIBRARY_PATH=../install/lib ./test-customext pk dummy-slliuw | grep "Executed successfully" |
26 | | -LD_LIBRARY_PATH=../install/lib ./test-custom-csr pk customcsr | grep "Executed successfully" |
| 38 | +# run tests |
| 39 | +time $INSTALL/bin/spike --isa=rv64gc $BUILD/pk/pk hello | grep "Hello, world! Pi is approximately 3.141588." |
| 40 | +$INSTALL/bin/spike --log-commits --isa=rv64gc $BUILD/pk/pk atomics 2> /dev/null | grep "First atomic counter is 1000, second is 100" |
| 41 | +LD_LIBRARY_PATH=$INSTALL/lib ./test-libriscv $BUILD/pk/pk hello | grep "Hello, world! Pi is approximately 3.141588." |
| 42 | +LD_LIBRARY_PATH=$INSTALL/lib ./test-customext $BUILD/pk/pk dummy-slliuw | grep "Executed successfully" |
| 43 | +LD_LIBRARY_PATH=$INSTALL/lib ./test-custom-csr $BUILD/pk/pk customcsr | grep "Executed successfully" |
0 commit comments