test-common.h revision 255e72915d4cbddceb435e13d81601755714e9f3
12a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)/*
22a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) * Author: Joshua Brindle <jbrindle@tresys.com>
32a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) *         Chad Sellers <csellers@tresys.com>
42a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) *
52a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) * Copyright (C) 2006 Tresys Technology, LLC
62a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) *
72a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) *  This library is free software; you can redistribute it and/or
82a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) *  modify it under the terms of the GNU Lesser General Public
92a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) *  License as published by the Free Software Foundation; either
102a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) *  version 2.1 of the License, or (at your option) any later version.
112a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) *
122a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) *  This library is distributed in the hope that it will be useful,
132a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) *  but WITHOUT ANY WARRANTY; without even the implied warranty of
142a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
152a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) *  Lesser General Public License for more details.
16c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) *
172a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) *  You should have received a copy of the GNU Lesser General Public
182a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) *  License along with this library; if not, write to the Free Software
19868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles) *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
20c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) */
21868fa2fe829687343ffae624259930155e16dbd8Torne (Richard Coles)
222a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#ifndef __TEST_COMMON_H__
232a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#define __TEST_COMMON_H__
242a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
252a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#include <sepol/policydb/policydb.h>
263551c9c881056c480085172ff9840cab31610854Torne (Richard Coles)
272a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)/* p		the policy being inspected
282a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) * id		string symbol identifier
292a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) * sym_type	symbol type (eg., SYM_ROLES, SYM_TYPES)
302a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) * scope_type	what scope the role should have (eg., SCOPE_DECL or SCOPE_REQ)
312a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) * decls	integer array of decl id's that we expect the role to have in the scope table
322a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) * len		number of elements in decls
332a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) *
342a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) * This is a utility function to test for the symbol's presence in the global symbol table,
352a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) * the scope table, and that the decl blocks we think this symbol is in are correct
362a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) */
372a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)extern void test_sym_presence(policydb_t * p, char *id, int sym_type, unsigned int scope_type, unsigned int *decls, unsigned int len);
382a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
392a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)/* Test the indexes in the policydb to ensure their correctness. These include
402a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) * the sym_val_to_name[], class_val_to_struct, role_val_to_struct, type_val_to_struct,
412a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) * user_val_to_struct, and bool_val_to_struct indexes.
422a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) */
432a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)extern void test_policydb_indexes(policydb_t * p);
442a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
452a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)/* Test alias datum to ensure that it is as expected
462a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) *
472a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) * id = the key for the alias
482a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) * primary_id = the key for its primary
492a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) * mode: 0 = test the datum according to the flavor value in the call
502a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)         1 = automatically detect the flavor value and test the datum accordingly
512a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) * flavor = flavor value if in mode 0
522a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) */
532a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)extern void test_alias_datum(policydb_t * p, char *id, char *primary_id, char mode, unsigned int flavor);
542a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
552a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)/* p		the policy being inspected
562a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) * id		string role identifier
572a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) * decl		the decl block which we are looking in for the role datum
58c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles) * types	the array of string types which we expect the role has in its type ebitmap
592a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) * len		number of elements in types
602a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) * flags	the expected flags in the role typeset (eg., * or ~)
612a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) *
622a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) * This is a utility function to test whether the type set associated with a role in a specific
632a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) * avrule decl block matches our expectations
642a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) */
652a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)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);
66c2e0dbddbe15c98d52c4786dac06cb8952a8ae6dTorne (Richard Coles)
672a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)/* p		the policy being inspected
682a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) * id		string attribute identifier
692a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) * decl		the decl block which we are looking in for the attribute datum
703551c9c881056c480085172ff9840cab31610854Torne (Richard Coles) * types	the array of string types which we expect the attribute has in its type ebitmap
712a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) * len		number of elements in types
722a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) *
732a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) * This is a utility function to test whether the type set associated with an attribute in a specific
742a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) * avrule decl block matches our expectations
752a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles) */
762a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)extern void test_attr_types(policydb_t * p, char *id, avrule_decl_t * decl, char **types, int len);
772a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)
782a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)#endif
792a99a7e74a7f215066514fe81d2bfa6639d9edddTorne (Richard Coles)