Added automation of Virsh commands#285
Added automation of Virsh commands#285Rohan-in-Qualcomm wants to merge 2 commits intoqualcomm-linux:mainfrom
Conversation
|
Please fix the checks |
smuppand
left a comment
There was a problem hiding this comment.
These changes are not aligned with the repository standards. Please review the contributions README and update accordingly.
381bdf3 to
9346e9d
Compare
|
Updated the PR with the requested changes. |
9346e9d to
4a8837d
Compare
This PR refactors the Virsh Commands into a modular suite of independent KVM test cases. Key Changes: Modular Architecture: Split the original script into 5 standalone test cases: Kvm-Setup: Defines and starts the VM. Kvm-Reboot: Verifies reboot functionality. Kvm-Suspend: Verifies suspend/pause functionality. Kvm-Resume: Verifies resume functionality. Kvm-UnDefine: Verifies destroy and undefine functionality. Common Library: Created kvm_common.sh to handle shared logic (define, start, clean, state checks) and reduce code duplication. Robust State Verification: Replaced simple exit code checks with a check_vm_state function that parses virsh domstate output to ensure the VM is actually in the expected state (e.g., "running", "paused", "shut off"). Independence: Each test script now manages its own lifecycle (Setup -> Test -> UnDefine), allowing them to be run individually or in any order. Reporting: Added .res file generation (PASS/FAIL) and LAVA-compatible .yaml metadata for automation integration. Signed-off-by: Rohan Dutta <rohadutt@qti.qualcomm.com>
4a8837d to
cc5c15c
Compare
Signed-off-by: Rohan Dutta <rohadutt@qti.qualcomm.com>
| #!/bin/bash | ||
|
|
||
| # Copyright (c) Qualcomm Technologies, Inc. and/or its subsidiaries. | ||
| # SPDX-License-Identifier: BSD-3-Clause-Clear |
There was a problem hiding this comment.
Rename the license to BSD-3-Clause across the files in the PR
| @@ -0,0 +1,93 @@ | |||
| #!/bin/bash | |||
There was a problem hiding this comment.
Please convert these scripts to POSIX /bin/sh and keep them ShellCheck-clean. The current implementation uses Bash-specific constructs in both the suite run.sh files and kvm_common.sh.
| exit 1 | ||
| fi | ||
|
|
||
| TESTNAME="Kvm-Teardown" |
There was a problem hiding this comment.
The Kvm-UnDefine / Kvm-Teardown naming is inconsistent across folder names, YAML paths, result filenames, and README content.
| if [ $? -ne 0 ]; then echo "$TESTNAME FAIL" > "$RES_FILE"; exit 1; fi | ||
|
|
||
| log_info "Destroying VM $VM_NAME" | ||
| virsh destroy "$VM_NAME" |
There was a problem hiding this comment.
Please add proper dependency / environment checks for virsh and the required VM setup, and use a clean SKIP path where appropriate instead of failing late.
| rm -f "$RES_FILE" | ||
|
|
||
| # Clean up old stdout logs from previous runs | ||
| rm -f *_stdout_*.log |
There was a problem hiding this comment.
Avoid broad cleanup like rm -f stdout.log tests should only remove artifacts created by the current run.
| export VM="hk-vm" | ||
| export VM_NAME="$VM" | ||
| export XML_FILE="/var/gunyah/vm.xml" | ||
| export NONRT_IMAGE_DIR="$TOOLS/nonrt_Image" |
There was a problem hiding this comment.
NONRT_IMAGE_DIR is exported here but does not appear to be used in this helper. If it is not needed, please remove it to avoid carrying unused variables.
| return 0 | ||
| } | ||
|
|
||
| check_vm_state() { |
There was a problem hiding this comment.
check_vm_state() uses Bash-only syntax (local, ==). Please make this POSIX-compliant. Also, consider whether virsh domstate output may need normalization before comparison.
| fi | ||
|
|
||
| vm_define && vm_start | ||
| if [ $? -ne 0 ]; then echo "$TESTNAME FAIL" > "$RES_FILE"; exit 1; fi |
There was a problem hiding this comment.
Please avoid compact patterns like vm_define && vm_start followed by $? checks. Use explicit if ...; then ...; else ...; fi blocks for clarity and ShellCheck friendliness.
|
|
||
| log_info "----------- KVM Suspend -----------" | ||
|
|
||
| if virsh list --all | grep -q -w "$VM_NAME"; then |
There was a problem hiding this comment.
Here the log and command use $VM, while other scripts use $VM_NAME. Please keep naming consistent across the suite to avoid confusion.
| @@ -0,0 +1,15 @@ | |||
| metadata: | |||
There was a problem hiding this comment.
The YAML structure is very minimal. Please align these with the repository’s standard LAVA test definition style used by other suites in this repo.
|
@ualcomm/qualcomm-linux-testing.triage This pull request has been marked as stale due to 30 days of inactivity. |
This PR refactors the Virsh Commands into a modular suite of independent KVM test cases.
Key Changes:
Created kvm_common.sh to handle shared logic (define, start, clean, state checks) and reduce code duplication.
Robust State Verification: Replaced simple exit code checks with a check_vm_state function that parses virsh domstate output to ensure the VM is actually in the expected state (e.g., "running", "paused", "shut off").
Independence: Each test script now manages its own lifecycle (Setup -> Test -> Undefine), allowing them to be run individually or in any order.
Reporting: Added .res file generation (PASS/FAIL) and LAVA-compatible .yaml metadata for automation integration.