Add linux_test CI build
MODIFY
.travis.yml
.travis.yml
matrix:
include:
+ # OSX continuous release build
- env: RIPES_PLATFORM='mac'
os: osx
osx_image: xcode10
@@ -10,11 +11,13 @@ matrix:
packages:
- tree
+ # Windows continuous release build
- os: windows
language: cpp
env:
- RIPES_PLATFORM: 'windows'
+ # Trusty continuous release build
- env: RIPES_PLATFORM='linux'
os: linux
dist: trusty
@@ -34,6 +37,27 @@ matrix:
- g++-8
- tree
+ # Bionic unit test build
+ - env: RIPES_PLATFORM='linux_test'
+ os: linux
+ dist: bionic
+ sudo: required
+ language: c++
+ compiler: gcc
+ addons:
+ apt:
+ sources:
+ - sourceline: 'ppa:beineri/opt-qt-5.11.0-bionic'
+ key_url: 'https://keyserver.ubuntu.com/pks/lookup?op=get&search=0x10C56D0DE9977759'
+ - ubuntu-toolchain-r-test
+ packages:
+ - qt511-meta-minimal
+ - qt511svg
+ - libc6-dev
+ - g++-8
+ - tree
+ - mesa-common-dev
+
before_install:
- source ${TRAVIS_BUILD_DIR}/scripts/${RIPES_PLATFORM}/before_install.sh

ADD
scripts/linux_test/after_success.sh
+#!/bin/bash
+
+# Fail on failing QTest executions
+# set -e
+
+pushd test
+
+find . -executable -type f -name "tst_*" | while read line; do
+ echo "Running unit test: "
+ echo "${line}"
+ ($line)
+done
\ No newline at end of file

ADD
scripts/linux_test/before_install.sh
+#!/bin/bash
+
+export CC=gcc-8
+export CXX=g++-8
+
+sudo update-alternatives --install /usr/bin/g++ g++ /usr/bin/g++-8 90
+
+source /opt/qt*/bin/qt*-env.sh
+
+pip install googledrivedownloader
+
+# Grab prebuilt riscv64-unknown-elf toolchain, required for building RISC-V
+# related unit tests
+wget --load-cookies /tmp/cookies.txt \
+ "https://docs.google.com/uc?export=download&confirm=$(wget --quiet --save-cookies /tmp/cookies.txt --keep-session-cookies --no-check-certificate 'https://docs.google.com/uc?export=download&id=1KHCVeLFw6ef_HF0E4g3sqczCFYG_8EtA' -O- | sed -rn 's/.*confirm=([0-9A-Za-z_]+).*/\1\n/p')&id=1KHCVeLFw6ef_HF0E4g3sqczCFYG_8EtA" \
+ -O riscv64-unknown-elf_x86-64.tar.gz && rm -rf /tmp/cookies.txt
+
+echo "Downloaded files:"
+ls -lha
+
+# Unpack and add to path
+tar -xvf riscv64-unknown-elf_x86-64.tar.gz
+export PATH=$(pwd)/riscv64-unknown-elf_x86-64/bin/:${PATH}

ADD
scripts/linux_test/travisbuild.sh
+#!/bin/bash
+
+set -e
+
+# build
+cmake -DRIPES_BUILD_TESTS=ON -DRIPES_ENABLE_RISCV_TESTS=ON -DCMAKE_BUILD_TYPE=Release .
+make -j $(nproc)
+
+echo "Post build folder contents:"
+ls -lh

