From 5394fab35408818bd71cf86df1f2353f1e193ff4 Mon Sep 17 00:00:00 2001 From: "Richard W.M. Jones" Date: Mon, 12 Mar 2012 15:09:15 +0000 Subject: fish: Rename tests and make test paths relative. When these tests were originally in the old regressions/ directory, they used to refer to guestfish via the path '../fish/guestfish'. Some of the tests were also called 'test-guestfish-*'. Now that the tests have been moved into the fish/ directory, neither of these things make sense. So change the relative path to './guestfish' and rename all 'test-guestfish-*' as 'test-*'. (cherry picked from commit 1f603bfd6d7cd17e88f737a496b7e5ee053750c2) --- fish/Makefile.am | 20 +++++----- fish/test-a.sh | 45 ++++++++++++++++++++++ fish/test-add-domain.sh | 6 +-- fish/test-copy.sh | 4 +- fish/test-d.sh | 73 +++++++++++++++++++++++++++++++++++ fish/test-edit.sh | 2 +- fish/test-escapes.sh | 87 ++++++++++++++++++++++++++++++++++++++++++ fish/test-events.sh | 82 +++++++++++++++++++++++++++++++++++++++ fish/test-find0.sh | 2 +- fish/test-guestfish-a.sh | 45 ---------------------- fish/test-guestfish-d.sh | 73 ----------------------------------- fish/test-guestfish-escapes.sh | 87 ------------------------------------------ fish/test-guestfish-events.sh | 82 --------------------------------------- fish/test-guestfish-tilde.sh | 70 --------------------------------- fish/test-read_file.sh | 4 +- fish/test-remote.sh | 16 ++++---- fish/test-reopen.sh | 2 +- fish/test-stringlist.sh | 10 ++--- fish/test-tilde.sh | 70 +++++++++++++++++++++++++++++++++ fish/test-upload-to-dir.sh | 2 +- 20 files changed, 391 insertions(+), 391 deletions(-) create mode 100755 fish/test-a.sh create mode 100755 fish/test-d.sh create mode 100755 fish/test-escapes.sh create mode 100755 fish/test-events.sh delete mode 100755 fish/test-guestfish-a.sh delete mode 100755 fish/test-guestfish-d.sh delete mode 100755 fish/test-guestfish-escapes.sh delete mode 100755 fish/test-guestfish-events.sh delete mode 100755 fish/test-guestfish-tilde.sh create mode 100755 fish/test-tilde.sh diff --git a/fish/Makefile.am b/fish/Makefile.am index 07784547..23dafd3a 100644 --- a/fish/Makefile.am +++ b/fish/Makefile.am @@ -236,12 +236,12 @@ TESTS_ENVIRONMENT = \ $(top_builddir)/run TESTS = \ + test-a.sh \ test-add-domain.sh \ - test-guestfish-a.sh \ - test-guestfish-d.sh \ - test-guestfish-escapes.sh \ - test-guestfish-events.sh \ - test-guestfish-tilde.sh + test-d.sh \ + test-escapes.sh \ + test-events.sh \ + test-tilde.sh if ENABLE_APPLIANCE TESTS += \ @@ -256,17 +256,17 @@ TESTS += \ endif EXTRA_DIST += \ + test-a.sh \ test-add-domain.sh \ test-copy.sh \ + test-d.sh \ test-edit.sh \ + test-escapes.sh \ + test-events.sh \ test-find0.sh \ - test-guestfish-a.sh \ - test-guestfish-d.sh \ - test-guestfish-escapes.sh \ - test-guestfish-events.sh \ - test-guestfish-tilde.sh \ test-read_file.sh \ test-remote.sh \ test-reopen.sh \ test-stringlist.sh \ + test-tilde.sh \ test-upload-to-dir.sh diff --git a/fish/test-a.sh b/fish/test-a.sh new file mode 100755 index 00000000..20cc5cd8 --- /dev/null +++ b/fish/test-a.sh @@ -0,0 +1,45 @@ +#!/bin/bash - +# libguestfs +# Copyright (C) 2010 Red Hat Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +# Test guestfish -a option. + +set -e + +rm -f test.out + +./guestfish -x -a /dev/null test.out 2>&1 + +! grep -sq 'add_drive.*format' test.out + +./guestfish -x --format=qcow2 -a /dev/null test.out 2>&1 + +grep -sq 'add_drive.*format:qcow2' test.out + +./guestfish -x --ro --format=qcow2 -a /dev/null test.out 2>&1 + +grep -sq 'add_drive.*readonly:true.*format:qcow2' test.out + +./guestfish -x --format -a /dev/null test.out 2>&1 + +! grep -sq 'add_drive.*format' test.out + +./guestfish -x -a /dev/null --format=qcow2 test.out 2>&1 + +! grep -sq 'add_drive.*format' test.out + +rm -f test.out diff --git a/fish/test-add-domain.sh b/fish/test-add-domain.sh index 6154a758..85937088 100755 --- a/fish/test-add-domain.sh +++ b/fish/test-add-domain.sh @@ -62,7 +62,7 @@ cat > test.xml < EOF -../fish/guestfish >test.out <test.out <test.out <test.out <test.out <test.out < test.xml < + + guest + + hvm + + + 524288 + + + + + + + + + + + + + + + + + + + + + + + + +EOF + +./guestfish -c "test://$cwd/test.xml" --ro -d guest \ + debug-drives test.out +grep -sq "test1.img.*snapshot=on" test.out +! grep -sq "test1.img.*format" test.out +grep -sq "test2.img.*snapshot=on.*format=raw" test.out +grep -sq "test3.img.*snapshot=on.*format=qcow2" test.out +grep -sq "test4.img.*snapshot=on.*format=raw" test.out + +rm -f test1.img test2.img test3.img test4.img test.xml test.out diff --git a/fish/test-edit.sh b/fish/test-edit.sh index 93b2e908..a077ada6 100755 --- a/fish/test-edit.sh +++ b/fish/test-edit.sh @@ -34,7 +34,7 @@ rm -f test1.img export EDITOR="echo second line of text >>" output=$( -../fish/guestfish -N fs -m /dev/sda1 <test.error | od > test.output +echo "" +echo " " +echo " " +echo "\n" +echo "\r" +echo "\n\n" +echo "\x01" +echo "\001" +echo "\100" + +# These are invalid: +-echo "\x00" +-echo "\000" +-echo "\x" +-echo "\x0" +-echo "\7" +-echo "\77" +-echo "\777" +-echo "\" +-echo "\\\" +-echo " +-echo """ +EOF + +# Since trace and debug output also goes to stderr, we must +# remove it before testing. +mv test.error test.error.old +< test.error.old \ + grep -v '^libguestfs: ' | \ + grep -vF "$HOME/.guestfish:" | \ + sed 's/.*guestfish: //' \ + > test.error + +if [ "$(cat test.error)" != "\ +invalid escape sequence in string (starting at offset 0) +invalid escape sequence in string (starting at offset 0) +invalid escape sequence in string (starting at offset 0) +invalid escape sequence in string (starting at offset 0) +invalid escape sequence in string (starting at offset 0) +invalid escape sequence in string (starting at offset 0) +invalid escape sequence in string (starting at offset 0) +unterminated double quote +unterminated double quote +unterminated double quote +command arguments not separated by whitespace" ]; then + echo "unexpected stderr from guestfish:" + cat test.error + echo "[end of stderr]" + exit 1 +fi + +if [ "$(cat test.output)" != "\ +0000000 020012 020012 005040 005012 005015 005012 000412 000412 +0000020 040012 000012 +0000023" ]; then + echo "unexpected stdout from guestfish:" + cat test.output + echo "[end of stdout]" + exit 1 +fi + +rm -f test.output test.error test.error.old diff --git a/fish/test-events.sh b/fish/test-events.sh new file mode 100755 index 00000000..76d3823f --- /dev/null +++ b/fish/test-events.sh @@ -0,0 +1,82 @@ +#!/bin/bash - +# libguestfs +# Copyright (C) 2011 Red Hat Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +# Test guestfish events. + +set -e + +rm -f test.out + +./guestfish -a /dev/null <<'EOF' | grep -v get_verbose | grep -v get_trace | grep -v 'library .*0x' > test.out +trace true + +event ev1 * "echo $EVENT $@" +event ev1 * "echo $EVENT $@" +event ev2 * "echo $EVENT $@" + +list-events +delete-event ev1 +list-events +reopen +list-events + +event ev1 close,subprocess_quit "echo $EVENT $@" +event ev2 close,subprocess_quit "echo $EVENT $@" +event ev3 launch "echo $EVENT $@" + +list-events +-delete-event ev4 +list-events +delete-event ev1 +list-events +delete-event ev3 +list-events + +EOF + +if [ "$(cat test.out)" != '"ev1" (0): *: echo $EVENT $@ +"ev1" (1): *: echo $EVENT $@ +"ev2" (2): *: echo $EVENT $@ +"ev2" (2): *: echo $EVENT $@ +enter get_autosync +trace get_autosync +trace get_autosync = 1 +enter get_path +trace get_path +trace get_path = "'$LIBGUESTFS_PATH'" +enter get_pgroup +trace get_pgroup +trace get_pgroup = 0 +trace close +close +"ev1" (0): close,subprocess_quit: echo $EVENT $@ +"ev2" (1): close,subprocess_quit: echo $EVENT $@ +"ev3" (2): launch_done: echo $EVENT $@ +"ev1" (0): close,subprocess_quit: echo $EVENT $@ +"ev2" (1): close,subprocess_quit: echo $EVENT $@ +"ev3" (2): launch_done: echo $EVENT $@ +"ev2" (1): close,subprocess_quit: echo $EVENT $@ +"ev3" (2): launch_done: echo $EVENT $@ +"ev2" (1): close,subprocess_quit: echo $EVENT $@ +close' ]; then + echo "$0: unexpected output from guestfish events" + cat test.out + exit 1 +fi + +rm test.out diff --git a/fish/test-find0.sh b/fish/test-find0.sh index 5fd31856..1fd638ee 100755 --- a/fish/test-find0.sh +++ b/fish/test-find0.sh @@ -22,7 +22,7 @@ set -e rm -f test.out -../fish/guestfish <<'EOF' +./guestfish <<'EOF' add-ro ../tests/data/test.iso run mount-ro /dev/sda / diff --git a/fish/test-guestfish-a.sh b/fish/test-guestfish-a.sh deleted file mode 100755 index 4fd45f73..00000000 --- a/fish/test-guestfish-a.sh +++ /dev/null @@ -1,45 +0,0 @@ -#!/bin/bash - -# libguestfs -# Copyright (C) 2010 Red Hat Inc. -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -# Test guestfish -a option. - -set -e - -rm -f test.out - -../fish/guestfish -x -a /dev/null test.out 2>&1 - -! grep -sq 'add_drive.*format' test.out - -../fish/guestfish -x --format=qcow2 -a /dev/null test.out 2>&1 - -grep -sq 'add_drive.*format:qcow2' test.out - -../fish/guestfish -x --ro --format=qcow2 -a /dev/null test.out 2>&1 - -grep -sq 'add_drive.*readonly:true.*format:qcow2' test.out - -../fish/guestfish -x --format -a /dev/null test.out 2>&1 - -! grep -sq 'add_drive.*format' test.out - -../fish/guestfish -x -a /dev/null --format=qcow2 test.out 2>&1 - -! grep -sq 'add_drive.*format' test.out - -rm -f test.out diff --git a/fish/test-guestfish-d.sh b/fish/test-guestfish-d.sh deleted file mode 100755 index 41f16094..00000000 --- a/fish/test-guestfish-d.sh +++ /dev/null @@ -1,73 +0,0 @@ -#!/bin/bash - -# libguestfs -# Copyright (C) 2010 Red Hat Inc. -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -# Test guestfish -d option. - -set -e - -rm -f test1.img test2.img test3.img test4.img test.xml test.out - -cwd="$(pwd)" - -truncate -s 1M test1.img test2.img test3.img test4.img - -# Libvirt test XML, see libvirt.git/examples/xml/test/testnode.xml -cat > test.xml < - - guest - - hvm - - - 524288 - - - - - - - - - - - - - - - - - - - - - - - - -EOF - -../fish/guestfish -c "test://$cwd/test.xml" --ro -d guest \ - debug-drives test.out -grep -sq "test1.img.*snapshot=on" test.out -! grep -sq "test1.img.*format" test.out -grep -sq "test2.img.*snapshot=on.*format=raw" test.out -grep -sq "test3.img.*snapshot=on.*format=qcow2" test.out -grep -sq "test4.img.*snapshot=on.*format=raw" test.out - -rm -f test1.img test2.img test3.img test4.img test.xml test.out diff --git a/fish/test-guestfish-escapes.sh b/fish/test-guestfish-escapes.sh deleted file mode 100755 index 3ab8a319..00000000 --- a/fish/test-guestfish-escapes.sh +++ /dev/null @@ -1,87 +0,0 @@ -#!/bin/bash - -# libguestfs -# Copyright (C) 2011 Red Hat Inc. -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -# Test guestfish string escapes. - -set -e - -rm -f test.output test.error test.error.old - -../fish/guestfish <<'EOF' 2>test.error | od > test.output -echo "" -echo " " -echo " " -echo "\n" -echo "\r" -echo "\n\n" -echo "\x01" -echo "\001" -echo "\100" - -# These are invalid: --echo "\x00" --echo "\000" --echo "\x" --echo "\x0" --echo "\7" --echo "\77" --echo "\777" --echo "\" --echo "\\\" --echo " --echo """ -EOF - -# Since trace and debug output also goes to stderr, we must -# remove it before testing. -mv test.error test.error.old -< test.error.old \ - grep -v '^libguestfs: ' | \ - grep -vF "$HOME/.guestfish:" | \ - sed 's/.*guestfish: //' \ - > test.error - -if [ "$(cat test.error)" != "\ -invalid escape sequence in string (starting at offset 0) -invalid escape sequence in string (starting at offset 0) -invalid escape sequence in string (starting at offset 0) -invalid escape sequence in string (starting at offset 0) -invalid escape sequence in string (starting at offset 0) -invalid escape sequence in string (starting at offset 0) -invalid escape sequence in string (starting at offset 0) -unterminated double quote -unterminated double quote -unterminated double quote -command arguments not separated by whitespace" ]; then - echo "unexpected stderr from guestfish:" - cat test.error - echo "[end of stderr]" - exit 1 -fi - -if [ "$(cat test.output)" != "\ -0000000 020012 020012 005040 005012 005015 005012 000412 000412 -0000020 040012 000012 -0000023" ]; then - echo "unexpected stdout from guestfish:" - cat test.output - echo "[end of stdout]" - exit 1 -fi - -rm -f test.output test.error test.error.old diff --git a/fish/test-guestfish-events.sh b/fish/test-guestfish-events.sh deleted file mode 100755 index d910c675..00000000 --- a/fish/test-guestfish-events.sh +++ /dev/null @@ -1,82 +0,0 @@ -#!/bin/bash - -# libguestfs -# Copyright (C) 2011 Red Hat Inc. -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -# Test guestfish events. - -set -e - -rm -f test.out - -../fish/guestfish -a /dev/null <<'EOF' | grep -v get_verbose | grep -v get_trace | grep -v 'library .*0x' > test.out -trace true - -event ev1 * "echo $EVENT $@" -event ev1 * "echo $EVENT $@" -event ev2 * "echo $EVENT $@" - -list-events -delete-event ev1 -list-events -reopen -list-events - -event ev1 close,subprocess_quit "echo $EVENT $@" -event ev2 close,subprocess_quit "echo $EVENT $@" -event ev3 launch "echo $EVENT $@" - -list-events --delete-event ev4 -list-events -delete-event ev1 -list-events -delete-event ev3 -list-events - -EOF - -if [ "$(cat test.out)" != '"ev1" (0): *: echo $EVENT $@ -"ev1" (1): *: echo $EVENT $@ -"ev2" (2): *: echo $EVENT $@ -"ev2" (2): *: echo $EVENT $@ -enter get_autosync -trace get_autosync -trace get_autosync = 1 -enter get_path -trace get_path -trace get_path = "'$LIBGUESTFS_PATH'" -enter get_pgroup -trace get_pgroup -trace get_pgroup = 0 -trace close -close -"ev1" (0): close,subprocess_quit: echo $EVENT $@ -"ev2" (1): close,subprocess_quit: echo $EVENT $@ -"ev3" (2): launch_done: echo $EVENT $@ -"ev1" (0): close,subprocess_quit: echo $EVENT $@ -"ev2" (1): close,subprocess_quit: echo $EVENT $@ -"ev3" (2): launch_done: echo $EVENT $@ -"ev2" (1): close,subprocess_quit: echo $EVENT $@ -"ev3" (2): launch_done: echo $EVENT $@ -"ev2" (1): close,subprocess_quit: echo $EVENT $@ -close' ]; then - echo "$0: unexpected output from guestfish events" - cat test.out - exit 1 -fi - -rm test.out diff --git a/fish/test-guestfish-tilde.sh b/fish/test-guestfish-tilde.sh deleted file mode 100755 index aed44311..00000000 --- a/fish/test-guestfish-tilde.sh +++ /dev/null @@ -1,70 +0,0 @@ -#!/bin/bash - -# libguestfs -# Copyright (C) 2011 Red Hat Inc. -# -# This program is free software; you can redistribute it and/or modify -# it under the terms of the GNU General Public License as published by -# the Free Software Foundation; either version 2 of the License, or -# (at your option) any later version. -# -# This program is distributed in the hope that it will be useful, -# but WITHOUT ANY WARRANTY; without even the implied warranty of -# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -# GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License -# along with this program; if not, write to the Free Software -# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. - -# Test guestfish tilde expansion. -# RHBZ#617440 guestfish: fails to tilde expand '~' when the $HOME env is unset -# RHBZ#511372 guestfish doesn't understand '~' in filenames -# and multiple other fixes to tilde handling. - -set -e - -# Don't rely on $HOME being set when this script is called. -HOME=$(pwd) -export HOME - -if [ `echo 'echo ~' | ../fish/guestfish` != "$HOME" ]; then - echo "$0: failed: did not expand ~ correctly" - exit 1 -fi - -if [ `echo 'echo ~/foo' | ../fish/guestfish` != "$HOME/foo" ]; then - echo "$0: failed: did not expand ~/foo correctly" - exit 1 -fi - -# We can be reasonably sure that the root user will always exist and -# should have a home directory. -root="$(echo ~root)" - -if [ `echo 'echo ~root' | ../fish/guestfish` != "$root" ]; then - echo "$0: failed: did not expand ~root correctly" - exit 1 -fi - -if [ `echo 'echo ~root/foo' | ../fish/guestfish` != "$root/foo" ]; then - echo "$0: failed: did not expand ~root/foo correctly" - exit 1 -fi - -# RHBZ#617440 -unset HOME -home="$(echo ~)" - -if [ `echo 'echo ~' | ../fish/guestfish` != "$home" ]; then - echo "$0: failed: did not expand ~ correctly when \$HOME unset" - exit 1 -fi - -if [ `echo 'echo ~/foo' | ../fish/guestfish` != "$home/foo" ]; then - echo "$0: failed: did not expand ~/foo correctly when \$HOME unset" - exit 1 -fi - -# Setting $HOME to pwd above causes guestfish to create a history -# file. Remove it. -rm -f .guestfish \ No newline at end of file diff --git a/fish/test-read_file.sh b/fish/test-read_file.sh index c6e41580..d0471333 100755 --- a/fish/test-read_file.sh +++ b/fish/test-read_file.sh @@ -22,7 +22,7 @@ set -e rm -f test.out -../fish/guestfish <<'EOF' > test.out +./guestfish <<'EOF' > test.out add-ro ../tests/data/test.iso run mount-ro /dev/sda / @@ -31,4 +31,4 @@ EOF cmp ../tests/data/helloworld.tar test.out -rm -f test.out \ No newline at end of file +rm -f test.out diff --git a/fish/test-remote.sh b/fish/test-remote.sh index ff5b85ad..a0010321 100755 --- a/fish/test-remote.sh +++ b/fish/test-remote.sh @@ -22,24 +22,24 @@ set -e rm -f test.img -eval `../fish/guestfish --listen` +eval `./guestfish --listen` -../fish/guestfish --remote alloc test.img 10M -../fish/guestfish --remote run -../fish/guestfish --remote part-disk /dev/sda mbr -../fish/guestfish --remote mkfs ext2 /dev/sda1 -../fish/guestfish --remote mount-options "" /dev/sda1 / +./guestfish --remote alloc test.img 10M +./guestfish --remote run +./guestfish --remote part-disk /dev/sda mbr +./guestfish --remote mkfs ext2 /dev/sda1 +./guestfish --remote mount-options "" /dev/sda1 / # Failure of the above commands will cause the guestfish listener to exit. # Incorrect return from echo_daemon will not, so need to ensure the listener # exits in any case, while still reporting an error. error=0 -echo=$(../fish/guestfish --remote echo_daemon "This is a test") +echo=$(./guestfish --remote echo_daemon "This is a test") if [ "$echo" != "This is a test" ]; then error=1; fi -../fish/guestfish --remote exit +./guestfish --remote exit rm -f test.img diff --git a/fish/test-reopen.sh b/fish/test-reopen.sh index 321f2a02..383fb077 100755 --- a/fish/test-reopen.sh +++ b/fish/test-reopen.sh @@ -23,7 +23,7 @@ set -e rm -f test.img -../fish/guestfish <<'EOF' +./guestfish <<'EOF' reopen reopen reopen diff --git a/fish/test-stringlist.sh b/fish/test-stringlist.sh index 1aa953bc..5928a810 100755 --- a/fish/test-stringlist.sh +++ b/fish/test-stringlist.sh @@ -22,7 +22,7 @@ set -e rm -f test.img -eval `../fish/guestfish --listen` +eval `./guestfish --listen` error=0 @@ -32,15 +32,15 @@ function check_echo { local echo - echo=$(../fish/guestfish --remote echo_daemon "$test") + echo=$(./guestfish --remote echo_daemon "$test") if [ "$echo" != "$expected" ]; then echo "Expected \"$expected\", got \"$echo\"" error=1 fi } -../fish/guestfish --remote alloc test.img 10M -../fish/guestfish --remote run +./guestfish --remote alloc test.img 10M +./guestfish --remote run check_echo "' '" " " check_echo "\'" "'" @@ -53,7 +53,7 @@ check_echo "'foo' 'bar'" "foo bar" check_echo "'foo' " "foo" check_echo " 'foo'" "foo" -../fish/guestfish --remote exit +./guestfish --remote exit rm -f test.img diff --git a/fish/test-tilde.sh b/fish/test-tilde.sh new file mode 100755 index 00000000..cf39d339 --- /dev/null +++ b/fish/test-tilde.sh @@ -0,0 +1,70 @@ +#!/bin/bash - +# libguestfs +# Copyright (C) 2011 Red Hat Inc. +# +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. + +# Test guestfish tilde expansion. +# RHBZ#617440 guestfish: fails to tilde expand '~' when the $HOME env is unset +# RHBZ#511372 guestfish doesn't understand '~' in filenames +# and multiple other fixes to tilde handling. + +set -e + +# Don't rely on $HOME being set when this script is called. +HOME=$(pwd) +export HOME + +if [ `echo 'echo ~' | ./guestfish` != "$HOME" ]; then + echo "$0: failed: did not expand ~ correctly" + exit 1 +fi + +if [ `echo 'echo ~/foo' | ./guestfish` != "$HOME/foo" ]; then + echo "$0: failed: did not expand ~/foo correctly" + exit 1 +fi + +# We can be reasonably sure that the root user will always exist and +# should have a home directory. +root="$(echo ~root)" + +if [ `echo 'echo ~root' | ./guestfish` != "$root" ]; then + echo "$0: failed: did not expand ~root correctly" + exit 1 +fi + +if [ `echo 'echo ~root/foo' | ./guestfish` != "$root/foo" ]; then + echo "$0: failed: did not expand ~root/foo correctly" + exit 1 +fi + +# RHBZ#617440 +unset HOME +home="$(echo ~)" + +if [ `echo 'echo ~' | ./guestfish` != "$home" ]; then + echo "$0: failed: did not expand ~ correctly when \$HOME unset" + exit 1 +fi + +if [ `echo 'echo ~/foo' | ./guestfish` != "$home/foo" ]; then + echo "$0: failed: did not expand ~/foo correctly when \$HOME unset" + exit 1 +fi + +# Setting $HOME to pwd above causes guestfish to create a history +# file. Remove it. +rm -f .guestfish diff --git a/fish/test-upload-to-dir.sh b/fish/test-upload-to-dir.sh index 1ef24a01..99aaad6b 100755 --- a/fish/test-upload-to-dir.sh +++ b/fish/test-upload-to-dir.sh @@ -24,7 +24,7 @@ set -e rm -f test1.img test.out -if ../fish/guestfish -N fs -m /dev/sda1 upload ../tests/data/test.iso / 2>test.out +if ./guestfish -N fs -m /dev/sda1 upload ../tests/data/test.iso / 2>test.out then echo "$0: expecting guestfish to return an error" exit 1 -- cgit