Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions Runner/suites/Kernel/Virtualization/Kvm-Reboot/Kvm-Reboot.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
metadata:
name: kvm-reboot
format: "Lava-Test Test Definition 1.0"
description: "Reboot an active Gunyah KVM Virtual Machine"
os:
- linux
scope:
- functional

run:
steps:
- REPO_PATH=$PWD
- cd Runner/suites/Kernel/Virtualization/Kvm-Reboot
- ./run.sh || true
- $REPO_PATH/Runner/utils/send-to-lava.sh Kvm-Reboot.res || true
23 changes: 23 additions & 0 deletions Runner/suites/Kernel/Virtualization/Kvm-Reboot/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Kvm-Reboot Test
© Qualcomm Technologies, Inc. and/or its subsidiaries.
SPDX-License-Identifier: BSD-3-Clause-Clear

## Overview
This test validates the reboot functionality of the Guest VM. It issues a reboot command via `virsh` and ensures the VM returns to a running state.

### The test checks for:
- Successful execution of `virsh reboot`.
- VM returning to **"running"** state.

## Usage
### Quick Example
```bash
cd /var/Runner/suites/Kernel/Virtualization/Kvm-Reboot
./run.sh
```

### Result Format
Test result will be saved in Kvm-Reboot.res.

### Output
Kvm-Reboot PASS OR Kvm-Reboot FAIL
59 changes: 59 additions & 0 deletions Runner/suites/Kernel/Virtualization/Kvm-Reboot/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
#!/bin/bash

# Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
# SPDX-License-Identifier: BSD-3-Clause-Clear

# Robustly find and source init_env
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
SEARCH_PATH="$SCRIPT_DIR"
LIB_PATH=""
while [ "$SEARCH_PATH" != "/" ]; do
if [ -f "$SEARCH_PATH/utils/kvm_common.sh" ]; then
LIB_PATH="$SEARCH_PATH/utils/kvm_common.sh"
break
fi
SEARCH_PATH=$(dirname "$SEARCH_PATH")
done

if [ -f "$LIB_PATH" ]; then
# shellcheck disable=SC1090
. "$LIB_PATH"
else
echo "[ERROR] Lib not found"
exit 1
fi

TESTNAME="Kvm-Reboot"
RES_FILE="${TESTNAME}.res"
rm -f "$RES_FILE"

# Clean up old stdout logs from previous runs
rm -f *_stdout_*.log

log_info "----------- KVM Reboot -----------"

if virsh list --all | grep -q -w "$VM_NAME"; then
log_info "Existing VM instance found. Cleaning up..."
vm_clean
fi

vm_define && vm_start
if [ $? -ne 0 ]; then echo "$TESTNAME FAIL" > "$RES_FILE"; exit 1; fi

# Test: Reboot
log_info "Rebooting $VM_NAME"
virsh reboot "$VM_NAME"
sleep 5

# Verify Running
check_vm_state "$VM_NAME" "running"
if [ $? -eq 0 ]; then
log_pass "VM rebooted successfully."
echo "$TESTNAME PASS" > "$RES_FILE"
else
log_fail "VM not running after reboot."
echo "$TESTNAME FAIL" > "$RES_FILE"
fi

# Cleanup
vm_clean
15 changes: 15 additions & 0 deletions Runner/suites/Kernel/Virtualization/Kvm-Resume/Kvm-Resume.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
metadata:
name: kvm-resume
format: "Lava-Test Test Definition 1.0"
description: "Resume a paused Gunyah KVM Virtual Machine"
os:
- linux
scope:
- functional

run:
steps:
- REPO_PATH=$PWD
- cd Runner/suites/Kernel/Virtualization/Kvm-Resume
- ./run.sh || true
- $REPO_PATH/Runner/utils/send-to-lava.sh Kvm-Resume.res || true
23 changes: 23 additions & 0 deletions Runner/suites/Kernel/Virtualization/Kvm-Resume/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Kvm-Resume Test
© Qualcomm Technologies, Inc. and/or its subsidiaries.
SPDX-License-Identifier: BSD-3-Clause-Clear

## Overview
This test validates that a suspended VM can be resumed to active execution.

### The test checks for:
- Successful execution of `virsh resume`.
- VM state transition back to **"running"**.

## Usage
### Quick Example
```bash
cd /var/Runner/suites/Kernel/Virtualization/Kvm-Resume
./run.sh
```

### Result Format
Test result will be saved in Kvm-Reboot.res.

### Output
Kvm-Reboot PASS OR Kvm-Reboot FAIL
63 changes: 63 additions & 0 deletions Runner/suites/Kernel/Virtualization/Kvm-Resume/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
#!/bin/bash

# Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
# SPDX-License-Identifier: BSD-3-Clause-Clear

# Robustly find and source init_env
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
SEARCH_PATH="$SCRIPT_DIR"
LIB_PATH=""
while [ "$SEARCH_PATH" != "/" ]; do
if [ -f "$SEARCH_PATH/utils/kvm_common.sh" ]; then
LIB_PATH="$SEARCH_PATH/utils/kvm_common.sh"
break
fi
SEARCH_PATH=$(dirname "$SEARCH_PATH")
done

if [ -f "$LIB_PATH" ]; then
# shellcheck disable=SC1090
. "$LIB_PATH"
else
echo "[ERROR] Lib not found"
exit 1
fi

TESTNAME="Kvm-Resume"
RES_FILE="${TESTNAME}.res"
rm -f "$RES_FILE"

# Clean up old stdout logs from previous runs
rm -f *_stdout_*.log

log_info "----------- KVM Resume -----------"

if virsh list --all | grep -q -w "$VM_NAME"; then
log_info "Existing VM instance found. Cleaning up..."
vm_clean
fi

