#!/bin/sh

# This is the expected entry point for Cockpit CI; will be called without
# arguments but with an appropriate $TEST_OS, and optionally $TEST_SCENARIO

set -eu

tools/make-bots

TEST_SCENARIO=${TEST_SCENARIO:-verify}
case $TEST_SCENARIO in
    verify)
        test/image-prepare --verbose $TEST_OS
        test/common/run-tests --jobs ${TEST_JOBS:-1} --test-dir test/verify
        ;;
    firefox)
        test/image-prepare --quick --verbose $TEST_OS
        TEST_BROWSER=firefox test/common/run-tests --jobs ${TEST_JOBS:-1} --test-dir test/verify
        ;;
    selenium-*)
        test/image-prepare --quick --verbose $TEST_OS
        test/selenium/run-tests --browser ${TEST_SCENARIO#*-}
        ;;
    container-*)
        test/image-prepare --quick --containers --verbose $TEST_OS
        test/containers/run-tests --container ${TEST_SCENARIO#*-}
        ;;
    dnf-copr*)
        test/image-prepare --verbose $TEST_OS
        bots/image-customize -v --run-command 'dnf -y copr enable rpmsoftwaremanagement/dnf-nightly && dnf -y update' $TEST_OS
        test/common/run-tests --jobs ${TEST_JOBS:-1} --test-dir test/verify
        ;;
    *)
        echo "Unknown test scenario: $TEST_SCENARIO"
        exit 1
esac
