mirror of
https://github.com/libguestfs/libguestfs.git
synced 2026-03-22 07:03:38 +00:00
tests: Use unique or temporary names for temporary files.
Review every test(!) to ensure that it: - Doesn't use a generic name (eg. "test1.img", "test.out") for any temporary file it needs. - Does instead use a unique name or a temporary name (eg. a name like "name-of-the-test.img", or a scratch disk). - Does not use 'rm -f' to clean up its temporary files (so we can detect errors if the wrong temporary file is created or removed). This allows tests to be run in parallel, so they don't stomp on each other's temporary files.
This commit is contained in:
4
.gitignore
vendored
4
.gitignore
vendored
@@ -106,7 +106,6 @@ Makefile.in
|
||||
/erlang/guestfs.beam
|
||||
/erlang/guestfs.erl
|
||||
/erlang/libguestfs-1.*
|
||||
/erlang/test.img
|
||||
/examples/copy-over
|
||||
/examples/create-disk
|
||||
/examples/debug-logging
|
||||
@@ -251,7 +250,6 @@ Makefile.in
|
||||
/lua/examples/stamp-guestfs-lua.pod
|
||||
/lua/guestfs.so
|
||||
/lua/lua-guestfs.c
|
||||
/lua/test.img
|
||||
/m4/ChangeLog
|
||||
/m4/gnulib-cache.m4
|
||||
/m4/intmax.m4
|
||||
@@ -405,8 +403,6 @@ Makefile.in
|
||||
/sysprep/sysprep-operations.pod
|
||||
/sysprep/virt-sysprep
|
||||
/sysprep/virt-sysprep.1
|
||||
/test1.img
|
||||
/test2.img
|
||||
/test.err
|
||||
/test.out
|
||||
/tests/c-api/test-add-drive-opts
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
main(_) ->
|
||||
{ok, G} = guestfs:create(),
|
||||
|
||||
Disk_image = "test.img",
|
||||
Disk_image = "test-lvcreate.img",
|
||||
|
||||
{ok, File} = file:open(Disk_image, [raw, write, binary]),
|
||||
{ok, _} = file:position(File, 512 * 1024 * 1024 - 1),
|
||||
|
||||
@@ -21,7 +21,7 @@
|
||||
main(_) ->
|
||||
{ok, G} = guestfs:create(),
|
||||
|
||||
Disk_image = "test.img",
|
||||
Disk_image = "test-readdir.img",
|
||||
|
||||
{ok, File} = file:open(Disk_image, [raw, write, binary]),
|
||||
{ok, _} = file:position(File, 10 * 1024 * 1024 - 1),
|
||||
|
||||
@@ -20,30 +20,30 @@
|
||||
|
||||
set -e
|
||||
|
||||
rm -f test.out
|
||||
rm -f test1.img
|
||||
rm -f test-a.out
|
||||
rm -f test-a.img
|
||||
|
||||
./guestfish sparse test1.img 100M
|
||||
./guestfish sparse test-a.img 100M
|
||||
|
||||
./guestfish -x -a test1.img </dev/null >test.out 2>&1
|
||||
./guestfish -x -a test-a.img </dev/null >test-a.out 2>&1
|
||||
|
||||
! grep -sq 'add_drive.*format' test.out
|
||||
! grep -sq 'add_drive.*format' test-a.out
|
||||
|
||||
./guestfish -x --format=qcow2 -a test1.img </dev/null >test.out 2>&1
|
||||
./guestfish -x --format=qcow2 -a test-a.img </dev/null >test-a.out 2>&1
|
||||
|
||||
grep -sq 'add_drive.*format:qcow2' test.out
|
||||
grep -sq 'add_drive.*format:qcow2' test-a.out
|
||||
|
||||
./guestfish -x --ro --format=qcow2 -a test1.img </dev/null >test.out 2>&1
|
||||
./guestfish -x --ro --format=qcow2 -a test-a.img </dev/null >test-a.out 2>&1
|
||||
|
||||
grep -sq 'add_drive.*readonly:true.*format:qcow2' test.out
|
||||
grep -sq 'add_drive.*readonly:true.*format:qcow2' test-a.out
|
||||
|
||||
./guestfish -x --format -a test1.img </dev/null >test.out 2>&1
|
||||
./guestfish -x --format -a test-a.img </dev/null >test-a.out 2>&1
|
||||
|
||||
! grep -sq 'add_drive.*format' test.out
|
||||
! grep -sq 'add_drive.*format' test-a.out
|
||||
|
||||
./guestfish -x -a test1.img --format=qcow2 </dev/null >test.out 2>&1
|
||||
./guestfish -x -a test-a.img --format=qcow2 </dev/null >test-a.out 2>&1
|
||||
|
||||
! grep -sq 'add_drive.*format' test.out
|
||||
! grep -sq 'add_drive.*format' test-a.out
|
||||
|
||||
rm test.out
|
||||
rm test1.img
|
||||
rm test-a.out
|
||||
rm test-a.img
|
||||
|
||||
@@ -20,17 +20,18 @@
|
||||
|
||||
set -e
|
||||
|
||||
rm -f test1.img test2.img test3.img test4.img test.xml test.out
|
||||
rm -f test-add-domain-{1,2,3,4}.img
|
||||
rm -f test-add-domain.xml test-add-domain.out
|
||||
|
||||
cwd="$(pwd)"
|
||||
|
||||
./guestfish sparse test1.img 1M
|
||||
./guestfish sparse test2.img 1M
|
||||
./guestfish sparse test3.img 1M
|
||||
./guestfish sparse test4.img 1M
|
||||
./guestfish sparse test-add-domain-1.img 1M
|
||||
./guestfish sparse test-add-domain-2.img 1M
|
||||
./guestfish sparse test-add-domain-3.img 1M
|
||||
./guestfish sparse test-add-domain-4.img 1M
|
||||
|
||||
# Libvirt test XML, see libvirt.git/examples/xml/test/testnode.xml
|
||||
cat > test.xml <<EOF
|
||||
cat > test-add-domain.xml <<EOF
|
||||
<node>
|
||||
<domain type="test">
|
||||
<name>guest</name>
|
||||
@@ -41,22 +42,22 @@ cat > test.xml <<EOF
|
||||
<memory>524288</memory>
|
||||
<devices>
|
||||
<disk type="file">
|
||||
<source file="$cwd/test1.img"/>
|
||||
<source file="$cwd/test-add-domain-1.img"/>
|
||||
<target dev="hda"/>
|
||||
</disk>
|
||||
<disk type="file">
|
||||
<driver name="qemu" type="raw"/>
|
||||
<source file="$cwd/test2.img"/>
|
||||
<source file="$cwd/test-add-domain-2.img"/>
|
||||
<target dev="hdb"/>
|
||||
</disk>
|
||||
<disk type="file">
|
||||
<driver name="qemu" type="qcow2"/>
|
||||
<source file="$cwd/test3.img"/>
|
||||
<source file="$cwd/test-add-domain-3.img"/>
|
||||
<target dev="hdc"/>
|
||||
</disk>
|
||||
<disk type="file">
|
||||
<driver name="qemu" type="raw"/>
|
||||
<source file="$cwd/test4.img"/>
|
||||
<source file="$cwd/test-add-domain-4.img"/>
|
||||
<target dev="hdd"/>
|
||||
<readonly/>
|
||||
</disk>
|
||||
@@ -65,35 +66,36 @@ cat > test.xml <<EOF
|
||||
</node>
|
||||
EOF
|
||||
|
||||
./guestfish >test.out <<EOF
|
||||
domain guest libvirturi:test://$cwd/test.xml readonly:true
|
||||
./guestfish >test-add-domain.out <<EOF
|
||||
domain guest libvirturi:test://$cwd/test-add-domain.xml readonly:true
|
||||
debug-drives
|
||||
EOF
|
||||
grep -sq "test1.img readonly" test.out
|
||||
! grep -sq "test1.img.*format" test.out
|
||||
grep -sq "test2.img readonly format=raw" test.out
|
||||
grep -sq "test3.img readonly format=qcow2" test.out
|
||||
grep -sq "test-add-domain-1.img readonly" test-add-domain.out
|
||||
! grep -sq "test-add-domain-1.img.*format" test-add-domain.out
|
||||
grep -sq "test-add-domain-2.img readonly format=raw" test-add-domain.out
|
||||
grep -sq "test-add-domain-3.img readonly format=qcow2" test-add-domain.out
|
||||
|
||||
# Test readonlydisk = "ignore".
|
||||
./guestfish >test.out <<EOF
|
||||
-domain guest libvirturi:test://$cwd/test.xml readonly:true readonlydisk:ignore
|
||||
./guestfish >test-add-domain.out <<EOF
|
||||
-domain guest libvirturi:test://$cwd/test-add-domain.xml readonly:true readonlydisk:ignore
|
||||
debug-drives
|
||||
EOF
|
||||
grep -sq "test1.img" test.out
|
||||
grep -sq "test2.img" test.out
|
||||
grep -sq "test3.img" test.out
|
||||
! grep -sq "test4.img" test.out
|
||||
grep -sq "test-add-domain-1.img" test-add-domain.out
|
||||
grep -sq "test-add-domain-2.img" test-add-domain.out
|
||||
grep -sq "test-add-domain-3.img" test-add-domain.out
|
||||
! grep -sq "test-add-domain-4.img" test-add-domain.out
|
||||
|
||||
# Test atomicity.
|
||||
rm test3.img
|
||||
rm test-add-domain-3.img
|
||||
|
||||
./guestfish >test.out <<EOF
|
||||
-domain guest libvirturi:test://$cwd/test.xml readonly:true
|
||||
./guestfish >test-add-domain.out <<EOF
|
||||
-domain guest libvirturi:test://$cwd/test-add-domain.xml readonly:true
|
||||
debug-drives
|
||||
EOF
|
||||
! grep -sq "test1.img" test.out
|
||||
! grep -sq "test2.img" test.out
|
||||
! grep -sq "test3.img" test.out
|
||||
! grep -sq "test4.img" test.out
|
||||
! grep -sq "test-add-domain-1.img" test-add-domain.out
|
||||
! grep -sq "test-add-domain-2.img" test-add-domain.out
|
||||
! grep -sq "test-add-domain-3.img" test-add-domain.out
|
||||
! grep -sq "test-add-domain-4.img" test-add-domain.out
|
||||
|
||||
rm -f test1.img test2.img test3.img test4.img test.xml test.out
|
||||
rm test-add-domain-{1,2,4}.img
|
||||
rm test-add-domain.xml test-add-domain.out
|
||||
|
||||
@@ -28,22 +28,22 @@ test -d /dev/fd || {
|
||||
|
||||
set -e
|
||||
|
||||
rm -f test1.img
|
||||
rm -rf original copy
|
||||
rm -f test-copy.img
|
||||
rm -rf test-copy-original test-copy-copy
|
||||
|
||||
mkdir original
|
||||
cp $srcdir/../tests/data/known* original
|
||||
cp -P ../tests/data/abssymlink* original
|
||||
mkdir test-copy-original
|
||||
cp $srcdir/../tests/data/known* test-copy-original
|
||||
cp -P ../tests/data/abssymlink* test-copy-original
|
||||
|
||||
output=$(
|
||||
./guestfish -N fs -m /dev/sda1 <<EOF
|
||||
./guestfish -N test-copy.img=fs -m /dev/sda1 <<EOF
|
||||
mkdir /data
|
||||
# This creates a directory /data/data/
|
||||
copy-in original /data
|
||||
is-file /data/original/known-1
|
||||
is-file /data/original/known-3
|
||||
is-file /data/original/known-5
|
||||
is-symlink /data/original/abssymlink
|
||||
copy-in test-copy-original /data
|
||||
is-file /data/test-copy-original/known-1
|
||||
is-file /data/test-copy-original/known-3
|
||||
is-file /data/test-copy-original/known-5
|
||||
is-symlink /data/test-copy-original/abssymlink
|
||||
is-file /data/known-1
|
||||
is-file /known-1
|
||||
EOF
|
||||
@@ -61,22 +61,22 @@ false" ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
mkdir copy
|
||||
mkdir test-copy-copy
|
||||
|
||||
./guestfish --ro -a test1.img -m /dev/sda1 <<EOF
|
||||
copy-out /data/original copy
|
||||
./guestfish --ro -a test-copy.img -m /dev/sda1 <<EOF
|
||||
copy-out /data/test-copy-original test-copy-copy
|
||||
EOF
|
||||
|
||||
if test ! -f copy/original/known-1 || \
|
||||
test ! -f copy/original/known-3 || \
|
||||
test ! -f copy/original/known-5 || \
|
||||
test ! -L copy/original/abssymlink || \
|
||||
test -f copy/known-1 || \
|
||||
if test ! -f test-copy-copy/test-copy-original/known-1 || \
|
||||
test ! -f test-copy-copy/test-copy-original/known-3 || \
|
||||
test ! -f test-copy-copy/test-copy-original/known-5 || \
|
||||
test ! -L test-copy-copy/test-copy-original/abssymlink || \
|
||||
test -f test-copy-copy/known-1 || \
|
||||
test -f known-1
|
||||
then
|
||||
echo "$0: error: copy-out command failed"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
rm -f test1.img
|
||||
rm -rf original copy
|
||||
rm test-copy.img
|
||||
rm -r test-copy-original test-copy-copy
|
||||
|
||||
@@ -20,17 +20,18 @@
|
||||
|
||||
set -e
|
||||
|
||||
rm -f test1.img test2.img test3.img test4.img test.xml test.out
|
||||
rm -f test-d-{1,2,3,4}.img
|
||||
rm -f test-d.xml test-d.out
|
||||
|
||||
cwd="$(pwd)"
|
||||
|
||||
./guestfish sparse test1.img 1M
|
||||
./guestfish sparse test2.img 1M
|
||||
./guestfish sparse test3.img 1M
|
||||
./guestfish sparse test4.img 1M
|
||||
./guestfish sparse test-d-1.img 1M
|
||||
./guestfish sparse test-d-2.img 1M
|
||||
./guestfish sparse test-d-3.img 1M
|
||||
./guestfish sparse test-d-4.img 1M
|
||||
|
||||
# Libvirt test XML, see libvirt.git/examples/xml/test/testnode.xml
|
||||
cat > test.xml <<EOF
|
||||
cat > test-d.xml <<EOF
|
||||
<node>
|
||||
<domain type="test">
|
||||
<name>guest</name>
|
||||
@@ -41,22 +42,22 @@ cat > test.xml <<EOF
|
||||
<memory>524288</memory>
|
||||
<devices>
|
||||
<disk type="file">
|
||||
<source file="$cwd/test1.img"/>
|
||||
<source file="$cwd/test-d-1.img"/>
|
||||
<target dev="hda"/>
|
||||
</disk>
|
||||
<disk type="file">
|
||||
<driver name="qemu" type="raw"/>
|
||||
<source file="$cwd/test2.img"/>
|
||||
<source file="$cwd/test-d-2.img"/>
|
||||
<target dev="hdb"/>
|
||||
</disk>
|
||||
<disk type="file">
|
||||
<driver name="qemu" type="qcow2"/>
|
||||
<source file="$cwd/test3.img"/>
|
||||
<source file="$cwd/test-d-3.img"/>
|
||||
<target dev="hdc"/>
|
||||
</disk>
|
||||
<disk type="file">
|
||||
<driver name="qemu" type="raw"/>
|
||||
<source file="$cwd/test4.img"/>
|
||||
<source file="$cwd/test-d-4.img"/>
|
||||
<target dev="hdd"/>
|
||||
<readonly/>
|
||||
</disk>
|
||||
@@ -65,12 +66,13 @@ cat > test.xml <<EOF
|
||||
</node>
|
||||
EOF
|
||||
|
||||
./guestfish -c "test://$cwd/test.xml" --ro -d guest \
|
||||
debug-drives </dev/null >test.out
|
||||
grep -sq "test1.img readonly" test.out
|
||||
! grep -sq "test1.img.*format" test.out
|
||||
grep -sq "test2.img readonly format=raw" test.out
|
||||
grep -sq "test3.img readonly format=qcow2" test.out
|
||||
grep -sq "test4.img readonly format=raw" test.out
|
||||
./guestfish -c "test://$cwd/test-d.xml" --ro -d guest \
|
||||
debug-drives </dev/null >test-d.out
|
||||
grep -sq "test-d-1.img readonly" test-d.out
|
||||
! grep -sq "test-d-1.img.*format" test-d.out
|
||||
grep -sq "test-d-2.img readonly format=raw" test-d.out
|
||||
grep -sq "test-d-3.img readonly format=qcow2" test-d.out
|
||||
grep -sq "test-d-4.img readonly format=raw" test-d.out
|
||||
|
||||
rm -f test1.img test2.img test3.img test4.img test.xml test.out
|
||||
rm test-d-{1,2,3,4}.img
|
||||
rm test-d.xml test-d.out
|
||||
|
||||
@@ -28,13 +28,13 @@ test -d /dev/fd || {
|
||||
|
||||
set -e
|
||||
|
||||
rm -f test1.img
|
||||
rm -f test-edit.img
|
||||
|
||||
# The command will be 'echo ... >>/tmp/tmpfile'
|
||||
export EDITOR="echo second line of text >>"
|
||||
|
||||
output=$(
|
||||
./guestfish -N fs -m /dev/sda1 <<EOF
|
||||
./guestfish -N test-edit.img=fs -m /dev/sda1 <<EOF
|
||||
write /file.txt "this is a test\n"
|
||||
chmod 0600 /file.txt
|
||||
chown 10 11 /file.txt
|
||||
@@ -57,4 +57,4 @@ gid: 11" ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
rm -f test1.img
|
||||
rm test-edit.img
|
||||
|
||||
@@ -20,12 +20,9 @@
|
||||
|
||||
set -e
|
||||
|
||||
rm -f test.img test.out
|
||||
rm -f test-glob.img test-glob.out
|
||||
|
||||
./guestfish > test.out <<EOF
|
||||
|
||||
sparse test.img 1G
|
||||
run
|
||||
./guestfish -N test-glob.img=disk:1G > test-glob.out <<EOF
|
||||
|
||||
pvcreate /dev/sda
|
||||
# Because glob doesn't do device name translation, we cannot test
|
||||
@@ -66,7 +63,7 @@ glob echo /dev/a*/* /dev/a*/*
|
||||
echo end
|
||||
EOF
|
||||
|
||||
if [ "$(cat test.out)" != "files
|
||||
if [ "$(cat test-glob.out)" != "files
|
||||
/foo/
|
||||
/foo/bar1
|
||||
/foo/bar2
|
||||
@@ -98,8 +95,8 @@ devices
|
||||
/dev/abc/lv3 /dev/abc/lv3
|
||||
end" ]; then
|
||||
echo "$0: error: unexpected output from glob command"
|
||||
cat test.out
|
||||
cat test-glob.out
|
||||
exit 1
|
||||
fi
|
||||
|
||||
rm -f test.img test.out
|
||||
rm test-glob.img test-glob.out
|
||||
|
||||
@@ -35,34 +35,34 @@ set -e
|
||||
|
||||
if [ $# -gt 0 -a "$1" = "--run-test" ]; then
|
||||
# Create some files and read them back.
|
||||
echo 'hello' > mp/hello
|
||||
chmod 0600 mp/hello
|
||||
rm mp/hello
|
||||
echo 'hello' > test-mount-local-mp/hello
|
||||
chmod 0600 test-mount-local-mp/hello
|
||||
rm test-mount-local-mp/hello
|
||||
|
||||
echo 'hello' > mp/hello
|
||||
ln -s mp/hello mp/goodbye
|
||||
ln mp/hello mp/link
|
||||
rm mp/goodbye mp/link
|
||||
echo 'hello' > test-mount-local-mp/hello
|
||||
ln -s test-mount-local-mp/hello test-mount-local-mp/goodbye
|
||||
ln test-mount-local-mp/hello test-mount-local-mp/link
|
||||
rm test-mount-local-mp/goodbye test-mount-local-mp/link
|
||||
|
||||
dd if=/dev/zero of=mp/zero bs=10k count=10
|
||||
dd if=/dev/zero of=test-mount-local-mp/zero bs=10k count=10
|
||||
sync
|
||||
rm mp/zero
|
||||
rm test-mount-local-mp/zero
|
||||
|
||||
echo 'mount-local test successful' > mp/ok
|
||||
echo 'mount-local test successful' > test-mount-local-mp/ok
|
||||
|
||||
# Unmount the mountpoint.
|
||||
../fuse/guestunmount mp
|
||||
../fuse/guestunmount test-mount-local-mp
|
||||
|
||||
exit 0
|
||||
fi
|
||||
|
||||
rm -f test1.img test.errors
|
||||
rm -rf mp
|
||||
rm -f test-mount-local.img test-mount-local.errors
|
||||
rm -rf test-mount-local-mp
|
||||
|
||||
mkdir mp
|
||||
mkdir test-mount-local-mp
|
||||
|
||||
if ! ./guestfish -N fs -m /dev/sda1 2>test.errors <<EOF; then
|
||||
mount-local mp
|
||||
if ! ./guestfish -N test-mount-local.img=fs -m /dev/sda1 2>test-mount-local.errors <<EOF; then
|
||||
mount-local test-mount-local-mp
|
||||
! $0 --run-test &
|
||||
mount-local-run
|
||||
|
||||
@@ -72,9 +72,9 @@ cat /ok
|
||||
|
||||
EOF
|
||||
echo "$0: test failed."
|
||||
cat test.errors
|
||||
cat test-mount-local.errors
|
||||
exit 1
|
||||
fi
|
||||
|
||||
rm -f test1.img test.errors
|
||||
rm -rf mp
|
||||
rm test-mount-local.img test-mount-local.errors
|
||||
rm -r test-mount-local-mp
|
||||
|
||||
@@ -20,11 +20,11 @@
|
||||
|
||||
set -e
|
||||
|
||||
rm -f test.img
|
||||
rm -f test-remote.img
|
||||
|
||||
eval `./guestfish --listen`
|
||||
|
||||
./guestfish --remote alloc test.img 10M
|
||||
./guestfish --remote alloc test-remote.img 10M
|
||||
./guestfish --remote run
|
||||
./guestfish --remote part-disk /dev/sda mbr
|
||||
./guestfish --remote mkfs ext2 /dev/sda1
|
||||
@@ -41,6 +41,6 @@ fi
|
||||
|
||||
./guestfish --remote exit
|
||||
|
||||
rm -f test.img
|
||||
rm test-remote.img
|
||||
|
||||
exit $error
|
||||
|
||||
@@ -21,21 +21,21 @@
|
||||
|
||||
set -e
|
||||
|
||||
rm -f test.img
|
||||
rm -f test-reopen.img
|
||||
|
||||
./guestfish <<'EOF'
|
||||
reopen
|
||||
reopen
|
||||
reopen
|
||||
|
||||
alloc test.img 5M
|
||||
alloc test-reopen.img 5M
|
||||
run
|
||||
reopen
|
||||
|
||||
alloc test.img 5M
|
||||
alloc test-reopen.img 5M
|
||||
run
|
||||
reopen
|
||||
|
||||
EOF
|
||||
|
||||
rm -f test.img
|
||||
rm test-reopen.img
|
||||
|
||||
@@ -20,7 +20,7 @@
|
||||
|
||||
set -e
|
||||
|
||||
rm -f test.img
|
||||
rm -f test-stringlist.img
|
||||
|
||||
eval `./guestfish --listen`
|
||||
|
||||
@@ -39,7 +39,7 @@ function check_echo {
|
||||
fi
|
||||
}
|
||||
|
||||
./guestfish --remote alloc test.img 10M
|
||||
./guestfish --remote alloc test-stringlist.img 10M
|
||||
./guestfish --remote run
|
||||
|
||||
check_echo "' '" " "
|
||||
@@ -55,6 +55,6 @@ check_echo " 'foo'" "foo"
|
||||
|
||||
./guestfish --remote exit
|
||||
|
||||
rm -f test.img
|
||||
rm test-stringlist.img
|
||||
|
||||
exit $error
|
||||
|
||||
@@ -22,18 +22,18 @@
|
||||
|
||||
set -e
|
||||
|
||||
rm -f test1.img test.out
|
||||
rm -f test-upload-to-dir.img test-upload-to-dir.out
|
||||
|
||||
if ./guestfish -N fs -m /dev/sda1 upload ../tests/data/test.iso / 2>test.out
|
||||
if ./guestfish -N test-upload-to-dir.img=fs -m /dev/sda1 upload ../tests/data/test.iso / 2>test-upload-to-dir.out
|
||||
then
|
||||
echo "$0: expecting guestfish to return an error"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! grep -q "upload: /: Is a directory" test.out; then
|
||||
if ! grep -q "upload: /: Is a directory" test-upload-to-dir.out; then
|
||||
echo "$0: unexpected error message from guestfish"
|
||||
cat test.out
|
||||
cat test-upload-to-dir.out
|
||||
exit 1
|
||||
fi
|
||||
|
||||
rm -f test1.img test.out
|
||||
rm test-upload-to-dir.img test-upload-to-dir.out
|
||||
|
||||
@@ -25,15 +25,15 @@ if [ -n "$SKIP_TEST_VIRT_FORMAT_SH" ]; then
|
||||
exit 77
|
||||
fi
|
||||
|
||||
rm -f test1.img
|
||||
rm -f test-virt-format.img
|
||||
|
||||
$VG ../fish/guestfish -N bootrootlv exit
|
||||
$VG ../fish/guestfish -N test-virt-format.img=bootrootlv exit
|
||||
|
||||
$VG ./virt-format --filesystem=ext3 -a test1.img
|
||||
$VG ./virt-format --filesystem=ext3 -a test-virt-format.img
|
||||
|
||||
if [ "$($VG ../cat/virt-filesystems -a test1.img)" != "/dev/sda1" ]; then
|
||||
if [ "$($VG ../cat/virt-filesystems -a test-virt-format.img)" != "/dev/sda1" ]; then
|
||||
echo "$0: unexpected output after using virt-format"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
rm -f test1.img
|
||||
rm test-virt-format.img
|
||||
|
||||
@@ -50,8 +50,8 @@ top_builddir=$(cd "$top_builddir" > /dev/null; pwd)
|
||||
guestfish="$top_builddir/fish/guestfish"
|
||||
guestmount="$top_builddir/fuse/guestmount"
|
||||
guestunmount="$top_builddir/fuse/guestunmount"
|
||||
image="$top_builddir/fuse/test.img"
|
||||
mp="$top_builddir/fuse/test-mp"
|
||||
image="$top_builddir/fuse/test-fuse.img"
|
||||
mp="$top_builddir/fuse/test-fuse-mp"
|
||||
|
||||
if [ ! -x "$guestfish" -o ! -x "$guestmount" -o ! -x "$guestunmount" ]
|
||||
then
|
||||
|
||||
@@ -26,10 +26,10 @@ main = do
|
||||
g <- G.create
|
||||
{- XXX replace with a call to add_drive_scratch once
|
||||
optional arguments are supported -}
|
||||
fd <- openFile "test.img" WriteMode
|
||||
fd <- openFile "test-lv-create.img" WriteMode
|
||||
hSetFileSize fd (500 * 1024 * 1024)
|
||||
hClose fd
|
||||
G.add_drive_ro g "test.img"
|
||||
G.add_drive_ro g "test-lv-create.img"
|
||||
G.launch g
|
||||
|
||||
G.pvcreate g "/dev/sda"
|
||||
@@ -41,4 +41,4 @@ main = do
|
||||
when (lvs /= ["/dev/VG/LV1", "/dev/VG/LV2"]) $
|
||||
fail "invalid list of LVs returned"
|
||||
|
||||
removeLink "test.img"
|
||||
removeLink "test-lv-create.img"
|
||||
|
||||
@@ -88,7 +88,7 @@ $(built_tests): %: %.hs Guestfs.hs
|
||||
$(GHC) $(GHCFLAGS) --make -main-is $@ -odir .$@ -o $@ $< $(srcdir)/Guestfs.hs -lguestfs
|
||||
|
||||
|
||||
CLEANFILES = $(all_targets) *~ *.hi *.o test.img
|
||||
CLEANFILES = $(all_targets) *~ *.hi *.o test-lv-create.img
|
||||
|
||||
clean-local:
|
||||
-rm -rf $(built_tests:%=.%)
|
||||
|
||||
@@ -18,14 +18,14 @@
|
||||
import os
|
||||
import guestfs
|
||||
|
||||
f = open ("test.img", "w")
|
||||
f = open ("rhbz811650.img", "w")
|
||||
f.truncate (500 * 1024 * 1024)
|
||||
f.close ()
|
||||
|
||||
g = guestfs.GuestFS (python_return_dict=True)
|
||||
|
||||
# Deliberate error: the disk format is supposed to be raw.
|
||||
g.add_drive ("test.img", format="qcow2");
|
||||
g.add_drive ("rhbz811650.img", format="qcow2");
|
||||
|
||||
# Because error() wasn't being called, guestfs_last_error would return
|
||||
# NULL, causing a segfault in the Python bindings (RHBZ#811650).
|
||||
@@ -34,4 +34,4 @@ try:
|
||||
except:
|
||||
pass
|
||||
|
||||
os.unlink ("test.img")
|
||||
os.unlink ("rhbz811650.img")
|
||||
|
||||
@@ -22,7 +22,7 @@ EXTRA_DIST = \
|
||||
virt-resize.pod \
|
||||
test-virt-resize.sh
|
||||
|
||||
CLEANFILES = *~ *.cmi *.cmo *.cmx *.cmxa *.o virt-resize test.img
|
||||
CLEANFILES = *~ *.cmi *.cmo *.cmx *.cmxa *.o virt-resize
|
||||
|
||||
# Alphabetical order.
|
||||
SOURCES = \
|
||||
|
||||
@@ -24,20 +24,21 @@ set -e
|
||||
# This exercises a number of interesting codepaths including resizing
|
||||
# LV content, handling GPT, and using qcow2 as a target.
|
||||
|
||||
$VG ../fish/guestfish -N bootrootlv:/dev/VG/LV:ext2:ext4:400M:32M:gpt </dev/null
|
||||
$VG ../fish/guestfish \
|
||||
-N test-virt-resize-1.img=bootrootlv:/dev/VG/LV:ext2:ext4:400M:32M:gpt </dev/null
|
||||
|
||||
qemu-img create -f qcow2 test2.img 500M
|
||||
qemu-img create -f qcow2 test-virt-resize-2.img 500M
|
||||
$VG ./virt-resize -d --debug-gc \
|
||||
--expand /dev/sda2 \
|
||||
--lv-expand /dev/VG/LV \
|
||||
--format raw --output-format qcow2 \
|
||||
test1.img test2.img
|
||||
test-virt-resize-1.img test-virt-resize-2.img
|
||||
|
||||
# Test shrinking in a semi-realistic scenario. Although the disk
|
||||
# image created above contains no data, we will nevertheless use
|
||||
# similar operations to ones that might be used by a real admin.
|
||||
|
||||
../fish/guestfish -a test1.img <<EOF
|
||||
../fish/guestfish -a test-virt-resize-1.img <<EOF
|
||||
run
|
||||
resize2fs-size /dev/VG/LV 190M
|
||||
lvresize /dev/VG/LV 190
|
||||
@@ -45,10 +46,10 @@ pvresize-size /dev/sda2 200M
|
||||
fsck ext4 /dev/VG/LV
|
||||
EOF
|
||||
|
||||
rm -f test2.img; ../fish/guestfish sparse test2.img 300M
|
||||
rm -f test-virt-resize-2.img; ../fish/guestfish sparse test-virt-resize-2.img 300M
|
||||
$VG ./virt-resize -d --debug-gc \
|
||||
--shrink /dev/sda2 \
|
||||
--format raw --output-format raw \
|
||||
test1.img test2.img
|
||||
test-virt-resize-1.img test-virt-resize-2.img
|
||||
|
||||
rm -f test1.img test2.img
|
||||
rm test-virt-resize-1.img test-virt-resize-2.img
|
||||
|
||||
@@ -22,7 +22,7 @@ EXTRA_DIST = \
|
||||
virt-sparsify.pod \
|
||||
test-virt-sparsify.sh
|
||||
|
||||
CLEANFILES = *~ *.cmi *.cmo *.cmx *.cmxa *.o virt-sparsify test.img
|
||||
CLEANFILES = *~ *.cmi *.cmo *.cmx *.cmxa *.o virt-sparsify
|
||||
|
||||
# Alphabetical order.
|
||||
SOURCES = \
|
||||
|
||||
@@ -19,13 +19,13 @@
|
||||
export LANG=C
|
||||
set -e
|
||||
|
||||
rm -f test1.img test2.img
|
||||
rm -f test-virt-sparsify-1.img test-virt-sparsify-2.img
|
||||
|
||||
# Create a filesystem, fill it with data, then delete the data. Then
|
||||
# prove that sparsifying it reduces the size of the final filesystem.
|
||||
|
||||
$VG ../fish/guestfish \
|
||||
-N bootrootlv:/dev/VG/LV:ext2:ext4:400M:32M:gpt <<EOF
|
||||
-N test-virt-sparsify-1.img=bootrootlv:/dev/VG/LV:ext2:ext4:400M:32M:gpt <<EOF
|
||||
mount /dev/VG/LV /
|
||||
mkdir /boot
|
||||
mount /dev/sda1 /boot
|
||||
@@ -37,10 +37,10 @@ rm /boot/big
|
||||
umount-all
|
||||
EOF
|
||||
|
||||
$VG ./virt-sparsify --debug-gc test1.img --convert qcow2 test2.img
|
||||
$VG ./virt-sparsify --debug-gc test-virt-sparsify-1.img --convert qcow2 test-virt-sparsify-2.img
|
||||
|
||||
size_before=$(du -s test1.img | awk '{print $1}')
|
||||
size_after=$(du -s test2.img | awk '{print $1}')
|
||||
size_before=$(du -s test-virt-sparsify-1.img | awk '{print $1}')
|
||||
size_after=$(du -s test-virt-sparsify-2.img | awk '{print $1}')
|
||||
|
||||
echo "test virt-sparsify: $size_before K -> $size_after K"
|
||||
|
||||
@@ -55,4 +55,4 @@ if [ $size_after -gt 15000 ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
rm -f test1.img test2.img
|
||||
rm test-virt-sparsify-1.img test-virt-sparsify-2.img
|
||||
|
||||
@@ -32,11 +32,11 @@ if [[ "$backend" != "direct" ]]; then
|
||||
exit 77
|
||||
fi
|
||||
|
||||
rm -f test.img test.out
|
||||
rm -f test-9p.img test-9p.out
|
||||
|
||||
../../fish/guestfish <<EOF
|
||||
# This dummy disk is not actually used, but libguestfs requires one.
|
||||
sparse test.img 1M
|
||||
sparse test-9p.img 1M
|
||||
|
||||
config -device 'virtio-9p-pci,fsdev=test9p,mount_tag=test9p'
|
||||
config -fsdev 'local,id=test9p,path=$(pwd),security_model=passthrough'
|
||||
@@ -44,13 +44,14 @@ config -fsdev 'local,id=test9p,path=$(pwd),security_model=passthrough'
|
||||
run
|
||||
|
||||
mount-9p test9p /
|
||||
ls / | grep 'test-9p.sh\$' > test.out
|
||||
ls / | grep 'test-9p.sh\$' > test-9p.out
|
||||
|
||||
EOF
|
||||
|
||||
if [ "$(cat test.out)" != "test-9p.sh" ]; then
|
||||
if [ "$(cat test-9p.out)" != "test-9p.sh" ]; then
|
||||
echo "$0: unexpected output from listing 9p directory:"
|
||||
cat test.out
|
||||
cat test-9p.out
|
||||
exit 1
|
||||
fi
|
||||
|
||||
rm test.img test.out
|
||||
rm test-9p.img test-9p.out
|
||||
|
||||
@@ -38,14 +38,14 @@ if ! $guestfish -a /dev/null run : available btrfs; then
|
||||
exit 77
|
||||
fi
|
||||
|
||||
rm -f test[1234].img
|
||||
rm -f test-btrfs-devices-{1,2,3,4}.img
|
||||
|
||||
$guestfish <<EOF
|
||||
# Add four empty disks
|
||||
sparse test1.img 1G
|
||||
sparse test2.img 1G
|
||||
sparse test3.img 1G
|
||||
sparse test4.img 1G
|
||||
sparse test-btrfs-devices-1.img 1G
|
||||
sparse test-btrfs-devices-2.img 1G
|
||||
sparse test-btrfs-devices-3.img 1G
|
||||
sparse test-btrfs-devices-4.img 1G
|
||||
run
|
||||
|
||||
part-disk /dev/sda mbr
|
||||
@@ -95,4 +95,4 @@ btrfs-device-delete "/dev/sdc1 /dev/sdd1" /
|
||||
|
||||
EOF
|
||||
|
||||
rm -f test[1234].img
|
||||
rm test-btrfs-devices-{1,2,3,4}.img
|
||||
|
||||
@@ -46,17 +46,17 @@ make_test_xml (FILE *fp, const char *cwd)
|
||||
" <memory>524288</memory>\n"
|
||||
" <devices>\n"
|
||||
" <disk type='file'>\n"
|
||||
" <source file='%s/test1.img'/>\n"
|
||||
" <source file='%s/test-add-libvirt-dom-1.img'/>\n"
|
||||
" <target dev='hda'/>\n"
|
||||
" </disk>\n"
|
||||
" <disk type='file'>\n"
|
||||
" <driver name='qemu' type='raw'/>\n"
|
||||
" <source file='%s/test2.img'/>\n"
|
||||
" <source file='%s/test-add-libvirt-dom-2.img'/>\n"
|
||||
" <target dev='hdb'/>\n"
|
||||
" </disk>\n"
|
||||
" <disk type='file'>\n"
|
||||
" <driver name='qemu' type='qcow2'/>\n"
|
||||
" <source file='%s/test3.img'/>\n"
|
||||
" <source file='%s/test-add-libvirt-dom-3.img'/>\n"
|
||||
" <target dev='hdc'/>\n"
|
||||
" </disk>\n"
|
||||
" </devices>\n"
|
||||
@@ -80,32 +80,34 @@ main (int argc, char *argv[])
|
||||
|
||||
cwd = xgetcwd ();
|
||||
|
||||
/* Create the libvirt XML and test images in the current directory. */
|
||||
fp = fopen ("test.xml", "w");
|
||||
/* Create the libvirt XML and test images in the current
|
||||
* directory.
|
||||
*/
|
||||
fp = fopen ("test-add-libvirt-dom.xml", "w");
|
||||
if (fp == NULL) {
|
||||
perror ("test.xml");
|
||||
perror ("test-add-libvirt-dom.xml");
|
||||
exit (EXIT_FAILURE);
|
||||
}
|
||||
make_test_xml (fp, cwd);
|
||||
fclose (fp);
|
||||
|
||||
fp = fopen ("test1.img", "w");
|
||||
fp = fopen ("test-add-libvirt-dom-1.img", "w");
|
||||
if (fp == NULL) {
|
||||
perror ("test1.img");
|
||||
perror ("test-add-libvirt-dom-1.img");
|
||||
exit (EXIT_FAILURE);
|
||||
}
|
||||
fclose (fp);
|
||||
|
||||
fp = fopen ("test2.img", "w");
|
||||
fp = fopen ("test-add-libvirt-dom-2.img", "w");
|
||||
if (fp == NULL) {
|
||||
perror ("test2.img");
|
||||
perror ("test-add-libvirt-dom-2.img");
|
||||
exit (EXIT_FAILURE);
|
||||
}
|
||||
fclose (fp);
|
||||
|
||||
fp = fopen ("test3.img", "w");
|
||||
fp = fopen ("test-add-libvirt-dom-3.img", "w");
|
||||
if (fp == NULL) {
|
||||
perror ("test3.img");
|
||||
perror ("test-add-libvirt-dom-3.img");
|
||||
exit (EXIT_FAILURE);
|
||||
}
|
||||
fclose (fp);
|
||||
@@ -118,7 +120,7 @@ main (int argc, char *argv[])
|
||||
}
|
||||
|
||||
/* Create the libvirt connection. */
|
||||
snprintf (libvirt_uri, sizeof libvirt_uri, "test://%s/test.xml", cwd);
|
||||
snprintf (libvirt_uri, sizeof libvirt_uri, "test://%s/test-add-libvirt-dom.xml", cwd);
|
||||
conn = virConnectOpenReadOnly (libvirt_uri);
|
||||
if (!conn) {
|
||||
err = virGetLastError ();
|
||||
@@ -143,10 +145,10 @@ main (int argc, char *argv[])
|
||||
|
||||
guestfs_close (g);
|
||||
|
||||
unlink ("test.xml");
|
||||
unlink ("test1.img");
|
||||
unlink ("test2.img");
|
||||
unlink ("test3.img");
|
||||
unlink ("test-add-libvirt-dom.xml");
|
||||
unlink ("test-add-libvirt-dom-1.img");
|
||||
unlink ("test-add-libvirt-dom-2.img");
|
||||
unlink ("test-add-libvirt-dom-3.img");
|
||||
|
||||
exit (EXIT_SUCCESS);
|
||||
}
|
||||
|
||||
@@ -72,11 +72,11 @@ display = \
|
||||
# include them in the libvirt fake XML to make sure that virt-df and
|
||||
# virt-alignment-scan don't break when they encounter them.
|
||||
blank-%.img:
|
||||
rm -f $@ test1.img
|
||||
rm -f $@ $@-t
|
||||
$(top_builddir)/run \
|
||||
../../fish/guestfish \
|
||||
-N "$$(echo $@ | sed -e 's/blank-//' -e 's/.img//')" exit
|
||||
mv test1.img $@
|
||||
-N $@-t="$$(echo $@ | sed -e 's/blank-//' -e 's/.img//')" exit
|
||||
mv $@-t $@
|
||||
$(call display,$@)
|
||||
|
||||
# Make a (dummy) Fedora image.
|
||||
|
||||
@@ -36,20 +36,20 @@ unless ($backend eq "libvirt" || $backend =~ /^libvirt:/) {
|
||||
$g->launch ();
|
||||
|
||||
# Create some temporary disks.
|
||||
open FILE, ">test1.img" or die "test1.img: $!";
|
||||
truncate FILE, 512 * 1024 * 1024 or die "test1.img: truncate: $!";
|
||||
open FILE, ">test-hot-add-1.img" or die "test-hot-add-1.img: $!";
|
||||
truncate FILE, 512 * 1024 * 1024 or die "test-hot-add-1.img: truncate: $!";
|
||||
close FILE;
|
||||
|
||||
open FILE, ">test2.img" or die "test2.img: $!";
|
||||
truncate FILE, 512 * 1024 * 1024 or die "test2.img: truncate: $!";
|
||||
open FILE, ">test-hot-add-2.img" or die "test-hot-add-2.img: $!";
|
||||
truncate FILE, 512 * 1024 * 1024 or die "test-hot-add-2.img: truncate: $!";
|
||||
close FILE;
|
||||
|
||||
die unless system ("qemu-img create -f qcow2 test3.img 1G") == 0;
|
||||
die unless system ("qemu-img create -f qcow2 test-hot-add-3.img 1G") == 0;
|
||||
|
||||
# Hot-add them. Labels are required.
|
||||
$g->add_drive ("test1.img", label => "a"); # autodetect format
|
||||
$g->add_drive ("test2.img", label => "b", format => "raw", readonly => 1);
|
||||
$g->add_drive ("test3.img", label => "c", format => "qcow2");
|
||||
$g->add_drive ("test-hot-add-1.img", label => "a"); # autodetect format
|
||||
$g->add_drive ("test-hot-add-2.img", label => "b", format => "raw", readonly => 1);
|
||||
$g->add_drive ("test-hot-add-3.img", label => "c", format => "qcow2");
|
||||
|
||||
# Check we can use the disks immediately.
|
||||
$g->part_disk ("/dev/disk/guestfs/a", "mbr");
|
||||
@@ -59,8 +59,8 @@ $g->mkfs ("ext2", "/dev/disk/guestfs/a1");
|
||||
$g->shutdown ();
|
||||
$g->close ();
|
||||
|
||||
unlink "test1.img";
|
||||
unlink "test2.img";
|
||||
unlink "test3.img";
|
||||
unlink "test-hot-add-1.img";
|
||||
unlink "test-hot-add-2.img";
|
||||
unlink "test-hot-add-3.img";
|
||||
|
||||
exit 0
|
||||
|
||||
@@ -33,20 +33,20 @@ unless ($backend eq "libvirt" || $backend =~ /^libvirt:/) {
|
||||
}
|
||||
|
||||
# Create some temporary disks.
|
||||
open FILE, ">test1.img" or die "test1.img: $!";
|
||||
truncate FILE, 512 * 1024 * 1024 or die "test1.img: truncate: $!";
|
||||
open FILE, ">test-hot-remove-1.img" or die "test-hot-remove-1.img: $!";
|
||||
truncate FILE, 512 * 1024 * 1024 or die "test-hot-remove-1.img: truncate: $!";
|
||||
close FILE;
|
||||
|
||||
open FILE, ">test2.img" or die "test2.img: $!";
|
||||
truncate FILE, 512 * 1024 * 1024 or die "test2.img: truncate: $!";
|
||||
open FILE, ">test-hot-remove-2.img" or die "test-hot-remove-2.img: $!";
|
||||
truncate FILE, 512 * 1024 * 1024 or die "test-hot-remove-2.img: truncate: $!";
|
||||
close FILE;
|
||||
|
||||
die unless system ("qemu-img create -f qcow2 test3.img 1G") == 0;
|
||||
die unless system ("qemu-img create -f qcow2 test-hot-remove-3.img 1G") == 0;
|
||||
|
||||
# Hot-add them. Labels are required.
|
||||
$g->add_drive ("test1.img", label => "a"); # autodetect format
|
||||
$g->add_drive ("test2.img", label => "b", format => "raw", readonly => 1);
|
||||
$g->add_drive ("test3.img", label => "c", format => "qcow2");
|
||||
$g->add_drive ("test-hot-remove-1.img", label => "a"); # autodetect format
|
||||
$g->add_drive ("test-hot-remove-2.img", label => "b", format => "raw", readonly => 1);
|
||||
$g->add_drive ("test-hot-remove-3.img", label => "c", format => "qcow2");
|
||||
|
||||
# Remove them (before launch).
|
||||
$g->remove_drive ("a");
|
||||
@@ -60,9 +60,9 @@ my @devices = $g->list_devices ();
|
||||
die unless 0 == @devices;
|
||||
|
||||
# Add them again (after launch).
|
||||
$g->add_drive ("test1.img", label => "a"); # autodetect format
|
||||
$g->add_drive ("test2.img", label => "b", format => "raw", readonly => 1);
|
||||
$g->add_drive ("test3.img", label => "c", format => "qcow2");
|
||||
$g->add_drive ("test-hot-remove-1.img", label => "a"); # autodetect format
|
||||
$g->add_drive ("test-hot-remove-2.img", label => "b", format => "raw", readonly => 1);
|
||||
$g->add_drive ("test-hot-remove-3.img", label => "c", format => "qcow2");
|
||||
|
||||
# Check we can use the disks immediately.
|
||||
$g->part_disk ("/dev/disk/guestfs/a", "mbr");
|
||||
@@ -81,8 +81,8 @@ die unless 0 == @devices;
|
||||
$g->shutdown ();
|
||||
$g->close ();
|
||||
|
||||
unlink "test1.img";
|
||||
unlink "test2.img";
|
||||
unlink "test3.img";
|
||||
unlink "test-hot-remove-1.img";
|
||||
unlink "test-hot-remove-2.img";
|
||||
unlink "test-hot-remove-3.img";
|
||||
|
||||
exit 0
|
||||
|
||||
@@ -35,13 +35,17 @@ unless ($backend eq "libvirt" || $backend =~ /^libvirt:/) {
|
||||
$g->launch ();
|
||||
|
||||
# Create a temporary disk.
|
||||
open FILE, ">test1.img" or die "test1.img: $!";
|
||||
truncate FILE, 512 * 1024 * 1024 or die "test1.img: truncate: $!";
|
||||
close FILE;
|
||||
open FILE, ">test-hotplug-repeated.img" or
|
||||
die "test-hotplug-repeated.img: $!";
|
||||
truncate FILE, 512 * 1024 * 1024 or
|
||||
die "test-hotplug-repeated.img: truncate: $!";
|
||||
close FILE or
|
||||
die "test-hotplug-repeated.img: close: $!";
|
||||
|
||||
my $start_t = time ();
|
||||
while (time () - $start_t <= 60) {
|
||||
$g->add_drive ("test1.img", label => "a", format => "raw");
|
||||
$g->add_drive ("test-hotplug-repeated.img",
|
||||
label => "a", format => "raw");
|
||||
$g->remove_drive ("a");
|
||||
}
|
||||
|
||||
@@ -52,6 +56,6 @@ die unless 0 == @devices;
|
||||
$g->shutdown ();
|
||||
$g->close ();
|
||||
|
||||
unlink "test1.img";
|
||||
unlink "test-hotplug-repeated.img";
|
||||
|
||||
exit 0
|
||||
|
||||
@@ -25,10 +25,10 @@ set -e
|
||||
exit 77
|
||||
}
|
||||
|
||||
rm -f test1.img test.output
|
||||
rm -f test-luks-list.img test-luks-list.out
|
||||
|
||||
../../fish/guestfish --keys-from-stdin > test.output <<'EOF'
|
||||
sparse test1.img 1G
|
||||
../../fish/guestfish --keys-from-stdin > test-luks-list.out <<'EOF'
|
||||
sparse test-luks-list.img 1G
|
||||
run
|
||||
part-init /dev/sda mbr
|
||||
part-add /dev/sda p 64 1048575
|
||||
@@ -83,7 +83,7 @@ pvs | sed 's,^/dev/[hv]d,/dev/sd,'
|
||||
EOF
|
||||
|
||||
# Expected vs actual output.
|
||||
if [ "$(cat test.output)" != "\
|
||||
if [ "$(cat test-luks-list.out)" != "\
|
||||
test 1
|
||||
/dev/mapper/lukstest
|
||||
test 2
|
||||
@@ -103,9 +103,9 @@ VG
|
||||
test 8
|
||||
/dev/sda2" ]; then
|
||||
echo "test-luks-list.sh: Unexpected output from test:"
|
||||
cat test.output
|
||||
cat test-luks-list.out
|
||||
echo "[end of output]"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
rm -f test1.img test.output
|
||||
rm test-luks-list.img test-luks-list.out
|
||||
|
||||
@@ -25,10 +25,10 @@ set -e
|
||||
exit 77
|
||||
}
|
||||
|
||||
rm -f test1.img
|
||||
rm -f test-luks.img
|
||||
|
||||
../../fish/guestfish --keys-from-stdin <<EOF
|
||||
sparse test1.img 1G
|
||||
sparse test-luks.img 1G
|
||||
run
|
||||
part-disk /dev/sda mbr
|
||||
|
||||
@@ -90,4 +90,4 @@ luks-close /dev/mapper/lukstest
|
||||
|
||||
EOF
|
||||
|
||||
rm -f test1.img
|
||||
rm test-luks.img
|
||||
|
||||
@@ -20,11 +20,11 @@
|
||||
|
||||
set -e
|
||||
|
||||
rm -f test1.img test2.img
|
||||
rm -f test-lvm-filtering-1.img test-lvm-filtering-2.img
|
||||
|
||||
actual=$(../../fish/guestfish <<'EOF'
|
||||
sparse test1.img 1G
|
||||
sparse test2.img 1G
|
||||
sparse test-lvm-filtering-1.img 1G
|
||||
sparse test-lvm-filtering-2.img 1G
|
||||
|
||||
run
|
||||
|
||||
@@ -83,7 +83,7 @@ VG2
|
||||
VG1
|
||||
VG2"
|
||||
|
||||
rm -f test1.img test2.img
|
||||
rm test-lvm-filtering-1.img test-lvm-filtering-2.img
|
||||
|
||||
if [ "$actual" != "$expected" ]; then
|
||||
echo "LVM filter test failed. Actual output was:"
|
||||
|
||||
@@ -37,43 +37,43 @@ fi
|
||||
|
||||
guestfish=../../fish/guestfish
|
||||
|
||||
rm -f test1.img test.fstab test.output
|
||||
rm -f inspect-fstab-md-{1,2}.img inspect-fstab-md.fstab inspect-fstab-md.output
|
||||
|
||||
# First, test the regular fedora image, which specifies /boot as /dev/md0
|
||||
cp ../guests/fedora-md1.img test1.img
|
||||
cp ../guests/fedora-md2.img test2.img
|
||||
cp ../guests/fedora-md1.img inspect-fstab-md-1.img
|
||||
cp ../guests/fedora-md2.img inspect-fstab-md-2.img
|
||||
|
||||
$guestfish -i test[12].img <<'EOF' | sort > test.output
|
||||
$guestfish -i inspect-fstab-md-[12].img <<'EOF' | sort > inspect-fstab-md.output
|
||||
exists /boot/grub/grub.conf
|
||||
EOF
|
||||
|
||||
if [ "$(cat test.output)" != "true" ]; then
|
||||
if [ "$(cat inspect-fstab-md.output)" != "true" ]; then
|
||||
echo "$0: /boot not correctly mounted (/dev/md0)"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Test inspection when /boot is specfied as /dev/md/boot
|
||||
cat <<'EOF' > test.fstab
|
||||
cat <<'EOF' > inspect-fstab-md.fstab
|
||||
/dev/VG/Root / ext2 default 0 0
|
||||
/dev/md/boot /boot ext2 default 0 0
|
||||
EOF
|
||||
|
||||
$guestfish -a test1.img -a test2.img <<'EOF'
|
||||
$guestfish -a inspect-fstab-md-1.img -a inspect-fstab-md-2.img <<'EOF'
|
||||
run
|
||||
mount /dev/VG/Root /
|
||||
upload test.fstab /etc/fstab
|
||||
upload inspect-fstab-md.fstab /etc/fstab
|
||||
EOF
|
||||
|
||||
$guestfish -i test[12].img <<'EOF' | sort > test.output
|
||||
$guestfish -i inspect-fstab-md-[12].img <<'EOF' | sort > inspect-fstab-md.output
|
||||
exists /boot/grub/grub.conf
|
||||
EOF
|
||||
|
||||
if [ "$(cat test.output)" != "true" ]; then
|
||||
if [ "$(cat inspect-fstab-md.output)" != "true" ]; then
|
||||
echo "$0: error: /boot not correctly mounted (/dev/md/boot)"
|
||||
cat test.output
|
||||
cat inspect-fstab-md.output
|
||||
exit 1
|
||||
fi
|
||||
|
||||
rm test.fstab
|
||||
rm test[12].img
|
||||
rm test.output
|
||||
rm inspect-fstab-md.fstab
|
||||
rm inspect-fstab-md-[12].img
|
||||
rm inspect-fstab-md.output
|
||||
|
||||
@@ -25,13 +25,13 @@ export LANG=C
|
||||
guestfish=../../fish/guestfish
|
||||
canonical="sed s,/dev/vd,/dev/sd,g"
|
||||
|
||||
rm -f test1.qcow2 test.fstab test.output
|
||||
rm -f inspect-fstab-1.qcow2 inspect-fstab.fstab inspect-fstab.output
|
||||
|
||||
# Start with the regular (good) fedora image, modify /etc/fstab
|
||||
# and then inspect it.
|
||||
qemu-img create -F raw -b ../guests/fedora.img -f qcow2 test1.qcow2
|
||||
qemu-img create -F raw -b ../guests/fedora.img -f qcow2 inspect-fstab-1.qcow2
|
||||
|
||||
cat <<'EOF' > test.fstab
|
||||
cat <<'EOF' > inspect-fstab.fstab
|
||||
/dev/VG/Root / ext2 default 0 0
|
||||
|
||||
# Xen-style partition names.
|
||||
@@ -49,18 +49,18 @@ cat <<'EOF' > test.fstab
|
||||
/dev/disk/by-id/ata-QEMU_HARDDISK_QM00001-part3 /id3 ext2 default 0 0
|
||||
EOF
|
||||
|
||||
$guestfish -a test1.qcow2 <<'EOF'
|
||||
$guestfish -a inspect-fstab-1.qcow2 <<'EOF'
|
||||
run
|
||||
mount /dev/VG/Root /
|
||||
upload test.fstab /etc/fstab
|
||||
upload inspect-fstab.fstab /etc/fstab
|
||||
EOF
|
||||
|
||||
# This will give a warning, but should not fail.
|
||||
$guestfish -a test1.qcow2 -i <<'EOF' | sort | $canonical > test.output
|
||||
$guestfish -a inspect-fstab-1.qcow2 -i <<'EOF' | sort | $canonical > inspect-fstab.output
|
||||
inspect-get-mountpoints /dev/VG/Root
|
||||
EOF
|
||||
|
||||
if [ "$(cat test.output)" != "/: /dev/VG/Root
|
||||
if [ "$(cat inspect-fstab.output)" != "/: /dev/VG/Root
|
||||
/boot: /dev/sda1
|
||||
/id1: /dev/sda1
|
||||
/id3: /dev/disk/by-id/ata-QEMU_HARDDISK_QM00001-part3
|
||||
@@ -68,41 +68,41 @@ if [ "$(cat test.output)" != "/: /dev/VG/Root
|
||||
/nosuchfile: /dev/VG/LV1
|
||||
/var: /dev/sdb3" ]; then
|
||||
echo "$0: error #1: unexpected output from inspect-get-mountpoints command"
|
||||
cat test.output
|
||||
cat inspect-fstab.output
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Test device name hints
|
||||
|
||||
cat <<'EOF' > test.fstab
|
||||
cat <<'EOF' > inspect-fstab.fstab
|
||||
/dev/VG/Root / ext2 default 0 0
|
||||
|
||||
# Device name which requires a hint
|
||||
/dev/xvdg1 /boot ext2 default 0 0
|
||||
EOF
|
||||
|
||||
$guestfish -a test1.qcow2 <<'EOF'
|
||||
$guestfish -a inspect-fstab-1.qcow2 <<'EOF'
|
||||
run
|
||||
mount /dev/VG/Root /
|
||||
upload test.fstab /etc/fstab
|
||||
upload inspect-fstab.fstab /etc/fstab
|
||||
EOF
|
||||
|
||||
$guestfish <<'EOF' | $canonical > test.output
|
||||
add test1.qcow2 readonly:true name:xvdg
|
||||
$guestfish <<'EOF' | $canonical > inspect-fstab.output
|
||||
add inspect-fstab-1.qcow2 readonly:true name:xvdg
|
||||
run
|
||||
inspect-os
|
||||
inspect-get-mountpoints /dev/VG/Root
|
||||
EOF
|
||||
|
||||
if [ "$(cat test.output)" != "/dev/VG/Root
|
||||
if [ "$(cat inspect-fstab.output)" != "/dev/VG/Root
|
||||
/: /dev/VG/Root
|
||||
/boot: /dev/sda1" ]; then
|
||||
echo "$0: error #2: unexpected output from inspect-get-mountpoints command"
|
||||
cat test.output
|
||||
cat inspect-fstab.output
|
||||
exit 1
|
||||
fi
|
||||
|
||||
cat <<'EOF' > test.fstab
|
||||
cat <<'EOF' > inspect-fstab.fstab
|
||||
/dev/VG/Root / ext2 default 0 0
|
||||
|
||||
# cciss device which requires a hint
|
||||
@@ -112,28 +112,28 @@ cat <<'EOF' > test.fstab
|
||||
/dev/cciss/c1d3 /var ext2 default 0 0
|
||||
EOF
|
||||
|
||||
$guestfish -a test1.qcow2 <<'EOF'
|
||||
$guestfish -a inspect-fstab-1.qcow2 <<'EOF'
|
||||
run
|
||||
mount /dev/VG/Root /
|
||||
upload test.fstab /etc/fstab
|
||||
upload inspect-fstab.fstab /etc/fstab
|
||||
EOF
|
||||
|
||||
$guestfish <<'EOF' | $canonical > test.output
|
||||
add test1.qcow2 readonly:true name:cciss/c1d3
|
||||
$guestfish <<'EOF' | $canonical > inspect-fstab.output
|
||||
add inspect-fstab-1.qcow2 readonly:true name:cciss/c1d3
|
||||
run
|
||||
inspect-os
|
||||
inspect-get-mountpoints /dev/VG/Root
|
||||
EOF
|
||||
|
||||
if [ "$(cat test.output)" != "/dev/VG/Root
|
||||
if [ "$(cat inspect-fstab.output)" != "/dev/VG/Root
|
||||
/: /dev/VG/Root
|
||||
/boot: /dev/sda1
|
||||
/var: /dev/sda" ]; then
|
||||
echo "$0: error #3: unexpected output from inspect-get-mountpoints command"
|
||||
cat test.output
|
||||
cat inspect-fstab.output
|
||||
exit 1
|
||||
fi
|
||||
|
||||
rm test.fstab
|
||||
rm test1.qcow2
|
||||
rm test.output
|
||||
rm inspect-fstab.fstab
|
||||
rm inspect-fstab-1.qcow2
|
||||
rm inspect-fstab.output
|
||||
|
||||
@@ -25,7 +25,7 @@ if [ -n "$SKIP_TEST_LIST_FILESYSTEMS_SH" ]; then
|
||||
exit 77
|
||||
fi
|
||||
|
||||
rm -f test.output
|
||||
rm -f list-fs.output
|
||||
|
||||
# Create 2 disks partitioned as:
|
||||
# sda1: 20M ext3
|
||||
@@ -37,10 +37,10 @@ rm -f test.output
|
||||
# md127 : 20M ext4
|
||||
# vg0 : 16M LV (lv0)
|
||||
# lv0 : 16M vfat
|
||||
../../fish/guestfish <<EOF | sed s,/dev/vd,/dev/sd,g > test.output
|
||||
../../fish/guestfish <<EOF | sed s,/dev/vd,/dev/sd,g > list-fs.output
|
||||
# Add 2 empty disks
|
||||
sparse fs-test1.img 50M
|
||||
sparse fs-test2.img 50M
|
||||
scratch 50M
|
||||
scratch 50M
|
||||
run
|
||||
|
||||
part-init /dev/sda mbr
|
||||
@@ -71,11 +71,11 @@ expected="/dev/sda1: ext3
|
||||
/dev/vg0/lv0: vfat"
|
||||
|
||||
# Check the output of list-filesystems
|
||||
if [ "$(cat test.output)" != "$expected" ]; then
|
||||
if [ "$(cat list-fs.output)" != "$expected" ]; then
|
||||
echo "$0: error: output of list-filesystems did not match expected output"
|
||||
printf "%s\n" "$output"
|
||||
exit 1;
|
||||
fi
|
||||
|
||||
|
||||
rm -f fs-test1.img fs-test2.img test.output
|
||||
rm list-fs.output
|
||||
|
||||
@@ -28,8 +28,8 @@ fi
|
||||
output=$(
|
||||
../../fish/guestfish <<EOF
|
||||
# Add 2 empty disks
|
||||
sparse md-test1.img 100M
|
||||
sparse md-test2.img 100M
|
||||
sparse list-md-devices-1.img 100M
|
||||
sparse list-md-devices-2.img 100M
|
||||
run
|
||||
|
||||
# list-md-devices should return nothing
|
||||
@@ -49,7 +49,7 @@ fi
|
||||
|
||||
# Ensure list-md-devices now returns the newly created md device
|
||||
output=$(
|
||||
../../fish/guestfish -a md-test1.img -a md-test2.img <<EOF
|
||||
../../fish/guestfish -a list-md-devices-1.img -a list-md-devices-2.img <<EOF
|
||||
run
|
||||
list-md-devices
|
||||
EOF
|
||||
@@ -61,4 +61,4 @@ if [ "$output" != "/dev/md127" ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
rm -f md-test1.img md-test2.img
|
||||
rm list-md-devices-1.img list-md-devices-2.img
|
||||
|
||||
@@ -25,14 +25,14 @@ if [ -n "$SKIP_TEST_MDADM_SH" ]; then
|
||||
exit 77
|
||||
fi
|
||||
|
||||
rm -f md-test1.img md-test2.img md-test3.img md-test4.img
|
||||
rm -f mdadm-{1,2,3,4}.img
|
||||
|
||||
../../fish/guestfish <<EOF
|
||||
# Add four empty disks
|
||||
sparse md-test1.img 100M
|
||||
sparse md-test2.img 100M
|
||||
sparse md-test3.img 100M
|
||||
sparse md-test4.img 100M
|
||||
sparse mdadm-1.img 100M
|
||||
sparse mdadm-2.img 100M
|
||||
sparse mdadm-3.img 100M
|
||||
sparse mdadm-4.img 100M
|
||||
run
|
||||
|
||||
# Create lots of test partitions.
|
||||
@@ -98,10 +98,10 @@ write /r5t3/baz "testing"
|
||||
EOF
|
||||
|
||||
eval `../../fish/guestfish --listen`
|
||||
../../fish/guestfish --remote add-ro md-test1.img
|
||||
../../fish/guestfish --remote add-ro md-test2.img
|
||||
../../fish/guestfish --remote add-ro md-test3.img
|
||||
../../fish/guestfish --remote add-ro md-test4.img
|
||||
../../fish/guestfish --remote add-ro mdadm-1.img
|
||||
../../fish/guestfish --remote add-ro mdadm-2.img
|
||||
../../fish/guestfish --remote add-ro mdadm-3.img
|
||||
../../fish/guestfish --remote add-ro mdadm-4.img
|
||||
../../fish/guestfish --remote run
|
||||
|
||||
for md in `../../fish/guestfish --remote list-md-devices`; do
|
||||
@@ -156,10 +156,10 @@ done
|
||||
../../fish/guestfish --remote exit
|
||||
|
||||
eval `../../fish/guestfish --listen`
|
||||
../../fish/guestfish --remote add-ro md-test1.img
|
||||
../../fish/guestfish --remote add-ro md-test2.img
|
||||
../../fish/guestfish --remote add-ro md-test3.img
|
||||
../../fish/guestfish --remote add-ro md-test4.img
|
||||
../../fish/guestfish --remote add-ro mdadm-1.img
|
||||
../../fish/guestfish --remote add-ro mdadm-2.img
|
||||
../../fish/guestfish --remote add-ro mdadm-3.img
|
||||
../../fish/guestfish --remote add-ro mdadm-4.img
|
||||
../../fish/guestfish --remote run
|
||||
|
||||
for md in `../../fish/guestfish --remote list-md-devices`; do
|
||||
@@ -168,4 +168,4 @@ done
|
||||
|
||||
../../fish/guestfish --remote exit
|
||||
|
||||
rm -f md-detail.out md-test1.img md-test2.img md-test3.img md-test4.img
|
||||
rm md-detail.out mdadm-1.img mdadm-2.img mdadm-3.img mdadm-4.img
|
||||
|
||||
@@ -25,7 +25,7 @@ if [ -n "$SKIP_TEST_NTFSCLONE_SH" ]; then
|
||||
exit 77
|
||||
fi
|
||||
|
||||
rm -f test1.img backup1 backup2
|
||||
rm -f test-ntfsclone.img ntfsclone-backup1 ntfsclone-backup2
|
||||
|
||||
guestfish=../../fish/guestfish
|
||||
|
||||
@@ -43,13 +43,13 @@ fi
|
||||
# Export the filesystems to the backup file.
|
||||
$guestfish --ro -a ../guests/windows.img <<EOF
|
||||
run
|
||||
ntfsclone-out /dev/sda1 backup1 preservetimestamps:true force:true
|
||||
ntfsclone-out /dev/sda2 backup2 metadataonly:true ignorefscheck:true
|
||||
ntfsclone-out /dev/sda1 ntfsclone-backup1 preservetimestamps:true force:true
|
||||
ntfsclone-out /dev/sda2 ntfsclone-backup2 metadataonly:true ignorefscheck:true
|
||||
EOF
|
||||
|
||||
# Restore to another disk image.
|
||||
output=$($guestfish -N part:300M <<EOF
|
||||
ntfsclone-in backup1 /dev/sda1
|
||||
output=$($guestfish -N test-ntfsclone.img=part:300M <<EOF
|
||||
ntfsclone-in ntfsclone-backup1 /dev/sda1
|
||||
vfs-type /dev/sda1
|
||||
EOF
|
||||
)
|
||||
@@ -59,6 +59,6 @@ if [ "$output" != "ntfs" ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
#ls -lh backup[12]
|
||||
#ls -lh ntfsclone-backup[12]
|
||||
|
||||
rm -f test1.img backup1 backup2
|
||||
rm test-ntfsclone.img ntfsclone-backup1 ntfsclone-backup2
|
||||
|
||||
@@ -22,11 +22,9 @@
|
||||
|
||||
set -e
|
||||
|
||||
rm -f test1.img
|
||||
|
||||
../../fish/guestfish -N disk <<EOF
|
||||
../../fish/guestfish <<EOF
|
||||
scratch 100M
|
||||
run
|
||||
-tar-in /tmp/nosuchfile /blah
|
||||
ping-daemon
|
||||
EOF
|
||||
|
||||
rm -f test1.img
|
||||
|
||||
@@ -26,14 +26,14 @@
|
||||
|
||||
set -e
|
||||
|
||||
rm -f test.img
|
||||
tmpfile=`mktemp`
|
||||
|
||||
size=$(awk 'BEGIN{ srand(); print int(16*1024*rand()) }')
|
||||
echo "$0: test size $size (bytes)"
|
||||
|
||||
../../fish/guestfish <<EOF
|
||||
# We want the file to be fully allocated.
|
||||
alloc test.img 10M
|
||||
alloc $tmpfile 10M
|
||||
run
|
||||
|
||||
part-disk /dev/sda mbr
|
||||
@@ -50,4 +50,4 @@ ping-daemon
|
||||
|
||||
EOF
|
||||
|
||||
rm -f test.img
|
||||
rm $tmpfile
|
||||
|
||||
@@ -22,14 +22,13 @@
|
||||
|
||||
set -e
|
||||
|
||||
rm -f test1.img
|
||||
|
||||
../../fish/guestfish -N fs -m /dev/sda1 <<'EOF'
|
||||
../../fish/guestfish -N test-cancellation-upload-daemoncancels.img=fs \
|
||||
-m /dev/sda1 <<'EOF'
|
||||
# Upload image, daemon should cancel because the image is too large
|
||||
# to upload into itself.
|
||||
-upload test.img /test
|
||||
-upload test-cancellation-upload-daemoncancels.img /test
|
||||
|
||||
ping-daemon
|
||||
EOF
|
||||
|
||||
rm -f test1.img
|
||||
rm test-cancellation-upload-daemoncancels.img
|
||||
|
||||
@@ -25,9 +25,9 @@ if [ "$(../../fish/guestfish get-backend)" != "direct" ]; then
|
||||
exit 77
|
||||
fi
|
||||
|
||||
rm -f test1.img
|
||||
|
||||
../../fish/guestfish -N disk <<'EOF'
|
||||
../../fish/guestfish <<'EOF'
|
||||
scratch 100M
|
||||
run
|
||||
# Kill the subprocess.
|
||||
kill-subprocess
|
||||
|
||||
@@ -35,9 +35,7 @@ kill-subprocess
|
||||
-sleep 1
|
||||
|
||||
# We should now be able to rerun the subprocess.
|
||||
add test1.img
|
||||
scratch 100M
|
||||
run
|
||||
ping-daemon
|
||||
EOF
|
||||
|
||||
rm -f test1.img
|
||||
|
||||
@@ -20,10 +20,8 @@
|
||||
|
||||
set -e
|
||||
|
||||
rm -f test.img
|
||||
|
||||
../../fish/guestfish <<'EOF'
|
||||
alloc test.img 10M
|
||||
scratch 100M
|
||||
|
||||
append "root=/dev/null"
|
||||
-run
|
||||
@@ -33,5 +31,3 @@ append ""
|
||||
run
|
||||
ping-daemon
|
||||
EOF
|
||||
|
||||
rm -f test.img
|
||||
|
||||
@@ -25,19 +25,21 @@ if [ "$(../../fish/guestfish get-backend)" != "direct" ]; then
|
||||
exit 77
|
||||
fi
|
||||
|
||||
rm -f test.pid test1.img
|
||||
rm -f qemudie-midcommand.pid
|
||||
|
||||
../../fish/guestfish -N disk <<'EOF'
|
||||
../../fish/guestfish <<'EOF'
|
||||
scratch 100M
|
||||
run
|
||||
# Kill the subprocess after a short wait.
|
||||
pid | cat > test.pid
|
||||
! sleep 2 ; kill $(cat test.pid) &
|
||||
pid | cat > qemudie-midcommand.pid
|
||||
! sleep 2 ; kill $(cat qemudie-midcommand.pid) &
|
||||
|
||||
-sleep 1000
|
||||
|
||||
# We should now be able to rerun the subprocess.
|
||||
add test1.img
|
||||
scratch 100M
|
||||
run
|
||||
ping-daemon
|
||||
EOF
|
||||
|
||||
rm -f test.pid test1.img
|
||||
rm qemudie-midcommand.pid
|
||||
|
||||
@@ -25,20 +25,22 @@ if [ "$(../../fish/guestfish get-backend)" != "direct" ]; then
|
||||
exit 77
|
||||
fi
|
||||
|
||||
rm -f test.pid test1.img
|
||||
rm -f qemudie-synch.pid
|
||||
|
||||
../../fish/guestfish -N disk <<'EOF'
|
||||
../../fish/guestfish <<'EOF'
|
||||
scratch 100M
|
||||
run
|
||||
# Kill subprocess.
|
||||
pid | cat > test.pid
|
||||
! kill $(cat test.pid) ; sleep 2
|
||||
pid | cat > qemudie-synch.pid
|
||||
! kill $(cat qemudie-synch.pid) ; sleep 2
|
||||
|
||||
# XXX The following sleep should NOT be necessary.
|
||||
-sleep 1
|
||||
|
||||
# We should now be able to rerun the subprocess.
|
||||
add test1.img
|
||||
scratch 100M
|
||||
run
|
||||
ping-daemon
|
||||
EOF
|
||||
|
||||
rm -f test.pid test1.img
|
||||
rm qemudie-synch.pid
|
||||
|
||||
@@ -22,13 +22,13 @@
|
||||
|
||||
set -e
|
||||
|
||||
rm -f test1.img
|
||||
rm -f liveness1.img
|
||||
|
||||
../../fish/guestfish sparse test1.img 100M
|
||||
test1_md5sum="$(md5sum test1.img | awk '{print $1}')"
|
||||
../../fish/guestfish sparse liveness1.img 100M
|
||||
liveness1_md5sum="$(md5sum liveness1.img | awk '{print $1}')"
|
||||
|
||||
../../fish/guestfish <<'EOF'
|
||||
add test1.img format:raw
|
||||
add liveness1.img format:raw
|
||||
run
|
||||
|
||||
part-disk /dev/sda mbr
|
||||
@@ -41,7 +41,7 @@ write /test "This is a test"
|
||||
EOF
|
||||
|
||||
# Verify that the disk has changed.
|
||||
if [ "$(md5sum test1.img | awk '{print $1}')" = "$test1_md5sum" ]; then
|
||||
if [ "$(md5sum liveness1.img | awk '{print $1}')" = "$liveness1_md5sum" ]; then
|
||||
echo "***** ERROR *****"
|
||||
echo "Write operations are not modifying an attached disk."
|
||||
echo
|
||||
@@ -49,4 +49,4 @@ if [ "$(md5sum test1.img | awk '{print $1}')" = "$test1_md5sum" ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
rm test1.img
|
||||
rm liveness1.img
|
||||
|
||||
@@ -22,21 +22,21 @@
|
||||
|
||||
set -e
|
||||
|
||||
rm -f test1.img test2.img test3.img
|
||||
rm -f isolation1.img isolation2.img isolation3.img
|
||||
|
||||
../../fish/guestfish sparse test1.img 100M
|
||||
test1_md5sum="$(md5sum test1.img | awk '{print $1}')"
|
||||
../../fish/guestfish sparse test2.img 100M
|
||||
test2_md5sum="$(md5sum test2.img | awk '{print $1}')"
|
||||
qemu-img create -f qcow2 test3.img 100M
|
||||
test3_md5sum="$(md5sum test3.img | awk '{print $1}')"
|
||||
../../fish/guestfish sparse isolation1.img 100M
|
||||
isolation1_md5sum="$(md5sum isolation1.img | awk '{print $1}')"
|
||||
../../fish/guestfish sparse isolation2.img 100M
|
||||
isolation2_md5sum="$(md5sum isolation2.img | awk '{print $1}')"
|
||||
qemu-img create -f qcow2 isolation3.img 100M
|
||||
isolation3_md5sum="$(md5sum isolation3.img | awk '{print $1}')"
|
||||
|
||||
# The vitally important calls are 'add-drive-ro' and
|
||||
# 'add-drive-opts ... readonly:true'.
|
||||
../../fish/guestfish <<'EOF'
|
||||
add-drive-ro test1.img
|
||||
add-drive-opts test2.img format:raw readonly:true
|
||||
add-drive-opts test3.img format:qcow2 readonly:true
|
||||
add-drive-ro isolation1.img
|
||||
add-drive-opts isolation2.img format:raw readonly:true
|
||||
add-drive-opts isolation3.img format:qcow2 readonly:true
|
||||
run
|
||||
|
||||
part-disk /dev/sda mbr
|
||||
@@ -78,14 +78,14 @@ function serious_error
|
||||
exit 1
|
||||
}
|
||||
|
||||
if [ "$(md5sum test1.img | awk '{print $1}')" != "$test1_md5sum" ]; then
|
||||
if [ "$(md5sum isolation1.img | awk '{print $1}')" != "$isolation1_md5sum" ]; then
|
||||
serious_error
|
||||
fi
|
||||
if [ "$(md5sum test2.img | awk '{print $1}')" != "$test2_md5sum" ]; then
|
||||
if [ "$(md5sum isolation2.img | awk '{print $1}')" != "$isolation2_md5sum" ]; then
|
||||
serious_error
|
||||
fi
|
||||
if [ "$(md5sum test3.img | awk '{print $1}')" != "$test3_md5sum" ]; then
|
||||
if [ "$(md5sum isolation3.img | awk '{print $1}')" != "$isolation3_md5sum" ]; then
|
||||
serious_error
|
||||
fi
|
||||
|
||||
rm test1.img test2.img test3.img
|
||||
rm isolation1.img isolation2.img isolation3.img
|
||||
|
||||
@@ -26,12 +26,10 @@
|
||||
|
||||
set -e
|
||||
|
||||
rm -f test1.img
|
||||
|
||||
../../fish/guestfish -N fs -m /dev/sda1 <<EOF
|
||||
../../fish/guestfish -N rhbz503169c13.img=fs -m /dev/sda1 <<EOF
|
||||
mkdir /dev
|
||||
-command /ignore-this-error
|
||||
unmount-all
|
||||
EOF
|
||||
|
||||
rm test1.img
|
||||
rm rhbz503169c13.img
|
||||
|
||||
@@ -21,10 +21,10 @@
|
||||
# "guestfish number parsing should not use atoi, should support '0...' for octal and '0x...' for hexadecimal"
|
||||
|
||||
set -e
|
||||
rm -f test.out test.err
|
||||
rm -f rhbz557655.out rhbz557655.err
|
||||
export LANG=C
|
||||
|
||||
../../fish/guestfish >> test.out 2>> test.err <<EOF
|
||||
../../fish/guestfish >> rhbz557655.out 2>> rhbz557655.err <<EOF
|
||||
# set-memsize is just a convenient non-daemon function that
|
||||
# takes a single integer argument.
|
||||
set-memsize 0
|
||||
@@ -48,7 +48,7 @@ get-memsize
|
||||
-set-memsize 123L
|
||||
EOF
|
||||
|
||||
../../fish/guestfish -N fs -m /dev/sda1 >> test.out 2>> test.err <<EOF
|
||||
../../fish/guestfish -N rhbz557655.img=fs -m /dev/sda1 >> rhbz557655.out 2>> rhbz557655.err <<EOF
|
||||
touch /test
|
||||
|
||||
# truncate-size takes an Int64 argument
|
||||
@@ -72,15 +72,15 @@ filesize /test
|
||||
EOF
|
||||
|
||||
# If we are running with debugging enabled (or even if not), then
|
||||
# other messages and warnings can end up in the test.err (stderr) log.
|
||||
# Thus filter out only lines we expect. 'proc 200' is the procedure
|
||||
# number of truncate_size.
|
||||
mv test.err test.err~
|
||||
grep -E 'set[-_]memsize|truncate[-_]size' test.err~ |
|
||||
# other messages and warnings can end up in the rhbz557655.err
|
||||
# (stderr) log. Thus filter out only lines we expect. 'proc 200' is
|
||||
# the procedure number of truncate_size.
|
||||
mv rhbz557655.err rhbz557655.err~
|
||||
grep -E 'set[-_]memsize|truncate[-_]size' rhbz557655.err~ |
|
||||
grep -Ev 'libguestfs: trace:' |
|
||||
grep -Ev 'proc 200' > test.err
|
||||
rm test.err~
|
||||
grep -Ev 'proc 200' > rhbz557655.err
|
||||
rm rhbz557655.err~
|
||||
|
||||
diff -u $srcdir/rhbz557655-expected.stdout test.out
|
||||
diff -u $srcdir/rhbz557655-expected.stderr test.err
|
||||
rm test.out test.err test1.img
|
||||
diff -u $srcdir/rhbz557655-expected.stdout rhbz557655.out
|
||||
diff -u $srcdir/rhbz557655-expected.stderr rhbz557655.err
|
||||
rm rhbz557655.out rhbz557655.err rhbz557655.img
|
||||
|
||||
@@ -22,12 +22,10 @@
|
||||
|
||||
set -e
|
||||
|
||||
rm -f test1.img
|
||||
|
||||
../../fish/guestfish -N disk <<EOF
|
||||
../../fish/guestfish <<EOF
|
||||
scratch 100M
|
||||
run
|
||||
-upload $srcdir/rhbz576879.sh /test.sh
|
||||
# Shouldn't lose synchronization, so next command should work:
|
||||
ping-daemon
|
||||
EOF
|
||||
|
||||
rm -f test1.img
|
||||
|
||||
@@ -23,22 +23,22 @@
|
||||
set -e
|
||||
export LANG=C
|
||||
|
||||
rm -f test.img test.tar
|
||||
rm -f rhbz580246.img rhbz580246.tar
|
||||
|
||||
dd if=/dev/zero of=test.img bs=1M count=2
|
||||
tar cf test.tar test.img
|
||||
dd if=/dev/zero of=rhbz580246.img bs=1M count=2
|
||||
tar cf rhbz580246.tar rhbz580246.img
|
||||
|
||||
output=$(
|
||||
../../fish/guestfish 2>&1 <<'EOF'
|
||||
add test.img
|
||||
add rhbz580246.img
|
||||
run
|
||||
mkfs ext2 /dev/sda
|
||||
mount /dev/sda /
|
||||
-tar-in test.tar /
|
||||
-tar-in rhbz580246.tar /
|
||||
EOF
|
||||
)
|
||||
|
||||
rm -f test.img test.tar
|
||||
rm -f rhbz580246.img rhbz580246.tar
|
||||
|
||||
# Check for error message in the output.
|
||||
if [[ ! $output =~ libguestfs:.error:.tar_in ]]; then
|
||||
|
||||
@@ -24,10 +24,10 @@ export LANG=C
|
||||
|
||||
guestfish=../../fish/guestfish
|
||||
|
||||
rm -f test.img test.output
|
||||
rm -f test.output
|
||||
|
||||
$guestfish > test.output <<EOF
|
||||
sparse test.img 100M
|
||||
scratch 100M
|
||||
run
|
||||
part-init /dev/sda mbr
|
||||
# Create an unordered layout.
|
||||
@@ -49,7 +49,7 @@ false" ]; then
|
||||
fi
|
||||
|
||||
$guestfish > test.output <<EOF
|
||||
sparse test.img 100M
|
||||
scratch 100M
|
||||
run
|
||||
part-init /dev/sda mbr
|
||||
part-add /dev/sda p 1 1000
|
||||
@@ -68,4 +68,4 @@ if [ "$(cat test.output)" != "false" ]; then
|
||||
exit 1
|
||||
fi
|
||||
|
||||
rm -f test.img test.output
|
||||
rm test.output
|
||||
|
||||
@@ -34,15 +34,15 @@ if [[ "$backend" =~ ^libvirt ]]; then
|
||||
exit 77
|
||||
fi
|
||||
|
||||
rm -f test.img
|
||||
rm -f rhbz690819.img
|
||||
|
||||
../../fish/guestfish sparse test.img 100M
|
||||
../../fish/guestfish sparse rhbz690819.img 100M
|
||||
|
||||
../../fish/guestfish <<EOF
|
||||
add-drive-with-if test.img ide
|
||||
add-drive-with-if rhbz690819.img ide
|
||||
run
|
||||
mkfs ext3 /dev/sda
|
||||
mount /dev/sda /
|
||||
EOF
|
||||
|
||||
rm -f test.img
|
||||
rm rhbz690819.img
|
||||
|
||||
@@ -34,16 +34,16 @@ filenames[7]='http:'
|
||||
filenames[8]='file:'
|
||||
filenames[9]='raw:'
|
||||
|
||||
rm -f -- test1.img "${filenames[@]}"
|
||||
rm -f -- rhbz811649.img "${filenames[@]}"
|
||||
|
||||
../../fish/guestfish sparse test1.img 10M
|
||||
../../fish/guestfish sparse rhbz811649.img 10M
|
||||
|
||||
for f in "${filenames[@]}"; do
|
||||
ln -- test1.img "$f"
|
||||
ln -- rhbz811649.img "$f"
|
||||
../../fish/guestfish <<EOF
|
||||
add "$f"
|
||||
run
|
||||
EOF
|
||||
done
|
||||
|
||||
rm -f -- test1.img "${filenames[@]}"
|
||||
rm -- rhbz811649.img "${filenames[@]}"
|
||||
|
||||
@@ -24,7 +24,8 @@ set -e
|
||||
export LANG=C
|
||||
|
||||
output=$(
|
||||
../../fish/guestfish -N fs -m /dev/sda1 <<EOF | sort -k 3
|
||||
../../fish/guestfish -N rhbz895904.img=fs \
|
||||
-m /dev/sda1 <<EOF | sort -k 3
|
||||
mkdir /test
|
||||
touch /test/file1
|
||||
mkdir /test/subdir
|
||||
@@ -40,4 +41,4 @@ if [ "$output" != "4294967295 0 ./file1
|
||||
exit 1
|
||||
fi
|
||||
|
||||
rm test1.img
|
||||
rm rhbz895904.img
|
||||
|
||||
@@ -23,11 +23,11 @@
|
||||
set -e
|
||||
export LANG=C
|
||||
|
||||
../../fish/guestfish -N fs -m /dev/sda1 <<EOF
|
||||
../../fish/guestfish -N rhbz957772.img=fs -m /dev/sda1 <<EOF
|
||||
mkdir "/test 1"
|
||||
touch "/test 2"
|
||||
tar-out "/test 1" /dev/null
|
||||
base64-out "/test 2" /dev/null
|
||||
EOF
|
||||
|
||||
rm test1.img
|
||||
rm rhbz957772.img
|
||||
|
||||
@@ -34,7 +34,7 @@ if [[ "$backend" =~ ^libvirt ]]; then
|
||||
exit 77
|
||||
fi
|
||||
|
||||
rm -f test1.img test2.img test3.img
|
||||
rm -f rhbz975797-*.img
|
||||
|
||||
# The timeout utility was not available in RHEL 5.
|
||||
if timeout --help >/dev/null 2>&1; then
|
||||
@@ -43,15 +43,15 @@ fi
|
||||
|
||||
# Use real disk images here since the code for adding /dev/null may
|
||||
# take shortcuts.
|
||||
truncate -s 1G test1.img
|
||||
truncate -s 1G test2.img
|
||||
truncate -s 1G test3.img
|
||||
truncate -s 1G rhbz975797-1.img
|
||||
truncate -s 1G rhbz975797-2.img
|
||||
truncate -s 1G rhbz975797-3.img
|
||||
|
||||
$timeout ../../fish/guestfish <<EOF
|
||||
add-drive test1.img iface:virtio
|
||||
add-drive test2.img iface:ide
|
||||
add-drive test3.img
|
||||
add-drive rhbz975797-1.img iface:virtio
|
||||
add-drive rhbz975797-2.img iface:ide
|
||||
add-drive rhbz975797-3.img
|
||||
run
|
||||
EOF
|
||||
|
||||
rm test1.img test2.img test3.img
|
||||
rm rhbz975797-*.img
|
||||
|
||||
@@ -81,7 +81,7 @@ trap cleanup INT TERM QUIT EXIT
|
||||
ip=169.254.2.2
|
||||
user="$(id -un)"
|
||||
|
||||
$guestfish --network -N fs -m /dev/sda1 <<EOF
|
||||
$guestfish --network -N test-rsync.img=fs -m /dev/sda1 <<EOF
|
||||
mkdir /dir1
|
||||
rsync-in "rsync://$user@$ip:$port/src/" /dir1/ archive:true
|
||||
mkdir /dir2
|
||||
@@ -102,5 +102,5 @@ if [ ! -f tmp/100kallnewlines ] || \
|
||||
fi
|
||||
|
||||
rm -r tmp
|
||||
rm test1.img
|
||||
rm test-rsync.img
|
||||
rm rsyncd.conf
|
||||
|
||||
@@ -18,6 +18,8 @@
|
||||
use strict;
|
||||
use warnings;
|
||||
|
||||
use File::Temp qw/tempdir/;
|
||||
|
||||
use Sys::Guestfs;
|
||||
|
||||
# These are two SELinux labels that we assume everyone is allowed to
|
||||
@@ -130,14 +132,14 @@ if ($test_via eq "direct") {
|
||||
}
|
||||
} else {
|
||||
# Make a local mountpoint and mount it.
|
||||
mkdir "mp" or die "mkdir: mp: $!";
|
||||
$g->mount_local ("mp");
|
||||
my $mpdir = tempdir (CLEANUP => 1);
|
||||
$g->mount_local ($mpdir);
|
||||
|
||||
# Run the test in another process.
|
||||
my $pid = fork ();
|
||||
die "fork: $!" unless defined $pid;
|
||||
if ($pid == 0) {
|
||||
exec ("$srcdir/run-test.pl", "--test", "mp", $test_type);
|
||||
exec ("$srcdir/run-test.pl", "--test", $mpdir, $test_type);
|
||||
die "run-test.pl: exec failed: $!\n";
|
||||
}
|
||||
|
||||
@@ -145,8 +147,6 @@ if ($test_via eq "direct") {
|
||||
|
||||
waitpid ($pid, 0);
|
||||
$errors++ if $?;
|
||||
|
||||
rmdir "mp" or die "rmdir: mp: $!";
|
||||
}
|
||||
|
||||
# Finish up.
|
||||
|
||||
@@ -16,6 +16,4 @@
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
rm -rf test.img mp
|
||||
|
||||
exec $srcdir/run-test.pl selinux direct
|
||||
|
||||
@@ -16,6 +16,4 @@
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
rm -rf test.img mp
|
||||
|
||||
exec $srcdir/run-test.pl selinux fuse
|
||||
|
||||
@@ -16,6 +16,4 @@
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
rm -rf test.img mp
|
||||
|
||||
exec $srcdir/run-test.pl xattrs direct
|
||||
|
||||
@@ -16,6 +16,4 @@
|
||||
# along with this program; if not, write to the Free Software
|
||||
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
|
||||
rm -rf test.img mp
|
||||
|
||||
exec $srcdir/run-test.pl xattrs fuse
|
||||
|
||||
Reference in New Issue
Block a user