1 /* 2 * Author: Joshua Brindle <jbrindle@tresys.com> 3 * Chad Sellers <csellers@tresys.com> 4 * 5 * Copyright (C) 2006 Tresys Technology, LLC 6 * 7 * This library is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU Lesser General Public 9 * License as published by the Free Software Foundation; either 10 * version 2.1 of the License, or (at your option) any later version. 11 * 12 * This library is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 15 * Lesser General Public License for more details. 16 * 17 * You should have received a copy of the GNU Lesser General Public 18 * License along with this library; if not, write to the Free Software 19 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA 20 */ 21 22 #ifndef __TEST_COMMON_H__ 23 #define __TEST_COMMON_H__ 24 25 #include <sepol/policydb/policydb.h> 26 27 /* p the policy being inspected 28 * id string symbol identifier 29 * sym_type symbol type (eg., SYM_ROLES, SYM_TYPES) 30 * scope_type what scope the role should have (eg., SCOPE_DECL or SCOPE_REQ) 31 * decls integer array of decl id's that we expect the role to have in the scope table 32 * len number of elements in decls 33 * 34 * This is a utility function to test for the symbol's presence in the global symbol table, 35 * the scope table, and that the decl blocks we think this symbol is in are correct 36 */ 37 extern void test_sym_presence(policydb_t * p, char *id, int sym_type, unsigned int scope_type, unsigned int *decls, unsigned int len); 38 39 /* Test the indexes in the policydb to ensure their correctness. These include 40 * the sym_val_to_name[], class_val_to_struct, role_val_to_struct, type_val_to_struct, 41 * user_val_to_struct, and bool_val_to_struct indexes. 42 */ 43 extern void test_policydb_indexes(policydb_t * p); 44 45 /* Test alias datum to ensure that it is as expected 46 * 47 * id = the key for the alias 48 * primary_id = the key for its primary 49 * mode: 0 = test the datum according to the flavor value in the call 50 1 = automatically detect the flavor value and test the datum accordingly 51 * flavor = flavor value if in mode 0 52 */ 53 extern void test_alias_datum(policydb_t * p, char *id, char *primary_id, char mode, unsigned int flavor); 54 55 /* p the policy being inspected 56 * id string role identifier 57 * decl the decl block which we are looking in for the role datum 58 * types the array of string types which we expect the role has in its type ebitmap 59 * len number of elements in types 60 * flags the expected flags in the role typeset (eg., * or ~) 61 * 62 * This is a utility function to test whether the type set associated with a role in a specific 63 * avrule decl block matches our expectations 64 */ 65 extern role_datum_t *test_role_type_set(policydb_t * p, char *id, avrule_decl_t * decl, char **types, unsigned int len, unsigned int flags); 66 67 /* p the policy being inspected 68 * id string attribute identifier 69 * decl the decl block which we are looking in for the attribute datum 70 * types the array of string types which we expect the attribute has in its type ebitmap 71 * len number of elements in types 72 * 73 * This is a utility function to test whether the type set associated with an attribute in a specific 74 * avrule decl block matches our expectations 75 */ 76 extern void test_attr_types(policydb_t * p, char *id, avrule_decl_t * decl, char **types, int len); 77 78 #endif 79