]> granicus.if.org Git - sudo/commitdiff
Move parser tests to sudoers directory and test the tokenizer output too.
authorTodd C. Miller <Todd.Miller@courtesan.com>
Mon, 21 Mar 2011 19:08:49 +0000 (15:08 -0400)
committerTodd C. Miller <Todd.Miller@courtesan.com>
Mon, 21 Mar 2011 19:08:49 +0000 (15:08 -0400)
14 files changed:
plugins/sudoers/Makefile.in
plugins/sudoers/regress/sudoers/test1.in [moved from plugins/sudoers/regress/visudo/test1.sh with 56% similarity, mode: 0644]
plugins/sudoers/regress/sudoers/test1.out.ok [new file with mode: 0644]
plugins/sudoers/regress/sudoers/test1.toke.ok [new file with mode: 0644]
plugins/sudoers/regress/sudoers/test2.in [moved from plugins/sudoers/regress/testsudoers/test2.sh with 81% similarity, mode: 0644]
plugins/sudoers/regress/sudoers/test2.out.ok [moved from plugins/sudoers/regress/testsudoers/test2.out with 100% similarity]
plugins/sudoers/regress/sudoers/test2.toke.ok [new file with mode: 0644]
plugins/sudoers/regress/sudoers/test3.in [new file with mode: 0644]
plugins/sudoers/regress/sudoers/test3.out.ok [moved from plugins/sudoers/regress/testsudoers/test3.ok with 100% similarity]
plugins/sudoers/regress/sudoers/test3.toke.ok [new file with mode: 0644]
plugins/sudoers/regress/testsudoers/test1.out.ok [moved from plugins/sudoers/regress/testsudoers/test1.ok with 100% similarity]
plugins/sudoers/regress/testsudoers/test1.sh
plugins/sudoers/regress/testsudoers/test3.sh [deleted file]
plugins/sudoers/regress/visudo/test1.ok [deleted file]

index ff70bdc5f901aaa37814776ec6c5f182da996016..4a08e7f84aca07dbafa646e4cb14a2f0d02e7de5 100644 (file)
@@ -365,7 +365,66 @@ uninstall:
 check: $(TEST_PROGS) visudo testsudoers
        @./check_iolog_path $(srcdir)/regress/iolog_path/data
        @./check_fill
-       @for t in $(srcdir)/regress/*/test*.sh; do SRCDIR=$(srcdir) $(SHELL) $$t; done
+       @passed=0; failed=0; total=0; \
+           for t in $(srcdir)/regress/sudoers/*.in; do \
+               dir=`dirname $$t`; \
+               dirbase=`basename $$dir`; \
+               base=`basename $$t .in`; \
+               out="$${base}.out"; \
+               toke="$${base}.toke"; \
+               ./testsudoers -dt <$$t >$$out 2>$$toke; \
+               if cmp $$out $$dir/$$out.ok >/dev/null; then \
+                   passed=`expr $$passed + 1`; \
+                   echo "$$dirbase/$$base (parse): OK"; \
+               else \
+                   failed=`expr $$failed + 1`; \
+                   echo "$$dirbase/$$base: FAIL"; \
+                   diff $$out $$dir/$$out.ok; \
+               fi; \
+               total=`expr $$total + 1`; \
+               if cmp $$toke $$dir/$$toke.ok >/dev/null; then \
+                   passed=`expr $$passed + 1`; \
+                   echo "$$dirbase/$$base (toke): OK"; \
+               else \
+                   failed=`expr $$failed + 1`; \
+                   echo "$$dirbase/$$base (toke): FAIL"; \
+                   diff $$out $$dir/$$out.ok; \
+               fi; \
+               total=`expr $$total + 1`; \
+           done; \
+           echo "$$dirbase: $$passed/$$total tests passed; $$failed/$$total tests failed"
+       @passed=0; failed=0; total=0; \
+           for t in $(srcdir)/regress/*/*.sh; do \
+               dir=`dirname $$t`; \
+               dirbase=`basename $$dir`; \
+               base=`basename $$t .sh`; \
+               out="$${base}.out"; \
+               err="$${base}.err"; \
+               $(SHELL) $$t >$$out 2>$$err; \
+               if cmp $$out $$dir/$$out.ok >/dev/null; then \
+                   passed=`expr $$passed + 1`; \
+                   echo "$$dirbase/$$base: OK"; \
+               else \
+                   failed=`expr $$failed + 1`; \
+                   echo "$$dirbase/$$base: FAIL"; \
+                   diff $$out $$dir/$$out.ok; \
+               fi; \
+               total=`expr $$total + 1`; \
+               if test -s $$dir/$$err.ok; then \
+                   if cmp $$err $$dir/$$err.ok >/dev/null; then \
+                       passed=`expr $$passed + 1`; \
+                       echo "$$dirbase/$$base (stderr): OK"; \
+                   else \
+                       failed=`expr $$failed + 1`; \
+                       echo "$$dirbase/$$base (stderr): FAIL"; \
+                       diff $$out $$dir/$$out.ok; \
+                   fi; \
+                   total=`expr $$total + 1`; \
+               elif test -s $$err; then \
+                   cat $$err 1>&2; \
+               fi; \
+           done; \
+           echo "$$dirbase: $$passed/$$total tests passed; $$failed/$$total tests failed"
 
 clean:
        -$(LIBTOOL) --mode=clean rm -f $(PROGS) *.lo *.o *.la *.a stamp-* core *.core core.* *.out
