blob: 39ec3605746728b452ccc22e97ad2526e76b7964 [file] [log] [blame]
#!/usr/bin/env bash
# Copyright 2021 The Android KVM Authors
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
# Script run inside the host. Reads the value of 'boot_test_mode' from
# the command line and checks that KVM was booted in that given mode by
# dumping logs using `dmesg`.
set -eufo pipefail
PASS() { echo -e "\e[32mPASS\e[0m"; }
FAIL() { echo -e "\e[31mFAIL\e[0m"; }
MODE="$(sed -E 's/.*boot_test_mode=([a-z]+).*/\1/' /proc/cmdline)"
case "${MODE}" in
vhe) EXPECT='kvm [1]: VHE mode initialized successfully';;
nvhe) EXPECT='kvm [1]: Hyp mode initialized successfully';;
pkvm) EXPECT='kvm [1]: Protected nVHE mode initialized successfully';;
*) echo "Could not parse expected KVM mode: ${MODE}" 1>&2
FAIL
exit 1
;;
esac
if dmesg | grep -F "${EXPECT}"; then
PASS
else
FAIL
fi