diff --git a/.gitlab-ci.yml b/.gitlab-ci.yml index ba3576c0..b9e0622e 100644 --- a/.gitlab-ci.yml +++ b/.gitlab-ci.yml @@ -7,10 +7,7 @@ stages: - build - WIDEIO - DDR3 - -cache: - paths: - - build/ + - Coverage build: stage: build @@ -22,7 +19,27 @@ build: - cd build - qmake ../DRAMSys/DRAMSys.pro - make -j4 - + - find . -name "*.o" -type f -delete + cache: + key: build + paths: + - build/ + policy: push + +coverage: + stage: Coverage + coverage: '/Total:\|(\d+\.?\d+\%)/' + script: + # delete all empty files since they produce errors + - find coverage -size 0 -type f -delete + - ls coverage/ -lah + - lcov `find coverage -type f -exec echo "-a {}" \;` -o coverage/final.out + - lcov --list coverage/final.out + artifacts: + paths: + - coverage/final.out + + include: - '/DRAMSys/tests/DDR3/ci.yml' - '/DRAMSys/tests/WIDEIO/ci.yml' diff --git a/DRAMSys/library/library.pro b/DRAMSys/library/library.pro index 84267536..58d3037b 100644 --- a/DRAMSys/library/library.pro +++ b/DRAMSys/library/library.pro @@ -58,11 +58,15 @@ DEFINES += SC_INCLUDE_DYNAMIC_PROCESSES unix:!macx { QMAKE_CXXFLAGS += -std=c++11 -O0 -g + QMAKE_CXXFLAGS += -fprofile-arcs -ftest-coverage -fPIC -O0 + QMAKE_LFLAGS += -lgcov --coverage } macx: { CONFIG += c++11 QMAKE_CXXFLAGS += -std=c++0x -stdlib=libc++ -O0 -g + QMAKE_CXXFLAGS += --coverage + QMAKE_LFLAGS += --coverage } QMAKE_CXXFLAGS += -isystem $${systemc_home}/include diff --git a/DRAMSys/simulator/simulator.pro b/DRAMSys/simulator/simulator.pro index b5b297cf..dd592f3d 100644 --- a/DRAMSys/simulator/simulator.pro +++ b/DRAMSys/simulator/simulator.pro @@ -29,11 +29,15 @@ DEFINES += SC_INCLUDE_DYNAMIC_PROCESSES unix:!macx { QMAKE_CXXFLAGS += -std=c++11 -O0 -g + QMAKE_CXXFLAGS += -fprofile-arcs -ftest-coverage -fPIC -O0 + QMAKE_LFLAGS += -lgcov --coverage } macx: { CONFIG += c++11 QMAKE_CXXFLAGS += -std=c++0x -stdlib=libc++ -O0 -g + QMAKE_CXXFLAGS += --coverage + QMAKE_LFLAGS += --coverage } INCLUDEPATH += ../library/src/simulation/ diff --git a/DRAMSys/tests/DDR3/ci.yml b/DRAMSys/tests/DDR3/ci.yml index 06cdadfa..b92199d0 100644 --- a/DRAMSys/tests/DDR3/ci.yml +++ b/DRAMSys/tests/DDR3/ci.yml @@ -10,9 +10,20 @@ example_ddr3: - perl -e 'if(`sqldiff ../../DRAMSys/tests/DDR3/expected/ddr3-example_ddr3_ch0.tdb ddr3-example_ddr3_ch0.tdb` eq "") {exit(0)} else {exit(-1)}' - cd ../traceAnalyzer - python3 ../../DRAMSys/traceAnalyzer/scripts/tests.py ../simulator/ddr3-example_ddr3_ch0.tdb | if ! grep "failed"; then exit 0; else exit 1; fi + # Run Code Coverage + - mkdir -p ${CI_PROJECT_DIR}/coverage + - lcov -q -c -d ${CI_PROJECT_DIR}/build/ -o ${CI_PROJECT_DIR}/coverage/${CI_JOB_NAME}.out + + cache: + key: build + paths: + - build/ + policy: pull + artifacts: paths: - build/simulator/ddr3-example_ddr3_ch0.tdb + - coverage/${CI_JOB_NAME}.out expire_in: 2 days # Testing Reordering with FR_FCFS Scheduling Algorithm: @@ -27,12 +38,22 @@ fr_fcfs: - perl -e 'if(`sqldiff ../../DRAMSys/tests/DDR3/expected/ddr3-fr_fcfs_ddr3_ch0.tdb ddr3-fr_fcfs_ddr3_ch0.tdb` eq "") {exit(0)} else {exit(-1)}' - cd ../traceAnalyzer - python3 ../../DRAMSys/traceAnalyzer/scripts/tests.py ../simulator/ddr3-fr_fcfs_ddr3_ch0.tdb | if ! grep "failed"; then exit 0; else exit 1; fi + # Run Code Coverage + - mkdir -p ${CI_PROJECT_DIR}/coverage + - lcov -q -c -d ${CI_PROJECT_DIR}/build/ -o ${CI_PROJECT_DIR}/coverage/${CI_JOB_NAME}.out + + cache: + key: build + paths: + - build/ + policy: pull allow_failure: true # TODO should be removed after first tests artifacts: paths: - build/simulator/ddr3-fr_fcfs_ddr3_ch0.tdb + - coverage/${CI_JOB_NAME}.out expire_in: 2 days # Testing with TLM Protocol Cchecker @@ -40,5 +61,20 @@ protocol_checker: stage: DDR3 script: - cd build/simulator - - ./DRAMSys ../../DRAMSys/tests/DDR3/simulations/ddr3-protocol_checker.xml ../../DRAMSys/tests/DDR3/ + - ./DRAMSys ../../DRAMSys/tests/DDR3/simulations/ddr3-protocol_checker.xml ../../DRAMSys/tests/DDR3/ > output.txt - echo "TODO" + - ls -lah + # Run Code Coverage + - mkdir -p ${CI_PROJECT_DIR}/coverage + - lcov -q -c -d ${CI_PROJECT_DIR}/build/ -o ${CI_PROJECT_DIR}/coverage/${CI_JOB_NAME}.out + + cache: + key: build + paths: + - build/ + policy: pull + + artifacts: + paths: + - coverage/${CI_JOB_NAME}.out + expire_in: 2 days diff --git a/DRAMSys/tests/WIDEIO/ci.yml b/DRAMSys/tests/WIDEIO/ci.yml index 76ca5555..7fc1ee7b 100644 --- a/DRAMSys/tests/WIDEIO/ci.yml +++ b/DRAMSys/tests/WIDEIO/ci.yml @@ -15,7 +15,16 @@ example_wideio: - python3 ../../DRAMSys/traceAnalyzer/scripts/tests.py ../simulator/wideio-example_wideio_ch1.tdb | if ! grep "failed"; then exit 0; else exit 1; fi - python3 ../../DRAMSys/traceAnalyzer/scripts/tests.py ../simulator/wideio-example_wideio_ch2.tdb | if ! grep "failed"; then exit 0; else exit 1; fi - python3 ../../DRAMSys/traceAnalyzer/scripts/tests.py ../simulator/wideio-example_wideio_ch3.tdb | if ! grep "failed"; then exit 0; else exit 1; fi + # Run Code Coverage + - mkdir -p ${CI_PROJECT_DIR}/coverage + - lcov -q -c -d ${CI_PROJECT_DIR}/build/ -o ${CI_PROJECT_DIR}/coverage/${CI_JOB_NAME}.out + cache: + key: build + paths: + - build/ + policy: pull + allow_failure: true # TODO: should be removed once the problems are fixed! artifacts: @@ -24,5 +33,6 @@ example_wideio: - build/simulator/wideio-example_wideio_ch1.tdb - build/simulator/wideio-example_wideio_ch2.tdb - build/simulator/wideio-example_wideio_ch3.tdb + - coverage/${CI_JOB_NAME}.out expire_in: 2 days diff --git a/README.md b/README.md index 04a58785..3fe92431 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ framework that consists of models reflecting the DRAM functionality, power consumption, temperature behaviour and retention time errors. Pipeline Status: [![pipeline status](https://git.eit.uni-kl.de/ems/astdm/dram.sys/badges/master/pipeline.svg)](https://git.eit.uni-kl.de/ems/astdm/dram.sys/commits/master) - +[![Coverage report](https://git.eit.uni-kl.de/ems/astdm/dram.sys/badges/master/coverage.svg?job=coverage)](https://git.eit.uni-kl.de/ems/astdm/dram.sys/commits/master) ## Basic Setup Open a terminal window, go to your home directory, create a directory for your