@@ -22,6 +22,8 @@ declare -A CHECKS=(
22
22
[" mount-home" ]=" 1"
23
23
[" containerd-user" ]=" 1"
24
24
[" restart" ]=" 1"
25
+ [" snapshot-online" ]=" 1"
26
+ [" snapshot-offline" ]=" 1"
25
27
[" port-forwards" ]=" 1"
26
28
[" vmnet" ]=" "
27
29
[" disk" ]=" "
@@ -43,6 +45,9 @@ case "$NAME" in
43
45
# ● run-r2b459797f5b04262bfa79984077a65c7.service loaded failed failed /usr/bin/systemctl start man-db-cache-update
44
46
CHECKS[" systemd-strict" ]=
45
47
;;
48
+ " 9p" )
49
+ CHECKS[" snapshot-online" ]=" "
50
+ ;;
46
51
" vmnet" )
47
52
CHECKS[" vmnet" ]=1
48
53
;;
@@ -299,6 +304,46 @@ if [[ -n ${CHECKS["restart"]} ]]; then
299
304
fi
300
305
fi
301
306
307
+ if [[ -n ${CHECKS["snapshot-online"]} ]]; then
308
+ INFO " Testing online snapshots"
309
+ limactl shell " $NAME " sh -c ' echo foo > /tmp/test'
310
+ limactl snapshot create " $NAME " --tag snap1
311
+ got=$( limactl snapshot list " $NAME " --quiet)
312
+ expected=" snap1"
313
+ INFO " snapshot list: expected=${expected} got=${got} "
314
+ if [ " $got " != " $expected " ]; then
315
+ ERROR " snapshot list did not return expected value"
316
+ exit 1
317
+ fi
318
+ limactl shell " $NAME " sh -c ' echo bar > /tmp/test'
319
+ limactl snapshot apply " $NAME " --tag snap1
320
+ got=$( limactl shell " $NAME " cat /tmp/test)
321
+ expected=" foo"
322
+ INFO " snapshot apply: expected=${expected} got=${got} "
323
+ if [ " $got " != " $expected " ]; then
324
+ ERROR " snapshot apply did not restore snapshot"
325
+ exit 1
326
+ fi
327
+ limactl snapshot delete " $NAME " --tag snap1
328
+ limactl shell " $NAME " rm /tmp/test
329
+ fi
330
+ if [[ -n ${CHECKS["snapshot-offline"]} ]]; then
331
+ INFO " Testing offline snapshots"
332
+ limactl stop " $NAME "
333
+ sleep 3
334
+ limactl snapshot create " $NAME " --tag snap2
335
+ got=$( limactl snapshot list " $NAME " --quiet)
336
+ expected=" snap2"
337
+ INFO " snapshot list: expected=${expected} got=${got} "
338
+ if [ " $got " != " $expected " ]; then
339
+ ERROR " snapshot list did not return expected value"
340
+ exit 1
341
+ fi
342
+ limactl snapshot apply " $NAME " --tag snap2
343
+ limactl snapshot delete " $NAME " --tag snap2
344
+ limactl start " $NAME "
345
+ fi
346
+
302
347
INFO " Stopping \" $NAME \" "
303
348
limactl stop " $NAME "
304
349
sleep 3
0 commit comments