Date: Wed, 4 Jul 2007 11:09:35 GMT From: Zhouyi ZHOU <zhouzhouyi@FreeBSD.org> To: Perforce Change Reviews <perforce@FreeBSD.org> Subject: PERFORCE change 122848 for review Message-ID: <200707041109.l64B9Zcw049019@repoman.freebsd.org>
next in thread | raw e-mail | index | archive | help
http://perforce.freebsd.org/chv.cgi?CH=122848 Change 122848 by zhouzhouyi@zhouzhouyi_mactest on 2007/07/04 11:08:58 Add new test cases, especially the mac command test cases Affected files ... .. //depot/projects/soc2007/zhouzhouyi_mactest_soc/regression/mactest/mactest.c#7 edit .. //depot/projects/soc2007/zhouzhouyi_mactest_soc/regression/mactest/tests/misc.sh#5 edit .. //depot/projects/soc2007/zhouzhouyi_mactest_soc/regression/mactest/tests/open/00.t#4 edit .. //depot/projects/soc2007/zhouzhouyi_mactest_soc/regression/mactest/tests/open/01.t#1 add Differences ... ==== //depot/projects/soc2007/zhouzhouyi_mactest_soc/regression/mactest/mactest.c#7 (text+ko) ==== @@ -62,6 +62,8 @@ enum action { ACTION_KILL, + ACTION_SETFMAC, + ACTION_GETFMAC, ACTION_OPEN, ACTION_CREATE, ACTION_UNLINK, @@ -104,6 +106,8 @@ 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 }}, { "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 } }, @@ -415,7 +419,22 @@ switch (scall->sd_action) { case ACTION_KILL: rval = kill(NUM(0),NUM(1)); - break; + 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_OPEN: flags = str2flags(open_flags, STR(1)); if (flags & O_CREAT) { @@ -709,14 +728,17 @@ /* See if record_from_conf is contained in record_from_log */ /* pid == -1 means matching the running pid */ pid = getpid(); + while (record_from_conf) { struct mactestlog_record * iterator = record_from_log; while (iterator) { - if (!(((record_from_conf->pid == -1)&& iterator->pid == pid)|| - record_from_conf->pid == iterator->pid)){ + if (!((record_from_conf->pid == -1&& iterator->pid == pid)|| + record_from_conf->pid == iterator->pid|| + record_from_conf->pid == -2/*matching any pid*/)){ iterator = iterator->next; continue; } + if (strcmp(record_from_conf->machookname, iterator->machookname)) { iterator = iterator->next; @@ -741,7 +763,6 @@ fprintf(stderr, "\n missing ...\n"); struct modes_or_flags *iterator1, *tmp1; struct labelstrings *iterator2, *tmp2; - fprintf(stderr, "pid = %d ", record_from_conf->pid); fprintf(stderr, "hookname: %s\n", record_from_conf->machookname); @@ -751,7 +772,7 @@ tmp1 = iterator1; iterator1 = iterator1->next; } - fprintf(stderr, " with modes or flags:"); + fprintf(stderr, " with modes or flags#"); while (tmp1) { fprintf(stderr, " %s", tmp1->modflagname); tmp1 = tmp1->prev; ==== //depot/projects/soc2007/zhouzhouyi_mactest_soc/regression/mactest/tests/misc.sh#5 (text+ko) ==== @@ -56,6 +56,24 @@ rm ${tmp_file} } +mactestexpect1() +{ + e="${1}" + shift + ${mactest} $* 2>${tmp_file} 1>>${tmp_file} + r=`cat ${tmp_file}` + echo "${r}" | grep ${e} >/dev/null 2>&1 + if [ $? -eq 0 ]; then + echo "ok ${ntest}" + else + echo ${r} + echo "not ok ${ntest}" + fi + ntest=`expr $ntest + 1` + rm ${tmp_file} +} + + maccmdexpect() { ==== //depot/projects/soc2007/zhouzhouyi_mactest_soc/regression/mactest/tests/open/00.t#4 (text+ko) ==== @@ -1,12 +1,12 @@ #!/bin/sh -# $FreeBSD: src/tools/regression/fstest/tests/open/00.t,v 1.2 2007/01/25 20:50:02 pjd Exp $ - +# $FreeBSD: src/tools/regression/mactest/tests/open/00.t,v 1.2 2007/01/25 20:50:02 pjd Exp $ +# test of open related system calls desc="open opens (and eventually creates) a file" dir=`dirname $0` . ${dir}/../misc.sh -echo "1..4" +echo "1..7" n0=`namegen` n1=`namegen` @@ -77,6 +77,19 @@ mactestexpect regular,0755 -m "mls/high" -f ${mactest_conf} lstat ${n0} type,mode + +############################################################# +#case setflags: + echo -n "pid = -1 mac_test_check_vnode_lookup with cr_label and dvplabel:" > ${mactest_conf} + echo "biba/high(low-high),mls/low(low-high) biba/high,mls/8" >> ${mactest_conf} + + 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 + + + ############################################################# #case unlink: #This case will show complex of access control for mls directory structure @@ -90,9 +103,20 @@ echo "pid = -1 mac_test_destroy_vnode_label" >> ${mactest_conf} mactestexpect 0 -m "mls/6" -f ${mactest_conf} unlink ${n0} - cd .. + + +############################################################# +#case chown: + echo -n "pid = -1 mac_test_check_vnode_lookup:" > ${mactest_conf} + echo "biba/high(low-high),mls/5(low-high) biba/high,mls/8" >> ${mactest_conf} + + 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 #cleanup: + cd .. rm -fr ${n1} fi
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?200707041109.l64B9Zcw049019>