]> granicus.if.org Git - psmisc/commitdiff
Start of test scripts for psmisc
authorCraig Small <csmall@users.sourceforge.net>
Fri, 22 Jun 2012 11:28:14 +0000 (21:28 +1000)
committerCraig Small <csmall@users.sourceforge.net>
Fri, 22 Jun 2012 11:28:14 +0000 (21:28 +1000)
.gitignore
Makefile.am
configure.ac
testsuite/.gitignore [new file with mode: 0644]
testsuite/Makefile.am [new file with mode: 0644]
testsuite/config/unix.exp [new file with mode: 0644]
testsuite/fuser.test/fuser.exp [new file with mode: 0644]
testsuite/global-conf.exp [new file with mode: 0644]
testsuite/killall.test/killall.exp [new file with mode: 0644]

index eb60dfbf8e5bdd13feda57c2b82e7c6670f6705d..5dcba9f083e3ee99d61d53edf91760811c9a7214 100644 (file)
@@ -8,7 +8,6 @@ config.h
 config.h.in
 config.log
 config.status
-config/
 configure
 doc/Makefile
 doc/Makefile.in
index fc53aa9b04752e94981b4e98d3d88c82fa53df27..819688650d73e2af57362966f9ccabc85ddccd58 100644 (file)
@@ -1,5 +1,5 @@
 
-SUBDIRS = doc src po icons 
+SUBDIRS = doc src po icons testsuite
 
 #EXTRA_DIST = config.rpath ABOUT-NLS mkinstalldirs
 
index 38818076279622f4427c9811a9b9b385a682f918..9df639d637dbb1c06535e7c4e04a06c23c08968e 100644 (file)
@@ -1,7 +1,7 @@
 dnl Process this file with autoconf to produce a configure script.
 AC_PREREQ([2.68])
 AC_CONFIG_MACRO_DIR([m4])
-AC_INIT([psmisc],[22.19])
+AC_INIT([psmisc],[22.20])
 AC_CONFIG_SRCDIR([src/comm.h])
 AC_CONFIG_HEADER([config.h])
 AC_CONFIG_AUX_DIR([config])
@@ -165,9 +165,16 @@ AC_CHECK_FUNCS([atexit getmntent memset nl_langinfo rawmemchr regcomp rpmatch se
 dnl Checks for Large File System
 AC_SYS_LARGEFILE
 
+if test x"$DEJAGNU" = x
+then
+  DEJAGNU="\$(top_srcdir)/testsuite/global-conf.exp"
+fi
+AC_SUBST(DEJAGNU)
+       
 AC_CONFIG_FILES([Makefile
                 doc/Makefile
                 src/Makefile
                 icons/Makefile
-                po/Makefile.in])
+                po/Makefile.in
+                testsuite/Makefile])
 AC_OUTPUT
diff --git a/testsuite/.gitignore b/testsuite/.gitignore
new file mode 100644 (file)
index 0000000..96ef030
--- /dev/null
@@ -0,0 +1,4 @@
+*.log
+*.sum
+site.bak
+site.exp
diff --git a/testsuite/Makefile.am b/testsuite/Makefile.am
new file mode 100644 (file)
index 0000000..e9bf8a4
--- /dev/null
@@ -0,0 +1,12 @@
+AUTOMAKE_OPTIONS = dejagnu
+export DEJAGNU
+
+# Programs that are expected across the board.
+DEJATOOL = killall 
+
+if WANT_FUSER
+  DEJATOOL += fuser
+endif
+
+
+EXTRA_DIST = 
diff --git a/testsuite/config/unix.exp b/testsuite/config/unix.exp
new file mode 100644 (file)
index 0000000..cd446c8
--- /dev/null
@@ -0,0 +1,19 @@
+
+
+regexp "(.*\/)testsuite" $objdir objdir topdir
+
+
+proc expect_pass { testname reg } {
+    expect {
+        -re "$reg" { pass "$testname" }
+        default { fail "$testname" }
+                timeout { fail "$testname" }
+    }
+}
+
+proc expect_nothing { test } {
+       expect {
+               -re "\\S" { fail "$test" }
+       eof { pass "$test" }
+       }
+}
diff --git a/testsuite/fuser.test/fuser.exp b/testsuite/fuser.test/fuser.exp
new file mode 100644 (file)
index 0000000..5c6a0c0
--- /dev/null
@@ -0,0 +1,42 @@
+#
+# Testsuite for fuser
+#
+proc cleanup { } {
+       global test_file
+       exec rm $test_file
+}
+
+set fuser "${topdir}src/fuser"
+set test_file [ exec mktemp ]
+
+set verbose_header "\\s+USER\\s+PID ACCESS COMMAND\\s*"
+
+set test "fuser with no arguments"
+spawn $fuser
+expect_pass "$test" "^No process specification given\\s*Usage: fuser"
+
+set test "fuser no args, no proc"
+spawn $fuser $test_file
+expect_nothing "$test"
+
+set test "fuser -a no proc"
+spawn $fuser -a $test_file
+expect_pass "$test" "^${test_file}:\\s*$"
+
+set test "fuser -v, no proc"
+spawn $fuser $test_file
+expect_nothing "$test"
+
+set test "fuser -av, no proc"
+spawn $fuser -av $test_file
+expect_pass "$test" "^${verbose_header}${test_file}:\\s*$"
+
+set test "fuser -va, no proc"
+spawn $fuser -av $test_file
+expect_pass "$test" "^${verbose_header}${test_file}:\\s*$"
+
+set test "fuser -l"
+spawn $fuser -l
+expect_pass "$test" "^(\[A-Z12\]+\\s*)+$"
+
+
diff --git a/testsuite/global-conf.exp b/testsuite/global-conf.exp
new file mode 100644 (file)
index 0000000..e69de29
diff --git a/testsuite/killall.test/killall.exp b/testsuite/killall.test/killall.exp
new file mode 100644 (file)
index 0000000..b244893
--- /dev/null
@@ -0,0 +1,19 @@
+#
+# Testsuite for killall
+#
+
+set killall "${topdir}src/killall"
+set fake_proc_name "afakeprocname"
+
+set test "killall with no arguments"
+spawn $killall
+expect_pass "$test" "^Usage: killall \\\[OPTION\\\]\\.\\.\\. \\\[--\\\] NAME\\.\\.\\."
+
+set test "killall list signals"
+spawn $killall -l
+expect_pass "$test" "^(\[A-Z12\]+\\s*)+$"
+
+set test "killall process not found"
+spawn $killall ${fake_proc_name}
+expect_pass "$test" "${fake_proc_name}: no process found"
+