old mode 100755 (executable)
new mode 100644 (file)
similarity index 56%
rename from plugins/sudoers/regress/visudo/test1.sh
rename to plugins/sudoers/regress/sudoers/test1.in
index 27d0dd7..872925c
@@ -1,22 +1,8 @@
-#!/bin/sh
 #
 # Verify that all command tags are parsed OK.
 # See http://www.sudo.ws/bugs/show_bug.cgi?id=437
 #
-
-WANT=${SRCDIR-.}/regress/visudo/test1.ok
-GOT=vs_test1.out
-./visudo -c -f- > $GOT <<EOF
 user1 ALL = LOG_INPUT: LOG_OUTPUT: /usr/bin/su -:\
       ALL = NOLOG_INPUT: NOLOG_OUTPUT: /usr/bin/id
 user2 ALL = NOPASSWD: NOEXEC: SETENV: /usr/bin/vi:\
       ALL = PASSWD: EXEC: NOSETENV: /usr/bin/echo
-EOF
-
-# Check results
-if cmp $WANT $GOT >/dev/null; then
-    echo "visudo 1: OK"
-else
-    echo "visudo 1: FAILED"
-    diff $WANT $GOT
-fi
diff --git a/plugins/sudoers/regress/sudoers/test1.out.ok b/plugins/sudoers/regress/sudoers/test1.out.ok
new file mode 100644 (file)
index 0000000..44cb652
--- /dev/null
@@ -0,0 +1,6 @@
+Parses OK.
+
+
+
+user1  ALL = /usr/bin/su - : ALL = /usr/bin/id
+user2  ALL = NOPASSWD: NOEXEC: /usr/bin/vi : ALL = PASSWD: EXEC: /usr/bin/echo
diff --git a/plugins/sudoers/regress/sudoers/test1.toke.ok b/plugins/sudoers/regress/sudoers/test1.toke.ok
new file mode 100644 (file)
index 0000000..3f3a7ad
--- /dev/null
@@ -0,0 +1,6 @@
+#
+#
+#
+#
+WORD(5) ALL = LOG_INPUT LOG_OUTPUT COMMAND ARG : ALL = NOLOG_INPUT NOLOG_OUTPUT COMMAND 
+WORD(5) ALL = NOPASSWD NOEXEC SETENV COMMAND : ALL = PASSWD EXEC NOSETENV COMMAND 
old mode 100755 (executable)
new mode 100644 (file)
similarity index 81%
rename from plugins/sudoers/regress/testsudoers/test2.sh
rename to plugins/sudoers/regress/sudoers/test2.in
index 892f0cd..cfdfaa3
@@ -1,13 +1,3 @@
-#!/bin/sh
-#
-# Test quoted words in sudoers.
-# Note that a backslash in double quotes is treated literally unless
-# it is escaping a double quote.
-#
-
-WANT=${SRCDIR-.}/regress/testsudoers/test2.out
-GOT=ts_test2.out
-./testsudoers -d > $GOT <<EOF
 # Check quoted user name in User_Alias
 User_Alias UA1 = "foo"
 User_Alias UA2 = "foo.bar"
@@ -68,12 +58,3 @@ Defaults>"some one" set_home
 "%:C/non_UNIX_0 c"     "hostf" = ("root") ALL
 "%:C/non\'UNIX_3 c"    "hostg" = ("root") ALL
 "+netgr"               "hosth" = ("root") ALL
