Skip to content

Commit

Permalink
Adjust GitHub actions CI for microarchitectural tests
Browse files Browse the repository at this point in the history
Signed-off-by: Maciej Kurc <[email protected]>
  • Loading branch information
mkurc-ant committed Sep 21, 2023
1 parent 0ae72ae commit d78233a
Show file tree
Hide file tree
Showing 8 changed files with 182 additions and 58 deletions.
57 changes: 26 additions & 31 deletions .github/scripts/convert_coverage_data.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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}"
5 changes: 5 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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]
Expand Down
6 changes: 6 additions & 0 deletions .github/workflows/report-coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
14 changes: 6 additions & 8 deletions .github/workflows/test-regression.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
9 changes: 4 additions & 5 deletions .github/workflows/test-riscof.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
11 changes: 4 additions & 7 deletions .github/workflows/test-riscv-dv.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
124 changes: 124 additions & 0 deletions .github/workflows/test-uarch.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,124 @@
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 *.dat; do
NEW_NAME=${OLD_NAME/coverage_/coverage_${TEST_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
14 changes: 7 additions & 7 deletions .github/workflows/test-verification.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -133,4 +133,4 @@ jobs:
uses: actions/upload-artifact@v3
with:
name: verification_tests_coverage_data
path: ./results/*.info
path: results/*.info

0 comments on commit d78233a

Please sign in to comment.