#! /bin/sh
set -xe
origin="$PWD"

# Run the bazel precheck steps (shutdown, remove cache)
firmware/validation/common/ci/bazel_precheck.sh

# Set up virtualenv
if [ -d tbc_pt_cooling_venv ]; then
    rm -rf tbc_pt_cooling_venv
fi

virtualenv -p python3.6 tbc_pt_cooling_venv
. tbc_pt_cooling_venv/bin/activate
python -m pip install -r firmware/validation/tbc_pt_cooling/requirements.txt

# Generate DBCs first. If this fails there is no point in continuing to test
# Note that this does not upload DBCs to Artifactory. To enable upload use the
# upload_dbc.sh script instead
firmware/validation/common/ci/generate_dbc.sh

# Run VH6A Smoke Test
python -m pytest firmware/validation/tbc_pt_cooling/test_deploy_vh6a.py \
                 --verbose
python -m pytest firmware/validation/tbc_pt_cooling/test_tbc_boot_info.py
python -m pytest firmware/validation/tbc_pt_cooling/test_cpu_resources.py
python -m pytest firmware/validation/tbc_pt_cooling/test_tbc_application_running.py

# Cleanup bazel job
cd $(bazel info workspace)
firmware/validation/common/ci/bazel_postcheck.sh
