TMP_ZCORE_SAFE="/tmp/zcore_safe_command_temp_"$$
ZCORE_COMMAND="zcore_safe_command"

mock_zcore_safe_successful(){
    cat scripts/vehicle/zcore_safe_command.sh > ${TMP_ZCORE_SAFE}
    echo "echo 'mock zcore exiting successfully';" > ${ZCORE_COMMAND}
    chmod +x ${ZCORE_COMMAND}

    trap "
    cat ${TMP_ZCORE_SAFE} > ${ZCORE_COMMAND} # Restore command
    " EXIT
}

mock_zcore_safe_failure(){
    echo "echo 'mock zcore exiting with failure'; exit 1;" > ${ZCORE_COMMAND}
    trap "
    cat ${TMP_ZCORE_SAFE} > ${ZCORE_COMMAND} # Restore command
    " EXIT
}

test_early_exit_if_zcore_is_running_script() {
    mock_zcore_safe_failure

    if ! HOME="." ${COMMAND_TO_TEST} > /dev/null; then
        echo " Script correctly exited when zcore check failed."
    else
        echo " Script failed to exit when zcore check failed."
        exit 1
    fi
}

test_command_exists() {
    if [ -f "${BIN_DEPENDENCY}" ]
    then
        echo "${BIN_DEPENDENCY} found."
    else
        echo "${BIN_DEPENDENCY} not found."
        exit 1
    fi
}
