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

# Entry point for BBC Smoke Tests

# Clean out anything that might be lurking around...
git clean -fdx

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

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

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

# DBC files are generated by the make_dbcs fixture defined in the dbc_builder.py plugin.

# Deploy First!
python -m pytest firmware/validation/bbc_smoke/test_deploy.py \
                 --exitfirst \
                 --verbose

# Now run some smoke tests
python -m pytest firmware/validation/bbc_smoke/ \
                 --ignore=firmware/validation/bbc_smoke/test_deploy.py \
                 --verbose

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