16cd6a6acSopenharmony_ci/*
26cd6a6acSopenharmony_ci * Author: Joshua Brindle <jbrindle@tresys.com>
36cd6a6acSopenharmony_ci *         Chad Sellers <csellers@tresys.com>
46cd6a6acSopenharmony_ci *
56cd6a6acSopenharmony_ci * Copyright (C) 2006 Tresys Technology, LLC
66cd6a6acSopenharmony_ci *
76cd6a6acSopenharmony_ci *  This library is free software; you can redistribute it and/or
86cd6a6acSopenharmony_ci *  modify it under the terms of the GNU Lesser General Public
96cd6a6acSopenharmony_ci *  License as published by the Free Software Foundation; either
106cd6a6acSopenharmony_ci *  version 2.1 of the License, or (at your option) any later version.
116cd6a6acSopenharmony_ci *
126cd6a6acSopenharmony_ci *  This library is distributed in the hope that it will be useful,
136cd6a6acSopenharmony_ci *  but WITHOUT ANY WARRANTY; without even the implied warranty of
146cd6a6acSopenharmony_ci *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
156cd6a6acSopenharmony_ci *  Lesser General Public License for more details.
166cd6a6acSopenharmony_ci *
176cd6a6acSopenharmony_ci *  You should have received a copy of the GNU Lesser General Public
186cd6a6acSopenharmony_ci *  License along with this library; if not, write to the Free Software
196cd6a6acSopenharmony_ci *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
206cd6a6acSopenharmony_ci */
216cd6a6acSopenharmony_ci
226cd6a6acSopenharmony_ci#ifndef __TEST_COMMON_H__
236cd6a6acSopenharmony_ci#define __TEST_COMMON_H__
246cd6a6acSopenharmony_ci
256cd6a6acSopenharmony_ci#include <sepol/policydb/policydb.h>
266cd6a6acSopenharmony_ci
276cd6a6acSopenharmony_ci/* p		the policy being inspected
286cd6a6acSopenharmony_ci * id		string symbol identifier
296cd6a6acSopenharmony_ci * sym_type	symbol type (eg., SYM_ROLES, SYM_TYPES)
306cd6a6acSopenharmony_ci * scope_type	what scope the role should have (eg., SCOPE_DECL or SCOPE_REQ)
316cd6a6acSopenharmony_ci * decls	integer array of decl id's that we expect the role to have in the scope table
326cd6a6acSopenharmony_ci * len		number of elements in decls
336cd6a6acSopenharmony_ci *
346cd6a6acSopenharmony_ci * This is a utility function to test for the symbol's presence in the global symbol table,
356cd6a6acSopenharmony_ci * the scope table, and that the decl blocks we think this symbol is in are correct
366cd6a6acSopenharmony_ci */
376cd6a6acSopenharmony_ciextern void test_sym_presence(policydb_t * p, const char *id, int sym_type, unsigned int scope_type, unsigned int *decls, unsigned int len);
386cd6a6acSopenharmony_ci
396cd6a6acSopenharmony_ci/* Test the indexes in the policydb to ensure their correctness. These include
406cd6a6acSopenharmony_ci * the sym_val_to_name[], class_val_to_struct, role_val_to_struct, type_val_to_struct,
416cd6a6acSopenharmony_ci * user_val_to_struct, and bool_val_to_struct indexes.
426cd6a6acSopenharmony_ci */
436cd6a6acSopenharmony_ciextern void test_policydb_indexes(policydb_t * p);
446cd6a6acSopenharmony_ci
456cd6a6acSopenharmony_ci/* Test alias datum to ensure that it is as expected
466cd6a6acSopenharmony_ci *
476cd6a6acSopenharmony_ci * id = the key for the alias
486cd6a6acSopenharmony_ci * primary_id = the key for its primary
496cd6a6acSopenharmony_ci * mode: 0 = test the datum according to the flavor value in the call
506cd6a6acSopenharmony_ci         1 = automatically detect the flavor value and test the datum accordingly
516cd6a6acSopenharmony_ci * flavor = flavor value if in mode 0
526cd6a6acSopenharmony_ci */
536cd6a6acSopenharmony_ciextern void test_alias_datum(policydb_t * p, const char *id, const char *primary_id, char mode, unsigned int flavor);
546cd6a6acSopenharmony_ci
556cd6a6acSopenharmony_ci/* p		the policy being inspected
566cd6a6acSopenharmony_ci * id		string role identifier
576cd6a6acSopenharmony_ci * decl		the decl block which we are looking in for the role datum
586cd6a6acSopenharmony_ci * types	the array of string types which we expect the role has in its type ebitmap
596cd6a6acSopenharmony_ci * len		number of elements in types
606cd6a6acSopenharmony_ci * flags	the expected flags in the role typeset (eg., * or ~)
616cd6a6acSopenharmony_ci *
626cd6a6acSopenharmony_ci * This is a utility function to test whether the type set associated with a role in a specific
636cd6a6acSopenharmony_ci * avrule decl block matches our expectations
646cd6a6acSopenharmony_ci */
656cd6a6acSopenharmony_ciextern 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);
666cd6a6acSopenharmony_ci
676cd6a6acSopenharmony_ci/* p		the policy being inspected
686cd6a6acSopenharmony_ci * id		string attribute identifier
696cd6a6acSopenharmony_ci * decl		the decl block which we are looking in for the attribute datum
706cd6a6acSopenharmony_ci * types	the array of string types which we expect the attribute has in its type ebitmap
716cd6a6acSopenharmony_ci * len		number of elements in types
726cd6a6acSopenharmony_ci *
736cd6a6acSopenharmony_ci * This is a utility function to test whether the type set associated with an attribute in a specific
746cd6a6acSopenharmony_ci * avrule decl block matches our expectations
756cd6a6acSopenharmony_ci */
766cd6a6acSopenharmony_ciextern void test_attr_types(policydb_t * p, const char *id, avrule_decl_t * decl, const char **types, int len);
776cd6a6acSopenharmony_ci
786cd6a6acSopenharmony_ci#endif
79