diff options
author | Richard W.M. Jones <rjones@redhat.com> | 2011-05-06 17:42:07 -0400 |
---|---|---|
committer | Richard W.M. Jones <rjones@redhat.com> | 2011-05-09 14:23:08 +0100 |
commit | 2b5fbc882a0a79646b668c7b95442f0b3673d63a (patch) | |
tree | eb1c1c18be1ecfecd37e62d7a16b374d6f1f7db5 /edit/test-virt-edit.sh | |
parent | 5ce759bfdc70c97121ef34ab4d5c918d568f2474 (diff) | |
download | libguestfs-2b5fbc882a0a79646b668c7b95442f0b3673d63a.tar.gz libguestfs-2b5fbc882a0a79646b668c7b95442f0b3673d63a.tar.xz libguestfs-2b5fbc882a0a79646b668c7b95442f0b3673d63a.zip |
Rewrite virt-edit in C.
Diffstat (limited to 'edit/test-virt-edit.sh')
-rwxr-xr-x | edit/test-virt-edit.sh | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/edit/test-virt-edit.sh b/edit/test-virt-edit.sh new file mode 100755 index 00000000..d43851b5 --- /dev/null +++ b/edit/test-virt-edit.sh @@ -0,0 +1,42 @@ +#!/bin/bash - + +export LANG=C +set -e + +# Make a copy of the Fedora image so we can write to it then +# discard it. +cp ../images/fedora.img test.img + +# Edit interactively. We have to simulate this by setting $EDITOR. +# The command will be: echo newline >> /tmp/file +export EDITOR='echo newline >>' +./virt-edit -a test.img /etc/test3 +if [ "$(../cat/virt-cat -a test.img /etc/test3)" != "a +b +c +d +e +f +newline" ]; then + echo "$0: error: mismatch in interactive editing of file /etc/test3" + exit 1 +fi +unset EDITOR + +# Edit non-interactively, only if we have 'perl' binary. +if perl --version >/dev/null 2>&1; then + ./virt-edit -a test.img /etc/test3 -e 's/^[a-f]/$lineno/' + if [ "$(../cat/virt-cat -a test.img /etc/test3)" != "1 +2 +3 +4 +5 +6 +newline" ]; then + echo "$0: error: mismatch in non-interactive editing of file /etc/test3" + exit 1 + fi +fi + +# Discard test image. +rm test.img |