1
0
Files
irix-657m-src/eoe/cmd/epltest/irixbtest/getplabel_lbl.c
2022-09-29 17:59:04 +03:00

371 lines
13 KiB
C

/*
* Copyright 1991, Silicon Graphics, Inc.
* All Rights Reserved.
*
* This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
* the contents of this file may not be disclosed to third parties, copied or
* duplicated in any form, in whole or in part, without the prior written
* permission of Silicon Graphics, Inc.
*
* RESTRICTED RIGHTS LEGEND:
* Use, duplication or disclosure by the Government is subject to restrictions
* as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
* and Computer Software clause at DFARS 252.227-7013, and/or in similar or
* successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
* rights reserved under the Copyright Laws of the United States.
*/
#include "lbl.h"
/*
* getplabel_lbl.c -- Tests for mac_get_proc() system call.
*/
static int getplabel_lbl0(struct label_info *parmsptr);
static struct label_info
getplabel_linfo0[] =
{
"pos00", 0, MSA, 0, 0, 0,0,0,0,0,0,0,0,0,0,
MIE, 0, 0, 0,0,0,0,0,0,0,0,0,0, PASS , 0,
"pos01", 1, MSH, 0, 0, 0,0,0,0,0,0,0,0,0,0,
MIE, 0, 0, 0,0,0,0,0,0,0,0,0,0, PASS , 0,
"pos02", 2, MSMH, 0, 0, 0,0,0,0,0,0,0,0,0,0,
MIE, 0, 0, 0,0,0,0,0,0,0,0,0,0, PASS , 0,
"pos03", 3, MSL, 0, 0, 0,0,0,0,0,0,0,0,0,0,
MIE, 0, 0, 0,0,0,0,0,0,0,0,0,0, PASS , 0,
"pos04", 4, MSML, 0, 0, 0,0,0,0,0,0,0,0,0,0,
MIE, 0, 0, 0,0,0,0,0,0,0,0,0,0, PASS , 0,
"pos05",5, MST, 200, 10, 2, 4, 6, 8,10,12,14,16,60000,65534,
MIE, 0, 0, 0,0,0,0,0,0,0,0,0,0, PASS , 0,
"pos06",6, MST, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
MIE, 0, 0, 0,0,0,0,0,0,0,0,0,0, PASS , 0,
"pos07",7, MSM, 200, 10, 2, 4, 6, 8,10,12,14,16,60000,65534,
MIE, 0, 0, 0,0,0,0,0,0,0,0,0,0, PASS , 0,
"pos08",8, MSM, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
MIE, 0, 0, 0,0,0,0,0,0,0,0,0,0, PASS , 0,
"pos09", 9, MSA, 0, 0, 0,0,0,0,0,0,0,0,0,0,
MIH, 0, 0, 0,0,0,0,0,0,0,0,0,0, PASS , 0,
"pos10", 10, MSH, 0, 0, 0,0,0,0,0,0,0,0,0,0,
MIH, 0, 0, 0,0,0,0,0,0,0,0,0,0, PASS , 0,
"pos11", 11, MSMH,0, 0, 0,0,0,0,0,0,0,0,0,0,
MIH, 0, 0, 0,0,0,0,0,0,0,0,0,0, PASS , 0,
"pos12", 12, MSL, 0, 0, 0,0,0,0,0,0,0,0,0,0,
MIH, 0, 0, 0,0,0,0,0,0,0,0,0,0, PASS , 0,
"pos13", 13, MSML,0, 0, 0,0,0,0,0,0,0,0,0,0,
MIH, 0, 0, 0,0,0,0,0,0,0,0,0,0, PASS , 0,
"pos14", 14, MST, 200, 10, 2, 4, 6, 8,10,12,14,16,60000,65534,
MIH, 0, 0, 0,0,0,0,0,0,0,0,0,0, PASS , 0,
"pos15", 15, MST, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
MIH, 0, 0, 0,0,0,0,0,0,0,0,0,0, PASS , 0,
"pos16", 16, MSM, 200, 10, 2, 4, 6, 8,10,12,14,16,60000,65534,
MIH, 0, 0, 0,0,0,0,0,0,0,0,0,0, PASS , 0,
"pos17", 17, MSM, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
MIH, 0, 0, 0,0,0,0,0,0,0,0,0,0, PASS , 0,
"pos18", 18, MSA, 0, 0, 0,0,0,0,0,0,0,0,0,0,
MIL, 0, 0, 0,0,0,0,0,0,0,0,0,0, PASS , 0,
"pos19", 19, MSH, 0, 0, 0,0,0,0,0,0,0,0,0,0,
MIL, 0, 0, 0,0,0,0,0,0,0,0,0,0, PASS , 0,
"pos20", 20, MSMH,0, 0, 0,0,0,0,0,0,0,0,0,0,
MIL, 0, 0, 0,0,0,0,0,0,0,0,0,0, PASS , 0,
"pos21", 21, MSL, 0, 0, 0,0,0,0,0,0,0,0,0,0,
MIL, 0, 0, 0,0,0,0,0,0,0,0,0,0, PASS , 0,
"pos22", 22, MSML,0, 0, 0,0,0,0,0,0,0,0,0,0,
MIL, 0, 0, 0,0,0,0,0,0,0,0,0,0, PASS , 0,
"pos23", 23, MST, 200, 10, 2, 4, 6, 8,10,12,14,16,60000,65534,
MIL, 0, 0, 0,0,0,0,0,0,0,0,0,0, PASS , 0,
"pos24", 24, MST, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
MIL, 0, 0, 0,0,0,0,0,0,0,0,0,0, PASS , 0,
"pos25", 25, MSM, 200, 10, 2, 4, 6, 8,10,12,14,16,60000,65534,
MIL, 0, 0, 0,0,0,0,0,0,0,0,0,0, PASS , 0,
"pos26", 26, MSM, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
MIL, 0, 0, 0,0,0,0,0,0,0,0,0,0, PASS , 0,
"pos27", 27, MSA, 0, 0, 0,0,0,0,0,0,0,0,0,0,
MIB, 200, 10, 3, 6, 9,12,15,18,21,24,30000,65533, PASS , 0,
"pos28", 28, MSH, 0, 0, 0,0,0,0,0,0,0,0,0,0,
MIB, 200, 10, 3, 6, 9,12,15,18,21,24,30000,65533, PASS , 0,
"pos29", 29, MSMH, 0, 0, 0,0,0,0,0,0,0,0,0,0,
MIB, 200, 10, 3, 6, 9,12,15,18,21,24,30000,65533, PASS , 0,
"pos30", 30, MSL, 0, 0, 0,0,0,0,0,0,0,0,0,0,
MIB, 200, 10, 3, 6, 9,12,15,18,21,24,30000,65533, PASS , 0,
"pos31", 31, MSML, 0, 0, 0,0,0,0,0,0,0,0,0,0,
MIB, 200, 10, 3, 6, 9,12,15,18,21,24,30000,65533, PASS , 0,
"pos32", 32, MST, 200, 10, 2, 4, 6, 8,10,12,14,16,60000,65534,
MIB, 200, 10, 3, 6, 9,12,15,18,21,24,30000,65533, PASS , 0,
"pos33", 33, MST, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
MIB, 200, 10, 3, 6, 9,12,15,18,21,24,30000,65533, PASS , 0,
"pos34", 34, MSM, 200, 10, 2, 4, 6, 8,10,12,14,16,60000,65534,
MIB, 200, 10, 3, 6, 9,12,15,18,21,24,30000,65533, PASS , 0,
"pos35", 35, MSM, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
MIB, 200, 10, 3, 6, 9,12,15,18,21,24,30000,65533, PASS , 0,
"pos36", 36, MSA, 0, 0, 0,0,0,0,0,0,0,0,0,0,
MIB, 1, 0, 0,0,0,0,0,0,0,0,0,0, PASS , 0,
"pos37", 37, MSH, 0, 0, 0,0,0,0,0,0,0,0,0,0,
MIB, 1, 0, 0,0,0,0,0,0,0,0,0,0, PASS , 0,
"pos38", 38, MSMH,0, 0, 0,0,0,0,0,0,0,0,0,0,
MIB, 1, 0, 0,0,0,0,0,0,0,0,0,0, PASS , 0,
"pos39", 39, MSL, 0, 0, 0,0,0,0,0,0,0,0,0,0,
MIB, 1, 0, 0,0,0,0,0,0,0,0,0,0, PASS , 0,
"pos40", 40, MSML,0, 0, 0,0,0,0,0,0,0,0,0,0,
MIB, 1, 0, 0,0,0,0,0,0,0,0,0,0, PASS , 0,
"pos41", 41, MST, 200, 10, 2, 4, 6, 8,10,12,14,16,60000,65534,
MIB, 1, 0, 0,0,0,0,0,0,0,0,0,0, PASS , 0,
"pos42", 42, MST, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
MIB, 1, 0, 0,0,0,0,0,0,0,0,0,0, PASS , 0,
"pos43", 43, MSM, 200, 10, 2, 4, 6, 8,10,12,14,16,60000,65534,
MIB, 1, 0, 0,0,0,0,0,0,0,0,0,0, PASS , 0,
"pos44", 44, MSM, 1, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
MIB, 1, 0, 0,0,0,0,0,0,0,0,0,0, PASS , 0,
};
static char *getplabel_ldesc0[] = {
"MSEN_ADMIN, MINT_EQUAL",
"MSEN_EQUAL, MINT_EQUAL",
"MSEN_HIGH, MINT_EQUAL",
"MSEN_MLD_HIGH, MINT_EQUAL",
"MSEN_LOW, MINT_EQUAL",
"MSEN_MLD_LOW, MINT_EQUAL",
"MSEN_TCSEC, level, cats, MINT_EQUAL",
"MSEN_TCSEC, level, MINT_EQUAL",
"MSEN_MLD, level, cats, MINT_EQUAL, plabel MLD",
"MSEN_MLD, level, MINT_EQUAL, plabel MLD",
"MSEN_ADMIN, MINT_HIGH",
"MSEN_EQUAL, MINT_HIGH",
"MSEN_HIGH, MINT_HIGH",
"MSEN_MLD_HIGH, MINT_HIGH, plabel MLD",
"MSEN_LOW, MINT_HIGH",
"MSEN_MLD_LOW, MINT_HIGH, plabel MLD",
"MSEN_TCSEC, level, cats, MINT_HIGH",
"MSEN_TCSEC, level, MINT_HIGH",
"MSEN_MLD, level, cats, MINT_HIGH, plabel MLD",
"MSEN_MLD, level, MINT_HIGH, plabel MLD",
"MSEN_ADMIN, MINT_LOW",
"MSEN_EQUAL, MINT_LOW",
"MSEN_HIGH, MINT_LOW",
"MSEN_MLD_HIGH, MINT_LOW, plabel MLD",
"MSEN_LOW, MINT_LOW",
"MSEN_MLD_LOW, MINT_LOW, plabel MLD",
"MSEN_TCSEC, level, cats, MINT_LOW",
"MSEN_TCSEC, level, MINT_LOW",
"MSEN_MLD, level, cats, MINT_LOW, plabel MLD",
"MSEN_MLD, level, MINT_LOW, plabel MLD",
"MSEN_ADMIN, MINT_BIBA, grade, divs",
"MSEN_EQUAL, MINT_BIBA, grade, divs",
"MSEN_HIGH, MINT_BIBA, grade, divs",
"MSEN_MLD_HIGH, MINT_BIBA, grade, divs, plabel MLD",
"MSEN_LOW, MINT_BIBA, grade, divs",
"MSEN_MLD_LOW, MINT_BIBA, grade, divs, plabel MLD",
"MSEN_TCSEC, level, cats, MINT_BIBA, grade, divs",
"MSEN_TCSEC, level, MINT_BIBA, grade, divs",
"MSEN_MLD, level, cats, MINT_BIBA, grade, divs, plabel MLD",
"MSEN_MLD, level, MINT_BIBA, grade, divs, plabel MLD",
"MSEN_ADMIN, MINT_BIBA, grade",
"MSEN_EQUAL, MINT_BIBA, grade",
"MSEN_HIGH, MINT_BIBA, grade",
"MSEN_MLD_HIGH, MINT_BIBA, grade, plabel MLD",
"MSEN_LOW, MINT_BIBA, grade" ,
"MSEN_MLD_LOW, MINT_BIBA, grade, plabel MLD",
"MSEN_TCSEC, level, cats, MINT_BIBA, grade",
"MSEN_TCSEC, level, MINT_BIBA, grade",
"MSEN_MLD, level, cats, MINT_BIBA, grade, plabel MLD",
"MSEN_MLD, level, MINT_BIBA, grade, plabel MLD",
"Invalid address",
};
int
getplabel_lbl(void)
{
char str[MSGLEN]; /* used to write to logfiles */
char testname[SLEN]; /* used to write to logfiles */
char *name; /* holds casename from struct */
short ncases0 = 45; /* number of label-matching test cases */
short num; /* holds casenum from struct */
int retval; /* value returned on function call */
int fail = 0; /* set when a test case fails */
int incomplete = 0; /* set when a test case is incomplete */
short i = 0; /* test case loop counter */
strcpy(testname,"getplabel_lbl");
/*
* Write formatted info to raw log.
*/
RAWLOG_SETUP( testname, ncases0 );
/*
* Call function getplabel_lbl0() for each label comparison test case.
*/
for (i = 0; i < ncases0; i++) {
/*
* Flush output streams.
*/
flush_raw_log();
retval = getplabel_lbl0(&getplabel_linfo0[i]);
num = getplabel_linfo0[i].casenum;
name = getplabel_linfo0[i].casename;
switch (retval) {
/*
* Write formatted result to raw log.
*/
case PASS: /* Passed */
RAWPASS(num, name);
break;
case FAIL: /* Failed */
RAWFAIL(num, name, getplabel_ldesc0[i]);
fail = 1;
break;
default:
RAWINC(num, name);
incomplete = 1;
break; /* Incomplete */
}
flush_raw_log();
}
/*
* Return 0, 1, or 2 to calling function, which records
* result in summary log. If ANY case failed or was
* incomplete, the whole test is recorded as failed or
* incomplete. Incomplete supercedes fail.
*/
if (incomplete)
return(INCOMPLETE);
if (fail)
return(FAIL);
return(PASS);
}
static int getplabel_lbl0(struct label_info *parmsptr)
{
register short i; /* Loop counter for cats & divs */
char testname[SLEN]; /* used to write to logfiles */
char namestring[MSGLEN]; /* Used in error messages. */
int retval = 0; /* Return value of test call. */
pid_t forkval; /* Returned value of fork call. */
int status; /* For wait. */
mac_t lptr; /* MAC label pointer. */
mac_t testptr; /* MAC label pointer for test call. */
strcpy(testname,"getplabel_lbl");
sprintf(namestring, "%s, case %d, %s:\n ", testname,
parmsptr->casenum, parmsptr->casename);
/*
* Fork a child to do setup and test call.
*/
if ( ( forkval = fork() ) == -1 ) {
w_error(SYSCALL, namestring, err[F_FORK], errno);
return(INCOMPLETE);
}
if ( forkval ) {
/*
* This is the parent. Wait for child and return
* 2 on unexpected error. Otherwise, return child's
* exit code.
*/
if ( wait(&status) == -1 ) {
w_error(SYSCALL, namestring, err[F_WAIT], errno);
return(INCOMPLETE);
}
if ( !WIFEXITED(status) ) {
w_error(GENERAL, namestring, err[C_NOTEXIT], 0);
return(INCOMPLETE);
}
return(WEXITSTATUS(status) );
}
/*
* This is the child.
*/
/*
* Calloc a mac pointer.
*/
lptr = mac_get_proc();
/*
* Set process label.
*/
lptr->ml_msen_type = parmsptr->obj_msen;
lptr->ml_level = parmsptr->obj_level;
lptr->ml_catcount = parmsptr->obj_catcount;
for (i = 0; i < parmsptr->obj_catcount; i++) {
lptr->ml_list[i] = parmsptr->obj_catlist[i];
}
lptr->ml_mint_type = parmsptr->obj_mint;
lptr->ml_grade = parmsptr->obj_grade;
lptr->ml_divcount = parmsptr->obj_divcount;
for (i = 0; i < parmsptr->obj_divcount; i++) {
lptr->ml_list[i + parmsptr->obj_catcount] =
parmsptr->obj_divlist[i];
}
if ( cap_setplabel(lptr) ) {
w_error(SYSCALL,namestring,err[F_SETPLABEL],errno);
exit(INCOMPLETE);
}
mac_free(lptr);
/*
* Here's the test: Call mac_get_proc(testptr).
*/
testptr = mac_get_proc();
retval = (testptr == NULL ? -1 : 0);
/*
* All cases are positive: retval should be 0, label
* fields should match what was passed to mac_set_proc().
*/
if ( retval == -1 ) {
w_error(SYSCALL, namestring, err[TESTCALL], errno);
exit(FAIL);
}
if (retval != 0) {
w_error(PRINTNUM, namestring, err[TEST_RETVAL],retval);
exit(FAIL);
}
if ( (testptr->ml_msen_type != parmsptr->obj_msen) ||
(testptr->ml_mint_type != parmsptr->obj_mint) ||
(testptr->ml_level != parmsptr->obj_level) ||
(testptr->ml_grade != parmsptr->obj_grade) ||
(testptr->ml_catcount != parmsptr->obj_catcount) ||
(testptr->ml_divcount != parmsptr->obj_divcount) ) {
w_error(GENERAL, namestring, err[BADLABEL], 0);
exit(FAIL);
}
for (i = 0; i < parmsptr->obj_catcount; i++) {
if (testptr->ml_list[i] != parmsptr->obj_catlist[i]) {
w_error(GENERAL, namestring, err[BADLABEL], 0);
exit(FAIL);
}
}
for (i = 0; i < parmsptr->obj_divcount; i++) {
if (testptr->ml_list[i + parmsptr->obj_catcount] !=
parmsptr->obj_divlist[i]) {
w_error(GENERAL, namestring, err[BADLABEL], 0);
exit(FAIL);
}
}
exit(PASS);
return(PASS);
}