-EOF
-
-# Check results
-if cmp $WANT $GOT >/dev/null; then
-    echo "testsudoers 2: OK"
-else
-    echo "testsudoers 2: FAILED"
-    diff $WANT $GOT
-fi
diff --git a/plugins/sudoers/regress/sudoers/test2.toke.ok b/plugins/sudoers/regress/sudoers/test2.toke.ok
new file mode 100644 (file)
index 0000000..fcd7b73
--- /dev/null
@@ -0,0 +1,60 @@
+#
+USERALIAS ALIAS = BEGINSTR STRBODY ENDSTR WORD(4) 
+USERALIAS ALIAS = BEGINSTR STRBODY ENDSTR WORD(4) 
+USERALIAS ALIAS = BEGINSTR STRBODY ENDSTR WORD(4) 
+USERALIAS ALIAS = BEGINSTR STRBODY ENDSTR WORD(4) 
+USERALIAS ALIAS = BEGINSTR STRBODY ENDSTR WORD(4) 
+
+#
+USERALIAS ALIAS = BEGINSTR STRBODY ENDSTR USERGROUP 
+USERALIAS ALIAS = BEGINSTR STRBODY ENDSTR USERGROUP 
+
+#
+USERALIAS ALIAS = BEGINSTR STRBODY ENDSTR USERGROUP 
+USERALIAS ALIAS = BEGINSTR STRBODY BACKSLASH STRBODY BACKSLASH STRBODY ENDSTR USERGROUP 
+USERALIAS ALIAS = BEGINSTR STRBODY ENDSTR USERGROUP 
+USERALIAS ALIAS = BEGINSTR STRBODY ENDSTR USERGROUP 
+USERALIAS ALIAS = BEGINSTR STRBODY BACKSLASH STRBODY ENDSTR USERGROUP 
+
+#
+RUNASALIAS ALIAS = BEGINSTR STRBODY ENDSTR WORD(4) 
+RUNASALIAS ALIAS = BEGINSTR STRBODY ENDSTR WORD(4) 
+RUNASALIAS ALIAS = BEGINSTR STRBODY ENDSTR WORD(4) 
+RUNASALIAS ALIAS = BEGINSTR STRBODY ENDSTR WORD(4) 
+
+#
+DEFAULTS_HOST BEGINSTR STRBODY ENDSTR WORD(4) DEFVAR 
+DEFAULTS_HOST BEGINSTR STRBODY ENDSTR WORD(4) DEFVAR 
+
+#
+DEFAULTS_USER BEGINSTR STRBODY ENDSTR WORD(4) DEFVAR 
+DEFAULTS_USER BEGINSTR STRBODY ENDSTR WORD(4) DEFVAR 
+DEFAULTS_USER BEGINSTR STRBODY ENDSTR WORD(4) DEFVAR 
+DEFAULTS_USER BEGINSTR STRBODY ENDSTR WORD(4) DEFVAR 
+DEFAULTS_USER BEGINSTR STRBODY ENDSTR WORD(4) DEFVAR 
+
+#
+DEFAULTS_RUNAS BEGINSTR STRBODY ENDSTR WORD(4) DEFVAR 
+DEFAULTS_RUNAS BEGINSTR STRBODY ENDSTR WORD(4) DEFVAR 
+
+#
+#
+#
+#
+
+#
+BEGINSTR STRBODY ENDSTR WORD(4) BEGINSTR STRBODY ENDSTR WORD(4) = ( BEGINSTR STRBODY ENDSTR WORD(4) ) ALL 
+BEGINSTR STRBODY ENDSTR WORD(4) BEGINSTR STRBODY ENDSTR WORD(4) = ( BEGINSTR STRBODY ENDSTR WORD(4) ) ALL 
+BEGINSTR STRBODY ENDSTR WORD(4) BEGINSTR STRBODY ENDSTR WORD(4) = ( BEGINSTR STRBODY ENDSTR WORD(4) ) ALL 
+BEGINSTR STRBODY ENDSTR WORD(4) BEGINSTR STRBODY ENDSTR WORD(4) = ( BEGINSTR STRBODY ENDSTR WORD(4) ) ALL 
+BEGINSTR STRBODY ENDSTR WORD(4) BEGINSTR STRBODY ENDSTR WORD(4) = ( BEGINSTR STRBODY ENDSTR WORD(4) ) ALL 
+
+#
+BEGINSTR STRBODY ENDSTR USERGROUP BEGINSTR STRBODY ENDSTR WORD(4) = ( BEGINSTR STRBODY ENDSTR WORD(4) ) ALL 
+BEGINSTR STRBODY ENDSTR USERGROUP BEGINSTR STRBODY ENDSTR WORD(4) = ( BEGINSTR STRBODY ENDSTR WORD(4) ) ALL 
+BEGINSTR STRBODY ENDSTR USERGROUP BEGINSTR STRBODY ENDSTR WORD(4) = ( BEGINSTR STRBODY ENDSTR WORD(4) ) ALL 
+BEGINSTR STRBODY BACKSLASH STRBODY BACKSLASH STRBODY ENDSTR USERGROUP BEGINSTR STRBODY ENDSTR WORD(4) = ( BEGINSTR STRBODY ENDSTR WORD(4) ) ALL 
+BEGINSTR STRBODY ENDSTR USERGROUP BEGINSTR STRBODY ENDSTR WORD(4) = ( BEGINSTR STRBODY ENDSTR WORD(4) ) ALL 
+BEGINSTR STRBODY ENDSTR USERGROUP BEGINSTR STRBODY ENDSTR WORD(4) = ( BEGINSTR STRBODY ENDSTR WORD(4) ) ALL 
+BEGINSTR STRBODY BACKSLASH STRBODY ENDSTR USERGROUP BEGINSTR STRBODY ENDSTR WORD(4) = ( BEGINSTR STRBODY ENDSTR WORD(4) ) ALL 
+BEGINSTR STRBODY ENDSTR NETGROUP BEGINSTR STRBODY ENDSTR WORD(4) = ( BEGINSTR STRBODY ENDSTR WORD(4) ) ALL 
diff --git a/plugins/sudoers/regress/sudoers/test3.in b/plugins/sudoers/regress/sudoers/test3.in
new file mode 100644 (file)
index 0000000..82fcd83
--- /dev/null
@@ -0,0 +1,6 @@
+# Test whitespace in User_List as part of a per-user Defaults entry
+User_Alias FOO = foo, bar
+Defaults:FOO env_reset
+Defaults:foo,bar env_reset
+Defaults:foo,\ bar env_reset
+Defaults:foo, bar env_reset
diff --git a/plugins/sudoers/regress/sudoers/test3.toke.ok b/plugins/sudoers/regress/sudoers/test3.toke.ok
new file mode 100644 (file)
index 0000000..49f2e51
--- /dev/null
@@ -0,0 +1,6 @@
+#
+USERALIAS ALIAS = WORD(5) , WORD(5) 
+DEFAULTS_USER ALIAS DEFVAR 
+DEFAULTS_USER WORD(5) , WORD(5) DEFVAR 
+DEFAULTS_USER WORD(5) , WORD(5) DEFVAR 
+DEFAULTS_USER WORD(5) , WORD(5) DEFVAR 
index c64c718f50c99a5c631083f665f62abb53f59f45..88eb9c431f0c3f178993748db88ec855506e831b 100755 (executable)
@@ -5,16 +5,6 @@
 # This is RedHat bug Bug 667103.
 #
 