MODIFY
test/CMakeLists.txt
test/CMakeLists.txt
@@ -15,19 +15,27 @@ endmacro()
# =============================================================================
option(RIPES_ENABLE_RISCV_TESTS "Enable RISC-V unit tests" OFF)
if(RIPES_ENABLE_RISCV_TESTS)
- # Ensure required RISC-V toolchain tools are available
- find_program(RV_AS riscv64-linux-gnu-as)
- if(NOT RV_AS)
- message(FATAL_ERROR "riscv64-linux-gnu-as not found! A RISC-V toolchain must be available to build and run the RISC-V tests.")
- endif()
+ message(STATUS "RISC-V Tests enabled")
+ message(STATUS "Locating required toolchain tools...")
+ list (APPEND RV_TOOLS
+ riscv64-unknown-elf-as
+ riscv64-unknown-elf-objdump
+ riscv64-unknown-elf-gcc
+ )
- find_program(RV_OBJCOPY riscv64-linux-gnu-objcopy)
- if(NOT RV_OBJCOPY)
- message(FATAL_ERROR "riscv64-linux-gnu-objcopy not found! A RISC-V toolchain must be available to build and run the RISC-V tests.")
+ foreach(tool ${RV_TOOLS})
+ # Ensure required RISC-V toolchain tools are available
+ unset(RV_TOOL CACHE)
+ find_program(RV_TOOL ${tool})
+ if(NOT RV_TOOL)
+ message(FATAL_ERROR "'${tool}' not found! A RISC-V toolchain must be available to build and run the RISC-V tests.")
endif()
+ message(STATUS "Found tool '${RV_TOOL}'")
+ endforeach()
# Point to bundled tests within source directory
set(VSRTL_RISCV_TEST_DIR ${CMAKE_CURRENT_SOURCE_DIR}/riscv-tests)
add_definitions(-DVSRTL_RISCV_TEST_DIR="${VSRTL_RISCV_TEST_DIR}")
create_qtest(tst_riscv)
+ message(STATUS "RISC-V tests configured successfully")
endif()

MODIFY
test/tst_riscv.cpp
test/tst_riscv.cpp
@@ -23,8 +23,8 @@ using namespace vsrtl::core;
// Compilation tools & directories
const QString s_testdir = VSRTL_RISCV_TEST_DIR;
const QString s_outdir = s_testdir + QDir::separator() + "build";
-const QString s_assembler = "riscv64-linux-gnu-as";
-const QString s_objcopy = "riscv64-linux-gnu-objcopy";
+const QString s_assembler = "riscv64-unknown-elf-as";
+const QString s_objcopy = "riscv64-unknown-elf-objcopy";
const QString s_linkerScript = "rvtest.ld";
// Ecall status codes
@@ -67,6 +67,7 @@ private:
void loadBinaryToSimulator(const QString& binFile);
bool skipTest(const QString& test);
QString executeSimulator();
+ QString dumpRegs();
QString m_currentTest;
std::unique_ptr<SingleCycleRISCV> m_design;
@@ -91,6 +92,16 @@ bool tst_RISCV::skipTest(const QString& test) {
return false;
}
+QString tst_RISCV::dumpRegs() {
+ QString str = "\n" + m_currentTest + "\nRegister dump:";
+ str += "\t PC:" + QString::number(m_design->pcForStage(0), 16) + "\n";
+ for (int i = 0; i < m_design->implementsISA()->regCnt(); i++) {
+ str += "\t" + m_design->implementsISA()->regName(i) + ":" + m_design->implementsISA()->regAlias(i) + ":\t" +
+ QString::number(m_design->registerFile->getRegister(i)) + "\n";
+ }
+ return str;
+}
+
void tst_RISCV::loadBinaryToSimulator(const QString& binFile) {
// Read test file
QFile testFile(binFile);
@@ -120,15 +131,19 @@ QString tst_RISCV::executeSimulator() {
if (status == s_success) {
stop |= true;
} else if (status == s_fail) {
- return "Test: '" + m_currentTest + "' failed: Internal test error.\n\t test number: " +
+ auto err = "Test: '" + m_currentTest + "' failed: Internal test error.\n\t test number: " +
QString::number(m_design->registerFile->getRegister(s_statusreg));
+ err += dumpRegs();
+ return err;
}
}
} while (!stop);
if (maxCyclesReached) {
- return "Test: '" + m_currentTest + "' failed: Maximum cycle count reached\n\t test number: " +
+ auto err = "Test: '" + m_currentTest + "' failed: Maximum cycle count reached\n\t test number: " +
QString::number(m_design->registerFile->getRegister(s_statusreg));
+ err += dumpRegs();
+ return err;
}
// Test successful
@@ -156,7 +171,7 @@ void tst_RISCV::runTests() {
loadBinaryToSimulator(binFile);
m_design->verifyAndInitialize();
- QString err = executeSimulator();
+ const QString err = executeSimulator();
if (!err.isNull()) {
QFAIL(err.toStdString().c_str());
}

Add linux_test CI build