Changeset 68 for trunk/test
- Timestamp:
- Oct 30, 2006, 12:03:44 AM (18 years ago)
- Location:
- trunk/test
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/test/test.sh
r60 r68 138 138 usage() { 139 139 echo "test.sh [options] <test_number> [hostname]" 140 echo " [-q|--quiet|-v|--verbose] [-s|--stoponerr] [- -no-cleanup]"140 echo " [-q|--quiet|-v|--verbose] [-s|--stoponerr] [-n|--no-cleanup]" 141 141 echo " [--srcdir=top_srcdir] [--color=always|never|auto]" 142 142 echo … … 149 149 echo " ${S}test.sh 7${E} -- GnuPG signed files / prelude log" 150 150 echo " ${S}test.sh 8${E} -- Suidcheck" 151 152 echo " ${S}test.sh 10${E} -- Test c/s init/check (testrc_2.in)" 153 echo " ${S}test.sh 11${E} -- Test full c/s init/check (testrc_2.in)" 154 echo " ${S}test.sh 12${E} -- Test full c/s w/gpg (testrc_2.in)" 155 echo " ${S}test.sh 13${E} -- Test full c/s w/mysql (testrc_2.in)" 156 echo " ${S}test.sh 14${E} -- Test full c/s w/postgres (testrc_2.in)" 151 echo " ${S}test.sh 9${E} -- Process check" 152 echo " ${S}test.sh 10${E} -- Port check" 153 154 echo " ${S}test.sh 20${E} -- Test c/s init/check (testrc_2.in)" 155 echo " ${S}test.sh 21${E} -- Test full c/s init/check (testrc_2.in)" 156 echo " ${S}test.sh 22${E} -- Test full c/s w/gpg (testrc_2.in)" 157 echo " ${S}test.sh 23${E} -- Test full c/s w/mysql (testrc_2.in)" 158 echo " ${S}test.sh 24${E} -- Test full c/s w/postgres (testrc_2.in)" 157 159 echo " ${S}test.sh all${E} -- All tests" 158 160 } … … 162 164 echo " (1) testcompile.sh (2) testhash.sh (3) testrun_1.sh (4) testrun_1a.sh" 163 165 echo " (5) testext.sh (6) testtimesrv.sh (7) testrun_1b.sh (8) testrun_1c.sh" 164 echo " (10) testrun_2.sh (11) testrun_2a.sh (12) testrun_2b.sh (13) testrun_2c.sh" 165 echo " (14) testrun_2d.sh" 166 echo " (9) testrun_1d.sh" 167 echo " (20) testrun_2.sh (21) testrun_2a.sh (22) testrun_2b.sh (23) testrun_2c.sh" 168 echo " (24) testrun_2d.sh" 166 169 } 167 170 … … 185 188 -q|--quiet) quiet=on; verbose= ;; 186 189 -s|--stoponerr) stoponerr=on;; 187 - -no-cleanup) cleanup= ;;190 -n|--no-cleanup) cleanup= ;; 188 191 --really-all) doall=on;; 189 192 --valgrind) usevalgrind=on;; … … 366 369 367 370 log_fail () { 368 log_msg "$1" "$2" failure "$3";371 [ -z "$quiet" ] && log_msg "$1" "$2" failure "$3"; 369 372 let "failcount = failcount + 1" >/dev/null; 370 373 test -z "$stoponerr" || exit 1; 371 374 } 372 375 log_ok () { 373 log_msg "$1" "$2" success "$3";376 [ -z "$quiet" ] && log_msg "$1" "$2" success "$3"; 374 377 let "okcount = okcount + 1" >/dev/null; 375 378 } 376 379 log_skip () { 377 log_msg "$1" "$2" skipped "$3";380 [ -z "$quiet" ] && log_msg "$1" "$2" skipped "$3"; 378 381 let "skipcount = skipcount + 1" >/dev/null; 379 382 } … … 441 444 print_summary () 442 445 { 443 let "gcount = okcount + skipcount + failcount" >/dev/null; 446 # let "gcount = okcount + skipcount + failcount" >/dev/null; 447 gcount=$MAXTEST; 448 let "failcount = gcount - okcount - skipcount" >/dev/null; 449 444 450 [ -z "$quiet" ] && { 445 451 echo … … 594 600 exit $? 595 601 fi 602 if test x$1 = x9; then 603 . ${SCRIPTDIR}/testrun_1.sh 604 . ${SCRIPTDIR}/testrun_1d.sh 605 testrun1d 606 print_summary 607 exit $? 608 fi 596 609 if test x$1 = x10; then 610 . ${SCRIPTDIR}/testrun_1.sh 611 . ${SCRIPTDIR}/testrun_1e.sh 612 testrun1e 613 print_summary 614 exit $? 615 fi 616 if test x$1 = x20; then 597 617 . ${SCRIPTDIR}/testrun_2.sh 598 618 testrun2 $hostname … … 600 620 exit $? 601 621 fi 602 if test x$1 = x 11; then622 if test x$1 = x21; then 603 623 . ${SCRIPTDIR}/testrun_2a.sh 604 624 testrun2a $hostname … … 606 626 exit $? 607 627 fi 608 if test x$1 = x 12; then628 if test x$1 = x22; then 609 629 . ${SCRIPTDIR}/testrun_2a.sh 610 630 . ${SCRIPTDIR}/testrun_2b.sh … … 613 633 exit $? 614 634 fi 615 if test x$1 = x 13; then635 if test x$1 = x23; then 616 636 . ${SCRIPTDIR}/testrun_2a.sh 617 637 . ${SCRIPTDIR}/testrun_2c.sh … … 620 640 exit $? 621 641 fi 622 if test x$1 = x 14; then642 if test x$1 = x24; then 623 643 . ${SCRIPTDIR}/testrun_2a.sh 624 644 . ${SCRIPTDIR}/testrun_2d.sh … … 644 664 let "TEST_MAX = TEST_MAX + MAXTEST" >/dev/null 645 665 . ${SCRIPTDIR}/testrun_1c.sh 666 let "TEST_MAX = TEST_MAX + MAXTEST" >/dev/null 667 . ${SCRIPTDIR}/testrun_1d.sh 668 let "TEST_MAX = TEST_MAX + MAXTEST" >/dev/null 669 . ${SCRIPTDIR}/testrun_1e.sh 646 670 let "TEST_MAX = TEST_MAX + MAXTEST" >/dev/null 647 671 . ${SCRIPTDIR}/testrun_2.sh … … 687 711 MAXTEST=${TEST_MAX}; export MAXTEST 688 712 testrun1c 713 # 714 . ${SCRIPTDIR}/testrun_1.sh 715 . ${SCRIPTDIR}/testrun_1d.sh 716 MAXTEST=${TEST_MAX}; export MAXTEST 717 testrun1d 718 # 719 . ${SCRIPTDIR}/testrun_1.sh 720 . ${SCRIPTDIR}/testrun_1e.sh 721 MAXTEST=${TEST_MAX}; export MAXTEST 722 testrun1e 689 723 # 690 724 . ${SCRIPTDIR}/testrun_2.sh -
trunk/test/testcompile.sh
r54 r68 20 20 # 21 21 22 MAXTEST=6 1; export MAXTEST22 MAXTEST=63; export MAXTEST 23 23 24 24 run_flawfinder () … … 164 164 # test standalone compilation 165 165 # 166 TEST="${S}standalone w/suidcheck ${E}"166 TEST="${S}standalone w/suidcheck w/processcheck${E}" 167 167 # 168 168 if test -r "Makefile"; then … … 170 170 fi 171 171 # 172 ${TOP_SRCDIR}/configure --quiet --prefix=$PW_DIR --localstatedir=$PW_DIR --with-config-file=$PW_DIR/samhainrc.test --enable-suidcheck > /dev/null 2>> test_log 172 ${TOP_SRCDIR}/configure --quiet --prefix=$PW_DIR --localstatedir=$PW_DIR --with-config-file=$PW_DIR/samhainrc.test --enable-suidcheck --enable-process-check > /dev/null 2>> test_log 173 # 174 let "num = num + 1" >/dev/null 175 testmake $? $num || let "numfail = numfail + 1" >/dev/null 176 let "num = num + 1" >/dev/null 177 run_smatch $? $num || let "numfail = numfail + 1" >/dev/null 178 179 # 180 # test standalone compilation 181 # 182 TEST="${S}standalone w/processcheck w/portcheck${E}" 183 # 184 if test -r "Makefile"; then 185 $MAKE distclean 186 fi 187 # 188 ${TOP_SRCDIR}/configure --quiet --prefix=$PW_DIR --localstatedir=$PW_DIR --with-config-file=$PW_DIR/samhainrc.test --enable-process-check --enable-port-check > /dev/null 2>> test_log 173 189 # 174 190 let "num = num + 1" >/dev/null -
trunk/test/testrun_1.sh
r51 r68 41 41 testrun1_setup=0 42 42 43 MAXTEST=1 1; export MAXTEST43 MAXTEST=13; export MAXTEST 44 44 45 45 test_dirs () { … … 70 70 # combine file check schedule with one-shot mode 71 71 # 72 TESTPOLICY_1 1="72 TESTPOLICY_13=" 73 73 [ReadOnly] 74 74 dir=99${BASE} 75 75 " 76 76 77 mod_testdata_1 1() {77 mod_testdata_13 () { 78 78 one_sec_sleep 79 79 echo "foobar" >"${BASE}/c/x"; # bad … … 87 87 } 88 88 89 chk_testdata_1 1() {89 chk_testdata_13 () { 90 90 # CDIRS="a b c a/a a/b a/c a/a/a a/a/b a/a/c a/a/a/a a/a/a/b a/a/a/c"; 91 91 tmp=`grep CRIT $LOGFILE | wc -l` … … 110 110 } 111 111 112 TESTPOLICY_1 0="112 TESTPOLICY_12=" 113 113 [ReadOnly] 114 114 dir=99${BASE} … … 119 119 " 120 120 121 mod_testdata_1 0() {121 mod_testdata_12 () { 122 122 one_sec_sleep 123 123 echo "foobar" >"${BASE}/b/x"; # ok … … 129 129 } 130 130 131 chk_testdata_12 () { 132 # CDIRS="a b c a/a a/b a/c a/a/a a/a/b a/a/c a/a/a/a a/a/a/b a/a/a/c"; 133 tmp=`grep CRIT $LOGFILE | wc -l` 134 if [ $tmp -ne 3 ]; then 135 [ -z "$verbose" ] || log_msg_fail "policy count"; 136 return 1 137 fi 138 egrep "CRIT.*POLICY \[ReadOnly\] C-------TS.*${BASE}/c/x" $LOGFILE >/dev/null 2>&1 139 if [ $? -ne 0 ]; then 140 [ -z "$verbose" ] || log_msg_fail "${BASE}/c/x"; 141 return 1 142 fi 143 egrep "CRIT.*POLICY \[Attributes\] -----M----.*${BASE}/a/a/x" $LOGFILE >/dev/null 2>&1 144 if [ $? -ne 0 ]; then 145 [ -z "$verbose" ] || log_msg_fail "${BASE}/a/a/x"; 146 return 1 147 fi 148 egrep "CRIT.*POLICY \[Attributes\] -----M----.*${BASE}/a/y" $LOGFILE >/dev/null 2>&1 149 if [ $? -ne 0 ]; then 150 [ -z "$verbose" ] || log_msg_fail "${BASE}/a/y"; 151 return 1 152 fi 153 CDIRS="a a/a a/b a/c c"; 154 NDIRS="b a/a/a a/a/b a/a/c a/a/a/a a/a/a/b a/a/a/c"; 155 test_dirs; 156 return $? 157 } 158 159 # 160 # --- ACL/SELinux test case 161 # 162 TESTPOLICY_11=" 163 [ReadOnly] 164 dir=99${BASE} 165 [IgnoreAll] 166 dir=-1${BASE}/b 167 [Attributes] 168 dir=1${BASE}/a 169 [Misc] 170 UseSelinuxCheck = no 171 UseAclCheck = no 172 " 173 174 mod_testdata_11 () { 175 one_sec_sleep 176 setfacl -m 'user:nobody:r--' "${BASE}/b/x"; # ok (ign) 177 setfacl -m 'user:nobody:r--' "${BASE}/c/x"; # bad 178 setfacl -m 'user:nobody:r--' "${BASE}/a/x"; # bad 179 setfattr -n 'security.selinux' -v "system_u:object_r:etc_t\000" "${BASE}/b/y"; # ok (ign) 180 setfattr -n 'security.selinux' -v "system_u:object_r:etc_t\000" "${BASE}/a/a/a/x";# ok (depth) 181 setfattr -n 'security.selinux' -v "system_u:object_r:etc_t\000" "${BASE}/a/x"; # bad 182 setfattr -n 'security.selinux' -v "system_u:object_r:etc_t\000" "${BASE}/a/y"; # bad 183 } 184 185 chk_testdata_11 () { 186 # CDIRS="a b c a/a a/b a/c a/a/a a/a/b a/a/c a/a/a/a a/a/a/b a/a/a/c"; 187 tmp=`grep CRIT $LOGFILE | wc -l` 188 if [ $tmp -ne 1 ]; then 189 [ -z "$verbose" ] || log_msg_fail "policy count"; 190 return 1 191 fi 192 egrep "CRIT.*POLICY \[ReadOnly\] --------T-.*${BASE}/c/x" $LOGFILE >/dev/null 2>&1 193 if [ $? -ne 0 ]; then 194 [ -z "$verbose" ] || log_msg_fail "${BASE}/c/x"; 195 return 1 196 fi 197 CDIRS="a a/a a/b a/c c"; 198 NDIRS="b a/a/a a/a/b a/a/c a/a/a/a a/a/a/b a/a/a/c"; 199 test_dirs; 200 return $? 201 } 202 203 TESTPOLICY_10=" 204 [ReadOnly] 205 dir=99${BASE} 206 [IgnoreAll] 207 dir=-1${BASE}/b 208 [Attributes] 209 dir=1${BASE}/a 210 " 211 212 mod_testdata_10 () { 213 one_sec_sleep 214 setfacl -m 'user:nobody:r--' "${BASE}/b/x"; # ok (ign) 215 setfacl -m 'user:nobody:r--' "${BASE}/c/x"; # bad 216 setfacl -m 'user:nobody:r--' "${BASE}/a/x"; # bad 217 setfattr -n 'security.selinux' -v "system_u:object_r:etc_t\000" "${BASE}/b/y"; # ok (ign) 218 setfattr -n 'security.selinux' -v "system_u:object_r:etc_t\000" "${BASE}/a/a/a/x";# ok (depth) 219 setfattr -n 'security.selinux' -v "system_u:object_r:etc_t\000" "${BASE}/a/x"; # bad 220 setfattr -n 'security.selinux' -v "system_u:object_r:etc_t\000" "${BASE}/a/y"; # bad 221 } 222 131 223 chk_testdata_10 () { 132 224 # CDIRS="a b c a/a a/b a/c a/a/a a/a/b a/a/c a/a/a/a a/a/a/b a/a/a/c"; … … 136 228 return 1 137 229 fi 138 egrep "CRIT.*POLICY \[ReadOnly\] C-------TS.*${BASE}/c/x" $LOGFILE >/dev/null 2>&1230 egrep "CRIT.*POLICY \[ReadOnly\] -----M--T-.*${BASE}/c/x" $LOGFILE >/dev/null 2>&1 139 231 if [ $? -ne 0 ]; then 140 232 [ -z "$verbose" ] || log_msg_fail "${BASE}/c/x"; 141 233 return 1 142 234 fi 143 egrep "CRIT.*POLICY \[Attributes\] -----M----.*${BASE}/a/ a/x" $LOGFILE >/dev/null 2>&1144 if [ $? -ne 0 ]; then 145 [ -z "$verbose" ] || log_msg_fail "${BASE}/a/ a/x";235 egrep "CRIT.*POLICY \[Attributes\] -----M----.*${BASE}/a/x" $LOGFILE >/dev/null 2>&1 236 if [ $? -ne 0 ]; then 237 [ -z "$verbose" ] || log_msg_fail "${BASE}/a/x"; 146 238 return 1 147 239 fi … … 825 917 run_check () 826 918 { 827 ${VALGRIND} ./samhain -t check -p none -l debug 2>>test_log_valgrind828 919 ${VALGRIND} ./samhain -t check -p none -l debug 2>>test_log_valgrind 920 829 921 if test x$? = x0; then 922 830 923 ./samhain -j -L $LOGFILE >"${LOGFILE}.tmp" && mv "${LOGFILE}.tmp" "${LOGFILE}" 924 831 925 if [ $? -ne 0 ]; then 832 926 [ -z "$quiet" ] && log_msg_fail "mv logfile..."; … … 927 1021 { 928 1022 if [ $1 -ne 0 ]; then 929 [ -z "$quiet" ] &&log_fail ${2} ${MAXTEST};1023 log_fail ${2} ${MAXTEST}; 930 1024 return 1 931 1025 fi … … 1012 1106 [ -z "$quiet" ] && log_ok ${tcount} ${MAXTEST}; 1013 1107 fi 1108 # 1014 1109 let "tcount = tcount + 1" >/dev/null 1110 # 1111 if [ -z "$doall" -a $tcount -eq 10 ]; then 1112 log_skip 10 $MAXTEST 'ACL/SELinux test (or use --really-all)' 1113 let "tcount = tcount + 1" >/dev/null 1114 fi 1115 # 1116 if [ -z "$doall" -a $tcount -eq 11 ]; then 1117 log_skip 11 $MAXTEST 'ACL/SELinux test (or use --really-all)' 1118 let "tcount = tcount + 1" >/dev/null 1119 fi 1120 # 1015 1121 POLICY=`eval echo '"$'"TESTPOLICY_$tcount"'"'` 1016 1122 done
Note:
See TracChangeset
for help on using the changeset viewer.