| 1 |
/* |
| 2 |
* Authors: Chad Sellers <[email protected]> |
| 3 |
* Joshua Brindle <[email protected]> |
| 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 |
#include "test-expander-attr-map.h" |
| 23 |
#include "test-common.h" |
| 24 |
#include "helpers.h" |
| 25 |
|
| 26 |
#include <sepol/policydb/policydb.h> |
| 27 |
#include <CUnit/Basic.h> |
| 28 |
#include <stdlib.h> |
| 29 |
|
| 30 |
extern policydb_t base_expanded2; |
| 31 |
|
| 32 |
void test_expander_attr_mapping(void) |
| 33 |
{ |
| 34 |
/* note that many cases are omitted because they don't make sense |
| 35 |
(i.e. declaring in an optional and then using it in the base) or |
| 36 |
because declare in optional then require in a different optional |
| 37 |
logic still doesn't work */ |
| 38 |
|
| 39 |
const char *typesb1[] = { "attr_check_base_1_1_t", "attr_check_base_1_2_t" }; |
| 40 |
const char *typesb2[] = { "attr_check_base_2_1_t", "attr_check_base_2_2_t" }; |
| 41 |
const char *typesb3[] = { "attr_check_base_3_1_t", "attr_check_base_3_2_t", |
| 42 |
"attr_check_base_3_3_t", "attr_check_base_3_4_t" |
| 43 |
}; |
| 44 |
const char *typesb4[] = { "attr_check_base_4_1_t", "attr_check_base_4_2_t" }; |
| 45 |
const char *typesb5[] = { "attr_check_base_5_1_t", "attr_check_base_5_2_t" }; |
| 46 |
const char *typesb6[] = { "attr_check_base_6_1_t", "attr_check_base_6_2_t", |
| 47 |
"attr_check_base_6_3_t", "attr_check_base_6_4_t" |
| 48 |
}; |
| 49 |
const char *typesbo2[] = { "attr_check_base_optional_2_1_t", |
| 50 |
"attr_check_base_optional_2_2_t" |
| 51 |
}; |
| 52 |
const char *typesbo5[] = { "attr_check_base_optional_5_1_t", |
| 53 |
"attr_check_base_optional_5_2_t" |
| 54 |
}; |
| 55 |
const char *typesm2[] = { "attr_check_mod_2_1_t", "attr_check_mod_2_2_t" }; |
| 56 |
const char *typesm4[] = { "attr_check_mod_4_1_t", "attr_check_mod_4_2_t" }; |
| 57 |
const char *typesm5[] = { "attr_check_mod_5_1_t", "attr_check_mod_5_2_t" }; |
| 58 |
const char *typesm6[] = { "attr_check_mod_6_1_t", "attr_check_mod_6_2_t", |
| 59 |
"attr_check_mod_6_3_t", "attr_check_mod_6_4_t" |
| 60 |
}; |
| 61 |
const char *typesmo2[] = { "attr_check_mod_optional_4_1_t", |
| 62 |
"attr_check_mod_optional_4_2_t" |
| 63 |
}; |
| 64 |
const char *typesb10[] = { "attr_check_base_10_1_t", "attr_check_base_10_2_t" }; |
| 65 |
const char *typesb11[] = { "attr_check_base_11_3_t", "attr_check_base_11_4_t" }; |
| 66 |
const char *typesm10[] = { "attr_check_mod_10_1_t", "attr_check_mod_10_2_t" }; |
| 67 |
const char *typesm11[] = { "attr_check_mod_11_3_t", "attr_check_mod_11_4_t" }; |
| 68 |
|
| 69 |
test_attr_types(&base_expanded2, "attr_check_base_1", NULL, typesb1, 2); |
| 70 |
test_attr_types(&base_expanded2, "attr_check_base_2", NULL, typesb2, 2); |
| 71 |
test_attr_types(&base_expanded2, "attr_check_base_3", NULL, typesb3, 4); |
| 72 |
test_attr_types(&base_expanded2, "attr_check_base_4", NULL, typesb4, 2); |
| 73 |
test_attr_types(&base_expanded2, "attr_check_base_5", NULL, typesb5, 2); |
| 74 |
test_attr_types(&base_expanded2, "attr_check_base_6", NULL, typesb6, 4); |
| 75 |
test_attr_types(&base_expanded2, "attr_check_base_optional_2", NULL, typesbo2, 2); |
| 76 |
test_attr_types(&base_expanded2, "attr_check_base_optional_5", NULL, typesbo5, 2); |
| 77 |
test_attr_types(&base_expanded2, "attr_check_mod_2", NULL, typesm2, 2); |
| 78 |
test_attr_types(&base_expanded2, "attr_check_mod_4", NULL, typesm4, 2); |
| 79 |
test_attr_types(&base_expanded2, "attr_check_mod_5", NULL, typesm5, 2); |
| 80 |
test_attr_types(&base_expanded2, "attr_check_mod_6", NULL, typesm6, 4); |
| 81 |
test_attr_types(&base_expanded2, "attr_check_mod_optional_4", NULL, typesmo2, 2); |
| 82 |
test_attr_types(&base_expanded2, "attr_check_base_7", NULL, NULL, 0); |
| 83 |
test_attr_types(&base_expanded2, "attr_check_base_8", NULL, NULL, 0); |
| 84 |
test_attr_types(&base_expanded2, "attr_check_base_9", NULL, NULL, 0); |
| 85 |
test_attr_types(&base_expanded2, "attr_check_base_10", NULL, typesb10, 2); |
| 86 |
test_attr_types(&base_expanded2, "attr_check_base_11", NULL, typesb11, 2); |
| 87 |
test_attr_types(&base_expanded2, "attr_check_mod_7", NULL, NULL, 0); |
| 88 |
test_attr_types(&base_expanded2, "attr_check_mod_8", NULL, NULL, 0); |
| 89 |
test_attr_types(&base_expanded2, "attr_check_mod_9", NULL, NULL, 0); |
| 90 |
test_attr_types(&base_expanded2, "attr_check_mod_10", NULL, typesm10, 2); |
| 91 |
test_attr_types(&base_expanded2, "attr_check_mod_11", NULL, typesm11, 2); |
| 92 |
test_attr_types(&base_expanded2, "attr_check_base_optional_8", NULL, NULL, 0); |
| 93 |
test_attr_types(&base_expanded2, "attr_check_mod_optional_7", NULL, NULL, 0); |
| 94 |
CU_ASSERT(!hashtab_search((&base_expanded2)->p_types.table, "attr_check_base_optional_disabled_5")); |
| 95 |
CU_ASSERT(!hashtab_search((&base_expanded2)->p_types.table, "attr_check_base_optional_disabled_5_1_t")); |
| 96 |
CU_ASSERT(!hashtab_search((&base_expanded2)->p_types.table, "attr_check_base_optional_disabled_5_2_t")); |
| 97 |
CU_ASSERT(!hashtab_search((&base_expanded2)->p_types.table, "attr_check_base_optional_disabled_8")); |
| 98 |
CU_ASSERT(!hashtab_search((&base_expanded2)->p_types.table, "attr_check_base_optional_disabled_8_1_t")); |
| 99 |
CU_ASSERT(!hashtab_search((&base_expanded2)->p_types.table, "attr_check_base_optional_disabled_8_2_t")); |
| 100 |
CU_ASSERT(!hashtab_search((&base_expanded2)->p_types.table, "attr_check_mod_optional_disabled_4")); |
| 101 |
CU_ASSERT(!hashtab_search((&base_expanded2)->p_types.table, "attr_check_mod_optional_disabled_4_1_t")); |
| 102 |
CU_ASSERT(!hashtab_search((&base_expanded2)->p_types.table, "attr_check_mod_optional_disabled_4_2_t")); |
| 103 |
CU_ASSERT(!hashtab_search((&base_expanded2)->p_types.table, "attr_check_mod_optional_disabled_7")); |
| 104 |
CU_ASSERT(!hashtab_search((&base_expanded2)->p_types.table, "attr_check_mod_optional_disabled_7_1_t")); |
| 105 |
CU_ASSERT(!hashtab_search((&base_expanded2)->p_types.table, "attr_check_mod_optional_disabled_7_2_t")); |
| 106 |
} |