vm_define && vm_start
if [ $? -ne 0 ]; then echo "$TESTNAME FAIL" > "$RES_FILE"; exit 1; fi

# Pre-req: Must be suspended first
log_info "Suspending VM for resume test..."
virsh suspend "$VM_NAME"
sleep 2

# Test: Resume
log_info "Resuming $VM_NAME"
virsh resume "$VM_NAME"

# Verify Running
check_vm_state "$VM_NAME" "running"
if [ $? -eq 0 ]; then
log_pass "VM resumed successfully."
echo "$TESTNAME PASS" > "$RES_FILE"
else
log_fail "VM failed to resume."
echo "$TESTNAME FAIL" > "$RES_FILE"
fi

# Cleanup
vm_clean
15 changes: 15 additions & 0 deletions Runner/suites/Kernel/Virtualization/Kvm-Setup/Kvm-Setup.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
metadata:
name: kvm-setup
format: "Lava-Test Test Definition 1.0"
description: "Setup and Start Gunyah KVM Virtual Machine"
os:
- linux
scope:
- functional

run:
steps:
- REPO_PATH=$PWD
- cd Runner/suites/Kernel/Virtualization/Kvm-Setup
- ./run.sh || true
- $REPO_PATH/Runner/utils/send-to-lava.sh Kvm-Setup.res || true
34 changes: 34 additions & 0 deletions Runner/suites/Kernel/Virtualization/Kvm-Setup/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
# Kvm-Setup Test
© Qualcomm Technologies, Inc. and/or its subsidiaries.
SPDX-License-Identifier: BSD-3-Clause-Clear

## Overview
This test case initializes the KVM environment by defining the Virtual Machine using an XML configuration and starting the domain. It verifies that the VM transitions to the `running` state.

### The test checks for:
- Successful **definition** of the VM from `vm.xml`.
- Successful **start** command execution.
- Verification that the VM state is **"running"**.

## Usage
### Instructions:
1. Ensure the `vm.xml` and guest image files are present in `/var/gunyah/`.
2. Navigate to the test directory.
3. Run the script.

### Quick Example
```bash
cd /var/Runner/suites/Kernel/Virtualization/Kvm-Setup
./run.sh
```

### Prerequisites
1. virsh tool must be installed.
2. Gunyah hypervisor must be enabled.
3. Root access is required.

### Result Format
Test result will be saved in Kvm-Setup.res.

### Output
Kvm-Setup PASS OR Kvm-Setup FAIL
62 changes: 62 additions & 0 deletions Runner/suites/Kernel/Virtualization/Kvm-Setup/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
#!/bin/bash

# Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries.
# SPDX-License-Identifier: BSD-3-Clause-Clear

# Robustly find and source init_env
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
SEARCH_PATH="$SCRIPT_DIR"
LIB_PATH=""
while [ "$SEARCH_PATH" != "/" ]; do
if [ -f "$SEARCH_PATH/utils/kvm_common.sh" ]; then
LIB_PATH="$SEARCH_PATH/utils/kvm_common.sh"
break
fi
SEARCH_PATH=$(dirname "$SEARCH_PATH")
done

if [ -f "$LIB_PATH" ]; then
# shellcheck disable=SC1090
. "$LIB_PATH"
else
echo "[ERROR] Lib not found"
exit 1
fi

# Define Test Metadata
TESTNAME="Kvm-Setup"
RES_FILE="${TESTNAME}.res"

# Clean up old stdout logs from previous runs
rm -f *_stdout_*.log

# Execution
log_info "----------- KVM Setup: Define and Start -----------"

# Clean up any existing result file
rm -f "$RES_FILE"

# Define VM
if virsh list --all | grep -q -w "$VM_NAME"; then
log_info "Existing VM instance found. Cleaning up..."
vm_clean
fi

# 2. Define
vm_define
if [ $? -ne 0 ]; then echo "$TESTNAME FAIL" > "$RES_FILE"; exit 1; fi

# 3. Start
vm_start
if [ $? -ne 0 ]; then echo "$TESTNAME FAIL" > "$RES_FILE"; exit 1; fi

# 4. Verify
check_vm_state "$VM_NAME" "running"
if [ $? -eq 0 ]; then
log_pass "VM is running."
echo "$TESTNAME PASS" > "$RES_FILE"
else
log_fail "VM failed to reach 'running' state."
echo "$TESTNAME FAIL" > "$RES_FILE"
exit 1
fi
15 changes: 15 additions & 0 deletions Runner/suites/Kernel/Virtualization/Kvm-Suspend/Kvm-Suspend.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
metadata:
name: kvm-suspend
format: "Lava-Test Test Definition 1.0"
description: "Suspend a running Gunyah KVM Virtual Machine"
os:
- linux
scope:
- functional

run:
steps:
- REPO_PATH=$PWD
- cd Runner/suites/Kernel/Virtualization/Kvm-Suspend
- ./run.sh || true
- $REPO_PATH/Runner/utils/send-to-lava.sh Kvm-Suspend.res || true
23 changes: 23 additions & 0 deletions Runner/suites/Kernel/Virtualization/Kvm-Suspend/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
# Kvm-Suspend Test
© Qualcomm Technologies, Inc. and/or its subsidiaries.
SPDX-License-Identifier: BSD-3-Clause-Clear

## Overview
This test checks the ability to suspend (pause) the execution of the Guest VM.

### The test checks for:
- Successful execution of `virsh suspend`.
- VM state transition to **"paused"**.

## Usage
### Quick Example
```bash
cd /var/Runner/suites/Kernel/Virtualization/Kvm-Suspend
./run.sh
```

### Result Format
Test result will be saved in Kvm-Suspend.res.

### Output
Kvm-Suspend PASS OR Kvm-Suspend FAIL
Loading
Loading