PERFORCE change 123249 for review

Zhouyi ZHOU zhouzhouyi at FreeBSD.org
Tue Jul 10 07:28:28 UTC 2007


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

Change 123249 by zhouzhouyi at zhouzhouyi_mactest on 2007/07/10 07:27:49

	Unify the shell function "system" handling in mactest.c to test MAC commands.
	Don't know if it is an error that command "ls" need a -l to work with -Z which has not been 
	mentioned in ls's manual page.

Affected files ...

.. //depot/projects/soc2007/zhouzhouyi_mactest_soc/regression/mactest/mactest.c#8 edit
.. //depot/projects/soc2007/zhouzhouyi_mactest_soc/regression/mactest/tests/open/01.t#2 edit

Differences ...

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

@@ -62,8 +62,7 @@
 
 enum action {
 	ACTION_KILL,
-	ACTION_SETFMAC,
-	ACTION_GETFMAC,
+	ACTION_SYSTEM,
 	ACTION_OPEN,
 	ACTION_CREATE,
 	ACTION_UNLINK,
@@ -106,8 +105,7 @@
 
 static struct syscall_desc syscalls[] = {
 	{ "kill", ACTION_KILL, { TYPE_NUMBER, TYPE_NUMBER, TYPE_NONE } },
-	{ "setfmac", ACTION_SETFMAC, { TYPE_STRING, TYPE_STRING, TYPE_NONE }},
-	{ "getfmac", ACTION_GETFMAC, { TYPE_STRING, TYPE_NONE }},
+	{ "system", ACTION_SYSTEM, { TYPE_NONE }},
 	{ "open", ACTION_OPEN, { TYPE_STRING, TYPE_STRING, TYPE_NUMBER | TYPE_OPTIONAL, TYPE_NONE } },
 	{ "create", ACTION_CREATE, { TYPE_STRING, TYPE_NUMBER, TYPE_NONE } },
 	{ "unlink", ACTION_UNLINK, { TYPE_STRING, TYPE_NONE } },
@@ -365,6 +363,7 @@
 	}
 	printf("\n");
 }
+char * systemargs = 0;
 
 static unsigned int
 call_syscall(struct syscall_desc *scall, char *argv[])
@@ -382,7 +381,20 @@
 	/*
 	 * Verify correctness of the arguments.
 	 */
-	for (i = 0; i < sizeof(args)/sizeof(args[0]); i++) {
+	systemargs = malloc(1024);
+	bzero(systemargs, 1024);
+        if (scall->sd_action == ACTION_SYSTEM){
+	  i = 0;
+	  int n = 0;
+	  while (argv[i])
+	    {
+	      n += sprintf(systemargs+n, "%s ", argv[i]);
+	      i++;
+	    }
+
+        } else {
+	  for (i = 0; i < sizeof(args)/sizeof(args[0]); i++) {
+	 
 		if (scall->sd_args[i] == TYPE_NONE) {
 			if (argv[i] == NULL || strcmp(argv[i], ":") == 0)
 				break;
@@ -410,7 +422,9 @@
 				}
 			}
 		}
+	   }
 	}
+
 	/*
 	 * Call the given syscall.
 	 */
@@ -420,21 +434,10 @@
 	case ACTION_KILL:
 		rval = kill(NUM(0),NUM(1));
 		break;
-	case ACTION_SETFMAC:
-		{
-			char shcmd[1024];
-			sprintf(shcmd, "setfmac %s %s", STR(0), STR(1));
-			rval = system(shcmd);
-			break;
-		}
-	case ACTION_GETFMAC:
-		{
-			char shcmd[1024];
-			int i = 0;
-			i = sprintf(shcmd, "getfmac %s", STR(0));
-			rval = system(shcmd);
-			return (i);
-		}
+	case ACTION_SYSTEM:
+	        rval = system(systemargs);
+		free(systemargs);
+		break;
 	case ACTION_OPEN:
 		flags = str2flags(open_flags, STR(1));
 		if (flags & O_CREAT) {

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

@@ -90,14 +90,22 @@
 
 #destroy old label
     echo "pid = -2 mac_test_destroy_vnode_label" >> ${mactest_conf}
-    mactestexpect 0 -m "mls/5(low-high)" -f ${mactest_conf} setfmac  "mls/7" ${n0}
+    mactestexpect 0 -m "mls/5(low-high)" -f ${mactest_conf} system setfmac  "mls/7" ${n0}
     
 #############################################################
-#caes getfmac command:
+#case getfmac command:
 #It is strange that there are no mac_check respect to get the vnode label
     echo -n "pid = -2 mac_test_copy_vnode_label with src label:" > ${mactest_conf}
     echo "biba/high,mls/7" >> ${mactest_conf}
-    mactestexpect1 "biba/high,mls/7"  -f ${mactest_conf} getfmac ${n0}
+    mactestexpect1 "biba/high,mls/7"  -f ${mactest_conf} system getfmac ${n0}
+
+#############################################################
+#case ls -l -Z command:
+#Why ls need -l to work with -Z, this is not correspond to the manual page of ls
+    echo -n "pid = -2 mac_test_copy_vnode_label with src label:" > ${mactest_conf}
+    echo "biba/high,mls/7" >> ${mactest_conf}
+    mactestexpect1 "biba/high,mls/7" -f ${mactest_conf} system ls -l -Z ${n0}
+
 #cleanup:
     cd ..
     rm -fr ${n1}


More information about the p4-projects mailing list