]> granicus.if.org Git - procps-ng/commitdiff
testsuite fixes
authorCraig Small <csmall@enc.com.au>
Wed, 23 Nov 2011 10:44:51 +0000 (21:44 +1100)
committerCraig Small <csmall@enc.com.au>
Wed, 23 Nov 2011 10:44:51 +0000 (21:44 +1100)
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/pwdx.test/pwdx.exp [new file with mode: 0644]

index 5338f532e2b78bb29ce591ef53d6345e64165a5a..a748c7e8a0afdd290dc82921aaac578acfd597b1 100644 (file)
@@ -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
index 88aaafda878244a7c2971461dd2e64efe15d8466..c832005f6e754524f0486ef67bf60b1e40681954 100644 (file)
@@ -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 (file)
index 0000000..1e6f935
--- /dev/null
@@ -0,0 +1,2 @@
+*.log
+*.sum
diff --git a/testsuite/Makefile.am b/testsuite/Makefile.am
new file mode 100644 (file)
index 0000000..dc57c45
--- /dev/null
@@ -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 (file)
index 0000000..d329d7e
--- /dev/null
@@ -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 (file)
index 0000000..cd60c21
--- /dev/null
@@ -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" }
+}
+