summaryrefslogtreecommitdiffstats
path: root/kernel/networking/libvirt/common
diff options
context:
space:
mode:
authorBill Peck <bpeck@redhat.com>2013-01-28 15:44:28 -0500
committerBill Peck <bpeck@redhat.com>2013-01-28 15:44:28 -0500
commit62ac6acc5e2f44f0fa56547bd7167d3d38a10be5 (patch)
tree37dada403720609951149f034a834bdbdfb858c3 /kernel/networking/libvirt/common
parent6ef978fcfe34ff90bca11a7486e7f517f785388d (diff)
Update libvirt ping and netperf commands to use ../common/autologin.exp
Diffstat (limited to 'kernel/networking/libvirt/common')
-rw-r--r--kernel/networking/libvirt/common/Makefile50
-rwxr-xr-xkernel/networking/libvirt/common/autologin.exp43
2 files changed, 93 insertions, 0 deletions
diff --git a/kernel/networking/libvirt/common/Makefile b/kernel/networking/libvirt/common/Makefile
new file mode 100644
index 0000000..329564f
--- /dev/null
+++ b/kernel/networking/libvirt/common/Makefile
@@ -0,0 +1,50 @@
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+#
+# Makefile of /kernel/networking/libvirt/common
+# Description: common code for libvirt functions
+# Author: Bill Peck <bpeck@redhat.com>
+#
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+#
+# Copyright (c) 2012 Red Hat, Inc. All rights reserved.
+#
+# This copyrighted material is made available to anyone wishing
+# to use, modify, copy, or redistribute it subject to the terms
+# and conditions of the GNU General Public License version 2.
+#
+# 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.
+#
+# ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+BUILT_FILES=
+
+FILES=$(METADATA) runtest.sh Makefile PURPOSE
+
+.PHONY: all install run download clean
+
+build: $(BUILT_FILES)
+ test -x autologin.exp || chmod a+x autologin.exp
+
+run: build
+
+clean:
+ rm -f *~ $(BUILT_FILES)
+
+
+include /usr/share/rhts/lib/rhts-make.include
+
+$(METADATA): Makefile
+ @echo "Owner: Bill Peck <bpeck@redhat.com>" > $(METADATA)
+ @echo "TestTime: 10m" >> $(METADATA)
+ @echo "License: GPLv2" >> $(METADATA)
+ @echo "Confidential: no" >> $(METADATA)
+ @echo "Destructive: no" >> $(METADATA)
+ @echo "Requires: expect" >> $(METADATA)
diff --git a/kernel/networking/libvirt/common/autologin.exp b/kernel/networking/libvirt/common/autologin.exp
new file mode 100755
index 0000000..609afc6
--- /dev/null
+++ b/kernel/networking/libvirt/common/autologin.exp
@@ -0,0 +1,43 @@
+#!/usr/bin/expect -f
+
+set login "root"
+set password "redhat"
+
+set timeout -1
+set guest [lindex $argv 0]
+set prompt "$login@.*\](%|#|\\\$) $"
+
+spawn virsh console $guest
+
+#login if needed
+expect "Escape character is"
+send "\r"
+expect {
+ {login:} { send "$login\r"
+ expect {
+ {Password:} { send "$password\r" }
+ }
+ }
+ -re $prompt { send "\r"}
+ }
+
+expect -re $prompt
+
+#run command
+for {set i 1} {$i < $argc} {incr i 1} {
+ set cmd [lindex $argv $i]
+ send "$cmd\r"
+ expect -re $prompt
+ sleep 1
+}
+
+#capture return code from last command
+send "echo \$?\r"
+expect -re "(\\d+)" {
+ set result $expect_out(1,string)
+}
+
+#logout
+send "exit\r"
+expect "logout"
+exit $result