-WANT=${SRCDIR-.}/regress/testsudoers/test1.ok
-GOT=ts_test1.out
-./testsudoers -g wheel root id > $GOT <<EOF
+./testsudoers -g wheel root id <<EOF
 root ALL = ALL
 EOF
-
-# Check results
-if cmp $WANT $GOT >/dev/null; then
-    echo "testsudoers 1: OK"
-else
-    echo "testsudoers 1: FAILED"
-    diff $WANT $GOT
-fi
diff --git a/plugins/sudoers/regress/testsudoers/test3.sh b/plugins/sudoers/regress/testsudoers/test3.sh
deleted file mode 100755 (executable)
index c6b6705..0000000
+++ /dev/null
@@ -1,22 +0,0 @@
-#!/bin/sh
-#
-# Test whitespace in User_List as part of a per-user Defaults entry
-#
-
-WANT=${SRCDIR-.}/regress/testsudoers/test3.ok
-GOT=ts_test3.out
-./testsudoers -d > $GOT <<EOF
-User_Alias FOO = foo, bar
-Defaults:FOO env_reset
-Defaults:foo,bar env_reset
-Defaults:foo,\ bar env_reset
-Defaults:foo, bar env_reset
-EOF
-
-# Check results
-if cmp $WANT $GOT >/dev/null; then
-    echo "testsudoers 3: OK"
-else
-    echo "testsudoers 3: FAILED"
-    diff $WANT $GOT
-fi
diff --git a/plugins/sudoers/regress/visudo/test1.ok b/plugins/sudoers/regress/visudo/test1.ok
deleted file mode 100644 (file)
index e5c355c..0000000
+++ /dev/null
@@ -1 +0,0 @@
-stdin: parsed OK