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

# Entry point for EMUv4 MON 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 emu_v4_mon_venv ]; then
    rm -rf emu_v4_mon_venv
fi

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

# Run Smoke Test
python -m pytest firmware/validation/emuv4_mon/test_deploy.py \
                 --log-cli-level=INFO \
                 --exitfirst \
                 --capture=no \
                 --verbose

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