This commit introduce the virsh-rename test script to test the 'domrename'
command. The test contains one succedeed script to rename and another failed
test.
Signed-off-by: Julio Faracco <jcfaracco(a)gmail.com>
---
tests/Makefile.am | 1 +
tests/virsh-rename | 43 +++++++++++++++++++++++++++++++++++++++++++
2 files changed, 44 insertions(+)
create mode 100755 tests/virsh-rename
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 3441dab..0ff90fb 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -410,6 +410,7 @@ libvirtd_test_scripts = \
virt-admin-self-test \
virsh-start \
virsh-undefine \
+ virsh-rename \
virsh-uriprecedence \
virsh-vcpupin \
$(NULL)
diff --git a/tests/virsh-rename b/tests/virsh-rename
new file mode 100755
index 0000000..4d976bb
--- /dev/null
+++ b/tests/virsh-rename
@@ -0,0 +1,43 @@
+#!/bin/sh
+# exercise virsh's "domrename" command
+
+# Copyright (C) 2008-2009, 2017 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 WITHEXP 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, see
+# <
http://www.gnu.org/licenses/>.
+
+. "$(dirname $0)/test-lib.sh"
+
+if test "$VERBOSE" = yes; then
+ set -x
+ $abs_top_builddir/tools/virsh --version
+fi
+
+fail=0
+
+# Succeed, now: first shut down, then rename the domain.
+$abs_top_builddir/tools/virsh -q -c test:///default \
+ 'shutdown test; domrename test anothertest' > out 2>&1
+test $? = 1 && fail=1
+
+# Failed, now: rename the domain without shutting down.
+$abs_top_builddir/tools/virsh -q -c test:///default \
+ 'domrename test anothertest' > out 2>&1
+test $? = 1 || fail=1
+cat <<\EOF > expout || fail=1
+error: Requested operation is not valid: cannot rename active domain
+EOF
+compare expout out || fail=1
+
+(exit $fail); exit $fail
--
2.7.4