diff --git a/Makefile.am b/Makefile.am index 5338f532..a748c7e8 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,7 +1,7 @@ AM_CPPFLAGS = -include $(top_builddir)/config.h ACLOCAL_AMFLAGS = -I m4 -SUBDIRS = proc ps +SUBDIRS = proc ps testsuite AM_CFLAGS = -Iproc AM_LDFLAGS = ./proc/libproc-ng.la diff --git a/configure.ac b/configure.ac index 88aaafda..c832005f 100644 --- a/configure.ac +++ b/configure.ac @@ -135,10 +135,17 @@ if test "x$enable_w_from" = xyes; then AC_DEFINE(W_SHOWFROM, 1, [enable w from field by default]) fi +if test x"$DEJAGNU" = x +then + DEJAGNU="\$(top_srcdir)/testsuite/global-conf.exp" +fi +AC_SUBST(DEJAGNU) + AC_CONFIG_FILES([ Makefile proc/Makefile proc/libproc-ng.pc ps/Makefile +testsuite/Makefile ]) AC_OUTPUT diff --git a/testsuite/.gitignore b/testsuite/.gitignore new file mode 100644 index 00000000..1e6f9352 --- /dev/null +++ b/testsuite/.gitignore @@ -0,0 +1,2 @@ +*.log +*.sum diff --git a/testsuite/Makefile.am b/testsuite/Makefile.am new file mode 100644 index 00000000..dc57c450 --- /dev/null +++ b/testsuite/Makefile.am @@ -0,0 +1,5 @@ +AUTOMAKE_OPTIONS = dejagnu +export DEJAGNU + +DEJATOOL = \ + pwdx diff --git a/testsuite/config/unix.exp b/testsuite/config/unix.exp new file mode 100644 index 00000000..d329d7ec --- /dev/null +++ b/testsuite/config/unix.exp @@ -0,0 +1,8 @@ + +proc pwdx_load { arg } { } +proc pwdx_exit {} {} +proc pwdx_version {} { + set tmp [ exec pwdx -V ] + regexp "procps-ng version (\[0-9.\]*)" $tmp tmp version + clone_output "pwdx version $version\n" +} diff --git a/testsuite/pwdx.test/pwdx.exp b/testsuite/pwdx.test/pwdx.exp new file mode 100644 index 00000000..cd60c211 --- /dev/null +++ b/testsuite/pwdx.test/pwdx.exp @@ -0,0 +1,30 @@ + +# Run pwdx with no arguments +set test "pwdx no args" +spawn pwdx +expect { + -re "^Usage: pwdx pid\.\.\." { pass "$test" } + eof { fail "$test" } + timeout { fail "$test" } +} + +# Run pwdx with pid 1 which is not reachable +set test "pwdx pid 1 should give permission denied" +spawn pwdx 1 +expect { + -re "^1: Permission denied" { pass "$test" } + eof { fail "$test" } + timeout { fail "$test" } +} + +# Run pwdx with existing pid +set test "pwdx finds sleep in cwd" +set sleep_pid [ exec sleep 600 & ] +set sleep_pwd [ pwd ] +spawn pwdx $sleep_pid +expect { + -re "^$sleep_pid: $sleep_pwd" { pass "$test" } + eof { fail "$test" } + timeout { fail "$test" } +} +