From: Craig Small Date: Fri, 22 Jun 2012 11:28:14 +0000 (+1000) Subject: Start of test scripts for psmisc X-Git-Tag: v22.20rc1~5^2~1 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=f10f9f2106c75802792595a87b92d59d9c82f6b8;p=psmisc Start of test scripts for psmisc --- diff --git a/.gitignore b/.gitignore index eb60dfb..5dcba9f 100644 --- a/.gitignore +++ b/.gitignore @@ -8,7 +8,6 @@ config.h config.h.in config.log config.status -config/ configure doc/Makefile doc/Makefile.in diff --git a/Makefile.am b/Makefile.am index fc53aa9..8196886 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,5 +1,5 @@ -SUBDIRS = doc src po icons +SUBDIRS = doc src po icons testsuite #EXTRA_DIST = config.rpath ABOUT-NLS mkinstalldirs diff --git a/configure.ac b/configure.ac index 3881807..9df639d 100644 --- a/configure.ac +++ b/configure.ac @@ -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 index 0000000..96ef030 --- /dev/null +++ b/testsuite/.gitignore @@ -0,0 +1,4 @@ +*.log +*.sum +site.bak +site.exp diff --git a/testsuite/Makefile.am b/testsuite/Makefile.am new file mode 100644 index 0000000..e9bf8a4 --- /dev/null +++ b/testsuite/Makefile.am @@ -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 index 0000000..cd446c8 --- /dev/null +++ b/testsuite/config/unix.exp @@ -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 index 0000000..5c6a0c0 --- /dev/null +++ b/testsuite/fuser.test/fuser.exp @@ -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 index 0000000..e69de29 diff --git a/testsuite/killall.test/killall.exp b/testsuite/killall.test/killall.exp new file mode 100644 index 0000000..b244893 --- /dev/null +++ b/testsuite/killall.test/killall.exp @@ -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" +