# vim: set ts=4 sw=4 expandtab:
example_wideio:
    stage: WIDEIO
    script:
        - export GCOV_PREFIX=$(pwd)
        - export GCOV_PREFIX_STRIP=$(pwd | awk -F"/" '{print NF-1}')
        # Generate specific traces for WIDEIO:
        - cd DRAMSys/tests/WIDEIO/traces/
        - perl generator.pl
        - cd -
        # Run DRAMSys
        - cd build/simulator
        - ./DRAMSys ../../DRAMSys/tests/WIDEIO/simulations/wideio-example.xml ../../DRAMSys/tests/WIDEIO/
        - ls
        # Run Traceanalyzer testing scripts:
        - cd ../traceAnalyzer
        - python3 ../../DRAMSys/traceAnalyzer/scripts/tests.py ../simulator/wideio-example_wideio_ch0.tdb | if ! grep "failed"; then exit 0; else exit 1; fi
        - 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
        - lcov -q -c --rc geninfo_adjust_src_path=$GCOV_PREFIX -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:
        paths:
          - build/simulator/wideio-example_wideio_ch0.tdb
          - 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

