From c4d03d9b99ee4f8c464b46c90101510681bc5c0e Mon Sep 17 00:00:00 2001 From: pcarrier Date: Sat, 27 Nov 2010 23:33:41 +0000 Subject: [tests] Replaced old expect scripts with pexpect git-svn-id: svn+ssh://svn.fedorahosted.org/svn/sos/trunk@1048 ef72aa8b-4018-0410-8976-d6e080ef94d8 --- tests/sosreport_pexpect.py | 28 ++++++++++++++++++++++++++++ testsuite/Makefile | 13 ------------- testsuite/config/unix.exp | 0 testsuite/site.exp | 3 --- testsuite/sos.test/batchmode.exp | 6 ------ testsuite/sos.test/plugin_install.exp | 7 ------- 6 files changed, 28 insertions(+), 29 deletions(-) create mode 100644 tests/sosreport_pexpect.py delete mode 100644 testsuite/Makefile delete mode 100644 testsuite/config/unix.exp delete mode 100644 testsuite/site.exp delete mode 100644 testsuite/sos.test/batchmode.exp delete mode 100644 testsuite/sos.test/plugin_install.exp diff --git a/tests/sosreport_pexpect.py b/tests/sosreport_pexpect.py new file mode 100644 index 00000000..164fa9c8 --- /dev/null +++ b/tests/sosreport_pexpect.py @@ -0,0 +1,28 @@ +#!/usr/bin/env python + +import unittest +import pexpect + +from re import search, escape +from os import kill +from signal import SIGINT + +class PexpectTest(unittest.TestCase): + def test_plugins_install(self): + sos = pexpect.spawn('/usr/sbin/sosreport -l') + try: + sos.expect('plugin.*does not install, skipping') + except pexpect.EOF: + pass + else: + self.fail("a plugin does not install or sosreport is too slow") + kill(sos.pid, SIGINT) + + def test_batchmode_removes_questions(self): + sos = pexpect.spawn('/usr/sbin/sosreport --batch') + grp = sos.expect('send this file to your support representative.', 15) + self.assertEquals(grp, 0) + kill(sos.pid, SIGINT) + +if __name__ == '__main__': + unittest.main() diff --git a/testsuite/Makefile b/testsuite/Makefile deleted file mode 100644 index 0328fe34..00000000 --- a/testsuite/Makefile +++ /dev/null @@ -1,13 +0,0 @@ -NAME=sos - -all: - echo "Nothing to build" - -install: - mkdir -p $(DESTDIR)/usr/share/$(NAME)/testsuite/config - mkdir -p $(DESTDIR)/usr/share/$(NAME)/testsuite/$(NAME).test - install -m644 *.exp $(DESTDIR)/usr/share/$(NAME)/testsuite/. - install -m644 config/unix.exp $(DESTDIR)/usr/share/$(NAME)/testsuite/config/. - install -m644 $(NAME).test/*.exp $(DESTDIR)/usr/share/$(NAME)/testsuite/$(NAME).test/. - -clean: diff --git a/testsuite/config/unix.exp b/testsuite/config/unix.exp deleted file mode 100644 index e69de29b..00000000 diff --git a/testsuite/site.exp b/testsuite/site.exp deleted file mode 100644 index c5e83146..00000000 --- a/testsuite/site.exp +++ /dev/null @@ -1,3 +0,0 @@ -set tool sos -set srcdir . -set objdir sos.test diff --git a/testsuite/sos.test/batchmode.exp b/testsuite/sos.test/batchmode.exp deleted file mode 100644 index ca0b11f3..00000000 --- a/testsuite/sos.test/batchmode.exp +++ /dev/null @@ -1,6 +0,0 @@ -set test "BATCHMODE" -spawn /usr/sbin/sosreport --batch -set timeout 15 -expect { - -re "^.*send this file to your support representative." { pass $test } -} diff --git a/testsuite/sos.test/plugin_install.exp b/testsuite/sos.test/plugin_install.exp deleted file mode 100644 index 265724b2..00000000 --- a/testsuite/sos.test/plugin_install.exp +++ /dev/null @@ -1,7 +0,0 @@ -# Tests for any plugins that do not install - -set test "plugin installs" -spawn /usr/sbin/sosreport -l -expect { - -re "plugin.*does not install, skipping" { fail $test } -} -- cgit