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