From de87df8c51f5017fe7445ea0e081b0da29252e84 Mon Sep 17 00:00:00 2001 From: Maciej Kurc Date: Tue, 19 Sep 2023 15:32:53 +0200 Subject: [PATCH] Adjust GitHub actions CI for microarchitectural tests Signed-off-by: Maciej Kurc --- .github/scripts/convert_coverage_data.sh | 57 +++++------ .github/workflows/ci.yml | 5 + .github/workflows/report-coverage.yml | 6 ++ .github/workflows/test-regression.yml | 14 ++- .github/workflows/test-riscof.yml | 9 +- .github/workflows/test-riscv-dv.yml | 11 +- .github/workflows/test-uarch.yml | 125 +++++++++++++++++++++++ .github/workflows/test-verification.yml | 14 +-- 8 files changed, 183 insertions(+), 58 deletions(-) create mode 100644 .github/workflows/test-uarch.yml diff --git a/.github/scripts/convert_coverage_data.sh b/.github/scripts/convert_coverage_data.sh index c19b853e5d2..bcedde0cd9e 100755 --- a/.github/scripts/convert_coverage_data.sh +++ b/.github/scripts/convert_coverage_data.sh @@ -4,46 +4,41 @@ SELF_DIR="$(dirname $(readlink -f ${BASH_SOURCE[0]}))" . ${SELF_DIR}/common.inc.sh convert_coverage_data(){ - # This function uses verilator_coverage module to convert a coverage .dat file: - # ${DAT_DIR}/coverage.dat - # into an .info file: - # ${RESULTS_DIR}/${FILE_PREFIX}_${COVERAGE}.info + # This function uses verilator_coverage module to convert a coverage .dat + # file(s) into an .info file(s) for further processing. # Args: - # COVERAGE : type of coverage - # DAT_DIR: path to dir containing coverage.dat file - # RESULTS_DIR: path to dir, where .info file will be placed - # FILE_PREFIX: prefix used in the name of coverage_.info - check_args_count $# 4 - COVERAGE=$1 - DAT_DIR=$2 - RESULTS_DIR=$3 - FILE_PREFIX=$4 - echo -e "${COLOR_WHITE}======= convert_coverage_data =======${COLOR_CLEAR}" - echo -e "${COLOR_WHITE}COVERAGE = ${COVERAGE}" - echo -e "${COLOR_WHITE}DAT_DIR = ${DAT_DIR}" - echo -e "${COLOR_WHITE}RESULTS_DIR = ${RESULTS_DIR}" - echo -e "${COLOR_WHITE}FILE_PREFIX = ${FILE_PREFIX}" - echo -e "${COLOR_WHITE}========== ${COVERAGE} coverage ==========${COLOR_CLEAR}" + # DAT_DIR: path to dir containing coverage.dat file(s) + DAT_DIR="${1:-results_verification}" + echo -e "${COLOR_WHITE}======= Parse arguments =======${COLOR_CLEAR}" + echo -e "${COLOR_WHITE}DAT_DIR = ${DAT_DIR}" + echo -e "${COLOR_WHITE}===============================${COLOR_CLEAR}" # Function body - if ! [ -f "${DAT_DIR}/coverage.dat" ]; then - echo -e "${COLOR_WHITE}coverage.dat not found in dir=${DAT_DIR} ${COLOR_RED}FAIL${COLOR_CLEAR}" + FILES=`find ${DAT_DIR} -name "coverage*.dat"` + if [ -z "$FILES" ]; then + echo -e "${COLOR_RED}ERROR: No coverage data files were found${COLOR_CLEAR}" + echo -e "${COLOR_RED}ERROR: Searched directory: `realpath ${DAT_DIR}`${COLOR_CLEAR}" + echo -e "${COLOR_RED}ERROR: convert_coverage_data ended with errors${COLOR_CLEAR}" exit -1 else - mkdir -p ${RESULTS_DIR} - cp ${DAT_DIR}/coverage.dat ${RESULTS_DIR}/${FILE_PREFIX}_${COVERAGE}.dat - verilator_coverage --write-info ${RESULTS_DIR}/${FILE_PREFIX}_${COVERAGE}.info ${RESULTS_DIR}/${FILE_PREFIX}_${COVERAGE}.dat - echo -e "${COLOR_WHITE}Conversion: ${DAT_DIR}/coverage.dat -> ${RESULTS_DIR}/${FILE_PREFIX}_${COVERAGE}.info ${COLOR_GREEN}SUCCEEDED${COLOR_CLEAR}" + for dat_file in ${FILES}; do + info_file=`basename -s .dat ${dat_file}`.info + info_realpath=`realpath \`dirname ${dat_file}\`` + info_file=${info_realpath}/${info_file} + verilator_coverage --write-info ${info_file} ${dat_file} + echo -e "${COLOR_WHITE}Conversion: ${dat_file} -> ${info_file} ${COLOR_GREEN}SUCCEEDED${COLOR_CLEAR}" + done fi } # Example usage -# RESULTS_DIR="results" -# COVERAGE="branch" -# DAT_DIR="." -# FILE_PREFIX="coverage_test" +# DAT_DIR="results_verification" # -# convert_coverage_data $COVERAGE $DAT_DIR $RESULTS_DIR $FILE_PREFIX +# convert_coverage_data $DAT_DIR + +echo -e "${COLOR_WHITE}========== convert_coverage_data ==============${COLOR_CLEAR}" -check_args_count $# 4 convert_coverage_data "$@" + +echo -e "${COLOR_WHITE}convert_coverage_data ${COLOR_GREEN}SUCCEEDED${COLOR_CLEAR}" +echo -e "${COLOR_WHITE}========== convert_coverage_data ==============${COLOR_CLEAR}" diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 1ba0f81ba90..b1d8b7c40a7 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -26,6 +26,11 @@ jobs: needs: [Build-Verilator] uses: ./.github/workflows/test-verification.yml + Test-Microarchitectural: + name: Test-Microarchitectural + needs: [Build-Verilator] + uses: ./.github/workflows/test-uarch.yml + Test-RISCV-DV: name: Test-RISCV-DV needs: [Build-Verilator, Build-Spike] diff --git a/.github/workflows/report-coverage.yml b/.github/workflows/report-coverage.yml index e10e07d3d36..a3ceded6b00 100644 --- a/.github/workflows/report-coverage.yml +++ b/.github/workflows/report-coverage.yml @@ -48,6 +48,12 @@ jobs: name: verification_tests_coverage_data path: ./ + - name: Download coverage reports + uses: actions/download-artifact@v3 + with: + name: uarch_tests_coverage_data + path: ./ + - name: Download coverage reports uses: actions/download-artifact@v3 with: diff --git a/.github/workflows/test-regression.yml b/.github/workflows/test-regression.yml index 7692715ced7..a4d22851df6 100644 --- a/.github/workflows/test-regression.yml +++ b/.github/workflows/test-regression.yml @@ -86,17 +86,15 @@ jobs: - name: Prepare coverage data run: | - pushd ${{ github.workspace }} - mkdir -p coverage_${{ matrix.test }} - mv ${TEST_PATH}/coverage.dat coverage_${{ matrix.test }}/ - echo "Prepared coverage data" - .github/scripts/convert_coverage_data.sh ${{ matrix.coverage }} ${{ github.workspace }}/coverage_${{ matrix.test }} ${{ github.workspace }}/results coverage_${{ matrix.test }} - echo "convert_coverage_data.sh exited with RET_CODE = "$? - popd + .github/scripts/convert_coverage_data.sh ${TEST_PATH}/ + echo "convert_coverage_data.sh exited with RET_CODE = "$? + mkdir -p results + mv ${TEST_PATH}/coverage.info \ + results/coverage_${{ matrix.test }}_${{ matrix.coverage }}.info - name: Pack artifacts if: always() uses: actions/upload-artifact@v3 with: name: regression_tests_coverage_data - path: ./results/*.info + path: results/*.info diff --git a/.github/workflows/test-riscof.yml b/.github/workflows/test-riscof.yml index 6ec0b446b14..d9545ea5554 100644 --- a/.github/workflows/test-riscof.yml +++ b/.github/workflows/test-riscof.yml @@ -141,11 +141,10 @@ jobs: - name: Prepare coverage data run: | export PATH=/opt/verilator/bin:$PATH - .github/scripts/convert_coverage_data.sh \ - ${{ matrix.coverage }} \ - riscof/coverage \ - riscof/coverage \ - coverage_riscof + .github/scripts/convert_coverage_data.sh riscof/coverage/ + echo "convert_coverage_data.sh exited with RET_CODE = "$? + mv riscof/coverage/coverage.info \ + riscof/coverage/coverage_riscof_${{ matrix.coverage }}.info - name: Pack artifacts if: always() diff --git a/.github/workflows/test-riscv-dv.yml b/.github/workflows/test-riscv-dv.yml index 0210066cc87..4c3c67982e4 100644 --- a/.github/workflows/test-riscv-dv.yml +++ b/.github/workflows/test-riscv-dv.yml @@ -246,14 +246,11 @@ jobs: - name: Prepare coverage data run: | - mkdir -p coverage_riscv-dv_${{ matrix.test }} - mv ${RV_ROOT}/tools/riscv-dv/work/coverage.dat coverage_riscv-dv_${{ matrix.test }}/ - echo "Prepared coverage data" - .github/scripts/convert_coverage_data.sh \ - ${{ matrix.coverage }} \ - coverage_riscv-dv_${{ matrix.test }} \ - results coverage_riscv-dv_${{ matrix.test }} + .github/scripts/convert_coverage_data.sh ${RV_ROOT}/tools/riscv-dv/work/ echo "convert_coverage_data.sh exited with RET_CODE = "$? + mkdir -p results + mv ${RV_ROOT}/tools/riscv-dv/work/coverage.info \ + results/coverage_riscv-dv_${{ matrix.test }}_${{ matrix.coverage }}.info - name: Pack artifacts if: always() diff --git a/.github/workflows/test-uarch.yml b/.github/workflows/test-uarch.yml new file mode 100644 index 00000000000..b6c9fa4ad98 --- /dev/null +++ b/.github/workflows/test-uarch.yml @@ -0,0 +1,125 @@ +name: VeeR-EL2 Microarchitectural tests + +on: + workflow_call: + +env: + VERILATOR_VERSION: v5.010 + +jobs: + tests: + name: Microarchitectural tests + runs-on: ubuntu-latest + strategy: + matrix: + test: ["block/pic", "block/pic_gw"] + env: + CCACHE_DIR: "/opt/verification/.cache/" + VERILATOR_VERSION: v5.010 + DEBIAN_FRONTEND: "noninteractive" + steps: + - name: Setup repository + uses: actions/checkout@v3 + with: + submodules: recursive + + - name: Setup Cache Metadata + id: cache_metadata + run: | + date=$(date +"%Y_%m_%d") + time=$(date +"%Y%m%d_%H%M%S_%N") + cache_verilator_restore_key=cache_verilator_ + cache_verilator_key=${cache_verilator_restore_key}${{ env.VERILATOR_VERSION }} + cache_test_restore_key=uarch_${{ matrix.test }}_${{ matrix.coverage }}_ + cache_test_key=${cache_test_restore_key}${time} + + echo "date=$date" | tee -a "$GITHUB_ENV" + echo "time=$time" | tee -a "$GITHUB_ENV" + echo "cache_verilator_restore_key=$cache_verilator_restore_key" | tee -a "$GITHUB_ENV" + echo "cache_verilator_key=$cache_verilator_key" | tee -a "$GITHUB_ENV" + echo "cache_test_restore_key=$cache_test_restore_key" | tee -a "$GITHUB_ENV" + echo "cache_test_key=$cache_test_key" | tee -a "$GITHUB_ENV" + + - name: Restore verilator cache + id: cache-verilator-restore + uses: actions/cache/restore@v3 + with: + path: | + /opt/verilator + /opt/verilator/.cache + key: ${{ env.cache_verilator_key }} + restore-keys: ${{ env.cache_verilator_restore_key }} + + - name: Setup tests cache + uses: actions/cache@v3 + id: cache-test-setup + with: + path: | + ${{ env.CCACHE_DIR }} + key: ${{ env.cache_test_key }} + restore-keys: ${{ env.cache_test_restore_key }} + + - name: Install prerequisities + run: | + sudo apt -qqy update && sudo apt -qqy --no-install-recommends install \ + autoconf automake autotools-dev \ + bc bison build-essential \ + ccache cpanminus curl \ + flex \ + gawk gcc-riscv64-unknown-elf git gperf \ + help2man \ + libexpat-dev libfl-dev libfl2 libgmp-dev \ + libmpc-dev libmpfr-dev libpython3-all-dev libtool \ + ninja-build \ + patchutils python3 python3-dev python3-pip \ + texinfo \ + zlib1g zlib1g-dev + sudo cpanm Bit::Vector + + - name: Setup environment + run: | + echo "/opt/verilator/bin" >> $GITHUB_PATH + RV_ROOT=`pwd` + echo "RV_ROOT=$RV_ROOT" >> $GITHUB_ENV + PYTHONUNBUFFERED=1 + echo "PYTHONUNBUFFERED=$PYTHONUNBUFFERED" >> $GITHUB_ENV + + TEST_TYPE=`echo ${{ matrix.test }} | cut -d'/' -f1` + TEST_NAME=`echo ${{ matrix.test }} | cut -d'/' -f2` + TEST_PATH=$RV_ROOT/verification/${TEST_TYPE} + + echo "TEST_TYPE=$TEST_TYPE" >> $GITHUB_ENV + echo "TEST_NAME=$TEST_NAME" >> $GITHUB_ENV + echo "TEST_PATH=$TEST_PATH" >> $GITHUB_ENV + + pip3 install meson nox + + - name: Run ${{ matrix.test }} + run: | + pushd ${TEST_PATH} + nox -s ${TEST_NAME}_verify + popd + + - name: Prepare coverage data + run: | + export PATH=/opt/verilator/bin:$PATH + .github/scripts/convert_coverage_data.sh ${TEST_PATH}/${TEST_NAME}/ + echo "convert_coverage_data.sh exited with RET_CODE = "$? + mkdir -p results + mv ${TEST_PATH}/${TEST_NAME}/*.info results/ + + # Prefix coverage results + pushd results + for OLD_NAME in *.info; do + NEW_NAME=${OLD_NAME/coverage_/coverage_${TEST_NAME}_} + echo "renaming '${OLD_NAME}' to '${NEW_NAME}'" + mv ${OLD_NAME} ${NEW_NAME} + done + popd + + - name: Upload coverage data artifacts + if: always() + uses: actions/upload-artifact@v3 + with: + name: uarch_tests_coverage_data + path: ./results/*.info diff --git a/.github/workflows/test-verification.yml b/.github/workflows/test-verification.yml index 2059b41490e..b54a0c22ded 100644 --- a/.github/workflows/test-verification.yml +++ b/.github/workflows/test-verification.yml @@ -113,12 +113,12 @@ jobs: - name: Prepare coverage data run: | - pushd ${{ github.workspace }} - mkdir -p coverage_${{ matrix.test }} - mv ${TEST_PATH}/coverage.dat coverage_${{ matrix.test }}/ - .github/scripts/convert_coverage_data.sh ${{ matrix.COVERAGE }} ${{ github.workspace }}/coverage_${{ matrix.test }} ${{ github.workspace }}/results coverage_${{ matrix.test }} - echo "convert_coverage_data.sh exited with RET_CODE = "$? - popd + export PATH=/opt/verilator/bin:$PATH + .github/scripts/convert_coverage_data.sh ${TEST_PATH}/coverage.dat + echo "convert_coverage_data.sh exited with RET_CODE = "$? + mkdir -p results + mv ${TEST_PATH}/coverage.info \ + results/coverage_${{ matrix.test }}_${{ matrix.coverage }}.info - name: Upload pytest-html artifacts if: always() @@ -133,4 +133,4 @@ jobs: uses: actions/upload-artifact@v3 with: name: verification_tests_coverage_data - path: ./results/*.info + path: results/*.info