summaryrefslogtreecommitdiffstats
path: root/tests/memres-test.sh
diff options
context:
space:
mode:
authorBruce Ashfield <bruce.ashfield@gmail.com>2026-01-01 17:15:29 +0000
committerBruce Ashfield <bruce.ashfield@gmail.com>2026-02-09 03:32:52 +0000
commit1165c61f5ab8ada644c7def03e991890c4d380ca (patch)
tree1cd1c1d58039afad5a1d24b5c10d8030237e2d7c /tests/memres-test.sh
parentc32e1081c81ba27f0d5a21a1885601f04d329d21 (diff)
downloadmeta-virtualization-1165c61f5ab8ada644c7def03e991890c4d380ca.tar.gz
tests: add pytest framework for vdkr and vpdmn
Add pytest-based test suite for testing vdkr and vpdmn CLI tools. Tests use a separate state directory (~/.vdkr-test/) to avoid interfering with production images. Test files: - conftest.py: Pytest fixtures for VdkrRunner and VpdmnRunner - test_vdkr.py: Docker CLI tests (images, vimport, vrun, volumes, etc.) - test_vpdmn.py: Podman CLI tests (mirrors vdkr test coverage) - memres-test.sh: Helper script for running tests with memres - pytest.ini: Pytest configuration and markers Test categories: - Basic operations: images, info, version - Import/export: vimport, load, save - Container execution: vrun, run, exec - Storage management: system df, vstorage - Memory resident mode: memres/vmemres start/stop/status Running tests: pytest tests/test_vdkr.py -v --vdkr-dir /tmp/vcontainer-standalone pytest tests/test_vpdmn.py -v --vdkr-dir /tmp/vcontainer-standalone Signed-off-by: Bruce Ashfield <bruce.ashfield@gmail.com>
Diffstat (limited to 'tests/memres-test.sh')
-rwxr-xr-xtests/memres-test.sh87
1 files changed, 87 insertions, 0 deletions
diff --git a/tests/memres-test.sh b/tests/memres-test.sh
new file mode 100755
index 00000000..5f10751d
--- /dev/null
+++ b/tests/memres-test.sh
@@ -0,0 +1,87 @@
1#!/bin/bash
2# Helper script to manage memres for the test state directory.
3#
4# Usage:
5# ./memres-test.sh start [--vdkr-dir /path/to/vdkr] [--arch x86_64|aarch64]
6# ./memres-test.sh stop [--vdkr-dir /path/to/vdkr] [--arch x86_64|aarch64]
7# ./memres-test.sh status [--vdkr-dir /path/to/vdkr] [--arch x86_64|aarch64]
8
9set -e
10
11# Defaults
12VDKR_DIR="${VDKR_STANDALONE_DIR:-/tmp/vdkr-standalone}"
13ARCH="${VDKR_ARCH:-x86_64}"
14TEST_STATE_DIR="$HOME/.vdkr-test"
15
16# Parse arguments
17CMD=""
18while [[ $# -gt 0 ]]; do
19 case $1 in
20 start|stop|status)
21 CMD="$1"
22 shift
23 ;;
24 --vdkr-dir)
25 VDKR_DIR="$2"
26 shift 2
27 ;;
28 --arch)
29 ARCH="$2"
30 shift 2
31 ;;
32 *)
33 echo "Unknown option: $1" >&2
34 exit 1
35 ;;
36 esac
37done
38
39if [ -z "$CMD" ]; then
40 echo "Usage: $0 start|stop|status [--vdkr-dir PATH] [--arch x86_64|aarch64]" >&2
41 exit 1
42fi
43
44# Validate vdkr directory
45if [ ! -d "$VDKR_DIR" ]; then
46 echo "Error: vdkr directory not found: $VDKR_DIR" >&2
47 echo "Set VDKR_STANDALONE_DIR or use --vdkr-dir" >&2
48 exit 1
49fi
50
51# Source environment
52if [ -f "$VDKR_DIR/init-env.sh" ]; then
53 source "$VDKR_DIR/init-env.sh"
54elif [ -f "$VDKR_DIR/setup-env.sh" ]; then
55 source "$VDKR_DIR/setup-env.sh"
56fi
57
58# Find vdkr binary - try symlink first, then main vdkr with --arch
59VDKR_BIN="$VDKR_DIR/vdkr-$ARCH"
60VDKR_ARGS=""
61if [ ! -x "$VDKR_BIN" ]; then
62 # Try main vdkr binary with --arch flag
63 VDKR_BIN="$VDKR_DIR/vdkr"
64 VDKR_ARGS="--arch $ARCH"
65 if [ ! -x "$VDKR_BIN" ]; then
66 echo "Error: vdkr binary not found: $VDKR_DIR/vdkr or $VDKR_DIR/vdkr-$ARCH" >&2
67 exit 1
68 fi
69fi
70
71STATE_DIR="$TEST_STATE_DIR/$ARCH"
72
73case "$CMD" in
74 start)
75 echo "Starting memres for tests (state: $STATE_DIR)..."
76 "$VDKR_BIN" $VDKR_ARGS --state-dir "$STATE_DIR" memres start
77 echo "Memres started. Run tests with:"
78 echo " pytest tests/test_vdkr.py -v --vdkr-dir $VDKR_DIR --arch $ARCH --skip-destructive"
79 ;;
80 stop)
81 echo "Stopping memres for tests..."
82 "$VDKR_BIN" $VDKR_ARGS --state-dir "$STATE_DIR" memres stop
83 ;;
84 status)
85 "$VDKR_BIN" $VDKR_ARGS --state-dir "$STATE_DIR" memres status
86 ;;
87esac