PERFORCE change 123673 for review

Zhouyi ZHOU zhouzhouyi at FreeBSD.org
Wed Jul 18 06:14:48 UTC 2007


http://perforce.freebsd.org/chv.cgi?CH=123673

Change 123673 by zhouzhouyi at zhouzhouyi_mactest on 2007/07/18 06:13:49

	adjust the function mactestexpect to do more acurate recording of error message returned
	especially the error message returned by shell command

Affected files ...

.. //depot/projects/soc2007/zhouzhouyi_mactest_soc/regression/mactest/mactest.c#10 edit
.. //depot/projects/soc2007/zhouzhouyi_mactest_soc/regression/mactest/tests/misc.sh#9 edit
.. //depot/projects/soc2007/zhouzhouyi_mactest_soc/regression/mactest/tests/open/00.t#5 edit
.. //depot/projects/soc2007/zhouzhouyi_mactest_soc/regression/mactest/tests/open/01.t#6 edit
.. //depot/projects/soc2007/zhouzhouyi_mactest_soc/regression/mactest/tests/open/02.t#3 edit
.. //depot/projects/soc2007/zhouzhouyi_mactest_soc/regression/mactest/tests/signal/00.t#3 edit
.. //depot/projects/soc2007/zhouzhouyi_mactest_soc/regression/mactest/tests/signal/01.t#3 edit

Differences ...

==== //depot/projects/soc2007/zhouzhouyi_mactest_soc/regression/mactest/mactest.c#10 (text+ko) ====

@@ -536,7 +536,8 @@
 		return (i);
 		//		exit(1);
 	}
-	printf("0\n");
+        if (scall->sd_action != ACTION_SYSTEM)
+	  printf("0\n");
 	return (i);
 }
 

==== //depot/projects/soc2007/zhouzhouyi_mactest_soc/regression/mactest/tests/misc.sh#9 (text+ko) ====

@@ -41,11 +41,16 @@
 }
 
 
