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