]> git.ipfire.org Git - thirdparty/systemd.git/blame - test/TEST-25-IMPORT/testsuite.sh
test: try to determine QEMU_SMP dynamically
[thirdparty/systemd.git] / test / TEST-25-IMPORT / testsuite.sh
CommitLineData
f5095a6a
LP
1#!/bin/bash
2# -*- mode: shell-script; indent-tabs-mode: nil; sh-basic-offset: 4; -*-
3# ex: ts=8 sw=4 sts=4 et filetype=sh
4set -ex
5set -o pipefail
6
7export SYSTEMD_PAGER=cat
8
9dd if=/dev/urandom of=/var/tmp/testimage.raw bs=$((1024*1024+7)) count=5
10
11# Test import
12machinectl import-raw /var/tmp/testimage.raw
13machinectl image-status testimage
14test -f /var/lib/machines/testimage.raw
15cmp /var/tmp/testimage.raw /var/lib/machines/testimage.raw
16
17# Test export
18machinectl export-raw testimage /var/tmp/testimage2.raw
19cmp /var/tmp/testimage.raw /var/tmp/testimage2.raw
20rm /var/tmp/testimage2.raw
21
22# Test compressed export (gzip)
23machinectl export-raw testimage /var/tmp/testimage2.raw.gz
24gunzip /var/tmp/testimage2.raw.gz
25cmp /var/tmp/testimage.raw /var/tmp/testimage2.raw
26rm /var/tmp/testimage2.raw
27
28# Test clone
29machinectl clone testimage testimage3
30test -f /var/lib/machines/testimage3.raw
31machinectl image-status testimage3
32test -f /var/lib/machines/testimage.raw
33machinectl image-status testimage
34cmp /var/tmp/testimage.raw /var/lib/machines/testimage.raw
35cmp /var/tmp/testimage.raw /var/lib/machines/testimage3.raw
36
37# Test removal
38machinectl remove testimage
39! test -f /var/lib/machines/testimage.raw
40! machinectl image-status testimage
41
42# Test export of clone
43machinectl export-raw testimage3 /var/tmp/testimage3.raw
44cmp /var/tmp/testimage.raw /var/tmp/testimage3.raw
45rm /var/tmp/testimage3.raw
46
47# Test rename
48machinectl rename testimage3 testimage4
49test -f /var/lib/machines/testimage4.raw
50machinectl image-status testimage4
51! test -f /var/lib/machines/testimage3.raw
52! machinectl image-status testimage3
53cmp /var/tmp/testimage.raw /var/lib/machines/testimage4.raw
54
55# Test export of rename
56machinectl export-raw testimage4 /var/tmp/testimage4.raw
57cmp /var/tmp/testimage.raw /var/tmp/testimage4.raw
58rm /var/tmp/testimage4.raw
59
60# Test removal
61machinectl remove testimage4
62! test -f /var/lib/machines/testimage4.raw
63! machinectl image-status testimage4
64
65# → And now, let's test directory trees ← #
66
67# Set up a directory we can import
68mkdir /var/tmp/scratch
69mv /var/tmp/testimage.raw /var/tmp/scratch/
70touch /var/tmp/scratch/anotherfile
71mkdir /var/tmp/scratch/adirectory
72echo "piep" > /var/tmp/scratch/adirectory/athirdfile
73
74# Test import-fs
75machinectl import-fs /var/tmp/scratch/
76test -d /var/lib/machines/scratch
77machinectl image-status scratch
78
79# Test export-tar
80machinectl export-tar scratch /var/tmp/scratch.tar.gz
81test -f /var/tmp/scratch.tar.gz
82mkdir /var/tmp/extract
83(cd /var/tmp/extract ; tar xzf /var/tmp/scratch.tar.gz)
84diff -r /var/tmp/scratch/ /var/tmp/extract/
85rm -rf /var/tmp/extract
86
87# Test import-tar
88machinectl import-tar /var/tmp/scratch.tar.gz scratch2
89test -d /var/lib/machines/scratch2
90machinectl image-status scratch2
91diff -r /var/tmp/scratch/ /var/lib/machines/scratch2
92
93# Test removal
94machinectl remove scratch
95! test -f /var/lib/machines/scratch
96! machinectl image-status scratch
97
98# Test clone
99machinectl clone scratch2 scratch3
100test -d /var/lib/machines/scratch2
101machinectl image-status scratch2
102test -d /var/lib/machines/scratch3
103machinectl image-status scratch3
104diff -r /var/tmp/scratch/ /var/lib/machines/scratch3
105
106# Test removal
107machinectl remove scratch2
108! test -f /var/lib/machines/scratch2
109! machinectl image-status scratch2
110
111# Test rename
112machinectl rename scratch3 scratch4
113test -d /var/lib/machines/scratch4
114machinectl image-status scratch4
115! test -f /var/lib/machines/scratch3
116! machinectl image-status scratch3
117diff -r /var/tmp/scratch/ /var/lib/machines/scratch4
118
119# Test removal
120machinectl remove scratch4
121! test -f /var/lib/machines/scratch4
122! machinectl image-status scratch4
123
124rm -rf /var/tmp/scratch
125
126echo OK > /testok
127
128exit 0