+
 mactestexpect()
 {
+	
 	e="${1}"
 	shift
 
+	e1="${1}"
+	shift
+
 	if [ -f ${tmp_file} ]; then
 	    rm ${tmp_file}
 	fi
@@ -62,19 +67,35 @@
 	setfmac ${label1} ${tmp_file} ${tmp_file1} /var/log/mactest
 
 	${mactest} $* 2>${tmp_file1} 1>>${tmp_file}
-	r=`cat ${tmp_file}|tail -1`
-	s=`cat ${tmp_file1}`
+
+	c=1
+	b=1
+
+	r=`cat ${tmp_file1}|tail -1`
 	echo "${r}" | egrep '^'${e}'$' >/dev/null 2>&1
-	if [ $? -eq 0 ] && [ ${#r} -eq ${#e} ] && [ ${#s} -eq 0 ]; then
+
+	if [ $? -eq 0 ]; then
+	    c=0
+	fi
+
+	s=`cat ${tmp_file}|tail -1`
+	echo "${s}" | egrep '^'${e1}'$' >/dev/null 2>&1
+
+	if [ $? -eq 0 ]; then
+	    b=0
+	fi
+
+	if [ ${c} -eq 0 ] && [ ${b} -eq 0 ]; then
 		echo "ok ${ntest}"
 	else
-	    if [ ${#s} != 0 ]; then
-		echo ${s}
-	    fi
+		if [ ${c} != 0 ]; then 
+		    cat ${tmp_file1}
+		fi
+		
+		if [ ${b} != 0 ]; then
+		    cat ${tmp_file}
+		fi
 
-	    if [ $? != 0 ] || [ ${#r} != ${#e} ]; then
-		echo ${r}
-	    fi
 		echo "not ok ${ntest}"
 	fi
 	ntest=`expr $ntest + 1`
@@ -83,6 +104,7 @@
 
 }
 
+
 maclabelexpect()
 {
 	e="${1}"
@@ -147,3 +169,6 @@
 {
 	echo "mactest_`dd if=/dev/random bs=1k count=1 2>/dev/null | openssl md5`"
 }
+
+
+

==== //depot/projects/soc2007/zhouzhouyi_mactest_soc/regression/mactest/tests/open/00.t#5 (text+ko) ====

@@ -40,7 +40,7 @@
 #associate the extattr of newly created vnode
     echo -n "pid = -1 mac_test_create_vnode_extattr:" >> ${mactest_conf}
     echo "biba/high(low-high),mls/8(low-high) * ${dvplabel} biba/high,mls/8" >> ${mactest_conf}
-    mactestexpect 0  -m "mls/8(low-high)"  -f ${mactest_conf} mkdir ${n1}  0755
+    mactestexpect "" 0  -m "mls/8(low-high)"  -f ${mactest_conf} mkdir ${n1}  0755
 
 
 
@@ -61,7 +61,7 @@
     echo -n "pid = -1 mac_test_check_vnode_open#VWRITE :" >> ${mactest_conf}
     echo "biba/high(low-high),mls/9(low-high) biba/high,mls/9" >> ${mactest_conf}
 
-    mactestexpect 0 -m "mls/9(low-high)" -f ${mactest_conf} open ${n0} O_CREAT,O_WRONLY 0755
+    mactestexpect "" 0 -m "mls/9(low-high)" -f ${mactest_conf} open ${n0} O_CREAT,O_WRONLY 0755
 
 
 
@@ -74,7 +74,7 @@
 #no file label
     echo -n "pid = -1 mac_test_check_vnode_stat with cred label, file label and vplabel:" >> ${mactest_conf} 
     echo "biba/high(low-high),mls/high(low-high) NULL biba/high,mls/9" >> ${mactest_conf}
-    mactestexpect regular,0755 -m "mls/high" -f ${mactest_conf} lstat ${n0} type,mode
+    mactestexpect "" regular,0755 -m "mls/high" -f ${mactest_conf} lstat ${n0} type,mode
 
 
 
@@ -85,8 +85,8 @@
 
     echo -n "pid = -1 mac_test_check_vnode_setflags with cr_label and vplabel:" > ${mactest_conf}
     echo "biba/high(low-high),mls/low(low-high) biba/high,mls/9" >> ${mactest_conf}
-    mactestexpect 0 -f ${mactest_conf}  chflags ${n0} SF_IMMUTABLE
-    mactestexpect 0 -f ${mactest_conf}  chflags ${n0} none
+    mactestexpect "" 0 -f ${mactest_conf}  chflags ${n0} SF_IMMUTABLE
+    mactestexpect "" 0 -f ${mactest_conf}  chflags ${n0} none
 
 
 
@@ -102,7 +102,7 @@
     echo "biba/high(low-high),mls/6(low-high) biba/high,mls/8 biba/high,mls/9" >> ${mactest_conf}
 
     echo "pid = -1 mac_test_destroy_vnode_label" >> ${mactest_conf}
-    mactestexpect 0 -m "mls/6" -f ${mactest_conf} unlink ${n0}
+    mactestexpect "" 0 -m "mls/6" -f ${mactest_conf} unlink ${n0}
 
 
 #############################################################
@@ -113,7 +113,7 @@
     echo -n "pid = -1 mac_test_check_vnode_setowner with cr_label and vplabel:" >> ${mactest_conf}
     echo "biba/high(low-high),mls/5(low-high) biba/high,mls/8" >> ${mactest_conf}
 
-    mactestexpect 0 -m "mls/5" -f ${mactest_conf} chown . 65535 65535
+    mactestexpect "" 0 -m "mls/5" -f ${mactest_conf} chown . 65535 65535
 
 #cleanup:
     cd ..

==== //depot/projects/soc2007/zhouzhouyi_mactest_soc/regression/mactest/tests/open/01.t#6 (text+ko) ====

@@ -40,7 +40,7 @@
 #associate the extattr of newly created vnode
     echo -n "pid = -1 mac_test_create_vnode_extattr:" >> ${mactest_conf}
     echo "biba/high(low-high),mls/8(low-high) * ${dvplabel} biba/high,mls/8" >> ${mactest_conf}
-    mactestexpect 0  -m "mls/8(low-high)"  -f ${mactest_conf} mkdir ${n1}  0755
+    mactestexpect ""  0  -m "mls/8(low-high)"  -f ${mactest_conf} mkdir ${n1}  0755
 
 
 
@@ -61,7 +61,7 @@
     echo -n "pid = -1 mac_test_check_vnode_open#VWRITE:" >> ${mactest_conf}
     echo "biba/high(low-high),mls/9(low-high) biba/high,mls/9" >> ${mactest_conf}
 
-    mactestexpect 0 -m "mls/9(low-high)" -f ${mactest_conf} open ${n0} O_CREAT,O_WRONLY 0755
+    mactestexpect ""  0 -m "mls/9(low-high)" -f ${mactest_conf} open ${n0} O_CREAT,O_WRONLY 0755
 
 
 
@@ -90,7 +90,7 @@
 
 #destroy old label
     echo "pid = -2 mac_test_destroy_vnode_label" >> ${mactest_conf}
-    mactestexpect 0 -m "mls/5(low-high)" -f ${mactest_conf} system setfmac  "mls/7" ${n0}
+    mactestexpect ""  "" -m "mls/5(low-high)" -f ${mactest_conf} system setfmac  "mls/7" ${n0}
     
 #############################################################
 #case getfmac command:

==== //depot/projects/soc2007/zhouzhouyi_mactest_soc/regression/mactest/tests/open/02.t#3 (text+ko) ====

@@ -9,7 +9,7 @@
 dir=`dirname $0`
 . ${dir}/../misc.sh
 
-echo "1..4"
+echo "1..5"
 
 n0=`namegen`
 n1=`namegen`
@@ -42,21 +42,28 @@
     echo "enforcing mac/mls!"
 
 #BLP: no write down
-    mactestexpect EACCES  -m "mls/10(low-high)"  -f ${mactest_conf} mkdir ${n1}  0755
+    mactestexpect "" EACCES  -m "mls/10(low-high)"  -f ${mactest_conf} mkdir ${n1}  0755
   
     rm ${mactest_conf}
     touch ${mactest_conf}
 #the mac hook checking is already done in previous test cases!
-    mactestexpect 0 -m ${dvplabel} -f ${mactest_conf} mkdir ${n1} 0755
-    mactestexpect 0 -m ${dvplabel} -f ${mactest_conf} system setfmac "mls/10" ${n1}
+    mactestexpect "" 0 -m ${dvplabel} -f ${mactest_conf} mkdir ${n1} 0755
+    mactestexpect "" "" -m ${dvplabel} -f ${mactest_conf} system setfmac "mls/10" ${n1}
 
 #BLP: no read high
     echo -n "pid = -1 mac_test_check_vnode_open#VREAD:" > ${mactest_conf}
     echo "biba/high(low-high),mls/low(low-high) biba/high,mls/10" >> ${mactest_conf}
-    mactestexpect EACCES -m ${dvplabel} -f ${mactest_conf} open ${n1} O_RDONLY
+    mactestexpect ""  EACCES -m ${dvplabel} -f ${mactest_conf} open ${n1} O_RDONLY
+
+#there will be mac_check_vnode_stat in setfmac
+    echo -n "pid = -2 mac_test_check_vnode_stat:" > ${mactest_conf}
+    echo "biba/high(low-high),mls/low(low-high) NULL biba/high,mls/10" >> ${mactest_conf}
+    mactestexpect "setfmac:.traversing.${n1}:.Permission.denied" "" -m ${dvplabel} -f ${mactest_conf} system setfmac "mls/low" ${n1}
+    
     t=`sysctl security.mac.mls.enabled=0`
     echo "disabling mac/mls!"
 
+  
 #BLP: ok read low
 #cleanup:
 #   cd ..

==== //depot/projects/soc2007/zhouzhouyi_mactest_soc/regression/mactest/tests/signal/00.t#3 (text+ko) ====


==== //depot/projects/soc2007/zhouzhouyi_mactest_soc/regression/mactest/tests/signal/01.t#3 (text+ko) ====

@@ -24,7 +24,7 @@
 
     echo "pid = -1 mac_test_check_proc_signal with cr_label and proc label: biba/high(low-high),mls/9(low-high) mls/3(2-7),biba/high(low-high)" > ${mactest_conf}
 
-    mactestexpect 0  -m "mls/9" -f ${mactest_conf}  kill ${pid}  9
+    mactestexpect "" 0  -m "mls/9" -f ${mactest_conf}  kill ${pid}  9
     
     rm ${mactest_conf}
     rm ${pid_file}


More information about the p4-projects mailing list