Home | History | Annotate | Download | only in unit
      1 /*
      2  * Copyright 2011 Tresys Technology, LLC. All rights reserved.
      3  *
      4  * Redistribution and use in source and binary forms, with or without
      5  * modification, are permitted provided that the following conditions are met:
      6  *
      7  *    1. Redistributions of source code must retain the above copyright notice,
      8  *       this list of conditions and the following disclaimer.
      9  *
     10  *    2. Redistributions in binary form must reproduce the above copyright notice,
     11  *       this list of conditions and the following disclaimer in the documentation
     12  *       and/or other materials provided with the distribution.
     13  *
     14  * THIS SOFTWARE IS PROVIDED BY TRESYS TECHNOLOGY, LLC ``AS IS'' AND ANY EXPRESS
     15  * OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
     16  * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
     17  * EVENT SHALL TRESYS TECHNOLOGY, LLC OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
     18  * INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
     19  * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
     20  * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
     21  * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE
     22  * OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
     23  * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
     24  *
     25  * The views and conclusions contained in the software and documentation are those
     26  * of the authors and should not be interpreted as representing official policies,
     27  * either expressed or implied, of Tresys Technology, LLC.
     28  */
     29 
     30 #include <sepol/policydb/policydb.h>
     31 
     32 #include "CuTest.h"
     33 #include "CilTest.h"
     34 #include "test_cil_build_ast.h"
     35 
     36 #include "../../src/cil_build_ast.h"
     37 
     38 #include "../../src/cil_tree.h"
     39 
     40 int __cil_build_ast_node_helper(struct cil_tree_node *, uint32_t *, void *);
     41 int __cil_build_ast_last_child_helper(__attribute__((unused)) struct cil_tree_node *parse_current, void *);
     42 //int __cil_build_constrain_tree(struct cil_tree_node *parse_current, struct cil_tree_node *expr_root);
     43 
     44 struct cil_args_build {
     45 	struct cil_tree_node *ast;
     46 	struct cil_db *db;
     47 	struct cil_tree_node *macro;
     48 	struct cil_tree_node *tifstack;
     49 };
     50 
     51 struct cil_args_build *gen_build_args(struct cil_tree_node *node, struct cil_db *db, struct cil_tree_node * macro, struct cil_tree_node *tifstack)
     52 {
     53 	struct cil_args_build *args = cil_malloc(sizeof(*args));
     54 	args->ast = node;
     55 	args->db = db;
     56 	args->macro = macro;
     57 	args->tifstack = tifstack;
     58 
     59 	return args;
     60 }
     61 
     62 // First seen in cil_gen_common
     63 void test_cil_parse_to_list(CuTest *tc) {
     64 	char *line[] = {"(", "allow", "test", "foo", "(", "bar", "(", "read", "write", ")", ")", ")", NULL};
     65 
     66 	struct cil_tree *test_tree;
     67 	gen_test_tree(&test_tree, line);
     68 
     69 	struct cil_tree_node *test_current;
     70 	test_current = test_tree->root->cl_head->cl_head;
     71 
     72 	struct cil_avrule *test_avrule;
     73 	cil_avrule_init(&test_avrule);
     74 	test_avrule->rule_kind = CIL_AVRULE_ALLOWED;
     75 	test_avrule->src_str = cil_strdup(test_current->next->data);
     76 	test_avrule->tgt_str = cil_strdup(test_current->next->next->data);
     77 
     78 	cil_classpermset_init(&test_avrule->classpermset);
     79 
     80 	test_avrule->classpermset->class_str = cil_strdup(test_current->next->next->next->cl_head->data);
     81 
     82 	cil_permset_init(&test_avrule->classpermset->permset);
     83 
     84 	cil_list_init(&test_avrule->classpermset->permset->perms_list_str);
     85 
     86 	test_current = test_current->next->next->next->cl_head->next->cl_head;
     87 
     88 	int rc = cil_parse_to_list(test_current, test_avrule->classpermset->permset->perms_list_str, CIL_AST_STR);
     89 	CuAssertIntEquals(tc, SEPOL_OK, rc);
     90 
     91 	cil_destroy_avrule(test_avrule);
     92 }
     93 
     94 void test_cil_parse_to_list_currnull_neg(CuTest *tc) {
     95 	char *line[] = {"(", "allow", "test", "foo", "(", "bar", "(", "read", "write", ")", ")", ")", NULL};
     96 
     97 	struct cil_tree *test_tree;
     98 	gen_test_tree(&test_tree, line);
     99 
    100 	struct cil_tree_node *test_current;
    101 	test_current = test_tree->root->cl_head->cl_head;
    102 
    103 	struct cil_avrule *test_avrule;
    104 	cil_avrule_init(&test_avrule);
    105 	test_avrule->rule_kind = CIL_AVRULE_ALLOWED;
    106 	test_avrule->src_str = cil_strdup(test_current->next->data);
    107 	test_avrule->tgt_str = cil_strdup(test_current->next->next->data);
    108 
    109 	cil_classpermset_init(&test_avrule->classpermset);
    110 
    111 	test_avrule->classpermset->class_str = cil_strdup(test_current->next->next->next->cl_head->data);
    112 
    113 	cil_permset_init(&test_avrule->classpermset->permset);
    114 
    115 	cil_list_init(&test_avrule->classpermset->permset->perms_list_str);
    116 
    117 	test_current = NULL;
    118 
    119 	int rc = cil_parse_to_list(test_current, test_avrule->classpermset->permset->perms_list_str, CIL_AST_STR);
    120 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
    121 
    122 	cil_destroy_avrule(test_avrule);
    123 }
    124 
    125 void test_cil_parse_to_list_listnull_neg(CuTest *tc) {
    126 	char *line[] = {"(", "allow", "test", "foo", "(", "bar", "(", "read", "write", ")", ")", ")", NULL};
    127 
    128 	struct cil_tree *test_tree;
    129 	gen_test_tree(&test_tree, line);
    130 
    131 	struct cil_tree_node *test_current;
    132 	test_current = test_tree->root->cl_head->cl_head;
    133 
    134 	struct cil_avrule *test_avrule;
    135 	cil_avrule_init(&test_avrule);
    136 	test_avrule->rule_kind = CIL_AVRULE_ALLOWED;
    137 	test_avrule->src_str = cil_strdup(test_current->next->data);
    138 	test_avrule->tgt_str = cil_strdup(test_current->next->next->data);
    139 
    140 	cil_classpermset_init(&test_avrule->classpermset);
    141 
    142 	test_avrule->classpermset->class_str = cil_strdup(test_current->next->next->next->cl_head->data);
    143 
    144 	cil_permset_init(&test_avrule->classpermset->permset);
    145 
    146 	test_current = test_current->next->next->next->cl_head->next->cl_head;
    147 
    148 	int rc = cil_parse_to_list(test_current, test_avrule->classpermset->permset->perms_list_str, CIL_AST_STR);
    149 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
    150 
    151 	cil_destroy_avrule(test_avrule);
    152 }
    153 
    154 void test_cil_set_to_list(CuTest *tc) {
    155 	char *line[] = {"(", "foo1", "foo2", "(", "foo3", ")", ")", NULL};
    156 
    157 	struct cil_tree *test_tree;
    158 	struct cil_list *cil_l = NULL;
    159 	struct cil_list *sub_list = NULL;
    160 
    161 	gen_test_tree(&test_tree, line);
    162 	cil_list_init(&cil_l);
    163 
    164 	int rc = cil_set_to_list(test_tree->root->cl_head, cil_l, 1);
    165 	sub_list = (struct cil_list *)cil_l->head->next->next->data;
    166 
    167 	CuAssertIntEquals(tc, SEPOL_OK, rc);
    168 	CuAssertStrEquals(tc, "foo1", (char*)cil_l->head->data);
    169 	CuAssertStrEquals(tc, "foo2", (char*)cil_l->head->next->data);
    170 	CuAssertStrEquals(tc, "foo3", (char*)sub_list->head->data);
    171 }
    172 
    173 void test_cil_set_to_list_tree_node_null_neg(CuTest *tc) {
    174 	struct cil_list *cil_l = NULL;
    175 	int rc = cil_set_to_list(NULL, cil_l, 1);
    176 
    177 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
    178 }
    179 
    180 void test_cil_set_to_list_cl_head_null_neg(CuTest *tc) {
    181 	char *line[] = {"(", "foo", "bar", ")", NULL};
    182 
    183 	struct cil_list *cil_l;
    184 	struct cil_tree *test_tree = NULL;
    185 
    186 	cil_list_init(&cil_l);
    187 	gen_test_tree(&test_tree, line);
    188 	test_tree->root->cl_head = NULL;
    189 
    190 	int rc = cil_set_to_list(test_tree->root, cil_l, 1);
    191 
    192 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
    193 }
    194 
    195 void test_cil_set_to_list_listnull_neg(CuTest *tc) {
    196 	char *line[] = {"(", "foo1", "foo2", "foo3", ")", NULL};
    197 
    198 	struct cil_tree *test_tree = NULL;
    199 	gen_test_tree(&test_tree, line);
    200 
    201 	int rc = cil_set_to_list(test_tree->root, NULL, 1);
    202 
    203 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
    204 }
    205 
    206 void test_cil_gen_block(CuTest *tc) {
    207 	char *line[] = {"(", "block", "a", "(", "type", "log", ")", ")", NULL};
    208 
    209 	struct cil_tree *test_tree;
    210 	gen_test_tree(&test_tree, line);
    211 
    212 	struct cil_tree_node *test_ast_node;
    213 	cil_tree_node_init(&test_ast_node);
    214 
    215 	struct cil_db *test_db;
    216 	cil_db_init(&test_db);
    217 
    218 	test_ast_node->parent = test_db->ast->root;
    219 	test_ast_node->line = 1;
    220 
    221 	int rc = cil_gen_block(test_db, test_tree->root->cl_head->cl_head, test_ast_node, 0);
    222 	CuAssertIntEquals(tc, SEPOL_OK, rc);
    223 	CuAssertPtrNotNull(tc, test_ast_node->data);
    224 	CuAssertIntEquals(tc, ((struct cil_block*)test_ast_node->data)->is_abstract, 0);
    225 	CuAssertIntEquals(tc, test_ast_node->flavor, CIL_BLOCK);
    226 }
    227 
    228 void test_cil_gen_block_justblock_neg(CuTest *tc) {
    229 	char *line[] = {"(", "block", ")", NULL};
    230 
    231 	struct cil_tree *test_tree;
    232 	gen_test_tree(&test_tree, line);
    233 
    234 	struct cil_tree_node *test_ast_node;
    235 	cil_tree_node_init(&test_ast_node);
    236 
    237 	struct cil_db *test_db;
    238 	cil_db_init(&test_db);
    239 
    240 	test_ast_node->parent = test_db->ast->root;
    241 	test_ast_node->line = 1;
    242 
    243 	int rc = cil_gen_block(test_db, test_tree->root->cl_head->cl_head, test_ast_node, 0);
    244 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
    245 }
    246 
    247 void test_cil_gen_block_noname_neg(CuTest *tc) {
    248 	char *line[] = {"(", "block", "(", "type", "log", ")", ")", NULL};
    249 
    250 	struct cil_tree *test_tree;
    251 	gen_test_tree(&test_tree, line);
    252 
    253 	struct cil_tree_node *test_ast_node;
    254 	cil_tree_node_init(&test_ast_node);
    255 
    256 	struct cil_db *test_db;
    257 	cil_db_init(&test_db);
    258 
    259 	test_ast_node->parent = test_db->ast->root;
    260 	test_ast_node->line = 1;
    261 
    262 	int rc = cil_gen_block(test_db, test_tree->root->cl_head->cl_head, test_ast_node, 0);
    263 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
    264 }
    265 
    266 void test_cil_gen_block_dbnull_neg(CuTest *tc) {
    267 	char *line[] = {"(", "block", "foo", "(", "type", "log", ")", ")", NULL};
    268 
    269 	struct cil_tree *test_tree;
    270 	gen_test_tree(&test_tree, line);
    271 
    272 	struct cil_tree_node *test_ast_node;
    273 	cil_tree_node_init(&test_ast_node);
    274 
    275 	struct cil_db *test_db = NULL;
    276 
    277 	int rc = cil_gen_block(test_db, test_tree->root->cl_head->cl_head, test_ast_node, 0);
    278 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
    279 }
    280 
    281 void test_cil_gen_block_treenull_neg(CuTest *tc) {
    282 	char *line[] = {"(", "block", "foo", "(", "type", "log", ")", ")", NULL};
    283 
    284 	struct cil_tree *test_tree;
    285 	gen_test_tree(&test_tree, line);
    286 
    287 	struct cil_tree_node *test_ast_node;
    288 	cil_tree_node_init(&test_ast_node);
    289 
    290 	test_tree->root->cl_head->cl_head = NULL;
    291 
    292 	struct cil_db *test_db;
    293 	cil_db_init(&test_db);
    294 
    295 	test_ast_node->parent = test_db->ast->root;
    296 	test_ast_node->line = 1;
    297 
    298 	int rc = cil_gen_block(test_db, test_tree->root->cl_head->cl_head, test_ast_node, 0);
    299 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
    300 }
    301 
    302 void test_cil_gen_block_nodenull_neg(CuTest *tc) {
    303 	char *line[] = {"(", "block", "foo", "(", "type", "log", ")", ")", NULL};
    304 
    305 	struct cil_tree *test_tree;
    306 	gen_test_tree(&test_tree, line);
    307 
    308 	struct cil_tree_node *test_ast_node = NULL;
    309 
    310 	struct cil_db *test_db;
    311 	cil_db_init(&test_db);
    312 
    313 	int rc = cil_gen_block(test_db, test_tree->root->cl_head->cl_head, test_ast_node, 0);
    314 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
    315 }
    316 
    317 void test_cil_gen_block_nodeparentnull_neg(CuTest *tc) {
    318 	char *line[] = {"(", "block", "foo", "(", "type", "log", ")", ")", NULL};
    319 
    320 	struct cil_tree *test_tree;
    321 	gen_test_tree(&test_tree, line);
    322 
    323 	struct cil_tree_node *test_ast_node;
    324 	cil_tree_node_init(&test_ast_node);
    325 
    326 	struct cil_db *test_db;
    327 	cil_db_init(&test_db);
    328 
    329 	test_ast_node->parent = NULL;
    330 	test_ast_node->line = 1;
    331 
    332 	int rc = cil_gen_block(test_db, test_tree->root->cl_head->cl_head, test_ast_node, 0);
    333 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
    334 }
    335 
    336 void test_cil_destroy_block(CuTest *tc) {
    337 	char *line[] = {"(", "block", "a", "(", "type", "log", ")", ")", NULL};
    338 
    339 	struct cil_tree *test_tree;
    340 	gen_test_tree(&test_tree, line);
    341 
    342 	struct cil_tree_node *test_ast_node;
    343 	cil_tree_node_init(&test_ast_node);
    344 
    345 	struct cil_db *test_db;
    346 	cil_db_init(&test_db);
    347 
    348 	test_ast_node->parent = test_db->ast->root;
    349 	test_ast_node->line = 1;
    350 
    351 	cil_gen_block(test_db, test_tree->root->cl_head->cl_head, test_ast_node, 0);
    352 
    353 	cil_destroy_block((struct cil_block*)test_ast_node->data);
    354 	CuAssertPtrEquals(tc, NULL,test_ast_node->data);
    355 }
    356 
    357 void test_cil_gen_blockinherit(CuTest *tc) {
    358 	char *line[] = {"(", "blockinherit", "foo", ")", NULL};
    359 
    360 	struct cil_tree *test_tree;
    361 	gen_test_tree(&test_tree, line);
    362 
    363 	struct cil_tree_node *test_ast_node;
    364 	cil_tree_node_init(&test_ast_node);
    365 
    366 	struct cil_db *test_db;
    367 	cil_db_init(&test_db);
    368 
    369 	test_ast_node->parent = test_db->ast->root;
    370 	test_ast_node->line = 1;
    371 
    372 	int rc = cil_gen_blockinherit(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
    373 	CuAssertIntEquals(tc, SEPOL_OK, rc);
    374 }
    375 
    376 void test_cil_gen_blockinherit_namelist_neg(CuTest *tc) {
    377 	char *line[] = {"(", "blockinherit", "(", "foo", ")", ")", NULL};
    378 
    379 	struct cil_tree *test_tree;
    380 	gen_test_tree(&test_tree, line);
    381 
    382 	struct cil_tree_node *test_ast_node;
    383 	cil_tree_node_init(&test_ast_node);
    384 
    385 	struct cil_db *test_db;
    386 	cil_db_init(&test_db);
    387 
    388 	test_ast_node->parent = test_db->ast->root;
    389 	test_ast_node->line = 1;
    390 
    391 	int rc = cil_gen_blockinherit(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
    392 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
    393 }
    394 
    395 void test_cil_gen_blockinherit_namenull_neg(CuTest *tc) {
    396 	char *line[] = {"(", "blockinherit", ")", NULL};
    397 
    398 	struct cil_tree *test_tree;
    399 	gen_test_tree(&test_tree, line);
    400 
    401 	struct cil_tree_node *test_ast_node;
    402 	cil_tree_node_init(&test_ast_node);
    403 
    404 	struct cil_db *test_db;
    405 	cil_db_init(&test_db);
    406 
    407 	test_ast_node->parent = test_db->ast->root;
    408 	test_ast_node->line = 1;
    409 
    410 	int rc = cil_gen_blockinherit(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
    411 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
    412 }
    413 
    414 void test_cil_gen_blockinherit_extra_neg(CuTest *tc) {
    415 	char *line[] = {"(", "blockinherit", "foo", "extra", ")", NULL};
    416 
    417 	struct cil_tree *test_tree;
    418 	gen_test_tree(&test_tree, line);
    419 
    420 	struct cil_tree_node *test_ast_node;
    421 	cil_tree_node_init(&test_ast_node);
    422 
    423 	struct cil_db *test_db;
    424 	cil_db_init(&test_db);
    425 
    426 	test_ast_node->parent = test_db->ast->root;
    427 	test_ast_node->line = 1;
    428 
    429 	int rc = cil_gen_blockinherit(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
    430 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
    431 }
    432 
    433 void test_cil_gen_blockinherit_dbnull_neg(CuTest *tc) {
    434 	char *line[] = {"(", "blockinherit", "foo", "extra", ")", NULL};
    435 
    436 	struct cil_tree *test_tree;
    437 	gen_test_tree(&test_tree, line);
    438 
    439 	struct cil_tree_node *test_ast_node;
    440 	cil_tree_node_init(&test_ast_node);
    441 
    442 	struct cil_db *test_db = NULL;
    443 
    444 	int rc = cil_gen_blockinherit(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
    445 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
    446 }
    447 
    448 void test_cil_gen_blockinherit_currnull_neg(CuTest *tc) {
    449 	char *line[] = {"(", ")", NULL};
    450 
    451 	struct cil_tree *test_tree;
    452 	gen_test_tree(&test_tree, line);
    453 
    454 	struct cil_tree_node *test_ast_node;
    455 	cil_tree_node_init(&test_ast_node);
    456 
    457 	struct cil_db *test_db;
    458 	cil_db_init(&test_db);
    459 
    460 	test_ast_node->parent = test_db->ast->root;
    461 	test_ast_node->line = 1;
    462 
    463 	int rc = cil_gen_blockinherit(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
    464 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
    465 }
    466 
    467 void test_cil_gen_blockinherit_astnull_neg(CuTest *tc) {
    468 	char *line[] = {"(", "blockinherit", "foo", "extra", ")", NULL};
    469 
    470 	struct cil_tree *test_tree;
    471 	gen_test_tree(&test_tree, line);
    472 
    473 	struct cil_tree_node *test_ast_node = NULL;
    474 
    475 	struct cil_db *test_db;
    476 	cil_db_init(&test_db);
    477 
    478 	int rc = cil_gen_blockinherit(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
    479 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
    480 }
    481 
    482 void test_cil_gen_perm(CuTest *tc) {
    483 	char *line[] = {"(", "class", "foo", "(", "read", "write", "open", ")", ")", NULL};
    484 
    485 	struct cil_tree *test_tree;
    486 	gen_test_tree(&test_tree, line);
    487 
    488 	struct cil_tree_node *test_ast_node;
    489 	cil_tree_node_init(&test_ast_node);
    490 
    491 	struct cil_db *test_db;
    492 	cil_db_init(&test_db);
    493 
    494 	struct cil_class *new_node;
    495 	cil_class_init(&new_node);
    496 
    497 	struct cil_tree_node *new_tree_node;
    498 	cil_tree_node_init(&new_tree_node);
    499 	new_tree_node->data = new_node;
    500 	new_tree_node->flavor = CIL_CLASS;
    501 
    502 	test_ast_node->parent = new_tree_node;
    503 	test_ast_node->line = 1;
    504 
    505 	int rc = cil_gen_perm(test_db, test_tree->root->cl_head->cl_head->next->next->cl_head, test_ast_node);
    506 	int rc1 = cil_gen_perm(test_db, test_tree->root->cl_head->cl_head->next->next->cl_head->next, test_ast_node);
    507 	int rc2 = cil_gen_perm(test_db, test_tree->root->cl_head->cl_head->next->next->cl_head->next->next, test_ast_node);
    508 	CuAssertIntEquals(tc, SEPOL_OK, rc);
    509 	CuAssertIntEquals(tc, SEPOL_OK, rc1);
    510 	CuAssertIntEquals(tc, SEPOL_OK, rc2);
    511 }
    512 
    513 void test_cil_gen_perm_dbnull_neg(CuTest *tc) {
    514 	char *line[] = {"(", "class", "file", "(", "read", "write", "open", ")", ")", NULL};
    515 
    516 	int rc = 0;
    517 	struct cil_tree *test_tree;
    518 	gen_test_tree(&test_tree, line);
    519 
    520 	struct cil_tree_node *test_current_perm = NULL;
    521 	struct cil_tree_node *test_new_ast = NULL;
    522 	struct cil_tree_node *test_ast_node;
    523 	cil_tree_node_init(&test_ast_node);
    524 
    525 	struct cil_db *test_db = NULL;
    526 
    527 	test_current_perm = test_tree->root->cl_head->cl_head->next->next->cl_head;
    528 
    529 	cil_tree_node_init(&test_new_ast);
    530 	test_new_ast->parent = test_ast_node;
    531 	test_new_ast->line = test_current_perm->line;
    532 
    533 	rc = cil_gen_perm(test_db, test_current_perm, test_new_ast);
    534 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
    535 }
    536 
    537 void test_cil_gen_perm_currnull_neg(CuTest *tc) {
    538 	char *line[] = {"(", "class", "file", "(", "read", "write", "open", ")", ")", NULL};
    539 
    540 	int rc = 0;
    541 	struct cil_tree *test_tree;
    542 	gen_test_tree(&test_tree, line);
    543 
    544 	struct cil_tree_node *test_current_perm = NULL;
    545 	struct cil_tree_node *test_new_ast = NULL;
    546 	struct cil_tree_node *test_ast_node;
    547 	cil_tree_node_init(&test_ast_node);
    548 
    549 	struct cil_db *test_db;
    550 	cil_db_init(&test_db);
    551 
    552 	test_ast_node->parent = test_db->ast->root;
    553 	test_ast_node->line = 1;
    554 
    555 	test_current_perm = NULL;
    556 
    557 	cil_tree_node_init(&test_new_ast);
    558 	test_new_ast->parent = test_ast_node;
    559 
    560 	rc = cil_gen_perm(test_db, test_current_perm, test_new_ast);
    561 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
    562 }
    563 
    564 void test_cil_gen_perm_astnull_neg(CuTest *tc) {
    565 	char *line[] = {"(", "class", "foo", "(", "read", "write", "open", ")", ")", NULL};
    566 
    567 	struct cil_tree *test_tree;
    568 	gen_test_tree(&test_tree, line);
    569 
    570 	struct cil_tree_node *test_ast_node = NULL;
    571 
    572 	struct cil_db *test_db;
    573 	cil_db_init(&test_db);
    574 
    575 	struct cil_class *new_node;
    576 	cil_class_init(&new_node);
    577 
    578 	struct cil_tree_node *new_tree_node;
    579 	cil_tree_node_init(&new_tree_node);
    580 	new_tree_node->data = new_node;
    581 	new_tree_node->flavor = CIL_CLASS;
    582 
    583 	int rc = cil_gen_perm(test_db, test_tree->root->cl_head->cl_head->next->next->cl_head, test_ast_node);
    584 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
    585 }
    586 
    587 void test_cil_gen_perm_nodenull_neg(CuTest *tc) {
    588 	char *line[] = {"(", "class", "file", "(", "read", "write", "open", ")", ")", NULL};
    589 
    590 	int rc = 0;
    591 	struct cil_tree *test_tree;
    592 	gen_test_tree(&test_tree, line);
    593 
    594 	struct cil_tree_node *test_current_perm = NULL;
    595 	struct cil_tree_node *test_new_ast = NULL;
    596 	struct cil_tree_node *test_ast_node = NULL;
    597 
    598 	struct cil_db *test_db;
    599 	cil_db_init(&test_db);
    600 
    601 	test_current_perm = test_tree->root->cl_head->cl_head->next->next->cl_head;
    602 
    603 	cil_tree_node_init(&test_new_ast);
    604 	test_new_ast->parent = test_ast_node;
    605 	test_new_ast->line = test_current_perm->line;
    606 
    607 	rc = cil_gen_perm(test_db, test_current_perm, test_new_ast);
    608 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
    609 }
    610 
    611 void test_cil_gen_permset(CuTest *tc) {
    612 	char *line[] = {"(", "permissionset", "foo", "(", "read", "write", ")", ")", NULL};
    613 
    614 	struct cil_tree *test_tree;
    615 	gen_test_tree(&test_tree, line);
    616 
    617 	struct cil_tree_node *test_ast_node;
    618 	cil_tree_node_init(&test_ast_node);
    619 
    620 	struct cil_db *test_db;
    621 	cil_db_init(&test_db);
    622 
    623 	test_ast_node->parent = test_db->ast->root;
    624 	test_ast_node->line = 1;
    625 
    626 	int rc = cil_gen_permset(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
    627 	CuAssertIntEquals(tc, SEPOL_OK, rc);
    628 }
    629 
    630 void test_cil_gen_permset_noname_neg(CuTest *tc) {
    631 	char *line[] = {"(", "permissionset", ")", NULL};
    632 
    633 	struct cil_tree *test_tree;
    634 	gen_test_tree(&test_tree, line);
    635 
    636 	struct cil_tree_node *test_ast_node;
    637 	cil_tree_node_init(&test_ast_node);
    638 
    639 	struct cil_db *test_db;
    640 	cil_db_init(&test_db);
    641 
    642 	test_ast_node->parent = test_db->ast->root;
    643 	test_ast_node->line = 1;
    644 
    645 	int rc = cil_gen_permset(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
    646 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
    647 }
    648 
    649 void test_cil_gen_permset_nameinparens_neg(CuTest *tc) {
    650 	char *line[] = {"(", "permissionset", "(", "foo", ")", "(", "read", "write", ")", ")", NULL};
    651 
    652 	struct cil_tree *test_tree;
    653 	gen_test_tree(&test_tree, line);
    654 
    655 	struct cil_tree_node *test_ast_node;
    656 	cil_tree_node_init(&test_ast_node);
    657 
    658 	struct cil_db *test_db;
    659 	cil_db_init(&test_db);
    660 
    661 	test_ast_node->parent = test_db->ast->root;
    662 	test_ast_node->line = 1;
    663 
    664 	int rc = cil_gen_permset(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
    665 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
    666 }
    667 
    668 void test_cil_gen_permset_noperms_neg(CuTest *tc) {
    669 	char *line[] = {"(", "permissionset", "foo", ")", NULL};
    670 
    671 	struct cil_tree *test_tree;
    672 	gen_test_tree(&test_tree, line);
    673 
    674 	struct cil_tree_node *test_ast_node;
    675 	cil_tree_node_init(&test_ast_node);
    676 
    677 	struct cil_db *test_db;
    678 	cil_db_init(&test_db);
    679 
    680 	test_ast_node->parent = test_db->ast->root;
    681 	test_ast_node->line = 1;
    682 
    683 	int rc = cil_gen_permset(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
    684 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
    685 }
    686 
    687 void test_cil_gen_permset_emptyperms_neg(CuTest *tc) {
    688 	char *line[] = {"(", "permissionset", "foo", "(", ")", ")", NULL};
    689 
    690 	struct cil_tree *test_tree;
    691 	gen_test_tree(&test_tree, line);
    692 
    693 	struct cil_tree_node *test_ast_node;
    694 	cil_tree_node_init(&test_ast_node);
    695 
    696 	struct cil_db *test_db;
    697 	cil_db_init(&test_db);
    698 
    699 	test_ast_node->parent = test_db->ast->root;
    700 	test_ast_node->line = 1;
    701 
    702 	int rc = cil_gen_permset(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
    703 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
    704 }
    705 
    706 void test_cil_gen_permset_extra_neg(CuTest *tc) {
    707 	char *line[] = {"(", "permissionset", "foo", "(", "read", "write", ")", "extra", ")", NULL};
    708 
    709 	struct cil_tree *test_tree;
    710 	gen_test_tree(&test_tree, line);
    711 
    712 	struct cil_tree_node *test_ast_node;
    713 	cil_tree_node_init(&test_ast_node);
    714 
    715 	struct cil_db *test_db;
    716 	cil_db_init(&test_db);
    717 
    718 	test_ast_node->parent = test_db->ast->root;
    719 	test_ast_node->line = 1;
    720 
    721 	int rc = cil_gen_permset(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
    722 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
    723 }
    724 
    725 void test_cil_gen_permset_dbnull_neg(CuTest *tc) {
    726 	char *line[] = {"(", "permissionset", "foo", "(", "read", "write", ")", ")", NULL};
    727 
    728 	struct cil_tree *test_tree;
    729 	gen_test_tree(&test_tree, line);
    730 
    731 	struct cil_tree_node *test_ast_node;
    732 	cil_tree_node_init(&test_ast_node);
    733 
    734 	struct cil_db *test_db = NULL;
    735 
    736 	int rc = cil_gen_permset(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
    737 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
    738 }
    739 
    740 void test_cil_gen_permset_currnull_neg(CuTest *tc) {
    741 	char *line[] = {"(", ")", NULL};
    742 
    743 	struct cil_tree *test_tree;
    744 	gen_test_tree(&test_tree, line);
    745 
    746 	struct cil_tree_node *test_ast_node;
    747 	cil_tree_node_init(&test_ast_node);
    748 
    749 	struct cil_db *test_db;
    750 	cil_db_init(&test_db);
    751 
    752 	test_ast_node->parent = test_db->ast->root;
    753 	test_ast_node->line = 1;
    754 
    755 	int rc = cil_gen_permset(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
    756 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
    757 }
    758 
    759 void test_cil_gen_permset_astnull_neg(CuTest *tc) {
    760 	char *line[] = {"(", "permissionset", "foo", "(", "read", "write", ")", ")", NULL};
    761 
    762 	struct cil_tree *test_tree;
    763 	gen_test_tree(&test_tree, line);
    764 
    765 	struct cil_tree_node *test_ast_node = NULL;
    766 
    767 	struct cil_db *test_db;
    768 	cil_db_init(&test_db);
    769 
    770 	int rc = cil_gen_permset(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
    771 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
    772 }
    773 
    774 void test_cil_gen_perm_nodes(CuTest *tc) {
    775 	char *line[] = {"(", "class", "file", "(", "read", "write", "open", ")", ")", NULL};
    776 
    777 	struct cil_tree *test_tree;
    778 	gen_test_tree(&test_tree, line);
    779 
    780 	struct cil_tree_node *test_ast_node;
    781 	cil_tree_node_init(&test_ast_node);
    782 
    783 	struct cil_db *test_db;
    784 	cil_db_init(&test_db);
    785 
    786 	char *test_key = test_tree->root->cl_head->cl_head->next->data;
    787 	struct cil_class *test_cls;
    788 	cil_class_init(&test_cls);
    789 
    790 	test_ast_node->parent = test_db->ast->root;
    791 	test_ast_node->line = 1;
    792 
    793 	cil_symtab_insert(&test_db->symtab[CIL_SYM_CLASSES], (hashtab_key_t)test_key, (struct cil_symtab_datum*)test_cls, test_ast_node);
    794 
    795 	test_ast_node->data = test_cls;
    796 	test_ast_node->flavor = CIL_CLASS;
    797 
    798 	int rc = cil_gen_perm_nodes(test_db, test_tree->root->cl_head->cl_head->next->next->cl_head, test_ast_node, CIL_PERM);
    799 	CuAssertIntEquals(tc, SEPOL_OK, rc);
    800 }
    801 
    802 void test_cil_gen_perm_nodes_failgen_neg(CuTest *tc) {
    803 	char *line[] = {"(", "class", "file", "(", "read", "write", "open", ")", ")", NULL};
    804 
    805 	struct cil_tree *test_tree;
    806 	gen_test_tree(&test_tree, line);
    807 
    808 	struct cil_tree_node *test_ast_node;
    809 	cil_tree_node_init(&test_ast_node);
    810 
    811 	struct cil_db *test_db;
    812 	cil_db_init(&test_db);
    813 
    814 	char *test_key = test_tree->root->cl_head->cl_head->next->data;
    815 	struct cil_class *test_cls;
    816 	cil_class_init(&test_cls);
    817 
    818 	cil_symtab_destroy(&test_cls->perms);
    819 
    820 	test_ast_node->parent = test_db->ast->root;
    821 	test_ast_node->line = 1;
    822 
    823 	cil_symtab_insert(&test_db->symtab[CIL_SYM_CLASSES], (hashtab_key_t)test_key, (struct cil_symtab_datum*)test_cls, test_ast_node);
    824 
    825 	test_ast_node->data = test_cls;
    826 	test_ast_node->flavor = CIL_CLASS;
    827 
    828 	int rc = cil_gen_perm_nodes(test_db, test_tree->root->cl_head->cl_head->next->next->cl_head, test_ast_node, CIL_PERM);
    829 	CuAssertIntEquals(tc, SEPOL_ENOMEM, rc);
    830 }
    831 
    832 void test_cil_gen_perm_nodes_inval_perm_neg(CuTest *tc) {
    833 	char *line[] = {"(", "class", "file", "(", "read", "(", "write", "open", ")", ")", NULL};
    834 
    835 	struct cil_tree *test_tree;
    836 	gen_test_tree(&test_tree, line);
    837 
    838 	struct cil_tree_node *test_ast_node;
    839 	cil_tree_node_init(&test_ast_node);
    840 
    841 	struct cil_db *test_db;
    842 	cil_db_init(&test_db);
    843 
    844 	char *test_key = test_tree->root->cl_head->cl_head->next->data;
    845 	struct cil_class *test_cls;
    846 	cil_class_init(&test_cls);
    847 
    848 	test_ast_node->parent = test_db->ast->root;
    849 	test_ast_node->line = 1;
    850 
    851 	cil_symtab_insert(&test_db->symtab[CIL_SYM_CLASSES], (hashtab_key_t)test_key, (struct cil_symtab_datum*)test_cls, test_ast_node);
    852 
    853 	test_ast_node->data = test_cls;
    854 	test_ast_node->flavor = CIL_CLASS;
    855 
    856 	int rc = cil_gen_perm_nodes(test_db, test_tree->root->cl_head->cl_head->next->next->cl_head, test_ast_node, CIL_PERM);
    857 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
    858 }
    859 
    860 void test_cil_fill_permset(CuTest *tc) {
    861 	char *line[] = {"(", "permissionset", "foo", "(", "read", "write", ")", ")", NULL};
    862 
    863 	struct cil_tree *test_tree;
    864 	gen_test_tree(&test_tree, line);
    865 
    866 	struct cil_tree_node *test_ast_node;
    867 	cil_tree_node_init(&test_ast_node);
    868 
    869 	struct cil_permset *permset;
    870 	cil_permset_init(&permset);
    871 
    872 	int rc = cil_fill_permset(test_tree->root->cl_head->cl_head->next->next->cl_head, permset);
    873 	CuAssertIntEquals(tc, SEPOL_OK, rc);
    874 }
    875 
    876 void test_cil_fill_permset_sublist_neg(CuTest *tc) {
    877 	char *line[] = {"(", "permissionset", "foo", "(", "read", "(", "write", ")", ")", ")", NULL};
    878 
    879 	struct cil_tree *test_tree;
    880 	gen_test_tree(&test_tree, line);
    881 
    882 	struct cil_tree_node *test_ast_node;
    883 	cil_tree_node_init(&test_ast_node);
    884 
    885 	struct cil_permset *permset;
    886 	cil_permset_init(&permset);
    887 
    888 	int rc = cil_fill_permset(test_tree->root->cl_head->cl_head->next->next->cl_head, permset);
    889 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
    890 }
    891 
    892 void test_cil_fill_permset_startpermnull_neg(CuTest *tc) {
    893 	char *line[] = {"(", "permissionset", "foo", "(", ")", ")", NULL};
    894 
    895 	struct cil_tree *test_tree;
    896 	gen_test_tree(&test_tree, line);
    897 
    898 	struct cil_tree_node *test_ast_node;
    899 	cil_tree_node_init(&test_ast_node);
    900 
    901 	struct cil_permset *permset;
    902 	cil_permset_init(&permset);
    903 
    904 	int rc = cil_fill_permset(test_tree->root->cl_head->cl_head->next->next->cl_head, permset);
    905 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
    906 }
    907 
    908 void test_cil_fill_permset_permsetnull_neg(CuTest *tc) {
    909 	char *line[] = {"(", "permissionset", "foo", "(", "read", "write", ")", ")", NULL};
    910 
    911 	struct cil_tree *test_tree;
    912 	gen_test_tree(&test_tree, line);
    913 
    914 	struct cil_tree_node *test_ast_node;
    915 	cil_tree_node_init(&test_ast_node);
    916 
    917 	struct cil_permset *permset = NULL;
    918 
    919 	int rc = cil_fill_permset(test_tree->root->cl_head->cl_head->next->next->cl_head, permset);
    920 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
    921 }
    922 
    923 void test_cil_gen_in(CuTest *tc) {
    924 	char *line[] = {"(", "in", "foo", "(", "allow", "test", "baz", "(", "char", "(", "read", ")", ")", ")", ")", NULL};
    925 
    926 	struct cil_tree *test_tree;
    927 	gen_test_tree(&test_tree, line);
    928 
    929 	struct cil_tree_node *test_ast_node;
    930 	cil_tree_node_init(&test_ast_node);
    931 
    932 	struct cil_db *test_db;
    933 	cil_db_init(&test_db);
    934 
    935 	test_ast_node->parent = test_db->ast->root;
    936 	test_ast_node->line = 1;
    937 
    938 	int rc = cil_gen_in(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
    939 	CuAssertIntEquals(tc, SEPOL_OK, rc);
    940 }
    941 
    942 void test_cil_gen_in_blockstrnull_neg(CuTest *tc) {
    943 	char *line[] = {"(", "in", ")", NULL};
    944 
    945 	struct cil_tree *test_tree;
    946 	gen_test_tree(&test_tree, line);
    947 
    948 	struct cil_tree_node *test_ast_node;
    949 	cil_tree_node_init(&test_ast_node);
    950 
    951 	struct cil_db *test_db;
    952 	cil_db_init(&test_db);
    953 
    954 	test_ast_node->parent = test_db->ast->root;
    955 	test_ast_node->line = 1;
    956 
    957 	int rc = cil_gen_in(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
    958 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
    959 }
    960 
    961 void test_cil_gen_in_extra_neg(CuTest *tc) {
    962 	char *line[] = {"(", "in", "foo", "(", "allow", "test", "baz", "(", "char", "(", "read", ")", ")", ")", "extra", ")", NULL};
    963 
    964 	struct cil_tree *test_tree;
    965 	gen_test_tree(&test_tree, line);
    966 
    967 	struct cil_tree_node *test_ast_node;
    968 	cil_tree_node_init(&test_ast_node);
    969 
    970 	struct cil_db *test_db;
    971 	cil_db_init(&test_db);
    972 
    973 	test_ast_node->parent = test_db->ast->root;
    974 	test_ast_node->line = 1;
    975 
    976 	int rc = cil_gen_in(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
    977 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
    978 }
    979 
    980 void test_cil_gen_in_dbnull_neg(CuTest *tc) {
    981 	char *line[] = {"(", "in", "foo", "(", "allow", "test", "baz", "(", "char", "(", "read", ")", ")", ")", ")", NULL};
    982 
    983 	struct cil_tree *test_tree;
    984 	gen_test_tree(&test_tree, line);
    985 
    986 	struct cil_tree_node *test_ast_node;
    987 	cil_tree_node_init(&test_ast_node);
    988 
    989 	struct cil_db *test_db = NULL;
    990 
    991 	int rc = cil_gen_in(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
    992 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
    993 }
    994 
    995 void test_cil_gen_in_currnull_neg(CuTest *tc) {
    996 	char *line[] = {"(", ")", NULL};
    997 
    998 	struct cil_tree *test_tree;
    999 	gen_test_tree(&test_tree, line);
   1000 
   1001 	struct cil_tree_node *test_ast_node;
   1002 	cil_tree_node_init(&test_ast_node);
   1003 
   1004 	struct cil_db *test_db;
   1005 	cil_db_init(&test_db);
   1006 
   1007 	test_ast_node->parent = test_db->ast->root;
   1008 	test_ast_node->line = 1;
   1009 
   1010 	int rc = cil_gen_in(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   1011 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   1012 }
   1013 
   1014 void test_cil_gen_in_astnull_neg(CuTest *tc) {
   1015 	char *line[] = {"(", "in", "foo", "(", "allow", "test", "baz", "(", "char", "(", "read", ")", ")", ")", ")", NULL};
   1016 
   1017 	struct cil_tree *test_tree;
   1018 	gen_test_tree(&test_tree, line);
   1019 
   1020 	struct cil_tree_node *test_ast_node = NULL;
   1021 
   1022 	struct cil_db *test_db;
   1023 	cil_db_init(&test_db);
   1024 
   1025 	int rc = cil_gen_in(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   1026 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   1027 }
   1028 
   1029 void test_cil_gen_class(CuTest *tc) {
   1030 	char *line[] = {"(", "class", "file", "(", "read", "write", "open", ")", ")", NULL};
   1031 
   1032 	struct cil_tree *test_tree;
   1033 	gen_test_tree(&test_tree, line);
   1034 
   1035 	struct cil_tree_node *test_ast_node;
   1036 	cil_tree_node_init(&test_ast_node);
   1037 
   1038 	struct cil_db *test_db;
   1039 	cil_db_init(&test_db);
   1040 
   1041 	test_ast_node->parent = test_db->ast->root;
   1042 	test_ast_node->line = 1;
   1043 
   1044 	int rc = cil_gen_class(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   1045 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   1046 	CuAssertPtrNotNull(tc, test_ast_node->cl_tail);
   1047 	CuAssertPtrNotNull(tc, test_ast_node->data);
   1048 	CuAssertIntEquals(tc, test_ast_node->flavor, CIL_CLASS);
   1049 }
   1050 
   1051 void test_cil_gen_class_noname_neg(CuTest *tc) {
   1052 	char *line[] = {"(", "class", "(", "read", "write", "open", ")", ")", NULL};
   1053 
   1054 	struct cil_tree *test_tree;
   1055 	gen_test_tree(&test_tree, line);
   1056 
   1057 	struct cil_tree_node *test_ast_node;
   1058 	cil_tree_node_init(&test_ast_node);
   1059 
   1060 	struct cil_db *test_db;
   1061 	cil_db_init(&test_db);
   1062 
   1063 	test_ast_node->parent = test_db->ast->root;
   1064 	test_ast_node->line = 1;
   1065 
   1066 	int rc = cil_gen_class(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   1067 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   1068 }
   1069 
   1070 void test_cil_gen_class_nodenull_neg(CuTest *tc) {
   1071 	char *line[] = {"(", "class", "(", "read", "write", "open", ")", ")", NULL};
   1072 
   1073 	struct cil_tree *test_tree;
   1074 	gen_test_tree(&test_tree, line);
   1075 
   1076 	struct cil_tree_node *test_ast_node = NULL;
   1077 
   1078 	struct cil_db *test_db;
   1079 	cil_db_init(&test_db);
   1080 
   1081 	int rc = cil_gen_class(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   1082 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   1083 }
   1084 
   1085 void test_cil_gen_class_dbnull_neg(CuTest *tc) {
   1086 	char *line[] = {"(", "class", "(", "read", "write", "open", ")", ")", NULL};
   1087 
   1088 	struct cil_tree *test_tree;
   1089 	gen_test_tree(&test_tree, line);
   1090 
   1091 	struct cil_tree_node *test_ast_node;
   1092 	cil_tree_node_init(&test_ast_node);
   1093 
   1094 	struct cil_db *test_db = NULL;
   1095 
   1096 	int rc = cil_gen_class(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   1097 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   1098 }
   1099 
   1100 void test_cil_gen_class_currnull_neg(CuTest *tc) {
   1101 	char *line[] = {"(", "class", "(", "read", "write", "open", ")", ")", NULL};
   1102 
   1103 	struct cil_tree *test_tree;
   1104 	gen_test_tree(&test_tree, line);
   1105 
   1106 	struct cil_tree_node *test_ast_node;
   1107 	cil_tree_node_init(&test_ast_node);
   1108 
   1109 	struct cil_db *test_db;
   1110 	cil_db_init(&test_db);
   1111 
   1112 	test_tree->root->cl_head->cl_head = NULL;
   1113 
   1114 	int rc = cil_gen_class(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   1115 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   1116 }
   1117 
   1118 void test_cil_gen_class_noclass_neg(CuTest *tc) {
   1119 	char *line[] = {"(", "test", "read", "write", "open", ")", ")", NULL};
   1120 
   1121 	struct cil_tree *test_tree;
   1122 	gen_test_tree(&test_tree, line);
   1123 
   1124 	struct cil_tree_node *test_ast_node;
   1125 	cil_tree_node_init(&test_ast_node);
   1126 
   1127 	struct cil_db *test_db;
   1128 	cil_db_init(&test_db);
   1129 
   1130 	test_ast_node->parent = test_db->ast->root;
   1131 	test_ast_node->line = 1;
   1132 
   1133 	int rc = cil_gen_class(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   1134 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   1135 }
   1136 
   1137 void test_cil_gen_class_noclassname_neg(CuTest *tc) {
   1138 	char *line[] = {"(", "class", ")", NULL};
   1139 
   1140 	struct cil_tree *test_tree;
   1141 	gen_test_tree(&test_tree, line);
   1142 
   1143 	struct cil_tree_node *test_ast_node;
   1144 	cil_tree_node_init(&test_ast_node);
   1145 
   1146 	struct cil_db *test_db;
   1147 	cil_db_init(&test_db);
   1148 
   1149 	test_ast_node->parent = test_db->ast->root;
   1150 	test_ast_node->line = 1;
   1151 
   1152 	int rc = cil_gen_class(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   1153 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   1154 }
   1155 
   1156 void test_cil_gen_class_namesublist_neg(CuTest *tc) {
   1157 	char *line[] = {"(", "class", "(", "foo", ")", ")", NULL};
   1158 
   1159 	struct cil_tree *test_tree;
   1160 	gen_test_tree(&test_tree, line);
   1161 
   1162 	struct cil_tree_node *test_ast_node;
   1163 	cil_tree_node_init(&test_ast_node);
   1164 
   1165 	struct cil_db *test_db;
   1166 	cil_db_init(&test_db);
   1167 
   1168 	test_ast_node->parent = test_db->ast->root;
   1169 	test_ast_node->line = 1;
   1170 
   1171 	int rc = cil_gen_class(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   1172 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   1173 }
   1174 
   1175 void test_cil_gen_class_noperms(CuTest *tc) {
   1176 	char *line[] = {"(", "class", "foo", ")", NULL};
   1177 
   1178 	struct cil_tree *test_tree;
   1179 	gen_test_tree(&test_tree, line);
   1180 
   1181 	struct cil_tree_node *test_ast_node;
   1182 	cil_tree_node_init(&test_ast_node);
   1183 
   1184 	struct cil_db *test_db;
   1185 	cil_db_init(&test_db);
   1186 
   1187 	test_ast_node->parent = test_db->ast->root;
   1188 	test_ast_node->line = 1;
   1189 
   1190 	int rc = cil_gen_class(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   1191 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   1192 }
   1193 
   1194 void test_cil_gen_class_permsnotinlist_neg(CuTest *tc) {
   1195 	char *line[] = {"(", "class", "foo", "read", "write", ")", NULL};
   1196 
   1197 	struct cil_tree *test_tree;
   1198 	gen_test_tree(&test_tree, line);
   1199 
   1200 	struct cil_tree_node *test_ast_node;
   1201 	cil_tree_node_init(&test_ast_node);
   1202 
   1203 	struct cil_db *test_db;
   1204 	cil_db_init(&test_db);
   1205 
   1206 	test_ast_node->parent = test_db->ast->root;
   1207 	test_ast_node->line = 1;
   1208 
   1209 	int rc = cil_gen_class(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   1210 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   1211 }
   1212 
   1213 void test_cil_gen_class_extrapermlist_neg(CuTest *tc) {
   1214 	char *line[] = {"(", "class", "foo", "(", "read", ")", "(", "write", ")", ")", NULL};
   1215 
   1216 	struct cil_tree *test_tree;
   1217 	gen_test_tree(&test_tree, line);
   1218 
   1219 	struct cil_tree_node *test_ast_node;
   1220 	cil_tree_node_init(&test_ast_node);
   1221 
   1222 	struct cil_db *test_db;
   1223 	cil_db_init(&test_db);
   1224 
   1225 	test_ast_node->parent = test_db->ast->root;
   1226 	test_ast_node->line = 1;
   1227 
   1228 	int rc = cil_gen_class(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   1229 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   1230 }
   1231 
   1232 void test_cil_gen_class_listinlist_neg(CuTest *tc) {
   1233         char *line[] = {"(", "class", "test", "(", "read", "(", "write", ")", ")", ")", NULL};
   1234 
   1235 	struct cil_tree *test_tree;
   1236 	gen_test_tree(&test_tree, line);
   1237 
   1238 	struct cil_tree_node *test_ast_node;
   1239 	cil_tree_node_init(&test_ast_node);
   1240 
   1241 	struct cil_db *test_db;
   1242 	cil_db_init(&test_db);
   1243 
   1244 	test_ast_node->parent = test_db->ast->root;
   1245 	test_ast_node->line = 1;
   1246 
   1247 	int rc = cil_gen_class(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   1248 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   1249 }
   1250 
   1251 void test_cil_fill_classpermset_anonperms(CuTest *tc) {
   1252 	char *line[] = {"(", "classpermissionset", "char_w", "(", "char", "(", "write", ")", ")", ")", NULL};
   1253 
   1254 	struct cil_tree *test_tree;
   1255 	gen_test_tree(&test_tree, line);
   1256 
   1257 	struct cil_tree_node *test_ast_node;
   1258 	cil_tree_node_init(&test_ast_node);
   1259 
   1260 	struct cil_classpermset *cps;
   1261 	cil_classpermset_init(&cps);
   1262 
   1263 	int rc = cil_fill_classpermset(test_tree->root->cl_head->cl_head->next->next->cl_head, cps);
   1264 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   1265 }
   1266 
   1267 void test_cil_fill_classpermset_anonperms_neg(CuTest *tc) {
   1268 	char *line[] = {"(", "classpermissionset", "char_w", "(", "char", "(", "write", "(", "extra", ")", ")", ")", ")", NULL};
   1269 
   1270 	struct cil_tree *test_tree;
   1271 	gen_test_tree(&test_tree, line);
   1272 
   1273 	struct cil_tree_node *test_ast_node;
   1274 	cil_tree_node_init(&test_ast_node);
   1275 
   1276 	struct cil_classpermset *cps;
   1277 	cil_classpermset_init(&cps);
   1278 
   1279 	int rc = cil_fill_classpermset(test_tree->root->cl_head->cl_head->next->next->cl_head, cps);
   1280 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   1281 }
   1282 
   1283 void test_cil_fill_classpermset_namedperms(CuTest *tc) {
   1284 	char *line[] = {"(", "classpermissionset", "char_w", "(", "char", "perms", ")", ")", NULL};
   1285 
   1286 	struct cil_tree *test_tree;
   1287 	gen_test_tree(&test_tree, line);
   1288 
   1289 	struct cil_tree_node *test_ast_node;
   1290 	cil_tree_node_init(&test_ast_node);
   1291 
   1292 	struct cil_classpermset *cps;
   1293 	cil_classpermset_init(&cps);
   1294 
   1295 	int rc = cil_fill_classpermset(test_tree->root->cl_head->cl_head->next->next->cl_head, cps);
   1296 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   1297 }
   1298 
   1299 void test_cil_fill_classpermset_extra_neg(CuTest *tc) {
   1300 	char *line[] = {"(", "classpermissionset", "char_w", "(", "char", "(", "write", ")", "extra", ")", ")", NULL};
   1301 
   1302 	struct cil_tree *test_tree;
   1303 	gen_test_tree(&test_tree, line);
   1304 
   1305 	struct cil_tree_node *test_ast_node;
   1306 	cil_tree_node_init(&test_ast_node);
   1307 
   1308 	struct cil_classpermset *cps;
   1309 	cil_classpermset_init(&cps);
   1310 
   1311 	int rc = cil_fill_classpermset(test_tree->root->cl_head->cl_head->next->next->cl_head, cps);
   1312 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   1313 }
   1314 
   1315 void test_cil_fill_classpermset_emptypermslist_neg(CuTest *tc) {
   1316 	char *line[] = {"(", "classpermissionset", "char_w", "(", "char", "(", ")", ")", ")", NULL};
   1317 
   1318 	struct cil_tree *test_tree;
   1319 	gen_test_tree(&test_tree, line);
   1320 
   1321 	struct cil_tree_node *test_ast_node;
   1322 	cil_tree_node_init(&test_ast_node);
   1323 
   1324 	struct cil_classpermset *cps;
   1325 	cil_classpermset_init(&cps);
   1326 
   1327 	int rc = cil_fill_classpermset(test_tree->root->cl_head->cl_head->next->next->cl_head, cps);
   1328 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   1329 }
   1330 
   1331 void test_cil_fill_classpermset_noperms_neg(CuTest *tc) {
   1332 	char *line[] = {"(", "classpermissionset", "char_w", "(", "char", ")", ")", NULL};
   1333 
   1334 	struct cil_tree *test_tree;
   1335 	gen_test_tree(&test_tree, line);
   1336 
   1337 	struct cil_tree_node *test_ast_node;
   1338 	cil_tree_node_init(&test_ast_node);
   1339 
   1340 	struct cil_classpermset *cps;
   1341 	cil_classpermset_init(&cps);
   1342 
   1343 	int rc = cil_fill_classpermset(test_tree->root->cl_head->cl_head->next->next->cl_head, cps);
   1344 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   1345 }
   1346 
   1347 void test_cil_fill_classpermset_noclass_neg(CuTest *tc) {
   1348 	char *line[] = {"(", "classpermissionset", "char_w", "(", "(", "write", ")", ")", ")", NULL};
   1349 
   1350 	struct cil_tree *test_tree;
   1351 	gen_test_tree(&test_tree, line);
   1352 
   1353 	struct cil_tree_node *test_ast_node;
   1354 	cil_tree_node_init(&test_ast_node);
   1355 
   1356 	struct cil_classpermset *cps;
   1357 	cil_classpermset_init(&cps);
   1358 
   1359 	int rc = cil_fill_classpermset(test_tree->root->cl_head->cl_head->next->next->cl_head, cps);
   1360 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   1361 }
   1362 
   1363 void test_cil_fill_classpermset_classnodenull_neg(CuTest *tc) {
   1364 	char *line[] = {"(", "classpermissionset", "char_w", "(", ")", ")", NULL};
   1365 
   1366 	struct cil_tree *test_tree;
   1367 	gen_test_tree(&test_tree, line);
   1368 
   1369 	struct cil_tree_node *test_ast_node;
   1370 	cil_tree_node_init(&test_ast_node);
   1371 
   1372 	struct cil_classpermset *cps;
   1373 	cil_classpermset_init(&cps);
   1374 
   1375 	int rc = cil_fill_classpermset(test_tree->root->cl_head->cl_head->next->next->cl_head, cps);
   1376 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   1377 }
   1378 
   1379 void test_cil_fill_classpermset_cpsnull_neg(CuTest *tc) {
   1380 	char *line[] = {"(", "classpermissionset", "char_w", "(", "char", "(", "read", ")", ")", ")", NULL};
   1381 
   1382 	struct cil_tree *test_tree;
   1383 	gen_test_tree(&test_tree, line);
   1384 
   1385 	struct cil_tree_node *test_ast_node;
   1386 	cil_tree_node_init(&test_ast_node);
   1387 
   1388 	struct cil_classpermset *cps = NULL;
   1389 
   1390 	int rc = cil_fill_classpermset(test_tree->root->cl_head->cl_head->next->next->cl_head, cps);
   1391 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   1392 }
   1393 
   1394 void test_cil_gen_classpermset(CuTest *tc) {
   1395 	char *line[] = {"(", "classpermissionset", "char_w", "(", "char", "(", "write", ")", ")", ")", NULL};
   1396 
   1397 	struct cil_tree *test_tree;
   1398 	gen_test_tree(&test_tree, line);
   1399 
   1400 	struct cil_tree_node *test_ast_node;
   1401 	cil_tree_node_init(&test_ast_node);
   1402 
   1403 	struct cil_db *test_db;
   1404 	cil_db_init(&test_db);
   1405 
   1406 	test_ast_node->parent = test_db->ast->root;
   1407 	test_ast_node->line = 1;
   1408 
   1409 	int rc = cil_gen_classpermset(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   1410 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   1411 }
   1412 
   1413 void test_cil_gen_classpermset_noname_neg(CuTest *tc) {
   1414 	char *line[] = {"(", "classpermissionset", ")", NULL};
   1415 
   1416 	struct cil_tree *test_tree;
   1417 	gen_test_tree(&test_tree, line);
   1418 
   1419 	struct cil_tree_node *test_ast_node;
   1420 	cil_tree_node_init(&test_ast_node);
   1421 
   1422 	struct cil_db *test_db;
   1423 	cil_db_init(&test_db);
   1424 
   1425 	test_ast_node->parent = test_db->ast->root;
   1426 	test_ast_node->line = 1;
   1427 
   1428 	int rc = cil_gen_classpermset(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   1429 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   1430 }
   1431 
   1432 void test_cil_gen_classpermset_nameinparens_neg(CuTest *tc) {
   1433 	char *line[] = {"(", "classpermissionset", "(", "foo", ")", "(", "read", "(", "write", ")", ")", ")", NULL};
   1434 
   1435 	struct cil_tree *test_tree;
   1436 	gen_test_tree(&test_tree, line);
   1437 
   1438 	struct cil_tree_node *test_ast_node;
   1439 	cil_tree_node_init(&test_ast_node);
   1440 
   1441 	struct cil_db *test_db;
   1442 	cil_db_init(&test_db);
   1443 
   1444 	test_ast_node->parent = test_db->ast->root;
   1445 	test_ast_node->line = 1;
   1446 
   1447 	int rc = cil_gen_classpermset(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   1448 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   1449 }
   1450 
   1451 void test_cil_gen_classpermset_noclass_neg(CuTest *tc) {
   1452 	char *line[] = {"(", "classpermissionset", "foo", ")", NULL};
   1453 
   1454 	struct cil_tree *test_tree;
   1455 	gen_test_tree(&test_tree, line);
   1456 
   1457 	struct cil_tree_node *test_ast_node;
   1458 	cil_tree_node_init(&test_ast_node);
   1459 
   1460 	struct cil_db *test_db;
   1461 	cil_db_init(&test_db);
   1462 
   1463 	test_ast_node->parent = test_db->ast->root;
   1464 	test_ast_node->line = 1;
   1465 
   1466 	int rc = cil_gen_classpermset(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   1467 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   1468 }
   1469 
   1470 void test_cil_gen_classpermset_noperms_neg(CuTest *tc) {
   1471 	char *line[] = {"(", "classpermissionset", "foo", "(", "char", ")", ")", ")", NULL};
   1472 
   1473 	struct cil_tree *test_tree;
   1474 	gen_test_tree(&test_tree, line);
   1475 
   1476 	struct cil_tree_node *test_ast_node;
   1477 	cil_tree_node_init(&test_ast_node);
   1478 
   1479 	struct cil_db *test_db;
   1480 	cil_db_init(&test_db);
   1481 
   1482 	test_ast_node->parent = test_db->ast->root;
   1483 	test_ast_node->line = 1;
   1484 
   1485 	int rc = cil_gen_classpermset(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   1486 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   1487 }
   1488 
   1489 void test_cil_gen_classpermset_emptyperms_neg(CuTest *tc) {
   1490 	char *line[] = {"(", "classpermissionset", "foo", "(", ")", ")", NULL};
   1491 
   1492 	struct cil_tree *test_tree;
   1493 	gen_test_tree(&test_tree, line);
   1494 
   1495 	struct cil_tree_node *test_ast_node;
   1496 	cil_tree_node_init(&test_ast_node);
   1497 
   1498 	struct cil_db *test_db;
   1499 	cil_db_init(&test_db);
   1500 
   1501 	test_ast_node->parent = test_db->ast->root;
   1502 	test_ast_node->line = 1;
   1503 
   1504 	int rc = cil_gen_classpermset(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   1505 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   1506 }
   1507 
   1508 void test_cil_gen_classpermset_extra_neg(CuTest *tc) {
   1509 	char *line[] = {"(", "classpermissionset", "foo", "(", "read", "(", "write", ")", ")", "extra", ")", NULL};
   1510 
   1511 	struct cil_tree *test_tree;
   1512 	gen_test_tree(&test_tree, line);
   1513 
   1514 	struct cil_tree_node *test_ast_node;
   1515 	cil_tree_node_init(&test_ast_node);
   1516 
   1517 	struct cil_db *test_db;
   1518 	cil_db_init(&test_db);
   1519 
   1520 	test_ast_node->parent = test_db->ast->root;
   1521 	test_ast_node->line = 1;
   1522 
   1523 	int rc = cil_gen_classpermset(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   1524 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   1525 }
   1526 
   1527 void test_cil_gen_classpermset_dbnull_neg(CuTest *tc) {
   1528 	char *line[] = {"(", "classpermissionset", "foo", "(", "read", "(", "write", ")", ")", ")", NULL};
   1529 
   1530 	struct cil_tree *test_tree;
   1531 	gen_test_tree(&test_tree, line);
   1532 
   1533 	struct cil_tree_node *test_ast_node;
   1534 	cil_tree_node_init(&test_ast_node);
   1535 
   1536 	struct cil_db *test_db = NULL;
   1537 
   1538 	int rc = cil_gen_classpermset(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   1539 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   1540 }
   1541 
   1542 void test_cil_gen_classpermset_currnull_neg(CuTest *tc) {
   1543 	char *line[] = {"(", ")", NULL};
   1544 
   1545 	struct cil_tree *test_tree;
   1546 	gen_test_tree(&test_tree, line);
   1547 
   1548 	struct cil_tree_node *test_ast_node;
   1549 	cil_tree_node_init(&test_ast_node);
   1550 
   1551 	struct cil_db *test_db;
   1552 	cil_db_init(&test_db);
   1553 
   1554 	test_ast_node->parent = test_db->ast->root;
   1555 	test_ast_node->line = 1;
   1556 
   1557 	int rc = cil_gen_classpermset(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   1558 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   1559 }
   1560 
   1561 void test_cil_gen_classpermset_astnull_neg(CuTest *tc) {
   1562 	char *line[] = {"(", "classpermissionset", "foo", "(", "read", "(", "write", ")", ")", ")", NULL};
   1563 
   1564 	struct cil_tree *test_tree;
   1565 	gen_test_tree(&test_tree, line);
   1566 
   1567 	struct cil_tree_node *test_ast_node = NULL;
   1568 
   1569 	struct cil_db *test_db;
   1570 	cil_db_init(&test_db);
   1571 
   1572 	int rc = cil_gen_classpermset(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   1573 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   1574 }
   1575 
   1576 void test_cil_gen_classmap_perm(CuTest *tc) {
   1577 	char *line[] = {"(", "classmap", "files", "(", "read", ")", ")", NULL};
   1578 
   1579 	struct cil_tree *test_tree;
   1580 	gen_test_tree(&test_tree, line);
   1581 
   1582 	struct cil_tree_node *test_ast_node;
   1583 	cil_tree_node_init(&test_ast_node);
   1584 
   1585 	struct cil_db *test_db;
   1586 	cil_db_init(&test_db);
   1587 
   1588 	test_ast_node->parent = test_db->ast->root;
   1589 	test_ast_node->line = 1;
   1590 
   1591 	struct cil_classmap *map = NULL;
   1592 	cil_classmap_init(&map);
   1593 
   1594 	test_ast_node->flavor = CIL_CLASSMAP;
   1595 	test_ast_node->data = map;
   1596 
   1597 	struct cil_tree_node *test_ast_node_a;
   1598 	cil_tree_node_init(&test_ast_node_a);
   1599 
   1600 	test_ast_node_a->parent = test_ast_node;
   1601 	test_ast_node_a->line = test_tree->root->cl_head->cl_head->next->next->cl_head->line;
   1602 	test_ast_node_a->path = test_tree->root->cl_head->cl_head->next->next->cl_head->path;
   1603 
   1604 	int rc = cil_gen_classmap_perm(test_db, test_tree->root->cl_head->cl_head->next->next->cl_head, test_ast_node_a);
   1605 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   1606 }
   1607 
   1608 void test_cil_gen_classmap_perm_dupeperm_neg(CuTest *tc) {
   1609 	char *line[] = {"(", "classmap", "files", "(", "read", ")", ")", NULL};
   1610 
   1611 	struct cil_tree *test_tree;
   1612 	gen_test_tree(&test_tree, line);
   1613 
   1614 	struct cil_tree_node *test_ast_node;
   1615 	cil_tree_node_init(&test_ast_node);
   1616 
   1617 	struct cil_db *test_db;
   1618 	cil_db_init(&test_db);
   1619 
   1620 	test_ast_node->parent = test_db->ast->root;
   1621 	test_ast_node->line = 1;
   1622 
   1623 	cil_gen_classmap(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   1624 
   1625 	struct cil_tree_node *test_ast_node_a;
   1626 	cil_tree_node_init(&test_ast_node_a);
   1627 
   1628 	test_ast_node_a->parent = test_ast_node;
   1629 	test_ast_node_a->line = test_tree->root->cl_head->cl_head->next->next->cl_head->line;
   1630 	test_ast_node_a->path = test_tree->root->cl_head->cl_head->next->next->cl_head->path;
   1631 
   1632 	int rc = cil_gen_classmap_perm(test_db, test_tree->root->cl_head->cl_head->next->next->cl_head, test_ast_node_a);
   1633 	CuAssertIntEquals(tc, SEPOL_EEXIST, rc);
   1634 }
   1635 
   1636 void test_cil_gen_classmap_perm_dbnull_neg(CuTest *tc) {
   1637 	char *line[] = {"(", "classmap", "files", "(", "read", ")", ")", NULL};
   1638 
   1639 	struct cil_tree *test_tree;
   1640 	gen_test_tree(&test_tree, line);
   1641 
   1642 	struct cil_tree_node *test_ast_node;
   1643 	cil_tree_node_init(&test_ast_node);
   1644 
   1645 	struct cil_db *test_db;
   1646 	cil_db_init(&test_db);
   1647 
   1648 	test_ast_node->parent = test_db->ast->root;
   1649 	test_ast_node->line = 1;
   1650 
   1651 	cil_gen_classmap(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   1652 
   1653 	struct cil_tree_node *test_ast_node_a;
   1654 	cil_tree_node_init(&test_ast_node_a);
   1655 
   1656 	test_ast_node_a->parent = test_ast_node;
   1657 	test_ast_node_a->line = test_tree->root->cl_head->cl_head->line;
   1658 	test_ast_node_a->path = test_tree->root->cl_head->cl_head->path;
   1659 
   1660 	test_db = NULL;
   1661 
   1662 	int rc = cil_gen_classmap_perm(test_db, test_tree->root->cl_head->cl_head->next->next->cl_head, test_ast_node_a);
   1663 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   1664 }
   1665 
   1666 void test_cil_gen_classmap_perm_currnull_neg(CuTest *tc) {
   1667 	char *line[] = {"(", "classmap", "files", "(", ")", ")", NULL};
   1668 
   1669 	struct cil_tree *test_tree;
   1670 	gen_test_tree(&test_tree, line);
   1671 
   1672 	struct cil_tree_node *test_ast_node;
   1673 	cil_tree_node_init(&test_ast_node);
   1674 
   1675 	struct cil_db *test_db;
   1676 	cil_db_init(&test_db);
   1677 
   1678 	test_ast_node->parent = test_db->ast->root;
   1679 	test_ast_node->line = 1;
   1680 
   1681 	cil_gen_classmap(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   1682 
   1683 	struct cil_tree_node *test_ast_node_a;
   1684 	cil_tree_node_init(&test_ast_node_a);
   1685 
   1686 	test_ast_node_a->parent = test_ast_node;
   1687 	test_ast_node_a->line = test_tree->root->cl_head->cl_head->line;
   1688 	test_ast_node_a->path = test_tree->root->cl_head->cl_head->path;
   1689 
   1690 	int rc = cil_gen_classmap_perm(test_db, test_tree->root->cl_head->cl_head->next->next->cl_head, test_ast_node_a);
   1691 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   1692 }
   1693 
   1694 void test_cil_gen_classmap_perm_astnull_neg(CuTest *tc) {
   1695 	char *line[] = {"(", "classmap", "files", "(", "read", ")", ")", NULL};
   1696 
   1697 	struct cil_tree *test_tree;
   1698 	gen_test_tree(&test_tree, line);
   1699 
   1700 	struct cil_tree_node *test_ast_node;
   1701 	cil_tree_node_init(&test_ast_node);
   1702 
   1703 	struct cil_db *test_db;
   1704 	cil_db_init(&test_db);
   1705 
   1706 	test_ast_node->parent = test_db->ast->root;
   1707 	test_ast_node->line = 1;
   1708 
   1709 	cil_gen_classmap(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   1710 
   1711 	struct cil_tree_node *test_ast_node_a = NULL;
   1712 
   1713 	int rc = cil_gen_classmap_perm(test_db, test_tree->root->cl_head->cl_head->next->next->cl_head, test_ast_node_a);
   1714 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   1715 }
   1716 
   1717 void test_cil_gen_classmap(CuTest *tc) {
   1718 	char *line[] = {"(", "classmap", "files", "(", "read", ")", ")", NULL};
   1719 
   1720 	struct cil_tree *test_tree;
   1721 	gen_test_tree(&test_tree, line);
   1722 
   1723 	struct cil_tree_node *test_ast_node;
   1724 	cil_tree_node_init(&test_ast_node);
   1725 
   1726 	struct cil_db *test_db;
   1727 	cil_db_init(&test_db);
   1728 
   1729 	test_ast_node->parent = test_db->ast->root;
   1730 	test_ast_node->line = 1;
   1731 
   1732 	int rc = cil_gen_classmap(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   1733 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   1734 }
   1735 
   1736 void test_cil_gen_classmap_extra_neg(CuTest *tc) {
   1737 	char *line[] = {"(", "classmap", "files", "(", "read", ")", "extra", ")", NULL};
   1738 
   1739 	struct cil_tree *test_tree;
   1740 	gen_test_tree(&test_tree, line);
   1741 
   1742 	struct cil_tree_node *test_ast_node;
   1743 	cil_tree_node_init(&test_ast_node);
   1744 
   1745 	struct cil_db *test_db;
   1746 	cil_db_init(&test_db);
   1747 
   1748 	test_ast_node->parent = test_db->ast->root;
   1749 	test_ast_node->line = 1;
   1750 
   1751 	int rc = cil_gen_classmap(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   1752 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   1753 }
   1754 
   1755 void test_cil_gen_classmap_noname_neg(CuTest *tc) {
   1756 	char *line[] = {"(", "classmap", ")", NULL};
   1757 
   1758 	struct cil_tree *test_tree;
   1759 	gen_test_tree(&test_tree, line);
   1760 
   1761 	struct cil_tree_node *test_ast_node;
   1762 	cil_tree_node_init(&test_ast_node);
   1763 
   1764 	struct cil_db *test_db;
   1765 	cil_db_init(&test_db);
   1766 
   1767 	test_ast_node->parent = test_db->ast->root;
   1768 	test_ast_node->line = 1;
   1769 
   1770 	int rc = cil_gen_classmap(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   1771 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   1772 }
   1773 
   1774 void test_cil_gen_classmap_emptyperms_neg(CuTest *tc) {
   1775 	char *line[] = {"(", "classmap", "files", "(", ")", ")", NULL};
   1776 
   1777 	struct cil_tree *test_tree;
   1778 	gen_test_tree(&test_tree, line);
   1779 
   1780 	struct cil_tree_node *test_ast_node;
   1781 	cil_tree_node_init(&test_ast_node);
   1782 
   1783 	struct cil_db *test_db;
   1784 	cil_db_init(&test_db);
   1785 
   1786 	test_ast_node->parent = test_db->ast->root;
   1787 	test_ast_node->line = 1;
   1788 
   1789 	int rc = cil_gen_classmap(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   1790 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   1791 }
   1792 
   1793 void test_cil_gen_classmap_dbnull_neg(CuTest *tc) {
   1794 	char *line[] = {"(", "classmap", "files", "(", "read", ")", ")", NULL};
   1795 
   1796 	struct cil_tree *test_tree;
   1797 	gen_test_tree(&test_tree, line);
   1798 
   1799 	struct cil_tree_node *test_ast_node;
   1800 	cil_tree_node_init(&test_ast_node);
   1801 
   1802 	struct cil_db *test_db = NULL;
   1803 
   1804 	int rc = cil_gen_classmap(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   1805 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   1806 }
   1807 
   1808 void test_cil_gen_classmap_currnull_neg(CuTest *tc) {
   1809 	char *line[] = {"(", ")", NULL};
   1810 
   1811 	struct cil_tree *test_tree;
   1812 	gen_test_tree(&test_tree, line);
   1813 
   1814 	struct cil_tree_node *test_ast_node;
   1815 	cil_tree_node_init(&test_ast_node);
   1816 
   1817 	struct cil_db *test_db;
   1818 	cil_db_init(&test_db);
   1819 
   1820 	test_ast_node->parent = test_db->ast->root;
   1821 	test_ast_node->line = 1;
   1822 
   1823 	int rc = cil_gen_classmap(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   1824 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   1825 }
   1826 
   1827 void test_cil_gen_classmap_astnull_neg(CuTest *tc) {
   1828 	char *line[] = {"(", "classmap", "files", "(", "read", ")", ")", NULL};
   1829 
   1830 	struct cil_tree *test_tree;
   1831 	gen_test_tree(&test_tree, line);
   1832 
   1833 	struct cil_tree_node *test_ast_node = NULL;
   1834 
   1835 	struct cil_db *test_db;
   1836 	cil_db_init(&test_db);
   1837 
   1838 	int rc = cil_gen_classmap(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   1839 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   1840 }
   1841 
   1842 void test_cil_gen_classmapping_anonpermset(CuTest *tc) {
   1843 	char *line[] = {"(", "classmapping", "files", "read",
   1844 			"(", "file", "(", "open", "read", "getattr", ")", ")", NULL};
   1845 
   1846 	struct cil_tree *test_tree;
   1847 	gen_test_tree(&test_tree, line);
   1848 
   1849 	struct cil_tree_node *test_ast_node;
   1850 	cil_tree_node_init(&test_ast_node);
   1851 
   1852 	struct cil_db *test_db;
   1853 	cil_db_init(&test_db);
   1854 
   1855 	test_ast_node->parent = test_db->ast->root;
   1856 	test_ast_node->line = 1;
   1857 
   1858 	int rc = cil_gen_classmapping(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   1859 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   1860 }
   1861 
   1862 void test_cil_gen_classmapping_anonpermset_neg(CuTest *tc) {
   1863 	char *line[] = {"(", "classmapping", "files", "read",
   1864 			"(", "file", "(", ")", ")", ")", NULL};
   1865 
   1866 	struct cil_tree *test_tree;
   1867 	gen_test_tree(&test_tree, line);
   1868 
   1869 	struct cil_tree_node *test_ast_node;
   1870 	cil_tree_node_init(&test_ast_node);
   1871 
   1872 	struct cil_db *test_db;
   1873 	cil_db_init(&test_db);
   1874 
   1875 	test_ast_node->parent = test_db->ast->root;
   1876 	test_ast_node->line = 1;
   1877 
   1878 	int rc = cil_gen_classmapping(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   1879 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   1880 }
   1881 
   1882 void test_cil_gen_classmapping_namedpermset(CuTest *tc) {
   1883 	char *line[] = {"(", "classmapping", "files", "read", "char_w", ")", NULL};
   1884 
   1885 	struct cil_tree *test_tree;
   1886 	gen_test_tree(&test_tree, line);
   1887 
   1888 	struct cil_tree_node *test_ast_node;
   1889 	cil_tree_node_init(&test_ast_node);
   1890 
   1891 	struct cil_db *test_db;
   1892 	cil_db_init(&test_db);
   1893 
   1894 	test_ast_node->parent = test_db->ast->root;
   1895 	test_ast_node->line = 1;
   1896 
   1897 	int rc = cil_gen_classmapping(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   1898 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   1899 }
   1900 
   1901 void test_cil_gen_classmapping_noclassmapname_neg(CuTest *tc) {
   1902 	char *line[] = {"(", "classmapping", ")", NULL};
   1903 
   1904 	struct cil_tree *test_tree;
   1905 	gen_test_tree(&test_tree, line);
   1906 
   1907 	struct cil_tree_node *test_ast_node;
   1908 	cil_tree_node_init(&test_ast_node);
   1909 
   1910 	struct cil_db *test_db;
   1911 	cil_db_init(&test_db);
   1912 
   1913 	test_ast_node->parent = test_db->ast->root;
   1914 	test_ast_node->line = 1;
   1915 
   1916 	int rc = cil_gen_classmapping(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   1917 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   1918 }
   1919 
   1920 void test_cil_gen_classmapping_noclassmapperm_neg(CuTest *tc) {
   1921 	char *line[] = {"(", "classmapping", "files", ")", NULL};
   1922 
   1923 	struct cil_tree *test_tree;
   1924 	gen_test_tree(&test_tree, line);
   1925 
   1926 	struct cil_tree_node *test_ast_node;
   1927 	cil_tree_node_init(&test_ast_node);
   1928 
   1929 	struct cil_db *test_db;
   1930 	cil_db_init(&test_db);
   1931 
   1932 	test_ast_node->parent = test_db->ast->root;
   1933 	test_ast_node->line = 1;
   1934 
   1935 	int rc = cil_gen_classmapping(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   1936 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   1937 }
   1938 
   1939 void test_cil_gen_classmapping_nopermissionsets_neg(CuTest *tc) {
   1940 	char *line[] = {"(", "classmapping", "files", "read", ")", NULL};
   1941 
   1942 	struct cil_tree *test_tree;
   1943 	gen_test_tree(&test_tree, line);
   1944 
   1945 	struct cil_tree_node *test_ast_node;
   1946 	cil_tree_node_init(&test_ast_node);
   1947 
   1948 	struct cil_db *test_db;
   1949 	cil_db_init(&test_db);
   1950 
   1951 	test_ast_node->parent = test_db->ast->root;
   1952 	test_ast_node->line = 1;
   1953 
   1954 	int rc = cil_gen_classmapping(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   1955 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   1956 }
   1957 
   1958 void test_cil_gen_classmapping_dbnull_neg(CuTest *tc) {
   1959 	char *line[] = {"(", "classmapping", "files", "read",
   1960 			"(", "file", "(", "open", "read", "getattr", ")", ")", NULL};
   1961 
   1962 	struct cil_tree *test_tree;
   1963 	gen_test_tree(&test_tree, line);
   1964 
   1965 	struct cil_tree_node *test_ast_node;
   1966 	cil_tree_node_init(&test_ast_node);
   1967 
   1968 	struct cil_db *test_db = NULL;
   1969 
   1970 	int rc = cil_gen_classmapping(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   1971 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   1972 }
   1973 
   1974 void test_cil_gen_classmapping_currnull_neg(CuTest *tc) {
   1975 	char *line[] = {"(", ")", NULL};
   1976 
   1977 	struct cil_tree *test_tree;
   1978 	gen_test_tree(&test_tree, line);
   1979 
   1980 	struct cil_tree_node *test_ast_node;
   1981 	cil_tree_node_init(&test_ast_node);
   1982 
   1983 	struct cil_db *test_db;
   1984 	cil_db_init(&test_db);
   1985 
   1986 	test_ast_node->parent = test_db->ast->root;
   1987 	test_ast_node->line = 1;
   1988 
   1989 	int rc = cil_gen_classmapping(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   1990 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   1991 }
   1992 
   1993 void test_cil_gen_classmapping_astnull_neg(CuTest *tc) {
   1994 	char *line[] = {"(", "classmapping", "files", "read",
   1995 			"(", "file", "(", "open", "read", "getattr", ")", ")", NULL};
   1996 
   1997 	struct cil_tree *test_tree;
   1998 	gen_test_tree(&test_tree, line);
   1999 
   2000 	struct cil_tree_node *test_ast_node = NULL;
   2001 
   2002 	struct cil_db *test_db;
   2003 	cil_db_init(&test_db);
   2004 
   2005 	int rc = cil_gen_classmapping(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   2006 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   2007 }
   2008 
   2009 void test_cil_gen_common(CuTest *tc) {
   2010 	char *line[] = {"(", "common", "test", "(", "read", "write", ")", ")", NULL};
   2011 
   2012 	struct cil_tree *test_tree;
   2013 	gen_test_tree(&test_tree, line);
   2014 
   2015 	struct cil_tree_node *test_ast_node;
   2016 	cil_tree_node_init(&test_ast_node);
   2017 
   2018 	struct cil_db *test_db;
   2019 	cil_db_init(&test_db);
   2020 
   2021 	test_ast_node->parent = test_db->ast->root;
   2022 	test_ast_node->line = 1;
   2023 
   2024 	int rc = cil_gen_common(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   2025 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   2026 	CuAssertPtrNotNull(tc, test_ast_node->data);
   2027 	CuAssertIntEquals(tc, test_ast_node->flavor, CIL_COMMON);
   2028 }
   2029 
   2030 void test_cil_gen_common_dbnull_neg(CuTest *tc) {
   2031 	char *line[] = {"(", "common", "test", "(", "read", "write", ")", ")", NULL};
   2032 
   2033 	struct cil_tree *test_tree;
   2034 	gen_test_tree(&test_tree, line);
   2035 
   2036 	struct cil_tree_node *test_ast_node;
   2037 	cil_tree_node_init(&test_ast_node);
   2038 
   2039 	struct cil_db *test_db = NULL;
   2040 
   2041 	int rc = cil_gen_common(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   2042 
   2043 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   2044 }
   2045 
   2046 void test_cil_gen_common_currnull_neg(CuTest *tc) {
   2047 	char *line[] = {"(", ")", NULL};
   2048 
   2049 	struct cil_tree *test_tree;
   2050 	gen_test_tree(&test_tree, line);
   2051 
   2052 	struct cil_tree_node *test_ast_node;
   2053 	cil_tree_node_init(&test_ast_node);
   2054 
   2055 	struct cil_db *test_db;
   2056 	cil_db_init(&test_db);
   2057 
   2058 	int rc = cil_gen_common(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   2059 
   2060 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   2061 }
   2062 
   2063 void test_cil_gen_common_astnull_neg(CuTest *tc) {
   2064 	char *line[] = {"(", "common", "test", "(", "read", "write", ")", ")", NULL};
   2065 
   2066 	struct cil_tree *test_tree;
   2067 	gen_test_tree(&test_tree, line);
   2068 
   2069 	struct cil_tree_node *test_ast_node = NULL;
   2070 
   2071 	struct cil_db *test_db;
   2072 	cil_db_init(&test_db);
   2073 
   2074 	int rc = cil_gen_common(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   2075 
   2076 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   2077 }
   2078 
   2079 void test_cil_gen_common_noname_neg(CuTest *tc) {
   2080 	char *line[] = {"(", "common", ")", NULL};
   2081 
   2082 	struct cil_tree *test_tree;
   2083 	gen_test_tree(&test_tree, line);
   2084 
   2085 	struct cil_tree_node *test_ast_node;
   2086 	cil_tree_node_init(&test_ast_node);
   2087 
   2088 	struct cil_db *test_db;
   2089 	cil_db_init(&test_db);
   2090 
   2091 	test_ast_node->parent = test_db->ast->root;
   2092 	test_ast_node->line = 1;
   2093 
   2094 	int rc = cil_gen_common(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   2095 
   2096 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   2097 }
   2098 
   2099 void test_cil_gen_common_twoperms_neg(CuTest *tc) {
   2100 	char *line[] = {"(", "common", "foo", "(", "write", ")", "(", "read", ")", ")", NULL};
   2101 
   2102 	struct cil_tree *test_tree;
   2103 	gen_test_tree(&test_tree, line);
   2104 
   2105 	struct cil_tree_node *test_ast_node;
   2106 	cil_tree_node_init(&test_ast_node);
   2107 
   2108 	struct cil_db *test_db;
   2109 	cil_db_init(&test_db);
   2110 
   2111 	test_ast_node->parent = test_db->ast->root;
   2112 	test_ast_node->line = 1;
   2113 
   2114 	int rc = cil_gen_common(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   2115 
   2116 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   2117 }
   2118 
   2119 void test_cil_gen_common_permsublist_neg(CuTest *tc) {
   2120         char *line[] = {"(", "common", "test", "(", "read", "(", "write", ")", ")", ")", NULL};
   2121 
   2122         struct cil_tree *test_tree;
   2123         gen_test_tree(&test_tree, line);
   2124 
   2125         struct cil_tree_node *test_ast_node;
   2126         cil_tree_node_init(&test_ast_node);
   2127 
   2128         struct cil_db *test_db;
   2129         cil_db_init(&test_db);
   2130 
   2131         test_ast_node->parent = test_db->ast->root;
   2132         test_ast_node->line = 1;
   2133 
   2134         int rc = cil_gen_common(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   2135 
   2136 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   2137 }
   2138 
   2139 void test_cil_gen_common_noperms_neg(CuTest *tc) {
   2140         char *line[] = {"(", "common", "test", "(", ")", ")", NULL};
   2141 
   2142         struct cil_tree *test_tree;
   2143         gen_test_tree(&test_tree, line);
   2144 
   2145         struct cil_tree_node *test_ast_node;
   2146         cil_tree_node_init(&test_ast_node);
   2147 
   2148         struct cil_db *test_db;
   2149         cil_db_init(&test_db);
   2150 
   2151         test_ast_node->parent = test_db->ast->root;
   2152         test_ast_node->line = 1;
   2153 
   2154         int rc = cil_gen_common(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   2155 
   2156 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   2157 }
   2158 
   2159 void test_cil_gen_sid(CuTest *tc) {
   2160 	char *line[] = {"(", "sid", "foo", ")", NULL};
   2161 
   2162 	struct cil_tree *test_tree;
   2163 	gen_test_tree(&test_tree, line);
   2164 
   2165 	struct cil_tree_node *test_ast_node;
   2166 	cil_tree_node_init(&test_ast_node);
   2167 
   2168 	struct cil_db *test_db;
   2169 	cil_db_init(&test_db);
   2170 
   2171 	test_ast_node->parent = test_db->ast->root;
   2172 	test_ast_node->line = 1;
   2173 
   2174 	int rc = cil_gen_sid(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   2175 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   2176 }
   2177 
   2178 void test_cil_gen_sid_noname_neg(CuTest *tc) {
   2179 	char *line[] = {"(", "sid", ")", NULL};
   2180 
   2181 	struct cil_tree *test_tree;
   2182 	gen_test_tree(&test_tree, line);
   2183 
   2184 	struct cil_tree_node *test_ast_node;
   2185 	cil_tree_node_init(&test_ast_node);
   2186 
   2187 	struct cil_db *test_db;
   2188 	cil_db_init(&test_db);
   2189 
   2190 	test_ast_node->parent = test_db->ast->root;
   2191 	test_ast_node->line = 1;
   2192 
   2193 	int rc = cil_gen_sid(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   2194 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   2195 }
   2196 
   2197 void test_cil_gen_sid_nameinparens_neg(CuTest *tc) {
   2198 	char *line[] = {"(", "sid", "(", "foo", ")", ")", NULL};
   2199 
   2200 	struct cil_tree *test_tree;
   2201 	gen_test_tree(&test_tree, line);
   2202 
   2203 	struct cil_tree_node *test_ast_node;
   2204 	cil_tree_node_init(&test_ast_node);
   2205 
   2206 	struct cil_db *test_db;
   2207 	cil_db_init(&test_db);
   2208 
   2209 	test_ast_node->parent = test_db->ast->root;
   2210 	test_ast_node->line = 1;
   2211 
   2212 	int rc = cil_gen_sid(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   2213 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   2214 }
   2215 
   2216 void test_cil_gen_sid_extra_neg(CuTest *tc) {
   2217 	char *line[] = {"(", "sid", "foo", "extra", ")", NULL};
   2218 
   2219 	struct cil_tree *test_tree;
   2220 	gen_test_tree(&test_tree, line);
   2221 
   2222 	struct cil_tree_node *test_ast_node;
   2223 	cil_tree_node_init(&test_ast_node);
   2224 
   2225 	struct cil_db *test_db;
   2226 	cil_db_init(&test_db);
   2227 
   2228 	test_ast_node->parent = test_db->ast->root;
   2229 	test_ast_node->line = 1;
   2230 
   2231 	int rc = cil_gen_sid(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   2232 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   2233 }
   2234 
   2235 void test_cil_gen_sid_dbnull_neg(CuTest *tc) {
   2236 	char *line[] = {"(", "sid", "foo", ")", NULL};
   2237 
   2238 	struct cil_tree *test_tree;
   2239 	gen_test_tree(&test_tree, line);
   2240 
   2241 	struct cil_tree_node *test_ast_node;
   2242 	cil_tree_node_init(&test_ast_node);
   2243 
   2244 	struct cil_db *test_db = NULL;
   2245 
   2246 	int rc = cil_gen_sid(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   2247 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   2248 }
   2249 
   2250 void test_cil_gen_sid_currnull_neg(CuTest *tc) {
   2251 	char *line[] = {"(", ")", NULL};
   2252 
   2253 	struct cil_tree *test_tree;
   2254 	gen_test_tree(&test_tree, line);
   2255 
   2256 	struct cil_tree_node *test_ast_node;
   2257 	cil_tree_node_init(&test_ast_node);
   2258 
   2259 	struct cil_db *test_db;
   2260 	cil_db_init(&test_db);
   2261 
   2262 	test_ast_node->parent = test_db->ast->root;
   2263 	test_ast_node->line = 1;
   2264 
   2265 	int rc = cil_gen_sid(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   2266 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   2267 }
   2268 
   2269 void test_cil_gen_sid_astnull_neg(CuTest *tc) {
   2270 	char *line[] = {"(", "sid", "foo", ")", NULL};
   2271 
   2272 	struct cil_tree *test_tree;
   2273 	gen_test_tree(&test_tree, line);
   2274 
   2275 	struct cil_tree_node *test_ast_node = NULL;
   2276 
   2277 	struct cil_db *test_db;
   2278 	cil_db_init(&test_db);
   2279 
   2280 	int rc = cil_gen_sid(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   2281 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   2282 }
   2283 
   2284 void test_cil_gen_sidcontext(CuTest *tc) {
   2285 	char *line[] = {"(", "sidcontext", "test", "(", "blah", "blah", "blah", "(", "(", "s0", "(", "c0", ")", ")", "(", "s0", "(", "c0", ")", ")", ")", ")", ")", NULL};
   2286 
   2287 	struct cil_tree *test_tree;
   2288 	gen_test_tree(&test_tree, line);
   2289 
   2290 	struct cil_tree_node *test_ast_node;
   2291 	cil_tree_node_init(&test_ast_node);
   2292 
   2293 	struct cil_db *test_db;
   2294 	cil_db_init(&test_db);
   2295 
   2296 
   2297 	test_ast_node->parent = test_db->ast->root;
   2298 	test_ast_node->line = 1;
   2299 
   2300 	int rc = cil_gen_sidcontext(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   2301 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   2302 	CuAssertPtrNotNull(tc, test_ast_node->data);
   2303 	CuAssertIntEquals(tc, test_ast_node->flavor, CIL_SIDCONTEXT);
   2304 }
   2305 
   2306 void test_cil_gen_sidcontext_namedcontext(CuTest *tc) {
   2307 	char *line[] = {"(", "sidcontext", "test", "something", ")", NULL};
   2308 
   2309 	struct cil_tree *test_tree;
   2310 	gen_test_tree(&test_tree, line);
   2311 
   2312 	struct cil_tree_node *test_ast_node;
   2313 	cil_tree_node_init(&test_ast_node);
   2314 
   2315 	struct cil_db *test_db;
   2316 	cil_db_init(&test_db);
   2317 
   2318 	test_ast_node->parent = test_db->ast->root;
   2319 	test_ast_node->line = 1;
   2320 
   2321 	int rc = cil_gen_sidcontext(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   2322 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   2323 	CuAssertPtrNotNull(tc, test_ast_node->data);
   2324 	CuAssertIntEquals(tc, test_ast_node->flavor, CIL_SIDCONTEXT);
   2325 }
   2326 
   2327 void test_cil_gen_sidcontext_halfcontext_neg(CuTest *tc) {
   2328 	char *line[] = {"(", "sidcontext", "test", "(", "blah", "blah", "blah", "(", "(", "s0", "(", "c0", ")", ")", ")", ")", ")", NULL};
   2329 
   2330 	struct cil_tree *test_tree;
   2331 	gen_test_tree(&test_tree, line);
   2332 
   2333 	struct cil_tree_node *test_ast_node;
   2334 	cil_tree_node_init(&test_ast_node);
   2335 
   2336 	struct cil_db *test_db;
   2337 	cil_db_init(&test_db);
   2338 
   2339 	test_ast_node->parent = test_db->ast->root;
   2340 	test_ast_node->line = 1;
   2341 
   2342 	int rc = cil_gen_sidcontext(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   2343 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   2344 }
   2345 
   2346 void test_cil_gen_sidcontext_noname_neg(CuTest *tc) {
   2347 	char *line[] = {"(", "sidcontext", "(", "blah", "blah", "blah", "(", "s0", "(", "c0", ")", ")", "(", "s0", "(", "c0", ")", ")", ")", ")", NULL};
   2348 
   2349 	struct cil_tree *test_tree;
   2350 	gen_test_tree(&test_tree, line);
   2351 
   2352 	struct cil_tree_node *test_ast_node;
   2353 	cil_tree_node_init(&test_ast_node);
   2354 
   2355 	struct cil_db *test_db;
   2356 	cil_db_init(&test_db);
   2357 
   2358 	test_ast_node->parent = test_db->ast->root;
   2359 	test_ast_node->line = 1;
   2360 
   2361 	int rc = cil_gen_sidcontext(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   2362 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   2363 }
   2364 
   2365 void test_cil_gen_sidcontext_empty_neg(CuTest *tc) {
   2366 	char *line[] = {"(", "sidcontext", ")", NULL};
   2367 
   2368 	struct cil_tree *test_tree;
   2369 	gen_test_tree(&test_tree, line);
   2370 
   2371 	struct cil_tree_node *test_ast_node;
   2372 	cil_tree_node_init(&test_ast_node);
   2373 
   2374 	struct cil_db *test_db;
   2375 	cil_db_init(&test_db);
   2376 
   2377 	test_ast_node->parent = test_db->ast->root;
   2378 	test_ast_node->line = 1;
   2379 
   2380 	int rc = cil_gen_sidcontext(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   2381 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   2382 }
   2383 
   2384 void test_cil_gen_sidcontext_nocontext_neg(CuTest *tc) {
   2385 	char *line[] = {"(", "sidcontext", "test", ")", NULL};
   2386 
   2387 	struct cil_tree *test_tree;
   2388 	gen_test_tree(&test_tree, line);
   2389 
   2390 	struct cil_tree_node *test_ast_node;
   2391 	cil_tree_node_init(&test_ast_node);
   2392 
   2393 	struct cil_db *test_db;
   2394 	cil_db_init(&test_db);
   2395 
   2396 	test_ast_node->parent = test_db->ast->root;
   2397 	test_ast_node->line = 1;
   2398 
   2399 	int rc = cil_gen_sidcontext(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   2400 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   2401 }
   2402 
   2403 void test_cil_gen_sidcontext_dblname_neg(CuTest *tc) {
   2404 	char *line[] = {"(", "sidcontext", "test", "test2", "(", "blah", "blah", "blah", "(", "s0", "(", "c0", ")", ")", "(", "s0", "(", "c0", ")", ")", ")", ")", NULL};
   2405 
   2406 	struct cil_tree *test_tree;
   2407 	gen_test_tree(&test_tree, line);
   2408 
   2409 	struct cil_tree_node *test_ast_node;
   2410 	cil_tree_node_init(&test_ast_node);
   2411 
   2412 	struct cil_db *test_db;
   2413 	cil_db_init(&test_db);
   2414 
   2415 	test_ast_node->parent = test_db->ast->root;
   2416 	test_ast_node->line = 1;
   2417 
   2418 	int rc = cil_gen_sidcontext(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   2419 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   2420 }
   2421 
   2422 void test_cil_gen_sidcontext_dbnull_neg(CuTest *tc) {
   2423 	char *line[] = {"(", "sidcontext", "test", "(", "blah", "blah", "blah", "(", "s0", "(", "c0", ")", ")", "(", "s0", "(", "c0", ")", ")", ")", ")", NULL};
   2424 
   2425 	struct cil_tree *test_tree;
   2426 	gen_test_tree(&test_tree, line);
   2427 
   2428 	struct cil_tree_node *test_ast_node;
   2429 	cil_tree_node_init(&test_ast_node);
   2430 
   2431 	struct cil_db *test_db = NULL;
   2432 
   2433 	int rc = cil_gen_sidcontext(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   2434 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   2435 }
   2436 
   2437 void test_cil_gen_sidcontext_pcurrnull_neg(CuTest *tc) {
   2438 	struct cil_tree_node *test_ast_node;
   2439 	cil_tree_node_init(&test_ast_node);
   2440 
   2441 	struct cil_db *test_db;
   2442 	cil_db_init(&test_db);
   2443 
   2444 	test_ast_node->parent = test_db->ast->root;
   2445 	test_ast_node->line = 1;
   2446 
   2447 	int rc = cil_gen_sidcontext(test_db, NULL, test_ast_node);
   2448 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   2449 }
   2450 
   2451 void test_cil_gen_sidcontext_astnodenull_neg(CuTest *tc) {
   2452 	char *line[] = {"(", "sidcontext", "test", "(", "blah", "blah", "blah", "(", "s0", "(", "c0", ")", ")", "(", "s0", "(", "c0", ")", ")", ")", ")", NULL};
   2453 
   2454 	struct cil_tree *test_tree;
   2455 	gen_test_tree(&test_tree, line);
   2456 
   2457 	struct cil_tree_node *test_ast_node;
   2458 	cil_tree_node_init(&test_ast_node);
   2459 
   2460 	struct cil_db *test_db;
   2461 	cil_db_init(&test_db);
   2462 
   2463 	test_ast_node->parent = test_db->ast->root;
   2464 	test_ast_node->line = 1;
   2465 
   2466 	int rc = cil_gen_sidcontext(test_db, test_tree->root->cl_head->cl_head, NULL);
   2467 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   2468 }
   2469 
   2470 void test_cil_gen_type(CuTest *tc) {
   2471 	char *line[] = {"(", "type", "test", ")", NULL};
   2472 
   2473 	struct cil_tree *test_tree;
   2474 	gen_test_tree(&test_tree, line);
   2475 
   2476 	struct cil_tree_node *test_ast_node;
   2477 	cil_tree_node_init(&test_ast_node);
   2478 
   2479 	struct cil_db *test_db;
   2480 	cil_db_init(&test_db);
   2481 
   2482 	test_ast_node->parent = test_db->ast->root;
   2483 	test_ast_node->line = 1;
   2484 
   2485 	int rc = cil_gen_type(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   2486 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   2487 	CuAssertPtrNotNull(tc, test_ast_node->data);
   2488 	CuAssertIntEquals(tc, test_ast_node->flavor, CIL_TYPE);
   2489 }
   2490 
   2491 void test_cil_gen_type_dbnull_neg(CuTest *tc) {
   2492 	char *line[] = {"(", "type", "test", ")", NULL};
   2493 
   2494 	struct cil_tree *test_tree;
   2495 	gen_test_tree(&test_tree, line);
   2496 
   2497 	struct cil_tree_node *test_ast_node;
   2498 	cil_tree_node_init(&test_ast_node);
   2499 
   2500 	struct cil_db *test_db = NULL;
   2501 
   2502 	int rc = cil_gen_type(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   2503 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   2504 }
   2505 
   2506 void test_cil_gen_type_currnull_neg(CuTest *tc) {
   2507 	char *line[] = {"(", ")", NULL};
   2508 
   2509 	struct cil_tree *test_tree;
   2510 	gen_test_tree(&test_tree, line);
   2511 
   2512 	struct cil_tree_node *test_ast_node;
   2513 	cil_tree_node_init(&test_ast_node);
   2514 
   2515 	struct cil_db *test_db;
   2516 	cil_db_init(&test_db);
   2517 
   2518 	test_ast_node->parent = test_db->ast->root;
   2519 	test_ast_node->line = 1;
   2520 
   2521 	int rc = cil_gen_type(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   2522 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   2523 }
   2524 
   2525 void test_cil_gen_type_astnull_neg(CuTest *tc) {
   2526 	char *line[] = {"(", "type", "test", ")", NULL};
   2527 
   2528 	struct cil_tree *test_tree;
   2529 	gen_test_tree(&test_tree, line);
   2530 
   2531 	struct cil_tree_node *test_ast_node = NULL;
   2532 
   2533 	struct cil_db *test_db;
   2534 	cil_db_init(&test_db);
   2535 
   2536 	int rc = cil_gen_type(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   2537 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   2538 }
   2539 
   2540 void test_cil_gen_type_extra_neg(CuTest *tc) {
   2541 	char *line[] = {"(", "type", "foo", "bar," ")", NULL};
   2542 
   2543 	struct cil_tree *test_tree;
   2544 	gen_test_tree(&test_tree, line);
   2545 
   2546 	struct cil_tree_node *test_ast_node;
   2547 	cil_tree_node_init(&test_ast_node);
   2548 
   2549 	struct cil_db *test_db;
   2550 	cil_db_init(&test_db);
   2551 
   2552 	test_ast_node->parent = test_db->ast->root;
   2553 	test_ast_node->line = 1;
   2554 
   2555 	int rc = cil_gen_type(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   2556 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   2557 }
   2558 
   2559 void test_cil_gen_typeattribute(CuTest *tc) {
   2560 	char *line[] = {"(", "typeattribute", "test", NULL};
   2561 
   2562 	struct cil_tree *test_tree;
   2563 	gen_test_tree(&test_tree, line);
   2564 
   2565 	struct cil_tree_node *test_ast_node;
   2566 	cil_tree_node_init(&test_ast_node);
   2567 
   2568 	struct cil_db *test_db;
   2569 	cil_db_init(&test_db);
   2570 
   2571 	test_ast_node->parent = test_db->ast->root;
   2572 	test_ast_node->line = 1;
   2573 
   2574 	int rc = cil_gen_typeattribute(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   2575 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   2576 	CuAssertPtrNotNull(tc, test_ast_node->data);
   2577 	CuAssertIntEquals(tc, test_ast_node->flavor, CIL_TYPEATTRIBUTE);
   2578 }
   2579 
   2580 void test_cil_gen_typeattribute_dbnull_neg(CuTest *tc) {
   2581 	char *line[] = {"(", "typeattribute", "test", ")", NULL};
   2582 
   2583 	struct cil_tree *test_tree;
   2584 	gen_test_tree(&test_tree, line);
   2585 
   2586 	struct cil_tree_node *test_ast_node;
   2587 	cil_tree_node_init(&test_ast_node);
   2588 
   2589 	struct cil_db *test_db = NULL;
   2590 
   2591 	int rc = cil_gen_typeattribute(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   2592 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   2593 }
   2594 
   2595 
   2596 void test_cil_gen_typeattribute_currnull_neg(CuTest *tc) {
   2597 	char *line[] = {"(", ")", NULL};
   2598 
   2599 	struct cil_tree *test_tree;
   2600 	gen_test_tree(&test_tree, line);
   2601 
   2602 	struct cil_tree_node *test_ast_node;
   2603 	cil_tree_node_init(&test_ast_node);
   2604 
   2605 	struct cil_db *test_db;
   2606 	cil_db_init(&test_db);
   2607 
   2608 	test_ast_node->parent = test_db->ast->root;
   2609 	test_ast_node->line = 1;
   2610 
   2611 	int rc = cil_gen_typeattribute(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   2612 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   2613 }
   2614 
   2615 
   2616 void test_cil_gen_typeattribute_astnull_neg(CuTest *tc) {
   2617 	char *line[] = {"(", "typeattribute", "test", ")", NULL};
   2618 
   2619 	struct cil_tree *test_tree;
   2620 	gen_test_tree(&test_tree, line);
   2621 
   2622 	struct cil_tree_node *test_ast_node = NULL;
   2623 
   2624 	struct cil_db *test_db;
   2625 	cil_db_init(&test_db);
   2626 
   2627 	int rc = cil_gen_typeattribute(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   2628 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   2629 }
   2630 
   2631 void test_cil_gen_typeattribute_extra_neg(CuTest *tc) {
   2632 	char *line[] = {"(", "typeattribute", "foo", "bar," ")", NULL};
   2633 
   2634 	struct cil_tree *test_tree;
   2635 	gen_test_tree(&test_tree, line);
   2636 
   2637 	struct cil_tree_node *test_ast_node;
   2638 	cil_tree_node_init(&test_ast_node);
   2639 
   2640 	struct cil_db *test_db;
   2641 	cil_db_init(&test_db);
   2642 
   2643 	test_ast_node->parent = test_db->ast->root;
   2644 	test_ast_node->line = 1;
   2645 
   2646 	int rc = cil_gen_typeattribute(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   2647 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   2648 }
   2649 
   2650 void test_cil_gen_typebounds(CuTest *tc) {
   2651 	char *line[] = {"(", "typebounds", "type_a", "type_b", ")", NULL};
   2652 
   2653 	struct cil_tree *test_tree;
   2654 	gen_test_tree(&test_tree, line);
   2655 
   2656 	struct cil_tree_node *test_ast_node;
   2657 	cil_tree_node_init(&test_ast_node);
   2658 
   2659 	struct cil_db *test_db;
   2660 	cil_db_init(&test_db);
   2661 
   2662 	test_ast_node->parent = test_db->ast->root;
   2663 	test_ast_node->line = 1;
   2664 
   2665 	int rc = cil_gen_typebounds(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   2666 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   2667 }
   2668 
   2669 void test_cil_gen_typebounds_notype1_neg(CuTest *tc) {
   2670 	char *line[] = {"(", "typebounds", ")", NULL};
   2671 
   2672 	struct cil_tree *test_tree;
   2673 	gen_test_tree(&test_tree, line);
   2674 
   2675 	struct cil_tree_node *test_ast_node;
   2676 	cil_tree_node_init(&test_ast_node);
   2677 
   2678 	struct cil_db *test_db;
   2679 	cil_db_init(&test_db);
   2680 
   2681 	test_ast_node->parent = test_db->ast->root;
   2682 	test_ast_node->line = 1;
   2683 
   2684 	int rc = cil_gen_typebounds(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   2685 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   2686 }
   2687 
   2688 void test_cil_gen_typebounds_type1inparens_neg(CuTest *tc) {
   2689 	char *line[] = {"(", "typebounds", "(", "type_a", ")", "type_b", ")", NULL};
   2690 
   2691 	struct cil_tree *test_tree;
   2692 	gen_test_tree(&test_tree, line);
   2693 
   2694 	struct cil_tree_node *test_ast_node;
   2695 	cil_tree_node_init(&test_ast_node);
   2696 
   2697 	struct cil_db *test_db;
   2698 	cil_db_init(&test_db);
   2699 
   2700 	test_ast_node->parent = test_db->ast->root;
   2701 	test_ast_node->line = 1;
   2702 
   2703 	int rc = cil_gen_typebounds(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   2704 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   2705 }
   2706 
   2707 void test_cil_gen_typebounds_notype2_neg(CuTest *tc) {
   2708 	char *line[] = {"(", "typebounds", "type_a", ")", NULL};
   2709 
   2710 	struct cil_tree *test_tree;
   2711 	gen_test_tree(&test_tree, line);
   2712 
   2713 	struct cil_tree_node *test_ast_node;
   2714 	cil_tree_node_init(&test_ast_node);
   2715 
   2716 	struct cil_db *test_db;
   2717 	cil_db_init(&test_db);
   2718 
   2719 	test_ast_node->parent = test_db->ast->root;
   2720 	test_ast_node->line = 1;
   2721 
   2722 	int rc = cil_gen_typebounds(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   2723 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   2724 }
   2725 
   2726 void test_cil_gen_typebounds_type2inparens_neg(CuTest *tc) {
   2727 	char *line[] = {"(", "typebounds", "type_a", "(", "type_b", ")", ")", NULL};
   2728 
   2729 	struct cil_tree *test_tree;
   2730 	gen_test_tree(&test_tree, line);
   2731 
   2732 	struct cil_tree_node *test_ast_node;
   2733 	cil_tree_node_init(&test_ast_node);
   2734 
   2735 	struct cil_db *test_db;
   2736 	cil_db_init(&test_db);
   2737 
   2738 	test_ast_node->parent = test_db->ast->root;
   2739 	test_ast_node->line = 1;
   2740 
   2741 	int rc = cil_gen_typebounds(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   2742 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   2743 }
   2744 
   2745 void test_cil_gen_typebounds_extra_neg(CuTest *tc) {
   2746 	char *line[] = {"(", "typebounds", "type_a", "type_b", "extra", ")", NULL};
   2747 
   2748 	struct cil_tree *test_tree;
   2749 	gen_test_tree(&test_tree, line);
   2750 
   2751 	struct cil_tree_node *test_ast_node;
   2752 	cil_tree_node_init(&test_ast_node);
   2753 
   2754 	struct cil_db *test_db;
   2755 	cil_db_init(&test_db);
   2756 
   2757 	test_ast_node->parent = test_db->ast->root;
   2758 	test_ast_node->line = 1;
   2759 
   2760 	int rc = cil_gen_typebounds(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   2761 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   2762 }
   2763 
   2764 void test_cil_gen_typebounds_dbnull_neg(CuTest *tc) {
   2765 	char *line[] = {"(", "typebounds", "type_a", "type_b", ")", NULL};
   2766 
   2767 	struct cil_tree *test_tree;
   2768 	gen_test_tree(&test_tree, line);
   2769 
   2770 	struct cil_tree_node *test_ast_node;
   2771 	cil_tree_node_init(&test_ast_node);
   2772 
   2773 	struct cil_db *test_db = NULL;
   2774 
   2775 	int rc = cil_gen_typebounds(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   2776 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   2777 }
   2778 
   2779 void test_cil_gen_typebounds_currnull_neg(CuTest *tc) {
   2780 	char *line[] = {"(", ")", NULL};
   2781 
   2782 	struct cil_tree *test_tree;
   2783 	gen_test_tree(&test_tree, line);
   2784 
   2785 	struct cil_tree_node *test_ast_node;
   2786 	cil_tree_node_init(&test_ast_node);
   2787 
   2788 	struct cil_db *test_db;
   2789 	cil_db_init(&test_db);
   2790 
   2791 	test_ast_node->parent = test_db->ast->root;
   2792 	test_ast_node->line = 1;
   2793 
   2794 	int rc = cil_gen_typebounds(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   2795 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   2796 }
   2797 
   2798 void test_cil_gen_typebounds_astnull_neg(CuTest *tc) {
   2799 	char *line[] = {"(", "typebounds", "type_a", "type_b", ")", NULL};
   2800 
   2801 	struct cil_tree *test_tree;
   2802 	gen_test_tree(&test_tree, line);
   2803 
   2804 	struct cil_tree_node *test_ast_node = NULL;
   2805 
   2806 	struct cil_db *test_db;
   2807 	cil_db_init(&test_db);
   2808 
   2809 	int rc = cil_gen_typebounds(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   2810 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   2811 }
   2812 
   2813 void test_cil_gen_typepermissive(CuTest *tc) {
   2814 	char *line[] = {"(", "typepermissive", "type_a", ")", NULL};
   2815 
   2816 	struct cil_tree *test_tree;
   2817 	gen_test_tree(&test_tree, line);
   2818 
   2819 	struct cil_tree_node *test_ast_node;
   2820 	cil_tree_node_init(&test_ast_node);
   2821 
   2822 	struct cil_db *test_db;
   2823 	cil_db_init(&test_db);
   2824 
   2825 	test_ast_node->parent = test_db->ast->root;
   2826 	test_ast_node->line = 1;
   2827 
   2828 	int rc = cil_gen_typepermissive(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   2829 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   2830 }
   2831 
   2832 void test_cil_gen_typepermissive_noname_neg(CuTest *tc) {
   2833 	char *line[] = {"(", "typepermissive", ")", NULL};
   2834 
   2835 	struct cil_tree *test_tree;
   2836 	gen_test_tree(&test_tree, line);
   2837 
   2838 	struct cil_tree_node *test_ast_node;
   2839 	cil_tree_node_init(&test_ast_node);
   2840 
   2841 	struct cil_db *test_db;
   2842 	cil_db_init(&test_db);
   2843 
   2844 	test_ast_node->parent = test_db->ast->root;
   2845 	test_ast_node->line = 1;
   2846 
   2847 	int rc = cil_gen_typepermissive(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   2848 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   2849 }
   2850 
   2851 void test_cil_gen_typepermissive_typeinparens_neg(CuTest *tc) {
   2852 	char *line[] = {"(", "typepermissive", "(", "type_a", ")", ")", NULL};
   2853 
   2854 	struct cil_tree *test_tree;
   2855 	gen_test_tree(&test_tree, line);
   2856 
   2857 	struct cil_tree_node *test_ast_node;
   2858 	cil_tree_node_init(&test_ast_node);
   2859 
   2860 	struct cil_db *test_db;
   2861 	cil_db_init(&test_db);
   2862 
   2863 	test_ast_node->parent = test_db->ast->root;
   2864 	test_ast_node->line = 1;
   2865 
   2866 	int rc = cil_gen_typepermissive(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   2867 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   2868 }
   2869 
   2870 void test_cil_gen_typepermissive_extra_neg(CuTest *tc) {
   2871 	char *line[] = {"(", "typepermissive", "type_a", "extra", ")", NULL};
   2872 
   2873 	struct cil_tree *test_tree;
   2874 	gen_test_tree(&test_tree, line);
   2875 
   2876 	struct cil_tree_node *test_ast_node;
   2877 	cil_tree_node_init(&test_ast_node);
   2878 
   2879 	struct cil_db *test_db;
   2880 	cil_db_init(&test_db);
   2881 
   2882 	test_ast_node->parent = test_db->ast->root;
   2883 	test_ast_node->line = 1;
   2884 
   2885 	int rc = cil_gen_typepermissive(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   2886 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   2887 }
   2888 
   2889 void test_cil_gen_typepermissive_dbnull_neg(CuTest *tc) {
   2890 	char *line[] = {"(", "typepermissive", "type_a", ")", NULL};
   2891 
   2892 	struct cil_tree *test_tree;
   2893 	gen_test_tree(&test_tree, line);
   2894 
   2895 	struct cil_tree_node *test_ast_node;
   2896 	cil_tree_node_init(&test_ast_node);
   2897 
   2898 	struct cil_db *test_db = NULL;
   2899 
   2900 	int rc = cil_gen_typepermissive(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   2901 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   2902 }
   2903 
   2904 void test_cil_gen_typepermissive_currnull_neg(CuTest *tc) {
   2905 	char *line[] = {"(", ")", NULL};
   2906 
   2907 	struct cil_tree *test_tree;
   2908 	gen_test_tree(&test_tree, line);
   2909 
   2910 	struct cil_tree_node *test_ast_node;
   2911 	cil_tree_node_init(&test_ast_node);
   2912 
   2913 	struct cil_db *test_db;
   2914 	cil_db_init(&test_db);
   2915 
   2916 	test_ast_node->parent = test_db->ast->root;
   2917 	test_ast_node->line = 1;
   2918 
   2919 	int rc = cil_gen_typepermissive(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   2920 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   2921 }
   2922 
   2923 void test_cil_gen_typepermissive_astnull_neg(CuTest *tc) {
   2924 	char *line[] = {"(", "typepermissive", "type_a", ")", NULL};
   2925 
   2926 	struct cil_tree *test_tree;
   2927 	gen_test_tree(&test_tree, line);
   2928 
   2929 	struct cil_tree_node *test_ast_node = NULL;
   2930 
   2931 	struct cil_db *test_db;
   2932 	cil_db_init(&test_db);
   2933 
   2934 	int rc = cil_gen_typepermissive(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   2935 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   2936 }
   2937 
   2938 void test_cil_gen_nametypetransition(CuTest *tc) {
   2939 	char *line[] = {"(", "nametypetransition", "str", "foo", "bar", "file", "foobar", ")", NULL};
   2940 
   2941 	struct cil_tree *test_tree;
   2942 	gen_test_tree(&test_tree, line);
   2943 
   2944 	struct cil_tree_node *test_ast_node;
   2945 	cil_tree_node_init(&test_ast_node);
   2946 
   2947 	struct cil_db *test_db;
   2948 	cil_db_init(&test_db);
   2949 
   2950 	test_ast_node->parent = test_db->ast->root;
   2951 	test_ast_node->line = 1;
   2952 
   2953 	int rc = cil_gen_nametypetransition(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   2954 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   2955 }
   2956 
   2957 void test_cil_gen_nametypetransition_strinparens_neg(CuTest *tc) {
   2958 	char *line[] = {"(", "nametypetransition", "(", "str", ")", "foo", "bar", "file", "foobar", ")", NULL};
   2959 
   2960 	struct cil_tree *test_tree;
   2961 	gen_test_tree(&test_tree, line);
   2962 
   2963 	struct cil_tree_node *test_ast_node;
   2964 	cil_tree_node_init(&test_ast_node);
   2965 
   2966 	struct cil_db *test_db;
   2967 	cil_db_init(&test_db);
   2968 
   2969 	test_ast_node->parent = test_db->ast->root;
   2970 	test_ast_node->line = 1;
   2971 
   2972 	int rc = cil_gen_nametypetransition(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   2973 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   2974 }
   2975 
   2976 void test_cil_gen_nametypetransition_nostr_neg(CuTest *tc) {
   2977 	char *line[] = {"(", "nametypetransition", ")", NULL};
   2978 
   2979 	struct cil_tree *test_tree;
   2980 	gen_test_tree(&test_tree, line);
   2981 
   2982 	struct cil_tree_node *test_ast_node;
   2983 	cil_tree_node_init(&test_ast_node);
   2984 
   2985 	struct cil_db *test_db;
   2986 	cil_db_init(&test_db);
   2987 
   2988 	test_ast_node->parent = test_db->ast->root;
   2989 	test_ast_node->line = 1;
   2990 
   2991 	int rc = cil_gen_nametypetransition(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   2992 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   2993 }
   2994 
   2995 void test_cil_gen_nametypetransition_srcinparens_neg(CuTest *tc) {
   2996 	char *line[] = {"(", "nametypetransition", "str", "(", "foo", ")", "bar", "file", "foobar", ")", NULL};
   2997 
   2998 	struct cil_tree *test_tree;
   2999 	gen_test_tree(&test_tree, line);
   3000 
   3001 	struct cil_tree_node *test_ast_node;
   3002 	cil_tree_node_init(&test_ast_node);
   3003 
   3004 	struct cil_db *test_db;
   3005 	cil_db_init(&test_db);
   3006 
   3007 	test_ast_node->parent = test_db->ast->root;
   3008 	test_ast_node->line = 1;
   3009 
   3010 	int rc = cil_gen_nametypetransition(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   3011 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   3012 }
   3013 
   3014 void test_cil_gen_nametypetransition_nosrc_neg(CuTest *tc) {
   3015 	char *line[] = {"(", "nametypetransition", "str", ")", NULL};
   3016 
   3017 	struct cil_tree *test_tree;
   3018 	gen_test_tree(&test_tree, line);
   3019 
   3020 	struct cil_tree_node *test_ast_node;
   3021 	cil_tree_node_init(&test_ast_node);
   3022 
   3023 	struct cil_db *test_db;
   3024 	cil_db_init(&test_db);
   3025 
   3026 	test_ast_node->parent = test_db->ast->root;
   3027 	test_ast_node->line = 1;
   3028 
   3029 	int rc = cil_gen_nametypetransition(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   3030 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   3031 }
   3032 
   3033 void test_cil_gen_nametypetransition_tgtinparens_neg(CuTest *tc) {
   3034 	char *line[] = {"(", "nametypetransition", "str", "foo", "(", "bar", ")", "file", "foobar", ")", NULL};
   3035 
   3036 	struct cil_tree *test_tree;
   3037 	gen_test_tree(&test_tree, line);
   3038 
   3039 	struct cil_tree_node *test_ast_node;
   3040 	cil_tree_node_init(&test_ast_node);
   3041 
   3042 	struct cil_db *test_db;
   3043 	cil_db_init(&test_db);
   3044 
   3045 	test_ast_node->parent = test_db->ast->root;
   3046 	test_ast_node->line = 1;
   3047 
   3048 	int rc = cil_gen_nametypetransition(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   3049 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   3050 }
   3051 
   3052 void test_cil_gen_nametypetransition_notgt_neg(CuTest *tc) {
   3053 	char *line[] = {"(", "nametypetransition", "str", "foo", ")", NULL};
   3054 
   3055 	struct cil_tree *test_tree;
   3056 	gen_test_tree(&test_tree, line);
   3057 
   3058 	struct cil_tree_node *test_ast_node;
   3059 	cil_tree_node_init(&test_ast_node);
   3060 
   3061 	struct cil_db *test_db;
   3062 	cil_db_init(&test_db);
   3063 
   3064 	test_ast_node->parent = test_db->ast->root;
   3065 	test_ast_node->line = 1;
   3066 
   3067 	int rc = cil_gen_nametypetransition(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   3068 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   3069 }
   3070 
   3071 void test_cil_gen_nametypetransition_classinparens_neg(CuTest *tc) {
   3072 	char *line[] = {"(", "nametypetransition", "str", "foo", "bar", "(", "file", ")", "foobar", ")", NULL};
   3073 
   3074 	struct cil_tree *test_tree;
   3075 	gen_test_tree(&test_tree, line);
   3076 
   3077 	struct cil_tree_node *test_ast_node;
   3078 	cil_tree_node_init(&test_ast_node);
   3079 
   3080 	struct cil_db *test_db;
   3081 	cil_db_init(&test_db);
   3082 
   3083 	test_ast_node->parent = test_db->ast->root;
   3084 	test_ast_node->line = 1;
   3085 
   3086 	int rc = cil_gen_nametypetransition(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   3087 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   3088 }
   3089 
   3090 void test_cil_gen_nametypetransition_noclass_neg(CuTest *tc) {
   3091 	char *line[] = {"(", "nametypetransition", "str", "foo", "bar", ")", NULL};
   3092 
   3093 	struct cil_tree *test_tree;
   3094 	gen_test_tree(&test_tree, line);
   3095 
   3096 	struct cil_tree_node *test_ast_node;
   3097 	cil_tree_node_init(&test_ast_node);
   3098 
   3099 	struct cil_db *test_db;
   3100 	cil_db_init(&test_db);
   3101 
   3102 	test_ast_node->parent = test_db->ast->root;
   3103 	test_ast_node->line = 1;
   3104 
   3105 	int rc = cil_gen_nametypetransition(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   3106 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   3107 }
   3108 
   3109 void test_cil_gen_nametypetransition_destinparens_neg(CuTest *tc) {
   3110 	char *line[] = {"(", "nametypetransition", "str", "foo", "bar", "file", "(", "foobar", ")", ")", NULL};
   3111 
   3112 	struct cil_tree *test_tree;
   3113 	gen_test_tree(&test_tree, line);
   3114 
   3115 	struct cil_tree_node *test_ast_node;
   3116 	cil_tree_node_init(&test_ast_node);
   3117 
   3118 	struct cil_db *test_db;
   3119 	cil_db_init(&test_db);
   3120 
   3121 	test_ast_node->parent = test_db->ast->root;
   3122 	test_ast_node->line = 1;
   3123 
   3124 	int rc = cil_gen_nametypetransition(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   3125 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   3126 }
   3127 
   3128 void test_cil_gen_nametypetransition_nodest_neg(CuTest *tc) {
   3129 	char *line[] = {"(", "nametypetransition", "str", "foo", "bar", "file", ")", NULL};
   3130 
   3131 	struct cil_tree *test_tree;
   3132 	gen_test_tree(&test_tree, line);
   3133 
   3134 	struct cil_tree_node *test_ast_node;
   3135 	cil_tree_node_init(&test_ast_node);
   3136 
   3137 	struct cil_db *test_db;
   3138 	cil_db_init(&test_db);
   3139 
   3140 	test_ast_node->parent = test_db->ast->root;
   3141 	test_ast_node->line = 1;
   3142 
   3143 	int rc = cil_gen_nametypetransition(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   3144 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   3145 }
   3146 
   3147 
   3148 void test_cil_gen_nametypetransition_extra_neg(CuTest *tc) {
   3149 	char *line[] = {"(", "nametypetransition", "str", "foo", "bar", "file", "foobar", "extra", ")", NULL};
   3150 
   3151 	struct cil_tree *test_tree;
   3152 	gen_test_tree(&test_tree, line);
   3153 
   3154 	struct cil_tree_node *test_ast_node;
   3155 	cil_tree_node_init(&test_ast_node);
   3156 
   3157 	struct cil_db *test_db;
   3158 	cil_db_init(&test_db);
   3159 
   3160 	test_ast_node->parent = test_db->ast->root;
   3161 	test_ast_node->line = 1;
   3162 
   3163 	int rc = cil_gen_nametypetransition(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   3164 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   3165 }
   3166 
   3167 void test_cil_gen_nametypetransition_dbnull_neg(CuTest *tc) {
   3168 	char *line[] = {"(", "nametypetransition", "str", "foo", "bar", "file", "foobar", "extra", ")", NULL};
   3169 
   3170 	struct cil_tree *test_tree;
   3171 	gen_test_tree(&test_tree, line);
   3172 
   3173 	struct cil_tree_node *test_ast_node;
   3174 	cil_tree_node_init(&test_ast_node);
   3175 
   3176 	struct cil_db *test_db = NULL;
   3177 
   3178 	int rc = cil_gen_nametypetransition(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   3179 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   3180 }
   3181 
   3182 void test_cil_gen_nametypetransition_currnull_neg(CuTest *tc) {
   3183 	char *line[] = {"(", ")", NULL};
   3184 
   3185 	struct cil_tree *test_tree;
   3186 	gen_test_tree(&test_tree, line);
   3187 
   3188 	struct cil_tree_node *test_ast_node;
   3189 	cil_tree_node_init(&test_ast_node);
   3190 
   3191 	struct cil_db *test_db;
   3192 	cil_db_init(&test_db);
   3193 
   3194 	test_ast_node->parent = test_db->ast->root;
   3195 	test_ast_node->line = 1;
   3196 
   3197 	int rc = cil_gen_nametypetransition(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   3198 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   3199 }
   3200 
   3201 void test_cil_gen_nametypetransition_astnull_neg(CuTest *tc) {
   3202 	char *line[] = {"(", "nametypetransition", "str", "foo", "bar", "file", "foobar", ")", NULL};
   3203 
   3204 	struct cil_tree *test_tree;
   3205 	gen_test_tree(&test_tree, line);
   3206 
   3207 	struct cil_tree_node *test_ast_node = NULL;
   3208 
   3209 	struct cil_db *test_db;
   3210 	cil_db_init(&test_db);
   3211 
   3212 	int rc = cil_gen_nametypetransition(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   3213 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   3214 }
   3215 
   3216 void test_cil_gen_rangetransition(CuTest *tc) {
   3217 	char *line[] = {"(", "rangetransition", "type_a_t", "type_b_t", "class", "(", "low_l", "high_l", ")", ")", NULL};
   3218 
   3219 	struct cil_tree *test_tree;
   3220 	gen_test_tree(&test_tree, line);
   3221 
   3222 	struct cil_tree_node *test_ast_node;
   3223 	cil_tree_node_init(&test_ast_node);
   3224 
   3225 	struct cil_db *test_db;
   3226 	cil_db_init(&test_db);
   3227 
   3228 	test_ast_node->parent = test_db->ast->root;
   3229 	test_ast_node->line = 1;
   3230 
   3231 	int rc = cil_gen_rangetransition(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   3232 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   3233 }
   3234 
   3235 void test_cil_gen_rangetransition_namedtransition(CuTest *tc) {
   3236 	char *line[] = {"(", "rangetransition", "type_a_t", "type_b_t", "class", "namedtrans", ")", NULL};
   3237 
   3238 	struct cil_tree *test_tree;
   3239 	gen_test_tree(&test_tree, line);
   3240 
   3241 	struct cil_tree_node *test_ast_node;
   3242 	cil_tree_node_init(&test_ast_node);
   3243 
   3244 	struct cil_db *test_db;
   3245 	cil_db_init(&test_db);
   3246 
   3247 	test_ast_node->parent = test_db->ast->root;
   3248 	test_ast_node->line = 1;
   3249 
   3250 	int rc = cil_gen_rangetransition(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   3251 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   3252 }
   3253 
   3254 void test_cil_gen_rangetransition_anon_low_l(CuTest *tc) {
   3255 	char *line[] = {"(", "rangetransition", "type_a_t", "type_b_t", "class", "(", "(", "s0", "(", "c0", ")", ")", "high_l", ")", ")", NULL};
   3256 
   3257 	struct cil_tree *test_tree;
   3258 	gen_test_tree(&test_tree, line);
   3259 
   3260 	struct cil_tree_node *test_ast_node;
   3261 	cil_tree_node_init(&test_ast_node);
   3262 
   3263 	struct cil_db *test_db;
   3264 	cil_db_init(&test_db);
   3265 
   3266 	test_ast_node->parent = test_db->ast->root;
   3267 	test_ast_node->line = 1;
   3268 
   3269 	int rc = cil_gen_rangetransition(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   3270 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   3271 }
   3272 
   3273 void test_cil_gen_rangetransition_anon_low_l_neg(CuTest *tc) {
   3274 	char *line[] = {"(", "rangetransition", "type_a_t", "type_b_t", "class", "(", "(", "s0", "(", ")", ")", "high_l", ")", ")", NULL};
   3275 
   3276 	struct cil_tree *test_tree;
   3277 	gen_test_tree(&test_tree, line);
   3278 
   3279 	struct cil_tree_node *test_ast_node;
   3280 	cil_tree_node_init(&test_ast_node);
   3281 
   3282 	struct cil_db *test_db;
   3283 	cil_db_init(&test_db);
   3284 
   3285 	test_ast_node->parent = test_db->ast->root;
   3286 	test_ast_node->line = 1;
   3287 
   3288 	int rc = cil_gen_rangetransition(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   3289 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   3290 }
   3291 
   3292 void test_cil_gen_rangetransition_anon_high_l(CuTest *tc) {
   3293 	char *line[] = {"(", "rangetransition", "type_a_t", "type_b_t", "class", "(", "low_l", "(", "s0", "(", "c0", ")",  ")", ")", ")", NULL};
   3294 
   3295 	struct cil_tree *test_tree;
   3296 	gen_test_tree(&test_tree, line);
   3297 
   3298 	struct cil_tree_node *test_ast_node;
   3299 	cil_tree_node_init(&test_ast_node);
   3300 
   3301 	struct cil_db *test_db;
   3302 	cil_db_init(&test_db);
   3303 
   3304 	test_ast_node->parent = test_db->ast->root;
   3305 	test_ast_node->line = 1;
   3306 
   3307 	int rc = cil_gen_rangetransition(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   3308 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   3309 }
   3310 
   3311 void test_cil_gen_rangetransition_anon_high_l_neg(CuTest *tc) {
   3312 	char *line[] = {"(", "rangetransition", "type_a_t", "type_b_t", "class", "(", "low_l", "(", "s0", "(", ")",  ")", ")", ")", NULL};
   3313 
   3314 	struct cil_tree *test_tree;
   3315 	gen_test_tree(&test_tree, line);
   3316 
   3317 	struct cil_tree_node *test_ast_node;
   3318 	cil_tree_node_init(&test_ast_node);
   3319 
   3320 	struct cil_db *test_db;
   3321 	cil_db_init(&test_db);
   3322 
   3323 	test_ast_node->parent = test_db->ast->root;
   3324 	test_ast_node->line = 1;
   3325 
   3326 	int rc = cil_gen_rangetransition(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   3327 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   3328 }
   3329 
   3330 void test_cil_gen_rangetransition_dbnull_neg(CuTest *tc) {
   3331 	char *line[] = {"(", "rangetransition", "type_a_t", "type_b_t", "class", "(", "low_l", "high_l", ")", ")", NULL};
   3332 
   3333 	struct cil_tree *test_tree;
   3334 	gen_test_tree(&test_tree, line);
   3335 
   3336 	struct cil_tree_node *test_ast_node;
   3337 	cil_tree_node_init(&test_ast_node);
   3338 
   3339 	struct cil_db *test_db = NULL;
   3340 
   3341 	int rc = cil_gen_rangetransition(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   3342 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   3343 }
   3344 
   3345 void test_cil_gen_rangetransition_currnull_neg(CuTest *tc) {
   3346 	char *line[] = {"(", ")", NULL};
   3347 
   3348 	struct cil_tree *test_tree;
   3349 	gen_test_tree(&test_tree, line);
   3350 
   3351 	struct cil_tree_node *test_ast_node;
   3352 	cil_tree_node_init(&test_ast_node);
   3353 
   3354 	struct cil_db *test_db;
   3355 	cil_db_init(&test_db);
   3356 
   3357 	test_ast_node->parent = test_db->ast->root;
   3358 	test_ast_node->line = 1;
   3359 
   3360 	int rc = cil_gen_rangetransition(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   3361 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   3362 }
   3363 
   3364 void test_cil_gen_rangetransition_astnull_neg(CuTest *tc) {
   3365 	char *line[] = {"(", "rangetransition", "type_a_t", "type_b_t", "class", "(", "low_l", "high_l", ")", ")", NULL};
   3366 
   3367 	struct cil_tree *test_tree;
   3368 	gen_test_tree(&test_tree, line);
   3369 
   3370 	struct cil_tree_node *test_ast_node = NULL;
   3371 
   3372 	struct cil_db *test_db;
   3373 	cil_db_init(&test_db);
   3374 
   3375 	int rc = cil_gen_rangetransition(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   3376 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   3377 }
   3378 
   3379 void test_cil_gen_rangetransition_nofirsttype_neg(CuTest *tc) {
   3380 	char *line[] = {"(", "rangetransition", ")", NULL};
   3381 
   3382 	struct cil_tree *test_tree;
   3383 	gen_test_tree(&test_tree, line);
   3384 
   3385 	struct cil_tree_node *test_ast_node;
   3386 	cil_tree_node_init(&test_ast_node);
   3387 
   3388 	struct cil_db *test_db;
   3389 	cil_db_init(&test_db);
   3390 
   3391 	test_ast_node->parent = test_db->ast->root;
   3392 	test_ast_node->line = 1;
   3393 
   3394 	int rc = cil_gen_rangetransition(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   3395 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   3396 }
   3397 
   3398 void test_cil_gen_rangetransition_firsttype_inparens_neg(CuTest *tc) {
   3399 	char *line[] = {"(", "rangetransition", "(", "type_a_t", ")", "type_b_t", "class", "(", "low_l", "high_l", ")", ")", NULL};
   3400 
   3401 	struct cil_tree *test_tree;
   3402 	gen_test_tree(&test_tree, line);
   3403 
   3404 	struct cil_tree_node *test_ast_node;
   3405 	cil_tree_node_init(&test_ast_node);
   3406 
   3407 	struct cil_db *test_db;
   3408 	cil_db_init(&test_db);
   3409 
   3410 	test_ast_node->parent = test_db->ast->root;
   3411 	test_ast_node->line = 1;
   3412 
   3413 	int rc = cil_gen_rangetransition(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   3414 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   3415 }
   3416 
   3417 void test_cil_gen_rangetransition_nosecondtype_neg(CuTest *tc) {
   3418 	char *line[] = {"(", "rangetransition", "type_a_t", ")", NULL};
   3419 
   3420 	struct cil_tree *test_tree;
   3421 	gen_test_tree(&test_tree, line);
   3422 
   3423 	struct cil_tree_node *test_ast_node;
   3424 	cil_tree_node_init(&test_ast_node);
   3425 
   3426 	struct cil_db *test_db;
   3427 	cil_db_init(&test_db);
   3428 
   3429 	test_ast_node->parent = test_db->ast->root;
   3430 	test_ast_node->line = 1;
   3431 
   3432 	int rc = cil_gen_rangetransition(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   3433 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   3434 }
   3435 
   3436 void test_cil_gen_rangetransition_secondtype_inparens_neg(CuTest *tc) {
   3437 	char *line[] = {"(", "rangetransition", "type_a_t", "(", "type_b_t", ")", "class", "(", "low_l", "high_l", ")", ")", NULL};
   3438 
   3439 	struct cil_tree *test_tree;
   3440 	gen_test_tree(&test_tree, line);
   3441 
   3442 	struct cil_tree_node *test_ast_node;
   3443 	cil_tree_node_init(&test_ast_node);
   3444 
   3445 	struct cil_db *test_db;
   3446 	cil_db_init(&test_db);
   3447 
   3448 	test_ast_node->parent = test_db->ast->root;
   3449 	test_ast_node->line = 1;
   3450 
   3451 	int rc = cil_gen_rangetransition(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   3452 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   3453 }
   3454 
   3455 void test_cil_gen_rangetransition_noclass_neg(CuTest *tc) {
   3456 	char *line[] = {"(", "rangetransition", "type_a_t", "type_b_t", ")", NULL};
   3457 
   3458 	struct cil_tree *test_tree;
   3459 	gen_test_tree(&test_tree, line);
   3460 
   3461 	struct cil_tree_node *test_ast_node;
   3462 	cil_tree_node_init(&test_ast_node);
   3463 
   3464 	struct cil_db *test_db;
   3465 	cil_db_init(&test_db);
   3466 
   3467 	test_ast_node->parent = test_db->ast->root;
   3468 	test_ast_node->line = 1;
   3469 
   3470 	int rc = cil_gen_rangetransition(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   3471 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   3472 }
   3473 
   3474 void test_cil_gen_rangetransition_class_inparens_neg(CuTest *tc) {
   3475 	char *line[] = {"(", "rangetransition", "type_a_t", "type_b_t", "(", "class", ")", "(", "low_l", "high_l", ")", ")", NULL};
   3476 
   3477 	struct cil_tree *test_tree;
   3478 	gen_test_tree(&test_tree, line);
   3479 
   3480 	struct cil_tree_node *test_ast_node;
   3481 	cil_tree_node_init(&test_ast_node);
   3482 
   3483 	struct cil_db *test_db;
   3484 	cil_db_init(&test_db);
   3485 
   3486 	test_ast_node->parent = test_db->ast->root;
   3487 	test_ast_node->line = 1;
   3488 
   3489 	int rc = cil_gen_rangetransition(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   3490 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   3491 }
   3492 
   3493 void test_cil_gen_rangetransition_nolevel_l_neg(CuTest *tc) {
   3494 	char *line[] = {"(", "rangetransition", "type_a_t", "type_b_t", "class", ")", NULL};
   3495 
   3496 	struct cil_tree *test_tree;
   3497 	gen_test_tree(&test_tree, line);
   3498 
   3499 	struct cil_tree_node *test_ast_node;
   3500 	cil_tree_node_init(&test_ast_node);
   3501 
   3502 	struct cil_db *test_db;
   3503 	cil_db_init(&test_db);
   3504 
   3505 	test_ast_node->parent = test_db->ast->root;
   3506 	test_ast_node->line = 1;
   3507 
   3508 	int rc = cil_gen_rangetransition(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   3509 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   3510 }
   3511 
   3512 void test_cil_gen_rangetransition_nolevel_h_neg(CuTest *tc) {
   3513 	char *line[] = {"(", "rangetransition", "type_a_t", "type_b_t", "class", "(", "low_l", ")", ")", NULL};
   3514 
   3515 	struct cil_tree *test_tree;
   3516 	gen_test_tree(&test_tree, line);
   3517 
   3518 	struct cil_tree_node *test_ast_node;
   3519 	cil_tree_node_init(&test_ast_node);
   3520 
   3521 	struct cil_db *test_db;
   3522 	cil_db_init(&test_db);
   3523 
   3524 	test_ast_node->parent = test_db->ast->root;
   3525 	test_ast_node->line = 1;
   3526 
   3527 	int rc = cil_gen_rangetransition(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   3528 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   3529 }
   3530 
   3531 void test_cil_gen_rangetransition_extra_neg(CuTest *tc) {
   3532 	char *line[] = {"(", "rangetransition", "type_a_t", "type_b_t", "class", "(", "low_l", "high_l", ")", "extra", ")", NULL};
   3533 
   3534 	struct cil_tree *test_tree;
   3535 	gen_test_tree(&test_tree, line);
   3536 
   3537 	struct cil_tree_node *test_ast_node;
   3538 	cil_tree_node_init(&test_ast_node);
   3539 
   3540 	struct cil_db *test_db;
   3541 	cil_db_init(&test_db);
   3542 
   3543 	test_ast_node->parent = test_db->ast->root;
   3544 	test_ast_node->line = 1;
   3545 
   3546 	int rc = cil_gen_rangetransition(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   3547 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   3548 }
   3549 
   3550 void test_cil_gen_expr_stack_and(CuTest *tc) {
   3551 	char *line[] = {"(", "booleanif", "(", "and", "foo", "bar", ")",
   3552 			"(", "true", "(", "allow", "foo", "bar", "baz", "(", "read", ")", ")", ")", ")", NULL};
   3553 
   3554 	struct cil_tree *test_tree;
   3555 	gen_test_tree(&test_tree, line);
   3556 
   3557 	struct cil_tree_node *test_ast_node;
   3558 	cil_tree_node_init(&test_ast_node);
   3559 
   3560 	struct cil_db *test_db;
   3561 	cil_db_init(&test_db);
   3562 
   3563 	test_ast_node->parent = test_db->ast->root;
   3564 	test_ast_node->line = 1;
   3565 
   3566 	struct cil_booleanif *bif;
   3567 	cil_boolif_init(&bif);
   3568 
   3569 	int rc = cil_gen_expr_stack(test_tree->root->cl_head->cl_head->next, CIL_BOOL, &bif->expr_stack);
   3570 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   3571 }
   3572 
   3573 void test_cil_gen_expr_stack_or(CuTest *tc) {
   3574 	char *line[] = {"(", "booleanif", "(", "or", "foo", "bar", ")",
   3575 			"(", "true", "(", "allow", "foo", "bar", "baz", "(", "read", ")", ")", ")", NULL};
   3576 
   3577 	struct cil_tree *test_tree;
   3578 	gen_test_tree(&test_tree, line);
   3579 
   3580 	struct cil_tree_node *test_ast_node;
   3581 	cil_tree_node_init(&test_ast_node);
   3582 
   3583 	struct cil_db *test_db;
   3584 	cil_db_init(&test_db);
   3585 
   3586 	test_ast_node->parent = test_db->ast->root;
   3587 	test_ast_node->line = 1;
   3588 
   3589 	struct cil_booleanif *bif;
   3590 	cil_boolif_init(&bif);
   3591 
   3592 	int rc = cil_gen_expr_stack(test_tree->root->cl_head->cl_head->next, CIL_BOOL, &bif->expr_stack);
   3593 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   3594 }
   3595 
   3596 void test_cil_gen_expr_stack_xor(CuTest *tc) {
   3597 	char *line[] = {"(", "booleanif", "(", "xor", "foo", "bar", ")",
   3598 			"(", "true", "(", "allow", "foo", "bar", "baz", "(", "read", ")", ")", ")", ")", NULL};
   3599 
   3600 	struct cil_tree *test_tree;
   3601 	gen_test_tree(&test_tree, line);
   3602 
   3603 	struct cil_tree_node *test_ast_node;
   3604 	cil_tree_node_init(&test_ast_node);
   3605 
   3606 	struct cil_db *test_db;
   3607 	cil_db_init(&test_db);
   3608 
   3609 	test_ast_node->parent = test_db->ast->root;
   3610 	test_ast_node->line = 1;
   3611 
   3612 	struct cil_booleanif *bif;
   3613 	cil_boolif_init(&bif);
   3614 
   3615 	int rc = cil_gen_expr_stack(test_tree->root->cl_head->cl_head->next, CIL_BOOL, &bif->expr_stack);
   3616 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   3617 }
   3618 
   3619 void test_cil_gen_expr_stack_not(CuTest *tc) {
   3620 	char *line[] = {"(", "booleanif", "(", "not", "foo", ")",
   3621 			"(", "true", "(", "allow", "foo", "bar", "baz", "(", "read", ")", ")", ")", ")", NULL};
   3622 
   3623 	struct cil_tree *test_tree;
   3624 	gen_test_tree(&test_tree, line);
   3625 
   3626 	struct cil_tree_node *test_ast_node;
   3627 	cil_tree_node_init(&test_ast_node);
   3628 
   3629 	struct cil_db *test_db;
   3630 	cil_db_init(&test_db);
   3631 
   3632 	test_ast_node->parent = test_db->ast->root;
   3633 	test_ast_node->line = 1;
   3634 
   3635 	struct cil_booleanif *bif;
   3636 	cil_boolif_init(&bif);
   3637 
   3638 	int rc = cil_gen_expr_stack(test_tree->root->cl_head->cl_head->next, CIL_BOOL, &bif->expr_stack);
   3639 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   3640 }
   3641 
   3642 void test_cil_gen_expr_stack_not_noexpr_neg(CuTest *tc) {
   3643 	char *line[] = {"(", "booleanif", "(", "not", ")",
   3644 			"(", "true", "(", "allow", "foo", "bar", "baz", "(", "read", ")", ")", ")", ")", NULL};
   3645 
   3646 	struct cil_tree *test_tree;
   3647 	gen_test_tree(&test_tree, line);
   3648 
   3649 	struct cil_tree_node *test_ast_node;
   3650 	cil_tree_node_init(&test_ast_node);
   3651 
   3652 	struct cil_db *test_db;
   3653 	cil_db_init(&test_db);
   3654 
   3655 	test_ast_node->parent = test_db->ast->root;
   3656 	test_ast_node->line = 1;
   3657 
   3658 	struct cil_booleanif *bif;
   3659 	cil_boolif_init(&bif);
   3660 
   3661 	int rc = cil_gen_expr_stack(test_tree->root->cl_head->cl_head->next, CIL_BOOL, &bif->expr_stack);
   3662 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   3663 }
   3664 
   3665 void test_cil_gen_expr_stack_not_extraexpr_neg(CuTest *tc) {
   3666 	char *line[] = {"(", "booleanif", "(", "not", "foo", "bar", ")",
   3667 			"(", "true", "(", "allow", "foo", "bar", "baz", "(", "read", ")", ")", ")", ")", NULL};
   3668 
   3669 	struct cil_tree *test_tree;
   3670 	gen_test_tree(&test_tree, line);
   3671 
   3672 	struct cil_tree_node *test_ast_node;
   3673 	cil_tree_node_init(&test_ast_node);
   3674 
   3675 	struct cil_db *test_db;
   3676 	cil_db_init(&test_db);
   3677 
   3678 	test_ast_node->parent = test_db->ast->root;
   3679 	test_ast_node->line = 1;
   3680 
   3681 	struct cil_booleanif *bif;
   3682 	cil_boolif_init(&bif);
   3683 
   3684 	int rc = cil_gen_expr_stack(test_tree->root->cl_head->cl_head->next, CIL_BOOL, &bif->expr_stack);
   3685 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   3686 }
   3687 
   3688 void test_cil_gen_expr_stack_eq(CuTest *tc) {
   3689 	char *line[] = {"(", "booleanif", "(", "eq", "foo", "bar", ")",
   3690 			"(", "true", "(", "allow", "foo", "bar", "baz", "(", "read", ")", ")", ")", ")", NULL};
   3691 
   3692 	struct cil_tree *test_tree;
   3693 	gen_test_tree(&test_tree, line);
   3694 
   3695 	struct cil_tree_node *test_ast_node;
   3696 	cil_tree_node_init(&test_ast_node);
   3697 
   3698 	struct cil_db *test_db;
   3699 	cil_db_init(&test_db);
   3700 
   3701 	test_ast_node->parent = test_db->ast->root;
   3702 	test_ast_node->line = 1;
   3703 
   3704 	struct cil_booleanif *bif;
   3705 	cil_boolif_init(&bif);
   3706 
   3707 	int rc = cil_gen_expr_stack(test_tree->root->cl_head->cl_head->next, CIL_BOOL, &bif->expr_stack);
   3708 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   3709 }
   3710 
   3711 void test_cil_gen_expr_stack_neq(CuTest *tc) {
   3712 	char *line[] = {"(", "booleanif", "(", "neq", "foo", "bar", ")",
   3713 			"(", "true", "(", "allow", "foo", "bar", "baz", "(", "read", ")", ")", ")", ")", NULL};
   3714 
   3715 	struct cil_tree *test_tree;
   3716 	gen_test_tree(&test_tree, line);
   3717 
   3718 	struct cil_tree_node *test_ast_node;
   3719 	cil_tree_node_init(&test_ast_node);
   3720 
   3721 	struct cil_db *test_db;
   3722 	cil_db_init(&test_db);
   3723 
   3724 	test_ast_node->parent = test_db->ast->root;
   3725 	test_ast_node->line = 1;
   3726 
   3727 	struct cil_booleanif *bif;
   3728 	cil_boolif_init(&bif);
   3729 
   3730 	int rc = cil_gen_expr_stack(test_tree->root->cl_head->cl_head->next, CIL_BOOL, &bif->expr_stack);
   3731 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   3732 }
   3733 
   3734 void test_cil_gen_expr_stack_nested(CuTest *tc) {
   3735 	char *line[] = {"(", "booleanif", "(", "or", "(","neq", "foo", "bar", ")", "(", "eq", "baz", "boo", ")", ")",
   3736 			"(", "true", "(", "allow", "foo", "bar", "baz", "(", "read", ")", ")", ")", ")", NULL};
   3737 
   3738 	struct cil_tree *test_tree;
   3739 	gen_test_tree(&test_tree, line);
   3740 
   3741 	struct cil_tree_node *test_ast_node;
   3742 	cil_tree_node_init(&test_ast_node);
   3743 
   3744 	struct cil_db *test_db;
   3745 	cil_db_init(&test_db);
   3746 
   3747 	test_ast_node->parent = test_db->ast->root;
   3748 	test_ast_node->line = 1;
   3749 
   3750 	struct cil_booleanif *bif;
   3751 	cil_boolif_init(&bif);
   3752 
   3753 	int rc = cil_gen_expr_stack(test_tree->root->cl_head->cl_head->next, CIL_BOOL, &bif->expr_stack);
   3754 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   3755 }
   3756 
   3757 void test_cil_gen_expr_stack_nested_neg(CuTest *tc) {
   3758 	char *line[] = {"(", "booleanif", "(", "(","neq", "foo", "bar", ")", ")",
   3759 			"(", "true", "(", "allow", "foo", "bar", "baz", "(", "read", ")", ")", ")", ")", NULL};
   3760 
   3761 	struct cil_tree *test_tree;
   3762 	gen_test_tree(&test_tree, line);
   3763 
   3764 	struct cil_tree_node *test_ast_node;
   3765 	cil_tree_node_init(&test_ast_node);
   3766 
   3767 	struct cil_db *test_db;
   3768 	cil_db_init(&test_db);
   3769 
   3770 	test_ast_node->parent = test_db->ast->root;
   3771 	test_ast_node->line = 1;
   3772 
   3773 	struct cil_booleanif *bif;
   3774 	cil_boolif_init(&bif);
   3775 
   3776 	int rc = cil_gen_expr_stack(test_tree->root->cl_head->cl_head->next, CIL_BOOL, &bif->expr_stack);
   3777 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   3778 }
   3779 
   3780 void test_cil_gen_expr_stack_nested_emptyargs_neg(CuTest *tc) {
   3781 	char *line[] = {"(", "booleanif", "(", "eq", "(", ")", "(", ")", ")",
   3782 			"(", "true", "(", "allow", "foo", "bar", "baz", "(", "read", ")", ")", ")", ")", NULL};
   3783 
   3784 	struct cil_tree *test_tree;
   3785 	gen_test_tree(&test_tree, line);
   3786 
   3787 	struct cil_tree_node *test_ast_node;
   3788 	cil_tree_node_init(&test_ast_node);
   3789 
   3790 	struct cil_db *test_db;
   3791 	cil_db_init(&test_db);
   3792 
   3793 	test_ast_node->parent = test_db->ast->root;
   3794 	test_ast_node->line = 1;
   3795 
   3796 	struct cil_booleanif *bif;
   3797 	cil_boolif_init(&bif);
   3798 
   3799 	int rc = cil_gen_expr_stack(test_tree->root->cl_head->cl_head->next, CIL_BOOL, &bif->expr_stack);
   3800 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   3801 }
   3802 
   3803 void test_cil_gen_expr_stack_nested_missingoperator_neg(CuTest *tc) {
   3804 	char *line[] = {"(", "booleanif", "(", "or", "(","foo", "bar", ")", "(", "eq", "baz", "boo", ")", ")",
   3805 			"(", "true", "(", "allow", "foo", "bar", "baz", "(", "read", ")", ")", ")", ")", NULL};
   3806 
   3807 	struct cil_tree *test_tree;
   3808 	gen_test_tree(&test_tree, line);
   3809 
   3810 	struct cil_tree_node *test_ast_node;
   3811 	cil_tree_node_init(&test_ast_node);
   3812 
   3813 	struct cil_db *test_db;
   3814 	cil_db_init(&test_db);
   3815 
   3816 	test_ast_node->parent = test_db->ast->root;
   3817 	test_ast_node->line = 1;
   3818 
   3819 	struct cil_booleanif *bif;
   3820 	cil_boolif_init(&bif);
   3821 
   3822 	int rc = cil_gen_expr_stack(test_tree->root->cl_head->cl_head->next, CIL_BOOL, &bif->expr_stack);
   3823 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   3824 }
   3825 
   3826 void test_cil_gen_expr_stack_arg1null_neg(CuTest *tc) {
   3827 	char *line[] = {"(", "booleanif", "(", "eq", ")",
   3828 			"(", "true", "(", "allow", "foo", "bar", "baz", "(", "read", ")", ")", ")", ")", NULL};
   3829 
   3830 	struct cil_tree *test_tree;
   3831 	gen_test_tree(&test_tree, line);
   3832 
   3833 	struct cil_tree_node *test_ast_node;
   3834 	cil_tree_node_init(&test_ast_node);
   3835 
   3836 	struct cil_db *test_db;
   3837 	cil_db_init(&test_db);
   3838 
   3839 	test_ast_node->parent = test_db->ast->root;
   3840 	test_ast_node->line = 1;
   3841 
   3842 	struct cil_booleanif *bif;
   3843 	cil_boolif_init(&bif);
   3844 
   3845 	int rc = cil_gen_expr_stack(test_tree->root->cl_head->cl_head->next, CIL_BOOL, &bif->expr_stack);
   3846 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   3847 }
   3848 
   3849 void test_cil_gen_expr_stack_arg2null_neg(CuTest *tc) {
   3850 	char *line[] = {"(", "booleanif", "(", "eq", "foo", ")",
   3851 			"(", "true", "(", "allow", "foo", "bar", "baz", "(", "read", ")", ")", ")", ")", NULL};
   3852 
   3853 	struct cil_tree *test_tree;
   3854 	gen_test_tree(&test_tree, line);
   3855 
   3856 	struct cil_tree_node *test_ast_node;
   3857 	cil_tree_node_init(&test_ast_node);
   3858 
   3859 	struct cil_db *test_db;
   3860 	cil_db_init(&test_db);
   3861 
   3862 	test_ast_node->parent = test_db->ast->root;
   3863 	test_ast_node->line = 1;
   3864 
   3865 	struct cil_booleanif *bif;
   3866 	cil_boolif_init(&bif);
   3867 
   3868 	int rc = cil_gen_expr_stack(test_tree->root->cl_head->cl_head->next, CIL_BOOL, &bif->expr_stack);
   3869 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   3870 }
   3871 
   3872 void test_cil_gen_expr_stack_extraarg_neg(CuTest *tc) {
   3873 	char *line[] = {"(", "booleanif", "(", "eq", "foo", "bar", "extra", ")",
   3874 			"(", "true", "(", "allow", "foo", "bar", "baz", "(", "read", ")", ")", ")", ")", NULL};
   3875 
   3876 	struct cil_tree *test_tree;
   3877 	gen_test_tree(&test_tree, line);
   3878 
   3879 	struct cil_tree_node *test_ast_node;
   3880 	cil_tree_node_init(&test_ast_node);
   3881 
   3882 	struct cil_db *test_db;
   3883 	cil_db_init(&test_db);
   3884 
   3885 	test_ast_node->parent = test_db->ast->root;
   3886 	test_ast_node->line = 1;
   3887 
   3888 	struct cil_booleanif *bif;
   3889 	cil_boolif_init(&bif);
   3890 
   3891 	int rc = cil_gen_expr_stack(test_tree->root->cl_head->cl_head->next, CIL_BOOL, &bif->expr_stack);
   3892 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   3893 }
   3894 
   3895 void test_cil_gen_expr_stack_currnull_neg(CuTest *tc) {
   3896 	char *line[] = {"(", "booleanif", "(", ")", ")", NULL};
   3897 
   3898 	struct cil_tree *test_tree;
   3899 	gen_test_tree(&test_tree, line);
   3900 
   3901 	struct cil_tree_node *test_ast_node;
   3902 	cil_tree_node_init(&test_ast_node);
   3903 
   3904 	struct cil_db *test_db;
   3905 	cil_db_init(&test_db);
   3906 
   3907 	test_ast_node->parent = test_db->ast->root;
   3908 	test_ast_node->line = 1;
   3909 
   3910 	struct cil_booleanif *bif;
   3911 	cil_boolif_init(&bif);
   3912 
   3913 	int rc = cil_gen_expr_stack(test_tree->root->cl_head->cl_head->next, CIL_BOOL, &bif->expr_stack);
   3914 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   3915 }
   3916 
   3917 void test_cil_gen_expr_stack_stacknull_neg(CuTest *tc) {
   3918 	char *line[] = {"(", "booleanif", "(", "xor", "foo", "bar", ")",
   3919 			"(", "true", "(", "allow", "foo", "bar", "(", "read", ")", ")", ")", ")", NULL};
   3920 
   3921 	struct cil_tree *test_tree;
   3922 	gen_test_tree(&test_tree, line);
   3923 
   3924 	struct cil_tree_node *test_ast_node;
   3925 	cil_tree_node_init(&test_ast_node);
   3926 
   3927 	struct cil_db *test_db;
   3928 	cil_db_init(&test_db);
   3929 
   3930 	test_ast_node->parent = test_db->ast->root;
   3931 	test_ast_node->line = 1;
   3932 
   3933 	int rc = cil_gen_expr_stack(test_tree->root->cl_head->cl_head->next, CIL_BOOL, NULL);
   3934 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   3935 }
   3936 
   3937 void test_cil_gen_boolif_multiplebools_true(CuTest *tc) {
   3938 	char *line[] = {"(", "booleanif", "(", "and", "foo", "bar", ")",
   3939 			"(", "true", "(", "allow", "foo", "bar", "(", "read", ")", ")", ")",
   3940 			"(", "true", "(", "allow", "foo", "bar", "(", "write", ")", ")", ")", ")",  NULL};
   3941 
   3942 	struct cil_tree *test_tree;
   3943 	gen_test_tree(&test_tree, line);
   3944 
   3945 	struct cil_tree_node *test_ast_node;
   3946 	cil_tree_node_init(&test_ast_node);
   3947 
   3948 	struct cil_db *test_db;
   3949 	cil_db_init(&test_db);
   3950 
   3951 	test_ast_node->parent = test_db->ast->root;
   3952 	test_ast_node->line = 1;
   3953 
   3954 	int rc = cil_gen_boolif(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   3955 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   3956 }
   3957 
   3958 void test_cil_gen_boolif_multiplebools_false(CuTest *tc) {
   3959 	char *line[] = {"(", "booleanif", "(", "and", "foo", "bar", ")",
   3960 			"(", "true", "(", "allow", "foo", "bar", "(", "read", ")", ")", ")",
   3961 			"(", "false", "(", "allow", "foo", "bar", "(", "write", ")", ")", ")", ")",  NULL};
   3962 
   3963 	struct cil_tree *test_tree;
   3964 	gen_test_tree(&test_tree, line);
   3965 
   3966 	struct cil_tree_node *test_ast_node;
   3967 	cil_tree_node_init(&test_ast_node);
   3968 
   3969 	struct cil_db *test_db;
   3970 	cil_db_init(&test_db);
   3971 
   3972 	test_ast_node->parent = test_db->ast->root;
   3973 	test_ast_node->line = 1;
   3974 
   3975 	int rc = cil_gen_boolif(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   3976 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   3977 }
   3978 
   3979 void test_cil_gen_boolif_multiplebools_unknowncond_neg(CuTest *tc) {
   3980 	char *line[] = {"(", "booleanif", "(", "and", "foo", "bar", ")",
   3981 			"(", "true", "(", "allow", "foo", "bar", "(", "read", ")", ")", ")",
   3982 			"(", "dne", "(", "allow", "foo", "bar", "(", "write", ")", ")", ")", ")",  NULL};
   3983 
   3984 	struct cil_tree *test_tree;
   3985 	gen_test_tree(&test_tree, line);
   3986 
   3987 	struct cil_tree_node *test_ast_node;
   3988 	cil_tree_node_init(&test_ast_node);
   3989 
   3990 	struct cil_db *test_db;
   3991 	cil_db_init(&test_db);
   3992 
   3993 	test_ast_node->parent = test_db->ast->root;
   3994 	test_ast_node->line = 1;
   3995 
   3996 	int rc = cil_gen_boolif(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   3997 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   3998 }
   3999 
   4000 void test_cil_gen_boolif_true(CuTest *tc) {
   4001 	char *line[] = {"(", "booleanif", "(", "and", "foo", "bar", ")",
   4002 			"(", "true", "(", "allow", "foo", "bar", "(", "read", ")", ")", ")", ")",  NULL};
   4003 
   4004 	struct cil_tree *test_tree;
   4005 	gen_test_tree(&test_tree, line);
   4006 
   4007 	struct cil_tree_node *test_ast_node;
   4008 	cil_tree_node_init(&test_ast_node);
   4009 
   4010 	struct cil_db *test_db;
   4011 	cil_db_init(&test_db);
   4012 
   4013 	test_ast_node->parent = test_db->ast->root;
   4014 	test_ast_node->line = 1;
   4015 
   4016 	int rc = cil_gen_boolif(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   4017 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   4018 }
   4019 
   4020 void test_cil_gen_boolif_false(CuTest *tc) {
   4021 	char *line[] = {"(", "booleanif", "(", "and", "foo", "bar", ")",
   4022 			"(", "false", "(", "allow", "foo", "bar", "(", "read", ")", ")", ")", ")",  NULL};
   4023 
   4024 	struct cil_tree *test_tree;
   4025 	gen_test_tree(&test_tree, line);
   4026 
   4027 	struct cil_tree_node *test_ast_node;
   4028 	cil_tree_node_init(&test_ast_node);
   4029 
   4030 	struct cil_db *test_db;
   4031 	cil_db_init(&test_db);
   4032 
   4033 	test_ast_node->parent = test_db->ast->root;
   4034 	test_ast_node->line = 1;
   4035 
   4036 	int rc = cil_gen_boolif(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   4037 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   4038 }
   4039 
   4040 void test_cil_gen_boolif_unknowncond_neg(CuTest *tc) {
   4041 	char *line[] = {"(", "booleanif", "(", "and", "foo", "bar", ")",
   4042 			"(", "dne", "(", "allow", "foo", "bar", "(", "read", ")", ")", ")", ")",  NULL};
   4043 
   4044 	struct cil_tree *test_tree;
   4045 	gen_test_tree(&test_tree, line);
   4046 
   4047 	struct cil_tree_node *test_ast_node;
   4048 	cil_tree_node_init(&test_ast_node);
   4049 
   4050 	struct cil_db *test_db;
   4051 	cil_db_init(&test_db);
   4052 
   4053 	test_ast_node->parent = test_db->ast->root;
   4054 	test_ast_node->line = 1;
   4055 
   4056 	int rc = cil_gen_boolif(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   4057 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   4058 }
   4059 
   4060 void test_cil_gen_boolif_nested(CuTest *tc) {
   4061 	char *line[] = {"(", "booleanif", "(", "and", "(", "or", "foo", "bar", ")", "baz", ")",
   4062 			"(", "true", "(", "allow", "foo", "baz", "(", "read", ")", ")", ")", ")", NULL};
   4063 
   4064 	struct cil_tree *test_tree;
   4065 	gen_test_tree(&test_tree, line);
   4066 
   4067 	struct cil_tree_node *test_ast_node;
   4068 	cil_tree_node_init(&test_ast_node);
   4069 
   4070 	struct cil_db *test_db;
   4071 	cil_db_init(&test_db);
   4072 
   4073 	test_ast_node->parent = test_db->ast->root;
   4074 	test_ast_node->line = 1;
   4075 
   4076 	int rc = cil_gen_boolif(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   4077 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   4078 }
   4079 
   4080 void test_cil_gen_boolif_nested_neg(CuTest *tc) {
   4081 	char *line[] = {"(", "booleanif", "(", "(", "or", "foo", "bar", ")", "baz", ")",
   4082 			"(", "true", "(", "allow", "foo", "baz", "(", "read", ")", ")", ")", ")", NULL};
   4083 
   4084 	struct cil_tree *test_tree;
   4085 	gen_test_tree(&test_tree, line);
   4086 
   4087 	struct cil_tree_node *test_ast_node;
   4088 	cil_tree_node_init(&test_ast_node);
   4089 
   4090 	struct cil_db *test_db;
   4091 	cil_db_init(&test_db);
   4092 
   4093 	test_ast_node->parent = test_db->ast->root;
   4094 	test_ast_node->line = 1;
   4095 
   4096 	int rc = cil_gen_boolif(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   4097 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   4098 }
   4099 
   4100 void test_cil_gen_boolif_extra_neg(CuTest *tc) {
   4101 	char *line[] = {"(", "booleanif", "(", "and", "(", "or", "foo", "bar", ")", "baz", "beef", ")",
   4102 			"(", "true", "(", "allow", "foo", "baz", "(", "read", ")", ")", ")", ")", NULL};
   4103 
   4104 	struct cil_tree *test_tree;
   4105 	gen_test_tree(&test_tree, line);
   4106 
   4107 	struct cil_tree_node *test_ast_node;
   4108 	cil_tree_node_init(&test_ast_node);
   4109 
   4110 	struct cil_db *test_db;
   4111 	cil_db_init(&test_db);
   4112 
   4113 	test_ast_node->parent = test_db->ast->root;
   4114 	test_ast_node->line = 1;
   4115 
   4116 	int rc = cil_gen_boolif(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   4117 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   4118 }
   4119 
   4120 void test_cil_gen_boolif_extra_parens_neg(CuTest *tc) {
   4121 	char *line[] = {"(", "booleanif", "(", "(", "or", "foo", "bar", ")", ")",
   4122 			"(", "true", "(", "allow", "foo", "baz", "(", "read", ")", ")", ")", ")", NULL};
   4123 
   4124 	struct cil_tree *test_tree;
   4125 	gen_test_tree(&test_tree, line);
   4126 
   4127 	struct cil_tree_node *test_ast_node;
   4128 	cil_tree_node_init(&test_ast_node);
   4129 
   4130 	struct cil_db *test_db;
   4131 	cil_db_init(&test_db);
   4132 
   4133 	test_ast_node->parent = test_db->ast->root;
   4134 	test_ast_node->line = 1;
   4135 
   4136 	int rc = cil_gen_boolif(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   4137 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   4138 }
   4139 
   4140 void test_cil_gen_boolif_nocond(CuTest *tc) {
   4141 	char *line[] = {"(", "booleanif", "baz",
   4142 			"(", "true", "(", "allow", "foo", "bar", "(", "read", ")", ")", ")", ")", NULL};
   4143 
   4144 	struct cil_tree *test_tree;
   4145 	gen_test_tree(&test_tree, line);
   4146 
   4147 	struct cil_tree_node *test_ast_node;
   4148 	cil_tree_node_init(&test_ast_node);
   4149 
   4150 	struct cil_db *test_db;
   4151 	cil_db_init(&test_db);
   4152 
   4153 	test_ast_node->parent = test_db->ast->root;
   4154 	test_ast_node->line = 1;
   4155 
   4156 	int rc = cil_gen_boolif(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   4157 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   4158 }
   4159 
   4160 void test_cil_gen_boolif_neg(CuTest *tc) {
   4161 	char *line[] = {"(", "booleanif", "(", "**", "foo", "bar", ")",
   4162 			"(", "true", "(", "allow", "foo", "bar", "(", "read", ")", ")", ")", ")", NULL};
   4163 
   4164 	struct cil_tree *test_tree;
   4165 	gen_test_tree(&test_tree, line);
   4166 
   4167 	struct cil_tree_node *test_ast_node;
   4168 	cil_tree_node_init(&test_ast_node);
   4169 
   4170 	struct cil_db *test_db;
   4171 	cil_db_init(&test_db);
   4172 
   4173 	test_ast_node->parent = test_db->ast->root;
   4174 	test_ast_node->line = 1;
   4175 
   4176 	int rc = cil_gen_boolif(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   4177 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   4178 }
   4179 
   4180 void test_cil_gen_boolif_dbnull_neg(CuTest *tc) {
   4181 	char *line[] = {"(", "booleanif", "(", "and", "foo", "bar", ")",
   4182 			"(", "true", "(", "allow", "foo", "bar", "(", "read", ")", ")", ")", ")", NULL};
   4183 
   4184 	struct cil_tree *test_tree;
   4185 	gen_test_tree(&test_tree, line);
   4186 
   4187 	struct cil_tree_node *test_ast_node;
   4188 	cil_tree_node_init(&test_ast_node);
   4189 
   4190 	struct cil_db *test_db = NULL;
   4191 
   4192 	int rc = cil_gen_boolif(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   4193 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   4194 }
   4195 
   4196 void test_cil_gen_boolif_currnull_neg(CuTest *tc) {
   4197 	char *line[] = {"(", ")", NULL};
   4198 
   4199 	struct cil_tree *test_tree;
   4200 	gen_test_tree(&test_tree, line);
   4201 
   4202 	struct cil_tree_node *test_ast_node;
   4203 	cil_tree_node_init(&test_ast_node);
   4204 
   4205 	struct cil_db *test_db;
   4206 	cil_db_init(&test_db);
   4207 
   4208 	test_ast_node->parent = test_db->ast->root;
   4209 	test_ast_node->line = 1;
   4210 
   4211 	int rc = cil_gen_boolif(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   4212 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   4213 }
   4214 
   4215 void test_cil_gen_boolif_astnull_neg(CuTest *tc) {
   4216 	char *line[] = {"(", "booleanif", "(", "and", "foo", "bar", ")",
   4217 			"(", "true", "(", "allow", "foo", "bar", "(", "read", ")", ")", ")", ")", NULL};
   4218 
   4219 	struct cil_tree *test_tree;
   4220 	gen_test_tree(&test_tree, line);
   4221 
   4222 	struct cil_tree_node *test_ast_node = NULL;
   4223 
   4224 	struct cil_db *test_db;
   4225 	cil_db_init(&test_db);
   4226 
   4227 	int rc = cil_gen_boolif(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   4228 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   4229 }
   4230 
   4231 void test_cil_gen_boolif_nocond_neg(CuTest *tc) {
   4232 	char *line[] = {"(", "booleanif", ")", NULL};
   4233 
   4234 	struct cil_tree *test_tree;
   4235 	gen_test_tree(&test_tree, line);
   4236 
   4237 	struct cil_tree_node *test_ast_node;
   4238 	cil_tree_node_init(&test_ast_node);
   4239 
   4240 	struct cil_db *test_db;
   4241 	cil_db_init(&test_db);
   4242 
   4243 	test_ast_node->parent = test_db->ast->root;
   4244 	test_ast_node->line = 1;
   4245 
   4246 	int rc = cil_gen_boolif(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   4247 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   4248 }
   4249 
   4250 void test_cil_gen_boolif_notruelist_neg(CuTest *tc) {
   4251 	char *line[] = {"(", "booleanif", "(", "and", "foo", "bar", ")", ")", NULL};
   4252 
   4253 	struct cil_tree *test_tree;
   4254 	gen_test_tree(&test_tree, line);
   4255 
   4256 	struct cil_tree_node *test_ast_node;
   4257 	cil_tree_node_init(&test_ast_node);
   4258 
   4259 	struct cil_db *test_db;
   4260 	cil_db_init(&test_db);
   4261 
   4262 	test_ast_node->parent = test_db->ast->root;
   4263 	test_ast_node->line = 1;
   4264 
   4265 	int rc = cil_gen_boolif(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   4266 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   4267 }
   4268 
   4269 void test_cil_gen_boolif_empty_cond_neg(CuTest *tc) {
   4270 	char *line[] = {"(", "booleanif", "(", ")",
   4271 			"(", "true", "(", "allow", "foo", "bar", "(", "read", ")", ")", ")", ")", NULL};
   4272 
   4273 	struct cil_tree *test_tree;
   4274 	gen_test_tree(&test_tree, line);
   4275 
   4276 	struct cil_tree_node *test_ast_node;
   4277 	cil_tree_node_init(&test_ast_node);
   4278 
   4279 	struct cil_db *test_db;
   4280 	cil_db_init(&test_db);
   4281 
   4282 	test_ast_node->parent = test_db->ast->root;
   4283 	test_ast_node->line = 1;
   4284 
   4285 	int rc = cil_gen_boolif(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   4286 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   4287 }
   4288 
   4289 void test_cil_gen_tunif_multiplebools_true(CuTest *tc) {
   4290 	char *line[] = {"(", "tunableif", "(", "and", "foo", "bar", ")",
   4291 			"(", "true", "(", "allow", "foo", "bar", "(", "read", ")", ")", ")",
   4292 			"(", "true", "(", "allow", "foo", "bar", "(", "write", ")", ")", ")", ")", NULL};
   4293 
   4294 	struct cil_tree *test_tree;
   4295 	gen_test_tree(&test_tree, line);
   4296 
   4297 	struct cil_tree_node *test_ast_node;
   4298 	cil_tree_node_init(&test_ast_node);
   4299 
   4300 	struct cil_db *test_db;
   4301 	cil_db_init(&test_db);
   4302 
   4303 	test_ast_node->parent = test_db->ast->root;
   4304 	test_ast_node->line = 1;
   4305 
   4306 	int rc = cil_gen_tunif(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   4307 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   4308 }
   4309 
   4310 void test_cil_gen_tunif_multiplebools_false(CuTest *tc) {
   4311 	char *line[] = {"(", "tunableif", "(", "and", "foo", "bar", ")",
   4312 			"(", "true", "(", "allow", "foo", "bar", "(", "read", ")", ")", ")",
   4313 			"(", "false", "(", "allow", "foo", "bar", "(", "write", ")", ")", ")", ")", NULL};
   4314 
   4315 	struct cil_tree *test_tree;
   4316 	gen_test_tree(&test_tree, line);
   4317 
   4318 	struct cil_tree_node *test_ast_node;
   4319 	cil_tree_node_init(&test_ast_node);
   4320 
   4321 	struct cil_db *test_db;
   4322 	cil_db_init(&test_db);
   4323 
   4324 	test_ast_node->parent = test_db->ast->root;
   4325 	test_ast_node->line = 1;
   4326 
   4327 	int rc = cil_gen_tunif(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   4328 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   4329 }
   4330 
   4331 void test_cil_gen_tunif_multiplebools_unknowncond_neg(CuTest *tc) {
   4332 	char *line[] = {"(", "tunableif", "(", "and", "foo", "bar", ")",
   4333 			"(", "true", "(", "allow", "foo", "bar", "(", "read", ")", ")", ")",
   4334 			"(", "dne", "(", "allow", "foo", "bar", "(", "write", ")", ")", ")", ")", NULL};
   4335 
   4336 	struct cil_tree *test_tree;
   4337 	gen_test_tree(&test_tree, line);
   4338 
   4339 	struct cil_tree_node *test_ast_node;
   4340 	cil_tree_node_init(&test_ast_node);
   4341 
   4342 	struct cil_db *test_db;
   4343 	cil_db_init(&test_db);
   4344 
   4345 	test_ast_node->parent = test_db->ast->root;
   4346 	test_ast_node->line = 1;
   4347 
   4348 	int rc = cil_gen_tunif(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   4349 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   4350 }
   4351 
   4352 void test_cil_gen_tunif_true(CuTest *tc) {
   4353 	char *line[] = {"(", "tunableif", "(", "and", "foo", "bar", ")",
   4354 			"(", "true", "(", "allow", "foo", "bar", "(", "read", ")", ")", ")", ")", NULL};
   4355 
   4356 	struct cil_tree *test_tree;
   4357 	gen_test_tree(&test_tree, line);
   4358 
   4359 	struct cil_tree_node *test_ast_node;
   4360 	cil_tree_node_init(&test_ast_node);
   4361 
   4362 	struct cil_db *test_db;
   4363 	cil_db_init(&test_db);
   4364 
   4365 	test_ast_node->parent = test_db->ast->root;
   4366 	test_ast_node->line = 1;
   4367 
   4368 	int rc = cil_gen_tunif(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   4369 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   4370 }
   4371 
   4372 void test_cil_gen_tunif_false(CuTest *tc) {
   4373 	char *line[] = {"(", "tunableif", "(", "and", "foo", "bar", ")",
   4374 			"(", "false", "(", "allow", "foo", "bar", "(", "read", ")", ")", ")", ")", NULL};
   4375 
   4376 	struct cil_tree *test_tree;
   4377 	gen_test_tree(&test_tree, line);
   4378 
   4379 	struct cil_tree_node *test_ast_node;
   4380 	cil_tree_node_init(&test_ast_node);
   4381 
   4382 	struct cil_db *test_db;
   4383 	cil_db_init(&test_db);
   4384 
   4385 	test_ast_node->parent = test_db->ast->root;
   4386 	test_ast_node->line = 1;
   4387 
   4388 	int rc = cil_gen_tunif(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   4389 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   4390 }
   4391 
   4392 void test_cil_gen_tunif_unknowncond_neg(CuTest *tc) {
   4393 	char *line[] = {"(", "tunableif", "(", "and", "foo", "bar", ")",
   4394 			"(", "dne", "(", "allow", "foo", "bar", "(", "read", ")", ")", ")", ")", NULL};
   4395 
   4396 	struct cil_tree *test_tree;
   4397 	gen_test_tree(&test_tree, line);
   4398 
   4399 	struct cil_tree_node *test_ast_node;
   4400 	cil_tree_node_init(&test_ast_node);
   4401 
   4402 	struct cil_db *test_db;
   4403 	cil_db_init(&test_db);
   4404 
   4405 	test_ast_node->parent = test_db->ast->root;
   4406 	test_ast_node->line = 1;
   4407 
   4408 	int rc = cil_gen_tunif(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   4409 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   4410 }
   4411 
   4412 void test_cil_gen_tunif_nocond(CuTest *tc) {
   4413 	char *line[] = {"(", "tunableif", "baz",
   4414 			"(", "true", "(", "allow", "foo", "bar", "(", "read", ")", ")", ")", ")", NULL};
   4415 
   4416 	struct cil_tree *test_tree;
   4417 	gen_test_tree(&test_tree, line);
   4418 
   4419 	struct cil_tree_node *test_ast_node;
   4420 	cil_tree_node_init(&test_ast_node);
   4421 
   4422 	struct cil_db *test_db;
   4423 	cil_db_init(&test_db);
   4424 
   4425 	test_ast_node->parent = test_db->ast->root;
   4426 	test_ast_node->line = 1;
   4427 
   4428 	int rc = cil_gen_tunif(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   4429 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   4430 }
   4431 
   4432 void test_cil_gen_tunif_nested(CuTest *tc) {
   4433 	char *line[] = {"(", "tunableif", "(", "and", "(", "or", "foo", "bar", ")", "baz", ")",
   4434 			"(", "true", "(", "allow", "foo", "baz", "(", "read", ")", ")", ")", ")", NULL};
   4435 
   4436 	struct cil_tree *test_tree;
   4437 	gen_test_tree(&test_tree, line);
   4438 
   4439 	struct cil_tree_node *test_ast_node;
   4440 	cil_tree_node_init(&test_ast_node);
   4441 
   4442 	struct cil_db *test_db;
   4443 	cil_db_init(&test_db);
   4444 
   4445 	test_ast_node->parent = test_db->ast->root;
   4446 	test_ast_node->line = 1;
   4447 
   4448 	int rc = cil_gen_tunif(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   4449 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   4450 }
   4451 
   4452 void test_cil_gen_tunif_nested_neg(CuTest *tc) {
   4453 	char *line[] = {"(", "tunableif", "(", "(", "or", "foo", "bar", ")", "baz", ")",
   4454 			"(", "true", "(", "allow", "foo", "baz", "(", "read", ")", ")", ")", ")", NULL};
   4455 
   4456 	struct cil_tree *test_tree;
   4457 	gen_test_tree(&test_tree, line);
   4458 
   4459 	struct cil_tree_node *test_ast_node;
   4460 	cil_tree_node_init(&test_ast_node);
   4461 
   4462 	struct cil_db *test_db;
   4463 	cil_db_init(&test_db);
   4464 
   4465 	test_ast_node->parent = test_db->ast->root;
   4466 	test_ast_node->line = 1;
   4467 
   4468 	int rc = cil_gen_tunif(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   4469 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   4470 }
   4471 
   4472 void test_cil_gen_tunif_extra_neg(CuTest *tc) {
   4473 	char *line[] = {"(", "tunableif", "(", "and", "(", "or", "foo", "bar", ")", "baz", "beef", ")",
   4474 			"(", "true", "(", "allow", "foo", "baz", "(", "read", ")", ")", ")", ")", NULL};
   4475 
   4476 	struct cil_tree *test_tree;
   4477 	gen_test_tree(&test_tree, line);
   4478 
   4479 	struct cil_tree_node *test_ast_node;
   4480 	cil_tree_node_init(&test_ast_node);
   4481 
   4482 	struct cil_db *test_db;
   4483 	cil_db_init(&test_db);
   4484 
   4485 	test_ast_node->parent = test_db->ast->root;
   4486 	test_ast_node->line = 1;
   4487 
   4488 	int rc = cil_gen_tunif(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   4489 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   4490 }
   4491 
   4492 void test_cil_gen_tunif_extra_parens_neg(CuTest *tc) {
   4493 	char *line[] = {"(", "tunableif", "(", "(", "or", "foo", "bar", ")", ")",
   4494 			"(", "true", "(", "allow", "foo", "baz", "(", "read", ")", ")", ")", ")", NULL};
   4495 
   4496 	struct cil_tree *test_tree;
   4497 	gen_test_tree(&test_tree, line);
   4498 
   4499 	struct cil_tree_node *test_ast_node;
   4500 	cil_tree_node_init(&test_ast_node);
   4501 
   4502 	struct cil_db *test_db;
   4503 	cil_db_init(&test_db);
   4504 
   4505 	test_ast_node->parent = test_db->ast->root;
   4506 	test_ast_node->line = 1;
   4507 
   4508 	int rc = cil_gen_tunif(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   4509 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   4510 }
   4511 
   4512 void test_cil_gen_tunif_neg(CuTest *tc) {
   4513 	char *line[] = {"(", "tunableif", "(", "**", "foo", "bar", ")",
   4514 			"(", "true", "(", "allow", "foo", "bar", "(", "read", ")", ")", ")", ")", NULL};
   4515 
   4516 	struct cil_tree *test_tree;
   4517 	gen_test_tree(&test_tree, line);
   4518 
   4519 	struct cil_tree_node *test_ast_node;
   4520 	cil_tree_node_init(&test_ast_node);
   4521 
   4522 	struct cil_db *test_db;
   4523 	cil_db_init(&test_db);
   4524 
   4525 	test_ast_node->parent = test_db->ast->root;
   4526 	test_ast_node->line = 1;
   4527 
   4528 	int rc = cil_gen_tunif(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   4529 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   4530 }
   4531 
   4532 void test_cil_gen_tunif_dbnull_neg(CuTest *tc) {
   4533 	char *line[] = {"(", "tunableif", "(", "and", "foo", "bar", ")",
   4534 			"(", "true", "(", "allow", "foo", "bar", "(", "read", ")", ")", ")", ")", NULL};
   4535 
   4536 	struct cil_tree *test_tree;
   4537 	gen_test_tree(&test_tree, line);
   4538 
   4539 	struct cil_tree_node *test_ast_node;
   4540 	cil_tree_node_init(&test_ast_node);
   4541 
   4542 	struct cil_db *test_db = NULL;
   4543 
   4544 	int rc = cil_gen_tunif(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   4545 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   4546 }
   4547 
   4548 void test_cil_gen_tunif_currnull_neg(CuTest *tc) {
   4549 	char *line[] = {"(", ")", NULL};
   4550 
   4551 	struct cil_tree *test_tree;
   4552 	gen_test_tree(&test_tree, line);
   4553 
   4554 	struct cil_tree_node *test_ast_node;
   4555 	cil_tree_node_init(&test_ast_node);
   4556 
   4557 	struct cil_db *test_db;
   4558 	cil_db_init(&test_db);
   4559 
   4560 	test_ast_node->parent = test_db->ast->root;
   4561 	test_ast_node->line = 1;
   4562 
   4563 	int rc = cil_gen_tunif(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   4564 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   4565 }
   4566 
   4567 void test_cil_gen_tunif_astnull_neg(CuTest *tc) {
   4568 	char *line[] = {"(", "tunableif", "(", "and", "foo", "bar", ")",
   4569 			"(", "true", "(", "allow", "foo", "bar", "(", "read", ")", ")", ")", ")", NULL};
   4570 
   4571 	struct cil_tree *test_tree;
   4572 	gen_test_tree(&test_tree, line);
   4573 
   4574 	struct cil_tree_node *test_ast_node = NULL;
   4575 
   4576 	struct cil_db *test_db;
   4577 	cil_db_init(&test_db);
   4578 
   4579 	int rc = cil_gen_tunif(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   4580 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   4581 }
   4582 
   4583 void test_cil_gen_tunif_nocond_neg(CuTest *tc) {
   4584 	char *line[] = {"(", "tunableif", ")", NULL};
   4585 
   4586 	struct cil_tree *test_tree;
   4587 	gen_test_tree(&test_tree, line);
   4588 
   4589 	struct cil_tree_node *test_ast_node;
   4590 	cil_tree_node_init(&test_ast_node);
   4591 
   4592 	struct cil_db *test_db;
   4593 	cil_db_init(&test_db);
   4594 
   4595 	test_ast_node->parent = test_db->ast->root;
   4596 	test_ast_node->line = 1;
   4597 
   4598 	int rc = cil_gen_tunif(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   4599 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   4600 }
   4601 
   4602 void test_cil_gen_tunif_notruelist_neg(CuTest *tc) {
   4603 	char *line[] = {"(", "tunableif", "(", "and", "foo", "bar", ")", ")", NULL};
   4604 
   4605 	struct cil_tree *test_tree;
   4606 	gen_test_tree(&test_tree, line);
   4607 
   4608 	struct cil_tree_node *test_ast_node;
   4609 	cil_tree_node_init(&test_ast_node);
   4610 
   4611 	struct cil_db *test_db;
   4612 	cil_db_init(&test_db);
   4613 
   4614 	test_ast_node->parent = test_db->ast->root;
   4615 	test_ast_node->line = 1;
   4616 
   4617 	int rc = cil_gen_tunif(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   4618 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   4619 }
   4620 
   4621 void test_cil_gen_condblock_true(CuTest *tc) {
   4622 	char *line[] = {"(", "true", "(", "allow", "foo", "bar", "baz", "(", "read", ")", ")", ")", NULL};
   4623 
   4624 	struct cil_tree *test_tree;
   4625 	gen_test_tree(&test_tree, line);
   4626 
   4627 	struct cil_tree_node *test_ast_node;
   4628 	cil_tree_node_init(&test_ast_node);
   4629 
   4630 	struct cil_db *test_db;
   4631 	cil_db_init(&test_db);
   4632 
   4633 	test_ast_node->parent = test_db->ast->root;
   4634 	test_ast_node->line = 1;
   4635 
   4636 	int rc = cil_gen_condblock(test_db, test_tree->root->cl_head->cl_head, test_ast_node, CIL_CONDTRUE);
   4637 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   4638 }
   4639 
   4640 void test_cil_gen_condblock_false(CuTest *tc) {
   4641 	char *line[] = {"(", "false", "(", "allow", "foo", "bar", "baz", "(", "read", ")", ")", ")", NULL};
   4642 
   4643 	struct cil_tree *test_tree;
   4644 	gen_test_tree(&test_tree, line);
   4645 
   4646 	struct cil_tree_node *test_ast_node;
   4647 	cil_tree_node_init(&test_ast_node);
   4648 
   4649 	struct cil_db *test_db;
   4650 	cil_db_init(&test_db);
   4651 
   4652 	test_ast_node->parent = test_db->ast->root;
   4653 	test_ast_node->line = 1;
   4654 
   4655 	int rc = cil_gen_condblock(test_db, test_tree->root->cl_head->cl_head, test_ast_node, CIL_CONDFALSE);
   4656 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   4657 }
   4658 
   4659 void test_cil_gen_condblock_dbnull_neg(CuTest *tc) {
   4660 	char *line[] = {"(", "false", "(", "allow", "foo", "bar", "baz", "(", "read", ")", ")", ")", NULL};
   4661 
   4662 	struct cil_tree *test_tree;
   4663 	gen_test_tree(&test_tree, line);
   4664 
   4665 	struct cil_tree_node *test_ast_node;
   4666 	cil_tree_node_init(&test_ast_node);
   4667 
   4668 	struct cil_db *test_db = NULL;
   4669 
   4670 	int rc = cil_gen_condblock(test_db, test_tree->root->cl_head->cl_head, test_ast_node, CIL_CONDFALSE);
   4671 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   4672 }
   4673 
   4674 void test_cil_gen_condblock_currnull_neg(CuTest *tc) {
   4675 	char *line[] = {"(", ")", NULL};
   4676 
   4677 	struct cil_tree *test_tree;
   4678 	gen_test_tree(&test_tree, line);
   4679 
   4680 	struct cil_tree_node *test_ast_node;
   4681 	cil_tree_node_init(&test_ast_node);
   4682 
   4683 	struct cil_db *test_db;
   4684 	cil_db_init(&test_db);
   4685 
   4686 	test_ast_node->parent = test_db->ast->root;
   4687 	test_ast_node->line = 1;
   4688 
   4689 	int rc = cil_gen_condblock(test_db, test_tree->root->cl_head->cl_head, test_ast_node, CIL_CONDFALSE);
   4690 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   4691 }
   4692 
   4693 void test_cil_gen_condblock_astnull_neg(CuTest *tc) {
   4694 	char *line[] = {"(", "false", "(", "allow", "foo", "bar", "baz", "(", "read", ")", ")", ")", NULL};
   4695 
   4696 	struct cil_tree *test_tree;
   4697 	gen_test_tree(&test_tree, line);
   4698 
   4699 	struct cil_tree_node *test_ast_node = NULL;
   4700 
   4701 	struct cil_db *test_db;
   4702 	cil_db_init(&test_db);
   4703 
   4704 	int rc = cil_gen_condblock(test_db, test_tree->root->cl_head->cl_head, test_ast_node, CIL_CONDFALSE);
   4705 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   4706 }
   4707 
   4708 void test_cil_gen_condblock_nocond_neg(CuTest *tc) {
   4709 	char *line[] = {"(", "true", ")", NULL};
   4710 
   4711 	struct cil_tree *test_tree;
   4712 	gen_test_tree(&test_tree, line);
   4713 
   4714 	struct cil_tree_node *test_ast_node;
   4715 	cil_tree_node_init(&test_ast_node);
   4716 
   4717 	struct cil_db *test_db;
   4718 	cil_db_init(&test_db);
   4719 
   4720 	test_ast_node->parent = test_db->ast->root;
   4721 	test_ast_node->line = 1;
   4722 
   4723 	int rc = cil_gen_condblock(test_db, test_tree->root->cl_head->cl_head, test_ast_node, CIL_CONDTRUE);
   4724 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   4725 }
   4726 
   4727 void test_cil_gen_condblock_extra_neg(CuTest *tc) {
   4728 	char *line[] = {"(", "true", "(", "allow", "foo", "bar", "baz", "(", "read", ")", ")", "Extra", ")", NULL};
   4729 
   4730 	struct cil_tree *test_tree;
   4731 	gen_test_tree(&test_tree, line);
   4732 
   4733 	struct cil_tree_node *test_ast_node;
   4734 	cil_tree_node_init(&test_ast_node);
   4735 
   4736 	struct cil_db *test_db;
   4737 	cil_db_init(&test_db);
   4738 
   4739 	test_ast_node->parent = test_db->ast->root;
   4740 	test_ast_node->line = 1;
   4741 
   4742 	int rc = cil_gen_condblock(test_db, test_tree->root->cl_head->cl_head, test_ast_node, CIL_CONDTRUE);
   4743 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   4744 }
   4745 
   4746 void test_cil_gen_typealias(CuTest *tc) {
   4747 	char *line[] = {"(", "typealias", ".test.type", "type_t", ")", "(", "type", "test", ")", NULL};
   4748 
   4749 	struct cil_tree *test_tree;
   4750 	gen_test_tree(&test_tree, line);
   4751 
   4752 	struct cil_tree_node *test_ast_node;
   4753 	cil_tree_node_init(&test_ast_node);
   4754 
   4755 	struct cil_db *test_db;
   4756 	cil_db_init(&test_db);
   4757 
   4758 	test_ast_node->parent = test_db->ast->root;
   4759 	test_ast_node->line = 1;
   4760 
   4761 	int rc = cil_gen_typealias(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   4762 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   4763 	CuAssertPtrNotNull(tc, test_ast_node->data);
   4764 	CuAssertStrEquals(tc, ((struct cil_typealias*)test_ast_node->data)->type_str, test_tree->root->cl_head->cl_head->next->data);
   4765 	CuAssertIntEquals(tc, test_ast_node->flavor, CIL_TYPEALIAS);
   4766 }
   4767 
   4768 void test_cil_gen_typealias_incomplete_neg(CuTest *tc) {
   4769 	char *line[] = {"(", "typealias", ")", NULL};
   4770 
   4771 	struct cil_tree *test_tree;
   4772 	gen_test_tree(&test_tree, line);
   4773 
   4774 	struct cil_tree_node *test_ast_node;
   4775 	cil_tree_node_init(&test_ast_node);
   4776 
   4777 	struct cil_db *test_db;
   4778 	cil_db_init(&test_db);
   4779 
   4780 	test_ast_node->parent = test_db->ast->root;
   4781 	test_ast_node->line = 1;
   4782 
   4783 	int rc = cil_gen_typealias(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   4784 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   4785 }
   4786 
   4787 void test_cil_gen_typealias_incomplete_neg2(CuTest *tc) {
   4788 	char *line[] = {"(", "typealias", ".test.type", ")", NULL};
   4789 
   4790 	struct cil_tree *test_tree;
   4791 	gen_test_tree(&test_tree, line);
   4792 
   4793 	struct cil_tree_node *test_ast_node;
   4794 	cil_tree_node_init(&test_ast_node);
   4795 
   4796 	struct cil_db *test_db;
   4797 	cil_db_init(&test_db);
   4798 
   4799 	test_ast_node->parent = test_db->ast->root;
   4800 	test_ast_node->line = 1;
   4801 
   4802 	int rc = cil_gen_typealias(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   4803 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   4804 }
   4805 
   4806 void test_cil_gen_typealias_extratype_neg(CuTest *tc) {
   4807 	char *line[] = {"(", "typealias", ".test.type", "foo", "extra_t", ")", NULL};
   4808 
   4809 	struct cil_tree *test_tree;
   4810 	gen_test_tree(&test_tree, line);
   4811 
   4812 	struct cil_tree_node *test_ast_node;
   4813 	cil_tree_node_init(&test_ast_node);
   4814 
   4815 	struct cil_db *test_db;
   4816 	cil_db_init(&test_db);
   4817 
   4818 	test_ast_node->parent = test_db->ast->root;
   4819 	test_ast_node->line = 1;
   4820 
   4821 	int rc = cil_gen_typealias(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   4822 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   4823 }
   4824 
   4825 void test_cil_gen_typealias_dbnull_neg(CuTest *tc) {
   4826 	char *line[] = {"(", "typealias", ".test.type", "type_t", ")", "(", "type", "test", ")", NULL};
   4827 
   4828 	struct cil_tree *test_tree;
   4829 	gen_test_tree(&test_tree, line);
   4830 
   4831 	struct cil_tree_node *test_ast_node;
   4832 	cil_tree_node_init(&test_ast_node);
   4833 
   4834 	struct cil_db *test_db = NULL;
   4835 
   4836 	int rc = cil_gen_typealias(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   4837 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   4838 }
   4839 
   4840 void test_cil_gen_typealias_currnull_neg(CuTest *tc) {
   4841 	char *line[] = {"(", ")", NULL};
   4842 
   4843 	struct cil_tree *test_tree;
   4844 	gen_test_tree(&test_tree, line);
   4845 
   4846 	struct cil_tree_node *test_ast_node;
   4847 	cil_tree_node_init(&test_ast_node);
   4848 
   4849 	struct cil_db *test_db;
   4850 	cil_db_init(&test_db);
   4851 
   4852 	test_ast_node->parent = test_db->ast->root;
   4853 	test_ast_node->line = 1;
   4854 
   4855 	int rc = cil_gen_typealias(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   4856 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   4857 }
   4858 
   4859 void test_cil_gen_typealias_astnull_neg(CuTest *tc) {
   4860 	char *line[] = {"(", "typealias", ".test.type", "type_t", ")", "(", "type", "test", ")", NULL};
   4861 
   4862 	struct cil_tree *test_tree;
   4863 	gen_test_tree(&test_tree, line);
   4864 
   4865 	struct cil_tree_node *test_ast_node = NULL;
   4866 
   4867 	struct cil_db *test_db;
   4868 	cil_db_init(&test_db);
   4869 
   4870 	int rc = cil_gen_typealias(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   4871 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   4872 }
   4873 
   4874 void test_cil_gen_typeattributeset(CuTest *tc) {
   4875 	char *line[] = {"(", "typeattributeset", "filetypes", "test_t", ")", NULL};
   4876 
   4877 	struct cil_tree *test_tree;
   4878 	gen_test_tree(&test_tree, line);
   4879 
   4880 	struct cil_tree_node *test_ast_node;
   4881 	cil_tree_node_init(&test_ast_node);
   4882 
   4883 	struct cil_db *test_db;
   4884 	cil_db_init(&test_db);
   4885 
   4886 	test_ast_node->parent = test_db->ast->root;
   4887 	test_ast_node->line = 1;
   4888 
   4889 	int rc = cil_gen_typeattributeset(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   4890 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   4891 	CuAssertPtrNotNull(tc, test_ast_node->data);
   4892 }
   4893 
   4894 void test_cil_gen_typeattributeset_and_two_types(CuTest *tc) {
   4895 	char *line[] = {"(", "typeattributeset", "filetypes", "(", "and", "test_t", "test2_t", ")", ")", NULL};
   4896 
   4897 	struct cil_tree *test_tree;
   4898 	gen_test_tree(&test_tree, line);
   4899 
   4900 	struct cil_tree_node *test_ast_node;
   4901 	cil_tree_node_init(&test_ast_node);
   4902 
   4903 	struct cil_db *test_db;
   4904 	cil_db_init(&test_db);
   4905 
   4906 	test_ast_node->parent = test_db->ast->root;
   4907 	test_ast_node->line = 1;
   4908 
   4909 	int rc = cil_gen_typeattributeset(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   4910 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   4911 	CuAssertPtrNotNull(tc, test_ast_node->data);
   4912 }
   4913 
   4914 void test_cil_gen_typeattributeset_not(CuTest *tc) {
   4915 	char *line[] = {"(", "typeattributeset", "filetypes", "(", "not", "notypes_t", ")", ")", NULL};
   4916 
   4917 	struct cil_tree *test_tree;
   4918 	gen_test_tree(&test_tree, line);
   4919 
   4920 	struct cil_tree_node *test_ast_node;
   4921 	cil_tree_node_init(&test_ast_node);
   4922 
   4923 	struct cil_db *test_db;
   4924 	cil_db_init(&test_db);
   4925 
   4926 	test_ast_node->parent = test_db->ast->root;
   4927 	test_ast_node->line = 1;
   4928 
   4929 	int rc = cil_gen_typeattributeset(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   4930 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   4931 	CuAssertPtrNotNull(tc, test_ast_node->data);
   4932 }
   4933 
   4934 void test_cil_gen_typeattributeset_exclude_attr(CuTest *tc) {
   4935 	char *line[] = {"(", "typeattributeset", "filetypes", "(", "not", "attr", ")", ")", NULL};
   4936 
   4937 	struct cil_tree *test_tree;
   4938 	gen_test_tree(&test_tree, line);
   4939 
   4940 	struct cil_tree_node *test_ast_node;
   4941 	cil_tree_node_init(&test_ast_node);
   4942 
   4943 	struct cil_db *test_db;
   4944 	cil_db_init(&test_db);
   4945 
   4946 	test_ast_node->parent = test_db->ast->root;
   4947 	test_ast_node->line = 1;
   4948 
   4949 	int rc = cil_gen_typeattributeset(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   4950 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   4951 	CuAssertPtrNotNull(tc, test_ast_node->data);
   4952 }
   4953 
   4954 void test_cil_gen_typeattributeset_exclude_neg(CuTest *tc) {
   4955 	char *line[] = {"(", "typeattributeset", "filetypes", "(", "not", ")", ")", NULL};
   4956 
   4957 	struct cil_tree *test_tree;
   4958 	gen_test_tree(&test_tree, line);
   4959 
   4960 	struct cil_tree_node *test_ast_node;
   4961 	cil_tree_node_init(&test_ast_node);
   4962 
   4963 	struct cil_db *test_db;
   4964 	cil_db_init(&test_db);
   4965 
   4966 	test_ast_node->parent = test_db->ast->root;
   4967 	test_ast_node->line = 1;
   4968 
   4969 	int rc = cil_gen_typeattributeset(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   4970 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   4971 }
   4972 
   4973 void test_cil_gen_typeattributeset_dbnull_neg(CuTest *tc) {
   4974 	char *line[] = {"(", "typeattributeset", "filetypes", "(", "not", "type_t", ")", ")", NULL};
   4975 
   4976 	struct cil_tree *test_tree;
   4977 	gen_test_tree(&test_tree, line);
   4978 
   4979 	struct cil_tree_node *test_ast_node;
   4980 	cil_tree_node_init(&test_ast_node);
   4981 
   4982 	struct cil_db *test_db = NULL;
   4983 
   4984 	int rc = cil_gen_typeattributeset(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   4985 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   4986 }
   4987 
   4988 void test_cil_gen_typeattributeset_currnull_neg(CuTest *tc) {
   4989 	char *line[] = {"(", ")", NULL};
   4990 
   4991 	struct cil_tree *test_tree;
   4992 	gen_test_tree(&test_tree, line);
   4993 
   4994 	struct cil_tree_node *test_ast_node;
   4995 	cil_tree_node_init(&test_ast_node);
   4996 
   4997 	struct cil_db *test_db;
   4998 	cil_db_init(&test_db);
   4999 
   5000 	test_ast_node->parent = test_db->ast->root;
   5001 	test_ast_node->line = 1;
   5002 
   5003 	int rc = cil_gen_typeattributeset(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   5004 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   5005 }
   5006 
   5007 void test_cil_gen_typeattributeset_astnull_neg(CuTest *tc) {
   5008 	char *line[] = {"(", "typeattributeset", "filetypes", "(", "not", ")", ")", NULL};
   5009 
   5010 	struct cil_tree *test_tree;
   5011 	gen_test_tree(&test_tree, line);
   5012 
   5013 	struct cil_tree_node *test_ast_node = NULL;
   5014 
   5015 	struct cil_db *test_db;
   5016 	cil_db_init(&test_db);
   5017 
   5018 	int rc = cil_gen_typeattributeset(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   5019 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   5020 }
   5021 
   5022 void test_cil_gen_typeattributeset_noname_neg(CuTest *tc) {
   5023 	char *line[] = {"(", "typeattributeset", ")", NULL};
   5024 
   5025 	struct cil_tree *test_tree;
   5026 	gen_test_tree(&test_tree, line);
   5027 
   5028 	struct cil_tree_node *test_ast_node;
   5029 	cil_tree_node_init(&test_ast_node);
   5030 
   5031 	struct cil_db *test_db;
   5032 	cil_db_init(&test_db);
   5033 
   5034 	test_ast_node->parent = test_db->ast->root;
   5035 	test_ast_node->line = 1;
   5036 
   5037 	int rc = cil_gen_typeattributeset(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   5038 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   5039 }
   5040 
   5041 void test_cil_gen_typeattributeset_nameinparens_neg(CuTest *tc) {
   5042 	char *line[] = {"(", "typeattributeset", "(", "filetypes", ")", "(", "test_t", ")", ")", NULL};
   5043 
   5044 	struct cil_tree *test_tree;
   5045 	gen_test_tree(&test_tree, line);
   5046 
   5047 	struct cil_tree_node *test_ast_node;
   5048 	cil_tree_node_init(&test_ast_node);
   5049 
   5050 	struct cil_db *test_db;
   5051 	cil_db_init(&test_db);
   5052 
   5053 	test_ast_node->parent = test_db->ast->root;
   5054 	test_ast_node->line = 1;
   5055 
   5056 	int rc = cil_gen_typeattributeset(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   5057 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   5058 }
   5059 
   5060 void test_cil_gen_typeattributeset_emptylists_neg(CuTest *tc) {
   5061 	char *line[] = {"(", "typeattributeset", "filetypes", "(", ")", ")", NULL};
   5062 
   5063 	struct cil_tree *test_tree;
   5064 	gen_test_tree(&test_tree, line);
   5065 
   5066 	struct cil_tree_node *test_ast_node;
   5067 	cil_tree_node_init(&test_ast_node);
   5068 
   5069 	struct cil_db *test_db;
   5070 	cil_db_init(&test_db);
   5071 
   5072 	test_ast_node->parent = test_db->ast->root;
   5073 	test_ast_node->line = 1;
   5074 
   5075 	int rc = cil_gen_typeattributeset(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   5076 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   5077 }
   5078 
   5079 void test_cil_gen_typeattributeset_listinparens_neg(CuTest *tc) {
   5080 	char *line[] = {"(", "typeattributeset", "filetypes", "(", "(", "test_t", ")", ")", ")", NULL};
   5081 
   5082 	struct cil_tree *test_tree;
   5083 	gen_test_tree(&test_tree, line);
   5084 
   5085 	struct cil_tree_node *test_ast_node;
   5086 	cil_tree_node_init(&test_ast_node);
   5087 
   5088 	struct cil_db *test_db;
   5089 	cil_db_init(&test_db);
   5090 
   5091 	test_ast_node->parent = test_db->ast->root;
   5092 	test_ast_node->line = 1;
   5093 
   5094 	int rc = cil_gen_typeattributeset(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   5095 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   5096 }
   5097 
   5098 void test_cil_gen_typeattributeset_extra_neg(CuTest *tc) {
   5099 	char *line[] = {"(", "typeattributeset", "filetypes", "(", "test_t", ")", "extra", ")", NULL};
   5100 
   5101 	struct cil_tree *test_tree;
   5102 	gen_test_tree(&test_tree, line);
   5103 
   5104 	struct cil_tree_node *test_ast_node;
   5105 	cil_tree_node_init(&test_ast_node);
   5106 
   5107 	struct cil_db *test_db;
   5108 	cil_db_init(&test_db);
   5109 
   5110 	test_ast_node->parent = test_db->ast->root;
   5111 	test_ast_node->line = 1;
   5112 
   5113 	int rc = cil_gen_typeattributeset(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   5114 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   5115 }
   5116 
   5117 void test_cil_gen_userbounds(CuTest *tc) {
   5118 	char *line[] = {"(", "userbounds", "user1", "user2", ")", NULL};
   5119 
   5120 	struct cil_tree *test_tree;
   5121 	gen_test_tree(&test_tree, line);
   5122 
   5123 	struct cil_tree_node *test_ast_node;
   5124 	cil_tree_node_init(&test_ast_node);
   5125 
   5126 	struct cil_db *test_db;
   5127 	cil_db_init(&test_db);
   5128 
   5129 	test_ast_node->parent = test_db->ast->root;
   5130 	test_ast_node->line = 1;
   5131 
   5132 	int rc = cil_gen_userbounds(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   5133 	CuAssertIntEquals(tc, rc, SEPOL_OK);
   5134 }
   5135 
   5136 void test_cil_gen_userbounds_notype1_neg(CuTest *tc) {
   5137 	char *line[] = {"(", "userbounds", ")", NULL};
   5138 
   5139 	struct cil_tree *test_tree;
   5140 	gen_test_tree(&test_tree, line);
   5141 
   5142 	struct cil_tree_node *test_ast_node;
   5143 	cil_tree_node_init(&test_ast_node);
   5144 
   5145 	struct cil_db *test_db;
   5146 	cil_db_init(&test_db);
   5147 
   5148 	test_ast_node->parent = test_db->ast->root;
   5149 	test_ast_node->line = 1;
   5150 
   5151 	int rc = cil_gen_userbounds(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   5152 	CuAssertIntEquals(tc, rc, SEPOL_ERR);
   5153 }
   5154 
   5155 void test_cil_gen_userbounds_type1_inparens_neg(CuTest *tc) {
   5156 	char *line[] = {"(", "userbounds", "(", "user1", ")", "user2", ")", NULL};
   5157 
   5158 	struct cil_tree *test_tree;
   5159 	gen_test_tree(&test_tree, line);
   5160 
   5161 	struct cil_tree_node *test_ast_node;
   5162 	cil_tree_node_init(&test_ast_node);
   5163 
   5164 	struct cil_db *test_db;
   5165 	cil_db_init(&test_db);
   5166 
   5167 	test_ast_node->parent = test_db->ast->root;
   5168 	test_ast_node->line = 1;
   5169 
   5170 	int rc = cil_gen_userbounds(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   5171 	CuAssertIntEquals(tc, rc, SEPOL_ERR);
   5172 }
   5173 
   5174 void test_cil_gen_userbounds_notype2_neg(CuTest *tc) {
   5175 	char *line[] = {"(", "userbounds", "user1", ")", NULL};
   5176 
   5177 	struct cil_tree *test_tree;
   5178 	gen_test_tree(&test_tree, line);
   5179 
   5180 	struct cil_tree_node *test_ast_node;
   5181 	cil_tree_node_init(&test_ast_node);
   5182 
   5183 	struct cil_db *test_db;
   5184 	cil_db_init(&test_db);
   5185 
   5186 	test_ast_node->parent = test_db->ast->root;
   5187 	test_ast_node->line = 1;
   5188 
   5189 	int rc = cil_gen_userbounds(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   5190 	CuAssertIntEquals(tc, rc, SEPOL_ERR);
   5191 }
   5192 
   5193 void test_cil_gen_userbounds_type2_inparens_neg(CuTest *tc) {
   5194 	char *line[] = {"(", "userbounds", "user1", "(", "user2", ")", ")", NULL};
   5195 
   5196 	struct cil_tree *test_tree;
   5197 	gen_test_tree(&test_tree, line);
   5198 
   5199 	struct cil_tree_node *test_ast_node;
   5200 	cil_tree_node_init(&test_ast_node);
   5201 
   5202 	struct cil_db *test_db;
   5203 	cil_db_init(&test_db);
   5204 
   5205 	test_ast_node->parent = test_db->ast->root;
   5206 	test_ast_node->line = 1;
   5207 
   5208 	int rc = cil_gen_userbounds(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   5209 	CuAssertIntEquals(tc, rc, SEPOL_ERR);
   5210 }
   5211 
   5212 void test_cil_gen_userbounds_extra_neg(CuTest *tc) {
   5213 	char *line[] = {"(", "userbounds", "user1", "user2", "extra", ")", NULL};
   5214 
   5215 	struct cil_tree *test_tree;
   5216 	gen_test_tree(&test_tree, line);
   5217 
   5218 	struct cil_tree_node *test_ast_node;
   5219 	cil_tree_node_init(&test_ast_node);
   5220 
   5221 	struct cil_db *test_db;
   5222 	cil_db_init(&test_db);
   5223 
   5224 	test_ast_node->parent = test_db->ast->root;
   5225 	test_ast_node->line = 1;
   5226 
   5227 	int rc = cil_gen_userbounds(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   5228 	CuAssertIntEquals(tc, rc, SEPOL_ERR);
   5229 }
   5230 
   5231 void test_cil_gen_userbounds_dbnull_neg(CuTest *tc) {
   5232 	char *line[] = {"(", "userbounds", "user1", "user2", ")", NULL};
   5233 
   5234 	struct cil_tree *test_tree;
   5235 	gen_test_tree(&test_tree, line);
   5236 
   5237 	struct cil_tree_node *test_ast_node;
   5238 	cil_tree_node_init(&test_ast_node);
   5239 
   5240 	struct cil_db *test_db = NULL;
   5241 
   5242 	int rc = cil_gen_userbounds(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   5243 	CuAssertIntEquals(tc, rc, SEPOL_ERR);
   5244 }
   5245 
   5246 void test_cil_gen_userbounds_currnull_neg(CuTest *tc) {
   5247 	char *line[] = {"(", ")", NULL};
   5248 
   5249 	struct cil_tree *test_tree;
   5250 	gen_test_tree(&test_tree, line);
   5251 
   5252 	struct cil_tree_node *test_ast_node;
   5253 	cil_tree_node_init(&test_ast_node);
   5254 
   5255 	struct cil_db *test_db;
   5256 	cil_db_init(&test_db);
   5257 
   5258 	test_ast_node->parent = test_db->ast->root;
   5259 	test_ast_node->line = 1;
   5260 
   5261 	int rc = cil_gen_userbounds(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   5262 	CuAssertIntEquals(tc, rc, SEPOL_ERR);
   5263 }
   5264 
   5265 void test_cil_gen_userbounds_astnull_neg(CuTest *tc) {
   5266 	char *line[] = {"(", "userbounds", "user1", "user2", ")", NULL};
   5267 
   5268 	struct cil_tree *test_tree;
   5269 	gen_test_tree(&test_tree, line);
   5270 
   5271 	struct cil_tree_node *test_ast_node = NULL;
   5272 
   5273 	struct cil_db *test_db;
   5274 	cil_db_init(&test_db);
   5275 
   5276 	int rc = cil_gen_userbounds(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   5277 	CuAssertIntEquals(tc, rc, SEPOL_ERR);
   5278 }
   5279 
   5280 void test_cil_gen_role(CuTest *tc) {
   5281 	char *line[] = {"(", "role", "test_r", ")", NULL};
   5282 
   5283 	struct cil_tree *test_tree;
   5284 	gen_test_tree(&test_tree, line);
   5285 
   5286 	struct cil_tree_node *test_ast_node;
   5287 	cil_tree_node_init(&test_ast_node);
   5288 
   5289 	struct cil_db *test_db;
   5290 	cil_db_init(&test_db);
   5291 
   5292 	test_ast_node->parent = test_db->ast->root;
   5293 	test_ast_node->line = 1;
   5294 
   5295 	int rc = cil_gen_role(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   5296 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   5297 	CuAssertPtrNotNull(tc, test_ast_node->data);
   5298 	CuAssertIntEquals(tc, test_ast_node->flavor, CIL_ROLE);
   5299 }
   5300 
   5301 void test_cil_gen_role_dbnull_neg(CuTest *tc) {
   5302 	char *line[] = {"(", "role", "test_r", ")", NULL};
   5303 
   5304 	struct cil_tree *test_tree;
   5305 	gen_test_tree(&test_tree, line);
   5306 
   5307 	struct cil_tree_node *test_ast_node;
   5308 	cil_tree_node_init(&test_ast_node);
   5309 
   5310 	struct cil_db *test_db = NULL;
   5311 
   5312 	int rc = cil_gen_role(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   5313 
   5314 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   5315 }
   5316 
   5317 void test_cil_gen_role_currnull_neg(CuTest *tc) {
   5318 	char *line[] = {"(", ")", NULL};
   5319 
   5320 	struct cil_tree *test_tree;
   5321 	gen_test_tree(&test_tree, line);
   5322 
   5323 	struct cil_tree_node *test_ast_node;
   5324 	cil_tree_node_init(&test_ast_node);
   5325 
   5326 	struct cil_db *test_db;
   5327 	cil_db_init(&test_db);
   5328 
   5329 	int rc = cil_gen_role(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   5330 
   5331 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   5332 }
   5333 
   5334 void test_cil_gen_role_astnull_neg(CuTest *tc) {
   5335 	char *line[] = {"(", "role", "test_r", ")", NULL};
   5336 
   5337 	struct cil_tree *test_tree;
   5338 	gen_test_tree(&test_tree, line);
   5339 
   5340 	struct cil_tree_node *test_ast_node = NULL;
   5341 
   5342 	struct cil_db *test_db;
   5343 	cil_db_init(&test_db);
   5344 
   5345 	int rc = cil_gen_role(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   5346 
   5347 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   5348 }
   5349 
   5350 void test_cil_gen_role_extrarole_neg(CuTest *tc) {
   5351 	char *line[] = {"(", "role", "test_r", "extra_r", ")", NULL};
   5352 
   5353 	struct cil_tree *test_tree;
   5354 	gen_test_tree(&test_tree, line);
   5355 
   5356 	struct cil_tree_node *test_ast_node;
   5357 	cil_tree_node_init(&test_ast_node);
   5358 
   5359 	struct cil_db *test_db;
   5360 	cil_db_init(&test_db);
   5361 
   5362 	test_ast_node->parent = test_db->ast->root;
   5363 	test_ast_node->line = 1;
   5364 
   5365 	int rc = cil_gen_role(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   5366 
   5367 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   5368 }
   5369 
   5370 void test_cil_gen_role_noname_neg(CuTest *tc) {
   5371 	char *line[] = {"(", "role", ")", NULL};
   5372 
   5373 	struct cil_tree *test_tree;
   5374 	gen_test_tree(&test_tree, line);
   5375 
   5376 	struct cil_tree_node *test_ast_node;
   5377 	cil_tree_node_init(&test_ast_node);
   5378 
   5379 	struct cil_db *test_db;
   5380 	cil_db_init(&test_db);
   5381 
   5382 	test_ast_node->parent = test_db->ast->root;
   5383 	test_ast_node->line = 1;
   5384 
   5385 	int rc = cil_gen_role(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   5386 
   5387 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   5388 }
   5389 
   5390 void test_cil_gen_roletransition(CuTest *tc) {
   5391 	char *line[] = {"(", "roletransition", "foo_r",  "bar_t", "process",  "foobar_r", ")", NULL};
   5392 
   5393 	struct cil_tree *test_tree;
   5394 	gen_test_tree(&test_tree, line);
   5395 
   5396 	struct cil_tree_node *test_ast_node;
   5397 	cil_tree_node_init(&test_ast_node);
   5398 
   5399 	struct cil_db *test_db;
   5400 	cil_db_init(&test_db);
   5401 
   5402 	test_ast_node->parent = test_db->ast->root;
   5403 	test_ast_node->line = 1;
   5404 
   5405 	int rc = cil_gen_roletransition(test_tree->root->cl_head->cl_head, test_ast_node);
   5406 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   5407 	CuAssertPtrNotNull(tc, test_ast_node->data);
   5408 	CuAssertIntEquals(tc, test_ast_node->flavor, CIL_ROLETRANSITION);
   5409 }
   5410 
   5411 void test_cil_gen_roletransition_currnull_neg(CuTest *tc) {
   5412 	struct cil_tree_node *test_ast_node;
   5413 	cil_tree_node_init(&test_ast_node);
   5414 
   5415 	int rc = cil_gen_roletransition(NULL, test_ast_node);
   5416 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   5417 }
   5418 
   5419 void test_cil_gen_roletransition_astnull_neg (CuTest *tc) {
   5420 	char *line[] = {"(", "roletransition" "foo_r", "bar_t", "process", "foobar_r", ")", NULL};
   5421 
   5422 	struct  cil_tree *test_tree;
   5423 	gen_test_tree(&test_tree, line);
   5424 
   5425 	struct cil_tree_node *test_ast_node = NULL;
   5426 
   5427 	int rc = cil_gen_roletransition(test_tree->root->cl_head->cl_head, test_ast_node);
   5428 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   5429 }
   5430 
   5431 void test_cil_gen_roletransition_srcnull_neg(CuTest *tc) {
   5432 	char *line[] = {"(", "roletransition", "foo_r", "bar_t", "process", "foobar_r", ")", NULL};
   5433 
   5434 	struct cil_tree *test_tree;
   5435 	gen_test_tree(&test_tree, line);
   5436 
   5437 	test_tree->root->cl_head->cl_head->next = NULL;
   5438 
   5439 	struct cil_tree_node *test_ast_node;
   5440 	cil_tree_node_init(&test_ast_node);
   5441 
   5442 	int rc = cil_gen_roletransition(test_tree->root->cl_head->cl_head, test_ast_node);
   5443 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   5444 }
   5445 
   5446 void test_cil_gen_roletransition_tgtnull_neg(CuTest *tc) {
   5447 	char *line[] = {"(", "roletransition", "foo_r", "bar_t", "process", "foobar_r", ")", NULL};
   5448 
   5449 	struct cil_tree *test_tree;
   5450 	gen_test_tree(&test_tree, line);
   5451 
   5452 	test_tree->root->cl_head->cl_head->next->next = NULL;
   5453 
   5454 	struct cil_tree_node *test_ast_node;
   5455 	cil_tree_node_init(&test_ast_node);
   5456 
   5457 	int rc = cil_gen_roletransition(test_tree->root->cl_head->cl_head, test_ast_node);
   5458 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   5459 }
   5460 
   5461 void test_cil_gen_roletransition_resultnull_neg(CuTest *tc) {
   5462 	char *line[] = {"(", "roletransition", "foo_r", "bar_t", "process", "foobar_r", ")", NULL};
   5463 
   5464 	struct cil_tree *test_tree;
   5465 	gen_test_tree(&test_tree, line);
   5466 
   5467 	test_tree->root->cl_head->cl_head->next->next->next->next = NULL;
   5468 
   5469 	struct cil_tree_node *test_ast_node;
   5470 	cil_tree_node_init(&test_ast_node);
   5471 
   5472 	int rc = cil_gen_roletransition(test_tree->root->cl_head->cl_head, test_ast_node);
   5473 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   5474 }
   5475 
   5476 void test_cil_gen_roletransition_extra_neg(CuTest *tc) {
   5477 	char *line[] = {"(", "roletransition", "foo_r", "bar_t", "process", "foobar_r", "extra", ")", NULL};
   5478 
   5479 	struct cil_tree *test_tree;
   5480 	gen_test_tree(&test_tree, line);
   5481 
   5482 	struct cil_tree_node *test_ast_node;
   5483 	cil_tree_node_init(&test_ast_node);
   5484 
   5485 	int rc = cil_gen_roletransition(test_tree->root->cl_head->cl_head, test_ast_node);
   5486 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   5487 }
   5488 
   5489 void test_cil_gen_bool_true(CuTest *tc) {
   5490 	char *line[] = {"(", "boolean", "foo", "true", ")", NULL};
   5491 
   5492 	struct cil_tree *test_tree;
   5493 	gen_test_tree(&test_tree, line);
   5494 
   5495 	struct cil_tree_node *test_ast_node;
   5496 	cil_tree_node_init(&test_ast_node);
   5497 
   5498 	struct cil_db *test_db;
   5499 	cil_db_init(&test_db);
   5500 
   5501 	test_ast_node->parent = test_db->ast->root;
   5502 	test_ast_node->line = 1;
   5503 
   5504 	int rc = cil_gen_bool(test_db, test_tree->root->cl_head->cl_head, test_ast_node, CIL_BOOL);
   5505 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   5506 	CuAssertPtrNotNull(tc, test_ast_node->data);
   5507 	CuAssertIntEquals(tc, ((struct cil_bool*)test_ast_node->data)->value, 1);
   5508 	CuAssertIntEquals(tc, test_ast_node->flavor, CIL_BOOL);
   5509 }
   5510 
   5511 void test_cil_gen_bool_tunable_true(CuTest *tc) {
   5512 	char *line[] = {"(", "tunable", "foo", "true", ")", NULL};
   5513 
   5514 	struct cil_tree *test_tree;
   5515 	gen_test_tree(&test_tree, line);
   5516 
   5517 	struct cil_tree_node *test_ast_node;
   5518 	cil_tree_node_init(&test_ast_node);
   5519 
   5520 	struct cil_db *test_db;
   5521 	cil_db_init(&test_db);
   5522 
   5523 	test_ast_node->parent = test_db->ast->root;
   5524 	test_ast_node->line = 1;
   5525 
   5526 	int rc = cil_gen_bool(test_db, test_tree->root->cl_head->cl_head, test_ast_node, CIL_TUNABLE);
   5527 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   5528 	CuAssertPtrNotNull(tc, test_ast_node->data);
   5529 	CuAssertIntEquals(tc, ((struct cil_bool*)test_ast_node->data)->value, 1);
   5530 	CuAssertIntEquals(tc, test_ast_node->flavor, CIL_TUNABLE);
   5531 }
   5532 
   5533 void test_cil_gen_bool_false(CuTest *tc) {
   5534 	char *line[] = {"(", "boolean", "bar", "false", ")", NULL};
   5535 
   5536 	struct cil_tree *test_tree;
   5537 	gen_test_tree(&test_tree, line);
   5538 
   5539 	struct cil_tree_node *test_ast_node;
   5540 	cil_tree_node_init(&test_ast_node);
   5541 
   5542 	struct cil_db *test_db;
   5543 	cil_db_init(&test_db);
   5544 
   5545 	test_ast_node->parent = test_db->ast->root;
   5546 	test_ast_node->line = 1;
   5547 
   5548 	int rc = cil_gen_bool(test_db, test_tree->root->cl_head->cl_head, test_ast_node, CIL_BOOL);
   5549 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   5550 	CuAssertPtrNotNull(tc, test_ast_node->data);
   5551 	CuAssertIntEquals(tc, ((struct cil_bool*)test_ast_node->data)->value, 0);
   5552 	CuAssertIntEquals(tc, test_ast_node->flavor, CIL_BOOL);
   5553 }
   5554 
   5555 void test_cil_gen_bool_tunable_false(CuTest *tc) {
   5556 	char *line[] = {"(", "tunable", "bar", "false", ")", NULL};
   5557 
   5558 	struct cil_tree *test_tree;
   5559 	gen_test_tree(&test_tree, line);
   5560 
   5561 	struct cil_tree_node *test_ast_node;
   5562 	cil_tree_node_init(&test_ast_node);
   5563 
   5564 	struct cil_db *test_db;
   5565 	cil_db_init(&test_db);
   5566 
   5567 	test_ast_node->parent = test_db->ast->root;
   5568 	test_ast_node->line = 1;
   5569 
   5570 	int rc = cil_gen_bool(test_db, test_tree->root->cl_head->cl_head, test_ast_node, CIL_TUNABLE);
   5571 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   5572 	CuAssertPtrNotNull(tc, test_ast_node->data);
   5573 	CuAssertIntEquals(tc, ((struct cil_bool*)test_ast_node->data)->value, 0);
   5574 	CuAssertIntEquals(tc, test_ast_node->flavor, CIL_TUNABLE);
   5575 }
   5576 
   5577 void test_cil_gen_bool_none_neg(CuTest *tc) {
   5578 	char *line[] = {"(", "boolean", "foo", ")", NULL};
   5579 
   5580 	struct cil_tree *test_tree;
   5581 	gen_test_tree(&test_tree, line);
   5582 
   5583 	struct cil_tree_node *test_ast_node;
   5584 	cil_tree_node_init(&test_ast_node);
   5585 
   5586 	struct cil_db *test_db;
   5587 	cil_db_init(&test_db);
   5588 
   5589 	test_ast_node->parent = test_db->ast->root;
   5590 	test_ast_node->line = 1;
   5591 
   5592 	int rc = cil_gen_bool(test_db, test_tree->root->cl_head->cl_head, test_ast_node, CIL_BOOL);
   5593 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   5594 }
   5595 
   5596 void test_cil_gen_bool_dbnull_neg(CuTest *tc) {
   5597 	char *line[] = {"(", "boolean", "foo", "bar", ")", NULL};
   5598 
   5599 	struct cil_tree *test_tree;
   5600 	gen_test_tree(&test_tree, line);
   5601 
   5602 	struct cil_tree_node *test_ast_node;
   5603 	cil_tree_node_init(&test_ast_node);
   5604 
   5605 	struct cil_db *test_db = NULL;
   5606 
   5607 	int rc = cil_gen_bool(test_db, test_tree->root->cl_head->cl_head, test_ast_node, CIL_BOOL);
   5608 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   5609 }
   5610 
   5611 void test_cil_gen_bool_currnull_neg(CuTest *tc) {
   5612 	char *line[] = {"(", ")", NULL};
   5613 
   5614 	struct cil_tree *test_tree;
   5615 	gen_test_tree(&test_tree, line);
   5616 
   5617 	struct cil_tree_node *test_ast_node;
   5618 	cil_tree_node_init(&test_ast_node);
   5619 
   5620 	struct cil_db *test_db;
   5621 	cil_db_init(&test_db);
   5622 
   5623 	test_ast_node->parent = test_db->ast->root;
   5624 	test_ast_node->line = 1;
   5625 
   5626 	int rc = cil_gen_bool(test_db, test_tree->root->cl_head->cl_head, test_ast_node, CIL_BOOL);
   5627 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   5628 }
   5629 
   5630 void test_cil_gen_bool_astnull_neg(CuTest *tc) {
   5631 	char *line[] = {"(", "boolean", "foo", "bar", ")", NULL};
   5632 
   5633 	struct cil_tree *test_tree;
   5634 	gen_test_tree(&test_tree, line);
   5635 
   5636 	struct cil_tree_node *test_ast_node = NULL;
   5637 
   5638 	struct cil_db *test_db;
   5639 	cil_db_init(&test_db);
   5640 
   5641 	int rc = cil_gen_bool(test_db, test_tree->root->cl_head->cl_head, test_ast_node, CIL_BOOL);
   5642 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   5643 }
   5644 
   5645 void test_cil_gen_bool_notbool_neg(CuTest *tc) {
   5646 	char *line[] = {"(", "boolean", "foo", "bar", ")", NULL};
   5647 
   5648 	struct cil_tree *test_tree;
   5649 	gen_test_tree(&test_tree, line);
   5650 
   5651 	struct cil_tree_node *test_ast_node;
   5652 	cil_tree_node_init(&test_ast_node);
   5653 
   5654 	struct cil_db *test_db;
   5655 	cil_db_init(&test_db);
   5656 
   5657 	test_ast_node->parent = test_db->ast->root;
   5658 	test_ast_node->line = 1;
   5659 
   5660 	int rc = cil_gen_bool(test_db, test_tree->root->cl_head->cl_head, test_ast_node, CIL_BOOL);
   5661 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   5662 }
   5663 
   5664 void test_cil_gen_bool_boolname_neg(CuTest *tc) {
   5665 	char *line[] = {"(", "boolean", ")", NULL};
   5666 
   5667 	struct cil_tree *test_tree;
   5668 	gen_test_tree(&test_tree, line);
   5669 
   5670 	struct cil_tree_node *test_ast_node;
   5671 	cil_tree_node_init(&test_ast_node);
   5672 
   5673 	struct cil_db *test_db;
   5674 	cil_db_init(&test_db);
   5675 
   5676 	test_ast_node->parent = test_db->ast->root;
   5677 	test_ast_node->line = 1;
   5678 
   5679 	int rc = cil_gen_bool(test_db, test_tree->root->cl_head->cl_head, test_ast_node, CIL_BOOL);
   5680 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   5681 }
   5682 
   5683 void test_cil_gen_bool_extraname_false_neg(CuTest *tc) {
   5684 	char *line[] = {"(", "boolean", "foo", "false", "bar", ")", NULL};
   5685 
   5686 	struct cil_tree *test_tree;
   5687 	gen_test_tree(&test_tree, line);
   5688 
   5689 	struct cil_tree_node *test_ast_node;
   5690 	cil_tree_node_init(&test_ast_node);
   5691 
   5692 	struct cil_db *test_db;
   5693 	cil_db_init(&test_db);
   5694 
   5695 	test_ast_node->parent = test_db->ast->root;
   5696 	test_ast_node->line = 1;
   5697 
   5698 	int rc = cil_gen_bool(test_db, test_tree->root->cl_head->cl_head, test_ast_node, CIL_BOOL);
   5699 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   5700 }
   5701 
   5702 void test_cil_gen_bool_extraname_true_neg(CuTest *tc) {
   5703 	char *line[] = {"(", "boolean", "foo", "true", "bar", ")", NULL};
   5704 
   5705 	struct cil_tree *test_tree;
   5706 	gen_test_tree(&test_tree, line);
   5707 
   5708 	struct cil_tree_node *test_ast_node;
   5709 	cil_tree_node_init(&test_ast_node);
   5710 
   5711 	struct cil_db *test_db;
   5712 	cil_db_init(&test_db);
   5713 
   5714 	test_ast_node->parent = test_db->ast->root;
   5715 	test_ast_node->line = 1;
   5716 
   5717 	int rc = cil_gen_bool(test_db, test_tree->root->cl_head->cl_head, test_ast_node, CIL_BOOL);
   5718 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   5719 }
   5720 
   5721 void test_cil_gen_constrain_expr_stack_eq2_t1type(CuTest *tc) {
   5722 	char *line[] = {"(", "mlsconstrain", "(", "file", "(", "create", "relabelto", ")", ")", "(", "eq", "t1", "type_t", ")", ")", NULL};
   5723 	struct cil_tree *test_tree;
   5724 	gen_test_tree(&test_tree, line);
   5725 
   5726 	struct cil_tree_node *test_ast_node;
   5727 	cil_tree_node_init(&test_ast_node);
   5728 
   5729 	struct cil_db *test_db;
   5730 	cil_db_init(&test_db);
   5731 
   5732 	test_ast_node->parent = test_db->ast->root;
   5733 	test_ast_node->line = 1;
   5734 
   5735 	struct cil_tree_node *parse_current = test_tree->root->cl_head->cl_head;
   5736 
   5737 	struct cil_constrain *cons;
   5738 	cil_constrain_init(&cons);
   5739 
   5740 	cil_classpermset_init(&cons->classpermset);
   5741 	cil_fill_classpermset(parse_current->next->cl_head, cons->classpermset);
   5742 
   5743 	int rc = cil_gen_expr_stack(parse_current->next->next, CIL_MLSCONSTRAIN, &cons->expr);
   5744 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   5745 }
   5746 
   5747 void test_cil_gen_constrain_expr_stack_eq2_t1t1_neg(CuTest *tc) {
   5748 	char *line[] = {"(", "mlsconstrain", "(", "file", "(", "create", "relabelto", ")", ")", "(", "eq", "t1", "t1", ")", ")", NULL};
   5749 	struct cil_tree *test_tree;
   5750 	gen_test_tree(&test_tree, line);
   5751 
   5752 	struct cil_tree_node *test_ast_node;
   5753 	cil_tree_node_init(&test_ast_node);
   5754 
   5755 	struct cil_db *test_db;
   5756 	cil_db_init(&test_db);
   5757 
   5758 	test_ast_node->parent = test_db->ast->root;
   5759 	test_ast_node->line = 1;
   5760 
   5761 	struct cil_tree_node *parse_current = test_tree->root->cl_head->cl_head;
   5762 
   5763 	struct cil_constrain *cons;
   5764 	cil_constrain_init(&cons);
   5765 	cil_classpermset_init(&cons->classpermset);
   5766 	cil_fill_classpermset(parse_current->next->cl_head, cons->classpermset);
   5767 
   5768 	int rc = cil_gen_expr_stack(parse_current->next->next->next, CIL_MLSCONSTRAIN, &cons->expr);
   5769 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   5770 }
   5771 
   5772 void test_cil_gen_constrain_expr_stack_eq2_t2type(CuTest *tc) {
   5773 	char *line[] = {"(", "mlsconstrain", "(", "file", "(", "create", "relabelto", ")", ")", "(", "eq", "t2", "type_t", ")", ")", NULL};
   5774 	struct cil_tree *test_tree;
   5775 	gen_test_tree(&test_tree, line);
   5776 
   5777 	struct cil_tree_node *test_ast_node;
   5778 	cil_tree_node_init(&test_ast_node);
   5779 
   5780 	struct cil_db *test_db;
   5781 	cil_db_init(&test_db);
   5782 
   5783 	test_ast_node->parent = test_db->ast->root;
   5784 	test_ast_node->line = 1;
   5785 
   5786 	struct cil_tree_node *parse_current = test_tree->root->cl_head->cl_head;
   5787 
   5788 	struct cil_constrain *cons;
   5789 	cil_constrain_init(&cons);
   5790 	cil_classpermset_init(&cons->classpermset);
   5791 	cil_fill_classpermset(parse_current->next->cl_head, cons->classpermset);
   5792 
   5793 	int rc = cil_gen_expr_stack(parse_current->next->next, CIL_MLSCONSTRAIN, &cons->expr);
   5794 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   5795 }
   5796 
   5797 void test_cil_gen_constrain_expr_stack_eq2_t2t2_neg(CuTest *tc) {
   5798 	char *line[] = {"(", "mlsconstrain", "(", "file", "(", "create", "relabelto", ")", ")", "(", "eq", "t2", "t2", ")", ")", NULL};
   5799 	struct cil_tree *test_tree;
   5800 	gen_test_tree(&test_tree, line);
   5801 
   5802 	struct cil_tree_node *test_ast_node;
   5803 	cil_tree_node_init(&test_ast_node);
   5804 
   5805 	struct cil_db *test_db;
   5806 	cil_db_init(&test_db);
   5807 
   5808 	test_ast_node->parent = test_db->ast->root;
   5809 	test_ast_node->line = 1;
   5810 
   5811 	struct cil_tree_node *parse_current = test_tree->root->cl_head->cl_head;
   5812 
   5813 	struct cil_constrain *cons;
   5814 	cil_constrain_init(&cons);
   5815 	cil_classpermset_init(&cons->classpermset);
   5816 	cil_fill_classpermset(parse_current->next->cl_head, cons->classpermset);
   5817 
   5818 	int rc = cil_gen_expr_stack(parse_current->next->next, CIL_MLSCONSTRAIN, &cons->expr);
   5819 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   5820 }
   5821 
   5822 void test_cil_gen_constrain_expr_stack_eq2_r1role(CuTest *tc) {
   5823 	char *line[] = {"(", "mlsconstrain", "(", "file", "(", "create", "relabelto", ")", ")", "(", "eq", "r1", "role_r", ")", ")", NULL};
   5824 	struct cil_tree *test_tree;
   5825 	gen_test_tree(&test_tree, line);
   5826 
   5827 	struct cil_tree_node *test_ast_node;
   5828 	cil_tree_node_init(&test_ast_node);
   5829 
   5830 	struct cil_db *test_db;
   5831 	cil_db_init(&test_db);
   5832 
   5833 	test_ast_node->parent = test_db->ast->root;
   5834 	test_ast_node->line = 1;
   5835 
   5836 	struct cil_tree_node *parse_current = test_tree->root->cl_head->cl_head;
   5837 
   5838 	struct cil_constrain *cons;
   5839 	cil_constrain_init(&cons);
   5840 	cil_classpermset_init(&cons->classpermset);
   5841 	cil_fill_classpermset(parse_current->next->cl_head, cons->classpermset);
   5842 
   5843 	int rc = cil_gen_expr_stack(parse_current->next->next, CIL_MLSCONSTRAIN, &cons->expr);
   5844 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   5845 }
   5846 
   5847 void test_cil_gen_constrain_expr_stack_eq2_r1r1_neg(CuTest *tc) {
   5848 	char *line[] = {"(", "mlsconstrain", "(", "file", "(", "create", "relabelto", ")", ")", "(", "eq", "r1", "r1", ")", ")", NULL};
   5849 	struct cil_tree *test_tree;
   5850 	gen_test_tree(&test_tree, line);
   5851 
   5852 	struct cil_tree_node *test_ast_node;
   5853 	cil_tree_node_init(&test_ast_node);
   5854 
   5855 	struct cil_db *test_db;
   5856 	cil_db_init(&test_db);
   5857 
   5858 	test_ast_node->parent = test_db->ast->root;
   5859 	test_ast_node->line = 1;
   5860 
   5861 	struct cil_tree_node *parse_current = test_tree->root->cl_head->cl_head;
   5862 
   5863 	struct cil_constrain *cons;
   5864 	cil_constrain_init(&cons);
   5865 	cil_classpermset_init(&cons->classpermset);
   5866 	cil_fill_classpermset(parse_current->next->cl_head, cons->classpermset);
   5867 
   5868 	int rc = cil_gen_expr_stack(parse_current->next->next, CIL_MLSCONSTRAIN, &cons->expr);
   5869 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   5870 }
   5871 
   5872 void test_cil_gen_constrain_expr_stack_eq2_r2role(CuTest *tc) {
   5873 	char *line[] = {"(", "mlsconstrain", "(", "file", "(", "create", "relabelto", ")", ")", "(", "eq", "r2", "role_r", ")", ")", NULL};
   5874 	struct cil_tree *test_tree;
   5875 	gen_test_tree(&test_tree, line);
   5876 
   5877 	struct cil_tree_node *test_ast_node;
   5878 	cil_tree_node_init(&test_ast_node);
   5879 
   5880 	struct cil_db *test_db;
   5881 	cil_db_init(&test_db);
   5882 
   5883 	test_ast_node->parent = test_db->ast->root;
   5884 	test_ast_node->line = 1;
   5885 
   5886 	struct cil_tree_node *parse_current = test_tree->root->cl_head->cl_head;
   5887 
   5888 	struct cil_constrain *cons;
   5889 	cil_constrain_init(&cons);
   5890 	cil_classpermset_init(&cons->classpermset);
   5891 	cil_fill_classpermset(parse_current->next->cl_head, cons->classpermset);
   5892 
   5893 	int rc = cil_gen_expr_stack(parse_current->next->next, CIL_MLSCONSTRAIN, &cons->expr);
   5894 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   5895 }
   5896 
   5897 void test_cil_gen_constrain_expr_stack_eq2_r2r2_neg(CuTest *tc) {
   5898 	char *line[] = {"(", "mlsconstrain", "(", "file", "(", "create", "relabelto", ")", ")", "(", "eq", "r2", "r2", ")", ")", NULL};
   5899 	struct cil_tree *test_tree;
   5900 	gen_test_tree(&test_tree, line);
   5901 
   5902 	struct cil_tree_node *test_ast_node;
   5903 	cil_tree_node_init(&test_ast_node);
   5904 
   5905 	struct cil_db *test_db;
   5906 	cil_db_init(&test_db);
   5907 
   5908 	test_ast_node->parent = test_db->ast->root;
   5909 	test_ast_node->line = 1;
   5910 
   5911 	struct cil_tree_node *parse_current = test_tree->root->cl_head->cl_head;
   5912 
   5913 	struct cil_constrain *cons;
   5914 	cil_constrain_init(&cons);
   5915 	cil_classpermset_init(&cons->classpermset);
   5916 	cil_fill_classpermset(parse_current->next->cl_head, cons->classpermset);
   5917 
   5918 	int rc = cil_gen_expr_stack(parse_current->next->next, CIL_MLSCONSTRAIN, &cons->expr);
   5919 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   5920 }
   5921 
   5922 void test_cil_gen_constrain_expr_stack_eq2_t1t2(CuTest *tc) {
   5923 	char *line[] = {"(", "mlsconstrain", "(", "file", "(", "create", "relabelto", ")", ")", "(", "eq", "t1", "t2", ")", ")", NULL};
   5924 	struct cil_tree *test_tree;
   5925 	gen_test_tree(&test_tree, line);
   5926 
   5927 	struct cil_tree_node *test_ast_node;
   5928 	cil_tree_node_init(&test_ast_node);
   5929 
   5930 	struct cil_db *test_db;
   5931 	cil_db_init(&test_db);
   5932 
   5933 	test_ast_node->parent = test_db->ast->root;
   5934 	test_ast_node->line = 1;
   5935 
   5936 	struct cil_tree_node *parse_current = test_tree->root->cl_head->cl_head;
   5937 
   5938 	struct cil_constrain *cons;
   5939 	cil_constrain_init(&cons);
   5940 	cil_classpermset_init(&cons->classpermset);
   5941 	cil_fill_classpermset(parse_current->next->cl_head, cons->classpermset);
   5942 
   5943 	int rc = cil_gen_expr_stack(parse_current->next->next, CIL_MLSCONSTRAIN, &cons->expr);
   5944 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   5945 }
   5946 
   5947 void test_cil_gen_constrain_expr_stack_eq_r1r2(CuTest *tc) {
   5948 	char *line[] = {"(", "mlsconstrain", "(", "file", "(", "create", "relabelto", ")", ")", "(", "eq", "r1", "r2", ")", ")", NULL};
   5949 	struct cil_tree *test_tree;
   5950 	gen_test_tree(&test_tree, line);
   5951 
   5952 	struct cil_tree_node *test_ast_node;
   5953 	cil_tree_node_init(&test_ast_node);
   5954 
   5955 	struct cil_db *test_db;
   5956 	cil_db_init(&test_db);
   5957 
   5958 	test_ast_node->parent = test_db->ast->root;
   5959 	test_ast_node->line = 1;
   5960 
   5961 	struct cil_tree_node *parse_current = test_tree->root->cl_head->cl_head;
   5962 
   5963 	struct cil_constrain *cons;
   5964 	cil_constrain_init(&cons);
   5965 	cil_classpermset_init(&cons->classpermset);
   5966 	cil_fill_classpermset(parse_current->next->cl_head, cons->classpermset);
   5967 
   5968 	int rc = cil_gen_expr_stack(parse_current->next->next, CIL_MLSCONSTRAIN, &cons->expr);
   5969 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   5970 }
   5971 
   5972 void test_cil_gen_constrain_expr_stack_eq2_r1r2(CuTest *tc) {
   5973 	char *line[] = {"(", "mlsconstrain", "(", "file", "(", "create", "relabelto", ")", ")", "(", "eq", "r1", "r2", ")", ")", NULL};
   5974 	struct cil_tree *test_tree;
   5975 	gen_test_tree(&test_tree, line);
   5976 
   5977 	struct cil_tree_node *test_ast_node;
   5978 	cil_tree_node_init(&test_ast_node);
   5979 
   5980 	struct cil_db *test_db;
   5981 	cil_db_init(&test_db);
   5982 
   5983 	test_ast_node->parent = test_db->ast->root;
   5984 	test_ast_node->line = 1;
   5985 
   5986 	struct cil_tree_node *parse_current = test_tree->root->cl_head->cl_head;
   5987 
   5988 	struct cil_constrain *cons;
   5989 	cil_constrain_init(&cons);
   5990 	cil_classpermset_init(&cons->classpermset);
   5991 	cil_fill_classpermset(parse_current->next->cl_head, cons->classpermset);
   5992 
   5993 	int rc = cil_gen_expr_stack(parse_current->next->next, CIL_MLSCONSTRAIN, &cons->expr);
   5994 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   5995 }
   5996 
   5997 void test_cil_gen_constrain_expr_stack_eq2_u1u2(CuTest *tc) {
   5998 	char *line[] = {"(", "mlsconstrain", "(", "file", "(", "create", "relabelto", ")", ")", "(", "eq", "u1", "u2", ")", ")", NULL};
   5999 	struct cil_tree *test_tree;
   6000 	gen_test_tree(&test_tree, line);
   6001 
   6002 	struct cil_tree_node *test_ast_node;
   6003 	cil_tree_node_init(&test_ast_node);
   6004 
   6005 	struct cil_db *test_db;
   6006 	cil_db_init(&test_db);
   6007 
   6008 	test_ast_node->parent = test_db->ast->root;
   6009 	test_ast_node->line = 1;
   6010 
   6011 	struct cil_tree_node *parse_current = test_tree->root->cl_head->cl_head;
   6012 
   6013 	struct cil_constrain *cons;
   6014 	cil_constrain_init(&cons);
   6015 	cil_classpermset_init(&cons->classpermset);
   6016 	cil_fill_classpermset(parse_current->next->cl_head, cons->classpermset);
   6017 
   6018 	int rc = cil_gen_expr_stack(parse_current->next->next, CIL_MLSCONSTRAIN, &cons->expr);
   6019 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   6020 }
   6021 
   6022 void test_cil_gen_constrain_expr_stack_eq2_u1user(CuTest *tc) {
   6023 	char *line[] = {"(", "mlsconstrain", "(", "file", "(", "create", "relabelto", ")", ")", "(", "eq", "u1", "user_u", ")", ")", NULL};
   6024 	struct cil_tree *test_tree;
   6025 	gen_test_tree(&test_tree, line);
   6026 
   6027 	struct cil_tree_node *test_ast_node;
   6028 	cil_tree_node_init(&test_ast_node);
   6029 
   6030 	struct cil_db *test_db;
   6031 	cil_db_init(&test_db);
   6032 
   6033 	test_ast_node->parent = test_db->ast->root;
   6034 	test_ast_node->line = 1;
   6035 
   6036 	struct cil_tree_node *parse_current = test_tree->root->cl_head->cl_head;
   6037 
   6038 	struct cil_constrain *cons;
   6039 	cil_constrain_init(&cons);
   6040 	cil_classpermset_init(&cons->classpermset);
   6041 	cil_fill_classpermset(parse_current->next->cl_head, cons->classpermset);
   6042 
   6043 	int rc = cil_gen_expr_stack(parse_current->next->next, CIL_MLSCONSTRAIN, &cons->expr);
   6044 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   6045 }
   6046 
   6047 void test_cil_gen_constrain_expr_stack_eq2_u1u1_neg(CuTest *tc) {
   6048 	char *line[] = {"(", "mlsconstrain", "(", "file", "(", "create", "relabelto", ")", ")", "(", "eq", "u1", "u1", ")", ")", NULL};
   6049 	struct cil_tree *test_tree;
   6050 	gen_test_tree(&test_tree, line);
   6051 
   6052 	struct cil_tree_node *test_ast_node;
   6053 	cil_tree_node_init(&test_ast_node);
   6054 
   6055 	struct cil_db *test_db;
   6056 	cil_db_init(&test_db);
   6057 
   6058 	test_ast_node->parent = test_db->ast->root;
   6059 	test_ast_node->line = 1;
   6060 
   6061 	struct cil_tree_node *parse_current = test_tree->root->cl_head->cl_head;
   6062 
   6063 	struct cil_constrain *cons;
   6064 	cil_constrain_init(&cons);
   6065 	cil_classpermset_init(&cons->classpermset);
   6066 	cil_fill_classpermset(parse_current->next->cl_head, cons->classpermset);
   6067 
   6068 	int rc = cil_gen_expr_stack(parse_current->next->next, CIL_MLSCONSTRAIN, &cons->expr);
   6069 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   6070 }
   6071 
   6072 void test_cil_gen_constrain_expr_stack_eq2_u2user(CuTest *tc) {
   6073 	char *line[] = {"(", "mlsconstrain", "(", "file", "(", "create", "relabelto", ")", ")", "(", "eq", "u2", "user_u", ")", ")", NULL};
   6074 	struct cil_tree *test_tree;
   6075 	gen_test_tree(&test_tree, line);
   6076 
   6077 	struct cil_tree_node *test_ast_node;
   6078 	cil_tree_node_init(&test_ast_node);
   6079 
   6080 	struct cil_db *test_db;
   6081 	cil_db_init(&test_db);
   6082 
   6083 	test_ast_node->parent = test_db->ast->root;
   6084 	test_ast_node->line = 1;
   6085 
   6086 	struct cil_tree_node *parse_current = test_tree->root->cl_head->cl_head;
   6087 
   6088 	struct cil_constrain *cons;
   6089 	cil_constrain_init(&cons);
   6090 	cil_classpermset_init(&cons->classpermset);
   6091 	cil_fill_classpermset(parse_current->next->cl_head, cons->classpermset);
   6092 
   6093 	int rc = cil_gen_expr_stack(parse_current->next->next, CIL_MLSCONSTRAIN, &cons->expr);
   6094 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   6095 }
   6096 
   6097 void test_cil_gen_constrain_expr_stack_eq2_u2u2_neg(CuTest *tc) {
   6098 	char *line[] = {"(", "mlsconstrain", "(", "file", "(", "create", "relabelto", ")", ")", "(", "eq", "u2", "u2", ")", ")", NULL};
   6099 	struct cil_tree *test_tree;
   6100 	gen_test_tree(&test_tree, line);
   6101 
   6102 	struct cil_tree_node *test_ast_node;
   6103 	cil_tree_node_init(&test_ast_node);
   6104 
   6105 	struct cil_db *test_db;
   6106 	cil_db_init(&test_db);
   6107 
   6108 	test_ast_node->parent = test_db->ast->root;
   6109 	test_ast_node->line = 1;
   6110 
   6111 	struct cil_tree_node *parse_current = test_tree->root->cl_head->cl_head;
   6112 
   6113 	struct cil_constrain *cons;
   6114 	cil_constrain_init(&cons);
   6115 	cil_classpermset_init(&cons->classpermset);
   6116 	cil_fill_classpermset(parse_current->next->cl_head, cons->classpermset);
   6117 
   6118 	int rc = cil_gen_expr_stack(parse_current->next->next, CIL_MLSCONSTRAIN, &cons->expr);
   6119 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   6120 }
   6121 
   6122 void test_cil_gen_constrain_expr_stack_eq_l2h2(CuTest *tc) {
   6123 	char *line[] = {"(", "mlsconstrain", "(", "file", "(", "create", "relabelto", ")", ")", "(", "eq", "l2", "h2", ")", ")", NULL};
   6124 	struct cil_tree *test_tree;
   6125 	gen_test_tree(&test_tree, line);
   6126 
   6127 	struct cil_tree_node *test_ast_node;
   6128 	cil_tree_node_init(&test_ast_node);
   6129 
   6130 	struct cil_db *test_db;
   6131 	cil_db_init(&test_db);
   6132 
   6133 	test_ast_node->parent = test_db->ast->root;
   6134 	test_ast_node->line = 1;
   6135 
   6136 	struct cil_tree_node *parse_current = test_tree->root->cl_head->cl_head;
   6137 
   6138 	struct cil_constrain *cons;
   6139 	cil_constrain_init(&cons);
   6140 	cil_classpermset_init(&cons->classpermset);
   6141 	cil_fill_classpermset(parse_current->next->cl_head, cons->classpermset);
   6142 
   6143 	int rc = cil_gen_expr_stack(parse_current->next->next, CIL_MLSCONSTRAIN, &cons->expr);
   6144 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   6145 }
   6146 
   6147 void test_cil_gen_constrain_expr_stack_eq_l2_neg(CuTest *tc) {
   6148 	char *line[] = {"(", "mlsconstrain", "(", "file", "(", "create", "relabelto", ")", ")", "(", "eq", "l2", "h1", ")", ")", NULL};
   6149 	struct cil_tree *test_tree;
   6150 	gen_test_tree(&test_tree, line);
   6151 
   6152 	struct cil_tree_node *test_ast_node;
   6153 	cil_tree_node_init(&test_ast_node);
   6154 
   6155 	struct cil_db *test_db;
   6156 	cil_db_init(&test_db);
   6157 
   6158 	test_ast_node->parent = test_db->ast->root;
   6159 	test_ast_node->line = 1;
   6160 
   6161 	struct cil_tree_node *parse_current = test_tree->root->cl_head->cl_head;
   6162 
   6163 	struct cil_constrain *cons;
   6164 	cil_constrain_init(&cons);
   6165 	cil_classpermset_init(&cons->classpermset);
   6166 	cil_fill_classpermset(parse_current->next->cl_head, cons->classpermset);
   6167 
   6168 	int rc = cil_gen_expr_stack(parse_current->next->next, CIL_MLSCONSTRAIN, &cons->expr);
   6169 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   6170 }
   6171 
   6172 void test_cil_gen_constrain_expr_stack_eq_l1l2(CuTest *tc) {
   6173 	char *line[] = {"(", "mlsconstrain", "(", "file", "(", "create", "relabelto", ")", ")", "(", "eq", "l1", "l2", ")", ")", NULL};
   6174 	struct cil_tree *test_tree;
   6175 	gen_test_tree(&test_tree, line);
   6176 
   6177 	struct cil_tree_node *test_ast_node;
   6178 	cil_tree_node_init(&test_ast_node);
   6179 
   6180 	struct cil_db *test_db;
   6181 	cil_db_init(&test_db);
   6182 
   6183 	test_ast_node->parent = test_db->ast->root;
   6184 	test_ast_node->line = 1;
   6185 
   6186 	struct cil_tree_node *parse_current = test_tree->root->cl_head->cl_head;
   6187 
   6188 	struct cil_constrain *cons;
   6189 	cil_constrain_init(&cons);
   6190 	cil_classpermset_init(&cons->classpermset);
   6191 	cil_fill_classpermset(parse_current->next->cl_head, cons->classpermset);
   6192 
   6193 	int rc = cil_gen_expr_stack(parse_current->next->next, CIL_MLSCONSTRAIN, &cons->expr);
   6194 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   6195 }
   6196 
   6197 void test_cil_gen_constrain_expr_stack_eq_l1h1(CuTest *tc) {
   6198 	char *line[] = {"(", "mlsconstrain", "(", "file", "(", "create", "relabelto", ")", ")", "(", "eq", "l1", "h1", ")", ")", NULL};
   6199 	struct cil_tree *test_tree;
   6200 	gen_test_tree(&test_tree, line);
   6201 
   6202 	struct cil_tree_node *test_ast_node;
   6203 	cil_tree_node_init(&test_ast_node);
   6204 
   6205 	struct cil_db *test_db;
   6206 	cil_db_init(&test_db);
   6207 
   6208 	test_ast_node->parent = test_db->ast->root;
   6209 	test_ast_node->line = 1;
   6210 
   6211 	struct cil_tree_node *parse_current = test_tree->root->cl_head->cl_head;
   6212 
   6213 	struct cil_constrain *cons;
   6214 	cil_constrain_init(&cons);
   6215 	cil_classpermset_init(&cons->classpermset);
   6216 	cil_fill_classpermset(parse_current->next->cl_head, cons->classpermset);
   6217 
   6218 	int rc = cil_gen_expr_stack(parse_current->next->next, CIL_MLSCONSTRAIN, &cons->expr);
   6219 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   6220 }
   6221 
   6222 void test_cil_gen_constrain_expr_stack_eq_l1h2(CuTest *tc) {
   6223 	char *line[] = {"(", "mlsconstrain", "(", "file", "(", "create", "relabelto", ")", ")", "(", "eq", "l1", "h2", ")", ")", NULL};
   6224 	struct cil_tree *test_tree;
   6225 	gen_test_tree(&test_tree, line);
   6226 
   6227 	struct cil_tree_node *test_ast_node;
   6228 	cil_tree_node_init(&test_ast_node);
   6229 
   6230 	struct cil_db *test_db;
   6231 	cil_db_init(&test_db);
   6232 
   6233 	test_ast_node->parent = test_db->ast->root;
   6234 	test_ast_node->line = 1;
   6235 
   6236 	struct cil_tree_node *parse_current = test_tree->root->cl_head->cl_head;
   6237 
   6238 	struct cil_constrain *cons;
   6239 	cil_constrain_init(&cons);
   6240 	cil_classpermset_init(&cons->classpermset);
   6241 	cil_fill_classpermset(parse_current->next->cl_head, cons->classpermset);
   6242 
   6243 	int rc = cil_gen_expr_stack(parse_current->next->next, CIL_MLSCONSTRAIN, &cons->expr);
   6244 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   6245 }
   6246 
   6247 void test_cil_gen_constrain_expr_stack_eq_h1l2(CuTest *tc) {
   6248 	char *line[] = {"(", "mlsconstrain", "(", "file", "(", "create", "relabelto", ")", ")", "(", "eq", "h1", "l2", ")", ")", NULL};
   6249 	struct cil_tree *test_tree;
   6250 	gen_test_tree(&test_tree, line);
   6251 
   6252 	struct cil_tree_node *test_ast_node;
   6253 	cil_tree_node_init(&test_ast_node);
   6254 
   6255 	struct cil_db *test_db;
   6256 	cil_db_init(&test_db);
   6257 
   6258 	test_ast_node->parent = test_db->ast->root;
   6259 	test_ast_node->line = 1;
   6260 
   6261 	struct cil_tree_node *parse_current = test_tree->root->cl_head->cl_head;
   6262 
   6263 	struct cil_constrain *cons;
   6264 	cil_constrain_init(&cons);
   6265 	cil_classpermset_init(&cons->classpermset);
   6266 	cil_fill_classpermset(parse_current->next->cl_head, cons->classpermset);
   6267 
   6268 	int rc = cil_gen_expr_stack(parse_current->next->next, CIL_MLSCONSTRAIN, &cons->expr);
   6269 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   6270 }
   6271 
   6272 void test_cil_gen_constrain_expr_stack_eq_h1h2(CuTest *tc) {
   6273 	char *line[] = {"(", "mlsconstrain", "(", "file", "(", "create", "relabelto", ")", ")", "(", "eq", "h1", "h2", ")", ")", NULL};
   6274 	struct cil_tree *test_tree;
   6275 	gen_test_tree(&test_tree, line);
   6276 
   6277 	struct cil_tree_node *test_ast_node;
   6278 	cil_tree_node_init(&test_ast_node);
   6279 
   6280 	struct cil_db *test_db;
   6281 	cil_db_init(&test_db);
   6282 
   6283 	test_ast_node->parent = test_db->ast->root;
   6284 	test_ast_node->line = 1;
   6285 
   6286 	struct cil_tree_node *parse_current = test_tree->root->cl_head->cl_head;
   6287 
   6288 	struct cil_constrain *cons;
   6289 	cil_constrain_init(&cons);
   6290 	cil_classpermset_init(&cons->classpermset);
   6291 	cil_fill_classpermset(parse_current->next->cl_head, cons->classpermset);
   6292 
   6293 	int rc = cil_gen_expr_stack(parse_current->next->next, CIL_MLSCONSTRAIN, &cons->expr);
   6294 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   6295 }
   6296 
   6297 void test_cil_gen_constrain_expr_stack_eq_h1_neg(CuTest *tc) {
   6298 	char *line[] = {"(", "mlsconstrain", "(", "file", "(", "create", "relabelto", ")", ")", "(", "eq", "h1", "l1", ")", ")", NULL};
   6299 	struct cil_tree *test_tree;
   6300 	gen_test_tree(&test_tree, line);
   6301 
   6302 	struct cil_tree_node *test_ast_node;
   6303 	cil_tree_node_init(&test_ast_node);
   6304 
   6305 	struct cil_db *test_db;
   6306 	cil_db_init(&test_db);
   6307 
   6308 	test_ast_node->parent = test_db->ast->root;
   6309 	test_ast_node->line = 1;
   6310 
   6311 	struct cil_tree_node *parse_current = test_tree->root->cl_head->cl_head;
   6312 
   6313 	struct cil_constrain *cons;
   6314 	cil_constrain_init(&cons);
   6315 	cil_classpermset_init(&cons->classpermset);
   6316 	cil_fill_classpermset(parse_current->next->cl_head, cons->classpermset);
   6317 
   6318 	int rc = cil_gen_expr_stack(parse_current->next->next, CIL_MLSCONSTRAIN, &cons->expr);
   6319 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   6320 }
   6321 
   6322 void test_cil_gen_constrain_expr_stack_eq_l1l1_neg(CuTest *tc) {
   6323 	char *line[] = {"(", "mlsconstrain", "(", "file", "(", "create", "relabelto", ")", ")", "(", "eq", "l1", "l1", ")", ")", NULL};
   6324 	struct cil_tree *test_tree;
   6325 	gen_test_tree(&test_tree, line);
   6326 
   6327 	struct cil_tree_node *test_ast_node;
   6328 	cil_tree_node_init(&test_ast_node);
   6329 
   6330 	struct cil_db *test_db;
   6331 	cil_db_init(&test_db);
   6332 
   6333 	test_ast_node->parent = test_db->ast->root;
   6334 	test_ast_node->line = 1;
   6335 
   6336 	struct cil_tree_node *parse_current = test_tree->root->cl_head->cl_head;
   6337 
   6338 	struct cil_constrain *cons;
   6339 	cil_constrain_init(&cons);
   6340 	cil_classpermset_init(&cons->classpermset);
   6341 	cil_fill_classpermset(parse_current->next->cl_head, cons->classpermset);
   6342 
   6343 	int rc = cil_gen_expr_stack(parse_current->next->next, CIL_MLSCONSTRAIN, &cons->expr);
   6344 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   6345 }
   6346 
   6347 void test_cil_gen_constrain_expr_stack_eq2_l1l2_constrain_neg(CuTest *tc) {
   6348 	char *line[] = {"(", "constrain", "(", "file", "(", "create", "relabelto", ")", ")", "(", "eq", "l1", "l2", ")", ")", NULL};
   6349 	struct cil_tree *test_tree;
   6350 	gen_test_tree(&test_tree, line);
   6351 
   6352 	struct cil_tree_node *test_ast_node;
   6353 	cil_tree_node_init(&test_ast_node);
   6354 
   6355 	struct cil_db *test_db;
   6356 	cil_db_init(&test_db);
   6357 
   6358 	test_ast_node->parent = test_db->ast->root;
   6359 	test_ast_node->line = 1;
   6360 
   6361 	struct cil_tree_node *parse_current = test_tree->root->cl_head->cl_head;
   6362 
   6363 	struct cil_constrain *cons;
   6364 	cil_constrain_init(&cons);
   6365 	cil_classpermset_init(&cons->classpermset);
   6366 	cil_fill_classpermset(parse_current->next->cl_head, cons->classpermset);
   6367 
   6368 	int rc = cil_gen_expr_stack(parse_current->next->next, CIL_CONSTRAIN, &cons->expr);
   6369 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   6370 }
   6371 
   6372 void test_cil_gen_constrain_expr_stack_eq_l1l2_constrain_neg(CuTest *tc) {
   6373 	char *line[] = {"(", "constrain", "(", "file", "(", "create", "relabelto", ")", ")", "(", "eq", "l1", "l2", ")", ")", NULL};
   6374 	struct cil_tree *test_tree;
   6375 	gen_test_tree(&test_tree, line);
   6376 
   6377 	struct cil_tree_node *test_ast_node;
   6378 	cil_tree_node_init(&test_ast_node);
   6379 
   6380 	struct cil_db *test_db;
   6381 	cil_db_init(&test_db);
   6382 
   6383 	test_ast_node->parent = test_db->ast->root;
   6384 	test_ast_node->line = 1;
   6385 
   6386 	struct cil_tree_node *parse_current = test_tree->root->cl_head->cl_head;
   6387 
   6388 	struct cil_constrain *cons;
   6389 	cil_constrain_init(&cons);
   6390 	cil_classpermset_init(&cons->classpermset);
   6391 	cil_fill_classpermset(parse_current->next->cl_head, cons->classpermset);
   6392 
   6393 	int rc = cil_gen_expr_stack(parse_current->next->next, CIL_CONSTRAIN, &cons->expr);
   6394 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   6395 }
   6396 
   6397 void test_cil_gen_constrain_expr_stack_eq_leftkeyword_neg(CuTest *tc) {
   6398 	char *line[] = {"(", "mlsconstrain", "(", "file", "(", "create", "relabelto", ")", ")", "(", "eq", "h2", "h1", ")", ")", NULL};
   6399 	struct cil_tree *test_tree;
   6400 	gen_test_tree(&test_tree, line);
   6401 
   6402 	struct cil_tree_node *test_ast_node;
   6403 	cil_tree_node_init(&test_ast_node);
   6404 
   6405 	struct cil_db *test_db;
   6406 	cil_db_init(&test_db);
   6407 
   6408 	test_ast_node->parent = test_db->ast->root;
   6409 	test_ast_node->line = 1;
   6410 
   6411 	struct cil_tree_node *parse_current = test_tree->root->cl_head->cl_head;
   6412 
   6413 	struct cil_constrain *cons;
   6414 	cil_constrain_init(&cons);
   6415 	cil_classpermset_init(&cons->classpermset);
   6416 	cil_fill_classpermset(parse_current->next->cl_head, cons->classpermset);
   6417 
   6418 	int rc = cil_gen_expr_stack(parse_current->next->next, CIL_MLSCONSTRAIN, &cons->expr);
   6419 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   6420 }
   6421 
   6422 void test_cil_gen_constrain_expr_stack_eq_noexpr1_neg(CuTest *tc) {
   6423 	char *line[] = {"(", "mlsconstrain", "(", "file", "(", "create", "relabelto", ")", ")", "(", "eq", ")", ")", ")", NULL};
   6424 	struct cil_tree *test_tree;
   6425 	gen_test_tree(&test_tree, line);
   6426 
   6427 	struct cil_tree_node *test_ast_node;
   6428 	cil_tree_node_init(&test_ast_node);
   6429 
   6430 	struct cil_db *test_db;
   6431 	cil_db_init(&test_db);
   6432 
   6433 	test_ast_node->parent = test_db->ast->root;
   6434 	test_ast_node->line = 1;
   6435 
   6436 	struct cil_tree_node *parse_current = test_tree->root->cl_head->cl_head;
   6437 
   6438 	struct cil_constrain *cons;
   6439 	cil_constrain_init(&cons);
   6440 	cil_classpermset_init(&cons->classpermset);
   6441 	cil_fill_classpermset(parse_current->next->cl_head, cons->classpermset);
   6442 
   6443 	int rc = cil_gen_expr_stack(parse_current->next->next, CIL_MLSCONSTRAIN, &cons->expr);
   6444 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   6445 }
   6446 
   6447 void test_cil_gen_constrain_expr_stack_eq_expr1inparens_neg(CuTest *tc) {
   6448 	char *line[] = {"(", "mlsconstrain", "(", "file", "(", "create", "relabelto", ")", ")", "(", "eq", "(", "l1", ")", ")", ")", NULL};
   6449 	struct cil_tree *test_tree;
   6450 	gen_test_tree(&test_tree, line);
   6451 
   6452 	struct cil_tree_node *test_ast_node;
   6453 	cil_tree_node_init(&test_ast_node);
   6454 
   6455 	struct cil_db *test_db;
   6456 	cil_db_init(&test_db);
   6457 
   6458 	test_ast_node->parent = test_db->ast->root;
   6459 	test_ast_node->line = 1;
   6460 
   6461 	struct cil_tree_node *parse_current = test_tree->root->cl_head->cl_head;
   6462 
   6463 	struct cil_constrain *cons;
   6464 	cil_constrain_init(&cons);
   6465 	cil_classpermset_init(&cons->classpermset);
   6466 	cil_fill_classpermset(parse_current->next->cl_head, cons->classpermset);
   6467 
   6468 	int rc = cil_gen_expr_stack(parse_current->next->next, CIL_MLSCONSTRAIN, &cons->expr);
   6469 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   6470 }
   6471 
   6472 void test_cil_gen_constrain_expr_stack_eq_noexpr2_neg(CuTest *tc) {
   6473 	char *line[] = {"(", "mlsconstrain", "(", "file", "(", "create", "relabelto", ")", ")", "(", "eq", "l1", ")", ")", ")", NULL};
   6474 	struct cil_tree *test_tree;
   6475 	gen_test_tree(&test_tree, line);
   6476 
   6477 	struct cil_tree_node *test_ast_node;
   6478 	cil_tree_node_init(&test_ast_node);
   6479 
   6480 	struct cil_db *test_db;
   6481 	cil_db_init(&test_db);
   6482 
   6483 	test_ast_node->parent = test_db->ast->root;
   6484 	test_ast_node->line = 1;
   6485 
   6486 	struct cil_tree_node *parse_current = test_tree->root->cl_head->cl_head;
   6487 
   6488 	struct cil_constrain *cons;
   6489 	cil_constrain_init(&cons);
   6490 	cil_classpermset_init(&cons->classpermset);
   6491 	cil_fill_classpermset(parse_current->next->cl_head, cons->classpermset);
   6492 
   6493 	int rc = cil_gen_expr_stack(parse_current->next->next, CIL_MLSCONSTRAIN, &cons->expr);
   6494 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   6495 }
   6496 
   6497 void test_cil_gen_constrain_expr_stack_eq_expr2inparens_neg(CuTest *tc) {
   6498 	char *line[] = {"(", "mlsconstrain", "(", "file", "(", "create", "relabelto", ")", ")", "(", "eq", "l1", "(", "h2", ")", ")", ")", NULL};
   6499 	struct cil_tree *test_tree;
   6500 	gen_test_tree(&test_tree, line);
   6501 
   6502 	struct cil_tree_node *test_ast_node;
   6503 	cil_tree_node_init(&test_ast_node);
   6504 
   6505 	struct cil_db *test_db;
   6506 	cil_db_init(&test_db);
   6507 
   6508 	test_ast_node->parent = test_db->ast->root;
   6509 	test_ast_node->line = 1;
   6510 
   6511 	struct cil_tree_node *parse_current = test_tree->root->cl_head->cl_head;
   6512 
   6513 	struct cil_constrain *cons;
   6514 	cil_constrain_init(&cons);
   6515 	cil_classpermset_init(&cons->classpermset);
   6516 	cil_fill_classpermset(parse_current->next->cl_head, cons->classpermset);
   6517 
   6518 	int rc = cil_gen_expr_stack(parse_current->next->next, CIL_MLSCONSTRAIN, &cons->expr);
   6519 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   6520 }
   6521 
   6522 void test_cil_gen_constrain_expr_stack_eq_extraexpr_neg(CuTest *tc) {
   6523 	char *line[] = {"(", "mlsconstrain", "(", "file", "(", "create", "relabelto", ")", ")", "(", "eq", "foo", "foo", "extra", ")", ")", NULL};
   6524 	struct cil_tree *test_tree;
   6525 	gen_test_tree(&test_tree, line);
   6526 
   6527 	struct cil_tree_node *test_ast_node;
   6528 	cil_tree_node_init(&test_ast_node);
   6529 
   6530 	struct cil_db *test_db;
   6531 	cil_db_init(&test_db);
   6532 
   6533 	test_ast_node->parent = test_db->ast->root;
   6534 	test_ast_node->line = 1;
   6535 
   6536 	struct cil_tree_node *parse_current = test_tree->root->cl_head->cl_head;
   6537 
   6538 	struct cil_constrain *cons;
   6539 	cil_constrain_init(&cons);
   6540 	cil_classpermset_init(&cons->classpermset);
   6541 	cil_fill_classpermset(parse_current->next->cl_head, cons->classpermset);
   6542 
   6543 	int rc = cil_gen_expr_stack(parse_current->next->next, CIL_MLSCONSTRAIN, &cons->expr);
   6544 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   6545 }
   6546 
   6547 void test_cil_gen_constrain_expr_stack_eq2(CuTest *tc) {
   6548 	char *line[] = {"(", "mlsconstrain", "(", "file", "(", "create", "relabelto", ")", ")", "(", "eq", "l2", "h2", ")", ")", NULL};
   6549 	struct cil_tree *test_tree;
   6550 	gen_test_tree(&test_tree, line);
   6551 
   6552 	struct cil_tree_node *test_ast_node;
   6553 	cil_tree_node_init(&test_ast_node);
   6554 
   6555 	struct cil_db *test_db;
   6556 	cil_db_init(&test_db);
   6557 
   6558 	test_ast_node->parent = test_db->ast->root;
   6559 	test_ast_node->line = 1;
   6560 
   6561 	struct cil_tree_node *parse_current = test_tree->root->cl_head->cl_head;
   6562 
   6563 	struct cil_constrain *cons;
   6564 	cil_constrain_init(&cons);
   6565 	cil_classpermset_init(&cons->classpermset);
   6566 	cil_fill_classpermset(parse_current->next->cl_head, cons->classpermset);
   6567 
   6568 	int rc = cil_gen_expr_stack(parse_current->next->next, CIL_MLSCONSTRAIN, &cons->expr);
   6569 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   6570 }
   6571 
   6572 void test_cil_gen_constrain_expr_stack_eq2_noexpr1_neg(CuTest *tc) {
   6573 	char *line[] = {"(", "mlsconstrain", "(", "file", "(", "create", "relabelto", ")", ")", "(", "eq", ")", ")", ")", NULL};
   6574 	struct cil_tree *test_tree;
   6575 	gen_test_tree(&test_tree, line);
   6576 
   6577 	struct cil_tree_node *test_ast_node;
   6578 	cil_tree_node_init(&test_ast_node);
   6579 
   6580 	struct cil_db *test_db;
   6581 	cil_db_init(&test_db);
   6582 
   6583 	test_ast_node->parent = test_db->ast->root;
   6584 	test_ast_node->line = 1;
   6585 
   6586 	struct cil_tree_node *parse_current = test_tree->root->cl_head->cl_head;
   6587 
   6588 	struct cil_constrain *cons;
   6589 	cil_constrain_init(&cons);
   6590 	cil_classpermset_init(&cons->classpermset);
   6591 	cil_fill_classpermset(parse_current->next->cl_head, cons->classpermset);
   6592 
   6593 	int rc = cil_gen_expr_stack(parse_current->next->next, CIL_MLSCONSTRAIN, &cons->expr);
   6594 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   6595 }
   6596 
   6597 void test_cil_gen_constrain_expr_stack_eq2_expr1inparens_neg(CuTest *tc) {
   6598 	char *line[] = {"(", "mlsconstrain", "(", "file", "(", "create", "relabelto", ")", ")", "(", "eq", "(", "l1", ")", ")", ")", NULL};
   6599 	struct cil_tree *test_tree;
   6600 	gen_test_tree(&test_tree, line);
   6601 
   6602 	struct cil_tree_node *test_ast_node;
   6603 	cil_tree_node_init(&test_ast_node);
   6604 
   6605 	struct cil_db *test_db;
   6606 	cil_db_init(&test_db);
   6607 
   6608 	test_ast_node->parent = test_db->ast->root;
   6609 	test_ast_node->line = 1;
   6610 
   6611 	struct cil_tree_node *parse_current = test_tree->root->cl_head->cl_head;
   6612 
   6613 	struct cil_constrain *cons;
   6614 	cil_constrain_init(&cons);
   6615 	cil_classpermset_init(&cons->classpermset);
   6616 	cil_fill_classpermset(parse_current->next->cl_head, cons->classpermset);
   6617 
   6618 	int rc = cil_gen_expr_stack(parse_current->next->next, CIL_MLSCONSTRAIN, &cons->expr);
   6619 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   6620 }
   6621 
   6622 void test_cil_gen_constrain_expr_stack_eq2_noexpr2_neg(CuTest *tc) {
   6623 	char *line[] = {"(", "mlsconstrain", "(", "file", "(", "create", "relabelto", ")", ")", "(", "eq", "l1", ")", ")", ")", NULL};
   6624 	struct cil_tree *test_tree;
   6625 	gen_test_tree(&test_tree, line);
   6626 
   6627 	struct cil_tree_node *test_ast_node;
   6628 	cil_tree_node_init(&test_ast_node);
   6629 
   6630 	struct cil_db *test_db;
   6631 	cil_db_init(&test_db);
   6632 
   6633 	test_ast_node->parent = test_db->ast->root;
   6634 	test_ast_node->line = 1;
   6635 
   6636 	struct cil_tree_node *parse_current = test_tree->root->cl_head->cl_head;
   6637 
   6638 	struct cil_constrain *cons;
   6639 	cil_constrain_init(&cons);
   6640 	cil_classpermset_init(&cons->classpermset);
   6641 	cil_fill_classpermset(parse_current->next->cl_head, cons->classpermset);
   6642 
   6643 	int rc = cil_gen_expr_stack(parse_current->next->next, CIL_MLSCONSTRAIN, &cons->expr);
   6644 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   6645 }
   6646 
   6647 void test_cil_gen_constrain_expr_stack_eq2_expr2inparens_neg(CuTest *tc) {
   6648 	char *line[] = {"(", "mlsconstrain", "(", "file", "(", "create", "relabelto", ")", ")", "(", "eq", "l1", "(", "h2", ")", ")", ")", NULL};
   6649 	struct cil_tree *test_tree;
   6650 	gen_test_tree(&test_tree, line);
   6651 
   6652 	struct cil_tree_node *test_ast_node;
   6653 	cil_tree_node_init(&test_ast_node);
   6654 
   6655 	struct cil_db *test_db;
   6656 	cil_db_init(&test_db);
   6657 
   6658 	test_ast_node->parent = test_db->ast->root;
   6659 	test_ast_node->line = 1;
   6660 
   6661 	struct cil_tree_node *parse_current = test_tree->root->cl_head->cl_head;
   6662 
   6663 	struct cil_constrain *cons;
   6664 	cil_constrain_init(&cons);
   6665 	cil_classpermset_init(&cons->classpermset);
   6666 	cil_fill_classpermset(parse_current->next->cl_head, cons->classpermset);
   6667 
   6668 	int rc = cil_gen_expr_stack(parse_current->next->next, CIL_MLSCONSTRAIN, &cons->expr);
   6669 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   6670 }
   6671 
   6672 void test_cil_gen_constrain_expr_stack_eq2_extraexpr_neg(CuTest *tc) {
   6673 	char *line[] = {"(", "mlsconstrain", "(", "file", "(", "create", "relabelto", ")", ")", "(", "eq", "foo", "foo", "extra", ")", ")", NULL};
   6674 	struct cil_tree *test_tree;
   6675 	gen_test_tree(&test_tree, line);
   6676 
   6677 	struct cil_tree_node *test_ast_node;
   6678 	cil_tree_node_init(&test_ast_node);
   6679 
   6680 	struct cil_db *test_db;
   6681 	cil_db_init(&test_db);
   6682 
   6683 	test_ast_node->parent = test_db->ast->root;
   6684 	test_ast_node->line = 1;
   6685 
   6686 	struct cil_tree_node *parse_current = test_tree->root->cl_head->cl_head;
   6687 
   6688 	struct cil_constrain *cons;
   6689 	cil_constrain_init(&cons);
   6690 	cil_classpermset_init(&cons->classpermset);
   6691 	cil_fill_classpermset(parse_current->next->cl_head, cons->classpermset);
   6692 
   6693 	int rc = cil_gen_expr_stack(parse_current->next->next, CIL_MLSCONSTRAIN, &cons->expr);
   6694 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   6695 }
   6696 
   6697 void test_cil_gen_constrain_expr_stack_noteq(CuTest *tc) {
   6698 	char *line[] = {"(", "mlsconstrain", "(", "file", "(", "create", "relabelto", ")", ")", "(", "neq", "l2", "h2", ")", ")", NULL};
   6699 	struct cil_tree *test_tree;
   6700 	gen_test_tree(&test_tree, line);
   6701 
   6702 	struct cil_tree_node *test_ast_node;
   6703 	cil_tree_node_init(&test_ast_node);
   6704 
   6705 	struct cil_db *test_db;
   6706 	cil_db_init(&test_db);
   6707 
   6708 	test_ast_node->parent = test_db->ast->root;
   6709 	test_ast_node->line = 1;
   6710 
   6711 	struct cil_tree_node *parse_current = test_tree->root->cl_head->cl_head;
   6712 
   6713 	struct cil_constrain *cons;
   6714 	cil_constrain_init(&cons);
   6715 	cil_classpermset_init(&cons->classpermset);
   6716 	cil_fill_classpermset(parse_current->next->cl_head, cons->classpermset);
   6717 
   6718 	int rc = cil_gen_expr_stack(parse_current->next->next, CIL_MLSCONSTRAIN, &cons->expr);
   6719 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   6720 }
   6721 
   6722 void test_cil_gen_constrain_expr_stack_noteq_noexpr1_neg(CuTest *tc) {
   6723 	char *line[] = {"(", "mlsconstrain", "(", "file", "(", "create", "relabelto", ")", ")", "(", "neq", ")", ")", ")", NULL};
   6724 	struct cil_tree *test_tree;
   6725 	gen_test_tree(&test_tree, line);
   6726 
   6727 	struct cil_tree_node *test_ast_node;
   6728 	cil_tree_node_init(&test_ast_node);
   6729 
   6730 	struct cil_db *test_db;
   6731 	cil_db_init(&test_db);
   6732 
   6733 	test_ast_node->parent = test_db->ast->root;
   6734 	test_ast_node->line = 1;
   6735 
   6736 	struct cil_tree_node *parse_current = test_tree->root->cl_head->cl_head;
   6737 
   6738 	struct cil_constrain *cons;
   6739 	cil_constrain_init(&cons);
   6740 	cil_classpermset_init(&cons->classpermset);
   6741 	cil_fill_classpermset(parse_current->next->cl_head, cons->classpermset);
   6742 
   6743 	int rc = cil_gen_expr_stack(parse_current->next->next, CIL_MLSCONSTRAIN, &cons->expr);
   6744 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   6745 }
   6746 
   6747 void test_cil_gen_constrain_expr_stack_noteq_expr1inparens_neg(CuTest *tc) {
   6748 	char *line[] = {"(", "mlsconstrain", "(", "file", "(", "create", "relabelto", ")", ")", "(", "neq", "(", "l1", ")", ")", ")", NULL};
   6749 	struct cil_tree *test_tree;
   6750 	gen_test_tree(&test_tree, line);
   6751 
   6752 	struct cil_tree_node *test_ast_node;
   6753 	cil_tree_node_init(&test_ast_node);
   6754 
   6755 	struct cil_db *test_db;
   6756 	cil_db_init(&test_db);
   6757 
   6758 	test_ast_node->parent = test_db->ast->root;
   6759 	test_ast_node->line = 1;
   6760 
   6761 	struct cil_tree_node *parse_current = test_tree->root->cl_head->cl_head;
   6762 
   6763 	struct cil_constrain *cons;
   6764 	cil_constrain_init(&cons);
   6765 	cil_classpermset_init(&cons->classpermset);
   6766 	cil_fill_classpermset(parse_current->next->cl_head, cons->classpermset);
   6767 
   6768 	int rc = cil_gen_expr_stack(parse_current->next->next, CIL_MLSCONSTRAIN, &cons->expr);
   6769 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   6770 }
   6771 
   6772 void test_cil_gen_constrain_expr_stack_noteq_noexpr2_neg(CuTest *tc) {
   6773 	char *line[] = {"(", "mlsconstrain", "(", "file", "(", "create", "relabelto", ")", ")", "(", "neq", "l1", ")", ")", ")", NULL};
   6774 	struct cil_tree *test_tree;
   6775 	gen_test_tree(&test_tree, line);
   6776 
   6777 	struct cil_tree_node *test_ast_node;
   6778 	cil_tree_node_init(&test_ast_node);
   6779 
   6780 	struct cil_db *test_db;
   6781 	cil_db_init(&test_db);
   6782 
   6783 	test_ast_node->parent = test_db->ast->root;
   6784 	test_ast_node->line = 1;
   6785 
   6786 	struct cil_tree_node *parse_current = test_tree->root->cl_head->cl_head;
   6787 
   6788 	struct cil_constrain *cons;
   6789 	cil_constrain_init(&cons);
   6790 	cil_classpermset_init(&cons->classpermset);
   6791 	cil_fill_classpermset(parse_current->next->cl_head, cons->classpermset);
   6792 
   6793 	int rc = cil_gen_expr_stack(parse_current->next->next, CIL_MLSCONSTRAIN, &cons->expr);
   6794 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   6795 }
   6796 
   6797 void test_cil_gen_constrain_expr_stack_noteq_expr2inparens_neg(CuTest *tc) {
   6798 	char *line[] = {"(", "mlsconstrain", "(", "file", "(", "create", "relabelto", ")", ")", "(", "neq", "l1", "(", "h2", ")", ")", ")", NULL};
   6799 	struct cil_tree *test_tree;
   6800 	gen_test_tree(&test_tree, line);
   6801 
   6802 	struct cil_tree_node *test_ast_node;
   6803 	cil_tree_node_init(&test_ast_node);
   6804 
   6805 	struct cil_db *test_db;
   6806 	cil_db_init(&test_db);
   6807 
   6808 	test_ast_node->parent = test_db->ast->root;
   6809 	test_ast_node->line = 1;
   6810 
   6811 	struct cil_tree_node *parse_current = test_tree->root->cl_head->cl_head;
   6812 
   6813 	struct cil_constrain *cons;
   6814 	cil_constrain_init(&cons);
   6815 	cil_classpermset_init(&cons->classpermset);
   6816 	cil_fill_classpermset(parse_current->next->cl_head, cons->classpermset);
   6817 
   6818 	int rc = cil_gen_expr_stack(parse_current->next->next, CIL_MLSCONSTRAIN, &cons->expr);
   6819 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   6820 }
   6821 
   6822 void test_cil_gen_constrain_expr_stack_noteq_extraexpr_neg(CuTest *tc) {
   6823 	char *line[] = {"(", "mlsconstrain", "(", "file", "(", "create", "relabelto", ")", ")", "(", "neq", "foo", "foo", "extra", ")", ")", NULL};
   6824 	struct cil_tree *test_tree;
   6825 	gen_test_tree(&test_tree, line);
   6826 
   6827 	struct cil_tree_node *test_ast_node;
   6828 	cil_tree_node_init(&test_ast_node);
   6829 
   6830 	struct cil_db *test_db;
   6831 	cil_db_init(&test_db);
   6832 
   6833 	test_ast_node->parent = test_db->ast->root;
   6834 	test_ast_node->line = 1;
   6835 
   6836 	struct cil_tree_node *parse_current = test_tree->root->cl_head->cl_head;
   6837 
   6838 	struct cil_constrain *cons;
   6839 	cil_constrain_init(&cons);
   6840 	cil_classpermset_init(&cons->classpermset);
   6841 	cil_fill_classpermset(parse_current->next->cl_head, cons->classpermset);
   6842 
   6843 	int rc = cil_gen_expr_stack(parse_current->next->next, CIL_MLSCONSTRAIN, &cons->expr);
   6844 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   6845 }
   6846 
   6847 void test_cil_gen_constrain_expr_stack_not(CuTest *tc) {
   6848 	char *line[] = {"(", "mlsconstrain", "(", "file", "(", "create", "relabelto", ")", ")", "(", "not", "(", "neq", "l2", "h2", ")", ")", ")", NULL};
   6849 	struct cil_tree *test_tree;
   6850 	gen_test_tree(&test_tree, line);
   6851 
   6852 	struct cil_tree_node *test_ast_node;
   6853 	cil_tree_node_init(&test_ast_node);
   6854 
   6855 	struct cil_db *test_db;
   6856 	cil_db_init(&test_db);
   6857 
   6858 	test_ast_node->parent = test_db->ast->root;
   6859 	test_ast_node->line = 1;
   6860 
   6861 	struct cil_tree_node *parse_current = test_tree->root->cl_head->cl_head;
   6862 
   6863 	struct cil_constrain *cons;
   6864 	cil_constrain_init(&cons);
   6865 	cil_classpermset_init(&cons->classpermset);
   6866 	cil_fill_classpermset(parse_current->next->cl_head, cons->classpermset);
   6867 
   6868 	int rc = cil_gen_expr_stack(parse_current->next->next, CIL_MLSCONSTRAIN, &cons->expr);
   6869 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   6870 }
   6871 
   6872 void test_cil_gen_constrain_expr_stack_not_noexpr_neg(CuTest *tc) {
   6873 	char *line[] = {"(", "mlsconstrain", "(", "file", "(", "create", "relabelto", ")", ")", "(", "not", ")", ")", ")", NULL};
   6874 	struct cil_tree *test_tree;
   6875 	gen_test_tree(&test_tree, line);
   6876 
   6877 	struct cil_tree_node *test_ast_node;
   6878 	cil_tree_node_init(&test_ast_node);
   6879 
   6880 	struct cil_db *test_db;
   6881 	cil_db_init(&test_db);
   6882 
   6883 	test_ast_node->parent = test_db->ast->root;
   6884 	test_ast_node->line = 1;
   6885 
   6886 	struct cil_tree_node *parse_current = test_tree->root->cl_head->cl_head;
   6887 
   6888 	struct cil_constrain *cons;
   6889 	cil_constrain_init(&cons);
   6890 	cil_classpermset_init(&cons->classpermset);
   6891 	cil_fill_classpermset(parse_current->next->cl_head, cons->classpermset);
   6892 
   6893 	int rc = cil_gen_expr_stack(parse_current->next->next, CIL_MLSCONSTRAIN, &cons->expr);
   6894 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   6895 }
   6896 
   6897 void test_cil_gen_constrain_expr_stack_not_emptyparens_neg(CuTest *tc) {
   6898 	char *line[] = {"(", "mlsconstrain", "(", "file", "(", "create", "relabelto", ")", ")", "(", "not", "(", ")", ")", ")", NULL};
   6899 	struct cil_tree *test_tree;
   6900 	gen_test_tree(&test_tree, line);
   6901 
   6902 	struct cil_tree_node *test_ast_node;
   6903 	cil_tree_node_init(&test_ast_node);
   6904 
   6905 	struct cil_db *test_db;
   6906 	cil_db_init(&test_db);
   6907 
   6908 	test_ast_node->parent = test_db->ast->root;
   6909 	test_ast_node->line = 1;
   6910 
   6911 	struct cil_tree_node *parse_current = test_tree->root->cl_head->cl_head;
   6912 
   6913 	struct cil_constrain *cons;
   6914 	cil_constrain_init(&cons);
   6915 	cil_classpermset_init(&cons->classpermset);
   6916 	cil_fill_classpermset(parse_current->next->cl_head, cons->classpermset);
   6917 
   6918 	int rc = cil_gen_expr_stack(parse_current->next->next, CIL_MLSCONSTRAIN, &cons->expr);
   6919 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   6920 }
   6921 
   6922 void test_cil_gen_constrain_expr_stack_not_extraparens_neg(CuTest *tc) {
   6923 	char *line[] = {"(", "mlsconstrain", "(", "file", "(", "create", "relabelto", ")", ")", "(", "not", "(", "neq", "l2", "h2", ")", "(", ")", ")", ")", NULL};
   6924 	struct cil_tree *test_tree;
   6925 	gen_test_tree(&test_tree, line);
   6926 
   6927 	struct cil_tree_node *test_ast_node;
   6928 	cil_tree_node_init(&test_ast_node);
   6929 
   6930 	struct cil_db *test_db;
   6931 	cil_db_init(&test_db);
   6932 
   6933 	test_ast_node->parent = test_db->ast->root;
   6934 	test_ast_node->line = 1;
   6935 
   6936 	struct cil_tree_node *parse_current = test_tree->root->cl_head->cl_head;
   6937 
   6938 	struct cil_constrain *cons;
   6939 	cil_constrain_init(&cons);
   6940 	cil_classpermset_init(&cons->classpermset);
   6941 	cil_fill_classpermset(parse_current->next->cl_head, cons->classpermset);
   6942 
   6943 
   6944 	int rc = cil_gen_expr_stack(parse_current->next->next, CIL_MLSCONSTRAIN, &cons->expr);
   6945 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   6946 }
   6947 
   6948 void test_cil_gen_constrain_expr_stack_or(CuTest *tc) {
   6949 	char *line[] = {"(", "mlsconstrain", "(", "file", "(", "create", "relabelto", ")", ")", "(", "or",
   6950 			"(", "neq", "l1", "l2", ")", "(", "neq", "l1", "h1", ")", ")", ")", NULL};
   6951 	struct cil_tree *test_tree;
   6952 	gen_test_tree(&test_tree, line);
   6953 
   6954 	struct cil_tree_node *test_ast_node;
   6955 	cil_tree_node_init(&test_ast_node);
   6956 
   6957 	struct cil_db *test_db;
   6958 	cil_db_init(&test_db);
   6959 
   6960 	test_ast_node->parent = test_db->ast->root;
   6961 	test_ast_node->line = 1;
   6962 
   6963 	struct cil_tree_node *parse_current = test_tree->root->cl_head->cl_head;
   6964 
   6965 	struct cil_constrain *cons;
   6966 	cil_constrain_init(&cons);
   6967 	cil_classpermset_init(&cons->classpermset);
   6968 	cil_fill_classpermset(parse_current->next->cl_head, cons->classpermset);
   6969 
   6970 	int rc = cil_gen_expr_stack(parse_current->next->next, CIL_MLSCONSTRAIN, &cons->expr);
   6971 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   6972 }
   6973 
   6974 void test_cil_gen_constrain_expr_stack_or_neg(CuTest *tc) {
   6975 	char *line[] = {"(", "mlsconstrain", "(", "file", "(", "create", "relabelto", ")", ")", "(", "or",
   6976 			"(", "foo", ")", "(", "neq", "l1", "h1", ")", ")", ")", NULL};
   6977 	struct cil_tree *test_tree;
   6978 	gen_test_tree(&test_tree, line);
   6979 
   6980 	struct cil_tree_node *test_ast_node;
   6981 	cil_tree_node_init(&test_ast_node);
   6982 
   6983 	struct cil_db *test_db;
   6984 	cil_db_init(&test_db);
   6985 
   6986 	test_ast_node->parent = test_db->ast->root;
   6987 	test_ast_node->line = 1;
   6988 
   6989 	struct cil_tree_node *parse_current = test_tree->root->cl_head->cl_head;
   6990 
   6991 	struct cil_constrain *cons;
   6992 	cil_constrain_init(&cons);
   6993 	cil_classpermset_init(&cons->classpermset);
   6994 	cil_fill_classpermset(parse_current->next->cl_head, cons->classpermset);
   6995 
   6996 	int rc = cil_gen_expr_stack(parse_current->next->next, CIL_MLSCONSTRAIN, &cons->expr);
   6997 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   6998 }
   6999 
   7000 void test_cil_gen_constrain_expr_stack_or_noexpr_neg(CuTest *tc) {
   7001 	char *line[] = {"(", "mlsconstrain", "(", "file", "(", "create", "relabelto", ")", ")", "(", "or", ")", ")", ")", NULL};
   7002 	struct cil_tree *test_tree;
   7003 	gen_test_tree(&test_tree, line);
   7004 
   7005 	struct cil_tree_node *test_ast_node;
   7006 	cil_tree_node_init(&test_ast_node);
   7007 
   7008 	struct cil_db *test_db;
   7009 	cil_db_init(&test_db);
   7010 
   7011 	test_ast_node->parent = test_db->ast->root;
   7012 	test_ast_node->line = 1;
   7013 
   7014 	struct cil_tree_node *parse_current = test_tree->root->cl_head->cl_head;
   7015 
   7016 	struct cil_constrain *cons;
   7017 	cil_constrain_init(&cons);
   7018 	cil_classpermset_init(&cons->classpermset);
   7019 	cil_fill_classpermset(parse_current->next->cl_head, cons->classpermset);
   7020 
   7021 	int rc = cil_gen_expr_stack(parse_current->next->next, CIL_MLSCONSTRAIN, &cons->expr);
   7022 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   7023 }
   7024 
   7025 void test_cil_gen_constrain_expr_stack_or_emptyfirstparens_neg(CuTest *tc) {
   7026 	char *line[] = {"(", "mlsconstrain", "(", "file", "(", "create", "relabelto", ")", ")", "(", "or", "(", ")", ")", ")", NULL};
   7027 	struct cil_tree *test_tree;
   7028 	gen_test_tree(&test_tree, line);
   7029 
   7030 	struct cil_tree_node *test_ast_node;
   7031 	cil_tree_node_init(&test_ast_node);
   7032 
   7033 	struct cil_db *test_db;
   7034 	cil_db_init(&test_db);
   7035 
   7036 	test_ast_node->parent = test_db->ast->root;
   7037 	test_ast_node->line = 1;
   7038 
   7039 	struct cil_tree_node *parse_current = test_tree->root->cl_head->cl_head;
   7040 
   7041 	struct cil_constrain *cons;
   7042 	cil_constrain_init(&cons);
   7043 	cil_classpermset_init(&cons->classpermset);
   7044 	cil_fill_classpermset(parse_current->next->cl_head, cons->classpermset);
   7045 
   7046 
   7047 	int rc = cil_gen_expr_stack(parse_current->next->next, CIL_MLSCONSTRAIN, &cons->expr);
   7048 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   7049 }
   7050 
   7051 void test_cil_gen_constrain_expr_stack_or_missingsecondexpr_neg(CuTest *tc) {
   7052 	char *line[] = {"(", "mlsconstrain", "(", "file", "(", "create", "relabelto", ")", ")", "(", "or", "(", "foo", ")", ")", ")", ")", NULL};
   7053 	struct cil_tree *test_tree;
   7054 	gen_test_tree(&test_tree, line);
   7055 
   7056 	struct cil_tree_node *test_ast_node;
   7057 	cil_tree_node_init(&test_ast_node);
   7058 
   7059 	struct cil_db *test_db;
   7060 	cil_db_init(&test_db);
   7061 
   7062 	test_ast_node->parent = test_db->ast->root;
   7063 	test_ast_node->line = 1;
   7064 
   7065 	struct cil_tree_node *parse_current = test_tree->root->cl_head->cl_head;
   7066 
   7067 	struct cil_constrain *cons;
   7068 	cil_constrain_init(&cons);
   7069 	cil_classpermset_init(&cons->classpermset);
   7070 	cil_fill_classpermset(parse_current->next->cl_head, cons->classpermset);
   7071 
   7072 	int rc = cil_gen_expr_stack(parse_current->next->next, CIL_MLSCONSTRAIN, &cons->expr);
   7073 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   7074 }
   7075 
   7076 void test_cil_gen_constrain_expr_stack_or_emptysecondparens_neg(CuTest *tc) {
   7077 	char *line[] = {"(", "mlsconstrain", "(", "file", "(", "create", "relabelto", ")", ")", "(", "or", "(", "foo", ")", "(", ")", ")", ")", NULL};
   7078 	struct cil_tree *test_tree;
   7079 	gen_test_tree(&test_tree, line);
   7080 
   7081 	struct cil_tree_node *test_ast_node;
   7082 	cil_tree_node_init(&test_ast_node);
   7083 
   7084 	struct cil_db *test_db;
   7085 	cil_db_init(&test_db);
   7086 
   7087 	test_ast_node->parent = test_db->ast->root;
   7088 	test_ast_node->line = 1;
   7089 
   7090 	struct cil_tree_node *parse_current = test_tree->root->cl_head->cl_head;
   7091 
   7092 	struct cil_constrain *cons;
   7093 	cil_constrain_init(&cons);
   7094 	cil_classpermset_init(&cons->classpermset);
   7095 	cil_fill_classpermset(parse_current->next->cl_head, cons->classpermset);
   7096 
   7097 	int rc = cil_gen_expr_stack(parse_current->next->next, CIL_MLSCONSTRAIN, &cons->expr);
   7098 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   7099 }
   7100 
   7101 void test_cil_gen_constrain_expr_stack_or_extraexpr_neg(CuTest *tc) {
   7102 	char *line[] = {"(", "mlsconstrain", "(", "file", "(", "create", "relabelto", ")", ")", "(", "or", "(", "foo", ")", "(", "foo", ")", "(", ")", ")", ")", NULL};
   7103 	struct cil_tree *test_tree;
   7104 	gen_test_tree(&test_tree, line);
   7105 
   7106 	struct cil_tree_node *test_ast_node;
   7107 	cil_tree_node_init(&test_ast_node);
   7108 
   7109 	struct cil_db *test_db;
   7110 	cil_db_init(&test_db);
   7111 
   7112 	test_ast_node->parent = test_db->ast->root;
   7113 	test_ast_node->line = 1;
   7114 
   7115 	struct cil_tree_node *parse_current = test_tree->root->cl_head->cl_head;
   7116 
   7117 	struct cil_constrain *cons;
   7118 	cil_constrain_init(&cons);
   7119 	cil_classpermset_init(&cons->classpermset);
   7120 	cil_fill_classpermset(parse_current->next->cl_head, cons->classpermset);
   7121 
   7122 	int rc = cil_gen_expr_stack(parse_current->next->next, CIL_MLSCONSTRAIN, &cons->expr);
   7123 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   7124 }
   7125 
   7126 void test_cil_gen_constrain_expr_stack_and(CuTest *tc) {
   7127 	char *line[] = {"(", "mlsconstrain", "(", "file", "(", "create", "relabelto", ")", ")", "(", "and",
   7128 			"(", "neq", "l1", "l2", ")", "(", "neq", "l1", "h1", ")", ")", ")", NULL};
   7129 	struct cil_tree *test_tree;
   7130 	gen_test_tree(&test_tree, line);
   7131 
   7132 	struct cil_tree_node *test_ast_node;
   7133 	cil_tree_node_init(&test_ast_node);
   7134 
   7135 	struct cil_db *test_db;
   7136 	cil_db_init(&test_db);
   7137 
   7138 	test_ast_node->parent = test_db->ast->root;
   7139 	test_ast_node->line = 1;
   7140 
   7141 	struct cil_tree_node *parse_current = test_tree->root->cl_head->cl_head;
   7142 
   7143 	struct cil_constrain *cons;
   7144 	cil_constrain_init(&cons);
   7145 	cil_classpermset_init(&cons->classpermset);
   7146 	cil_fill_classpermset(parse_current->next->cl_head, cons->classpermset);
   7147 
   7148 	int rc = cil_gen_expr_stack(parse_current->next->next, CIL_MLSCONSTRAIN, &cons->expr);
   7149 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   7150 }
   7151 
   7152 void test_cil_gen_constrain_expr_stack_and_neg(CuTest *tc) {
   7153 	char *line[] = {"(", "mlsconstrain", "(", "file", "(", "create", "relabelto", ")", ")", "(", "and",
   7154 			"(", "foo", ")", "(", "neq", "l1", "h1", ")", ")", ")", NULL};
   7155 	struct cil_tree *test_tree;
   7156 	gen_test_tree(&test_tree, line);
   7157 
   7158 	struct cil_tree_node *test_ast_node;
   7159 	cil_tree_node_init(&test_ast_node);
   7160 
   7161 	struct cil_db *test_db;
   7162 	cil_db_init(&test_db);
   7163 
   7164 	test_ast_node->parent = test_db->ast->root;
   7165 	test_ast_node->line = 1;
   7166 
   7167 	struct cil_tree_node *parse_current = test_tree->root->cl_head->cl_head;
   7168 
   7169 	struct cil_constrain *cons;
   7170 	cil_constrain_init(&cons);
   7171 	cil_classpermset_init(&cons->classpermset);
   7172 	cil_fill_classpermset(parse_current->next->cl_head, cons->classpermset);
   7173 
   7174 	int rc = cil_gen_expr_stack(parse_current->next->next, CIL_MLSCONSTRAIN, &cons->expr);
   7175 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   7176 }
   7177 
   7178 void test_cil_gen_constrain_expr_stack_and_noexpr_neg(CuTest *tc) {
   7179 	char *line[] = {"(", "mlsconstrain", "(", "file", "(", "create", "relabelto", ")", ")", "(", "and", ")", ")", ")", NULL};
   7180 	struct cil_tree *test_tree;
   7181 	gen_test_tree(&test_tree, line);
   7182 
   7183 	struct cil_tree_node *test_ast_node;
   7184 	cil_tree_node_init(&test_ast_node);
   7185 
   7186 	struct cil_db *test_db;
   7187 	cil_db_init(&test_db);
   7188 
   7189 	test_ast_node->parent = test_db->ast->root;
   7190 	test_ast_node->line = 1;
   7191 
   7192 	struct cil_tree_node *parse_current = test_tree->root->cl_head->cl_head;
   7193 
   7194 	struct cil_constrain *cons;
   7195 	cil_constrain_init(&cons);
   7196 	cil_classpermset_init(&cons->classpermset);
   7197 	cil_fill_classpermset(parse_current->next->cl_head, cons->classpermset);
   7198 
   7199 	int rc = cil_gen_expr_stack(parse_current->next->next, CIL_MLSCONSTRAIN, &cons->expr);
   7200 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   7201 }
   7202 
   7203 void test_cil_gen_constrain_expr_stack_and_emptyfirstparens_neg(CuTest *tc) {
   7204 	char *line[] = {"(", "mlsconstrain", "(", "file", "(", "create", "relabelto", ")", ")", "(", "and", "(", ")", ")", ")", NULL};
   7205 	struct cil_tree *test_tree;
   7206 	gen_test_tree(&test_tree, line);
   7207 
   7208 	struct cil_tree_node *test_ast_node;
   7209 	cil_tree_node_init(&test_ast_node);
   7210 
   7211 	struct cil_db *test_db;
   7212 	cil_db_init(&test_db);
   7213 
   7214 	test_ast_node->parent = test_db->ast->root;
   7215 	test_ast_node->line = 1;
   7216 
   7217 	struct cil_tree_node *parse_current = test_tree->root->cl_head->cl_head;
   7218 
   7219 	struct cil_constrain *cons;
   7220 	cil_constrain_init(&cons);
   7221 	cil_classpermset_init(&cons->classpermset);
   7222 	cil_fill_classpermset(parse_current->next->cl_head, cons->classpermset);
   7223 
   7224 	int rc = cil_gen_expr_stack(parse_current->next->next, CIL_MLSCONSTRAIN, &cons->expr);
   7225 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   7226 }
   7227 
   7228 void test_cil_gen_constrain_expr_stack_and_missingsecondexpr_neg(CuTest *tc) {
   7229 	char *line[] = {"(", "mlsconstrain", "(", "file", "(", "create", "relabelto", ")", ")", "(", "and", "(", "foo", ")", ")", ")", ")", NULL};
   7230 	struct cil_tree *test_tree;
   7231 	gen_test_tree(&test_tree, line);
   7232 
   7233 	struct cil_tree_node *test_ast_node;
   7234 	cil_tree_node_init(&test_ast_node);
   7235 
   7236 	struct cil_db *test_db;
   7237 	cil_db_init(&test_db);
   7238 
   7239 	test_ast_node->parent = test_db->ast->root;
   7240 	test_ast_node->line = 1;
   7241 
   7242 	struct cil_tree_node *parse_current = test_tree->root->cl_head->cl_head;
   7243 
   7244 	struct cil_constrain *cons;
   7245 	cil_constrain_init(&cons);
   7246 	cil_classpermset_init(&cons->classpermset);
   7247 	cil_fill_classpermset(parse_current->next->cl_head, cons->classpermset);
   7248 
   7249 	int rc = cil_gen_expr_stack(parse_current->next->next, CIL_MLSCONSTRAIN, &cons->expr);
   7250 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   7251 }
   7252 
   7253 void test_cil_gen_constrain_expr_stack_and_emptysecondparens_neg(CuTest *tc) {
   7254 	char *line[] = {"(", "mlsconstrain", "(", "file", "(", "create", "relabelto", ")", ")", "(", "and", "(", "foo", ")", "(", ")", ")", ")", NULL};
   7255 	struct cil_tree *test_tree;
   7256 	gen_test_tree(&test_tree, line);
   7257 
   7258 	struct cil_tree_node *test_ast_node;
   7259 	cil_tree_node_init(&test_ast_node);
   7260 
   7261 	struct cil_db *test_db;
   7262 	cil_db_init(&test_db);
   7263 
   7264 	test_ast_node->parent = test_db->ast->root;
   7265 	test_ast_node->line = 1;
   7266 
   7267 	struct cil_tree_node *parse_current = test_tree->root->cl_head->cl_head;
   7268 
   7269 	struct cil_constrain *cons;
   7270 	cil_constrain_init(&cons);
   7271 	cil_classpermset_init(&cons->classpermset);
   7272 	cil_fill_classpermset(parse_current->next->cl_head, cons->classpermset);
   7273 
   7274 	int rc = cil_gen_expr_stack(parse_current->next->next, CIL_MLSCONSTRAIN, &cons->expr);
   7275 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   7276 }
   7277 
   7278 void test_cil_gen_constrain_expr_stack_and_extraexpr_neg(CuTest *tc) {
   7279 	char *line[] = {"(", "mlsconstrain", "(", "file", "(", "create", "relabelto", ")", ")", "(", "and", "(", "foo", ")", "(", "foo", ")", "(", ")", ")", ")", NULL};
   7280 	struct cil_tree *test_tree;
   7281 	gen_test_tree(&test_tree, line);
   7282 
   7283 	struct cil_tree_node *test_ast_node;
   7284 	cil_tree_node_init(&test_ast_node);
   7285 
   7286 	struct cil_db *test_db;
   7287 	cil_db_init(&test_db);
   7288 
   7289 	test_ast_node->parent = test_db->ast->root;
   7290 	test_ast_node->line = 1;
   7291 
   7292 	struct cil_tree_node *parse_current = test_tree->root->cl_head->cl_head;
   7293 
   7294 	struct cil_constrain *cons;
   7295 	cil_constrain_init(&cons);
   7296 	cil_classpermset_init(&cons->classpermset);
   7297 	cil_fill_classpermset(parse_current->next->cl_head, cons->classpermset);
   7298 
   7299 	int rc = cil_gen_expr_stack(parse_current->next->next, CIL_MLSCONSTRAIN, &cons->expr);
   7300 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   7301 }
   7302 
   7303 void test_cil_gen_constrain_expr_stack_dom(CuTest *tc) {
   7304 	char *line[] = {"(", "mlsconstrain", "(", "file", "(", "create", "relabelto", ")", ")", "(", "dom", "l2", "h2", ")", ")", NULL};
   7305 	struct cil_tree *test_tree;
   7306 	gen_test_tree(&test_tree, line);
   7307 
   7308 	struct cil_tree_node *test_ast_node;
   7309 	cil_tree_node_init(&test_ast_node);
   7310 
   7311 	struct cil_db *test_db;
   7312 	cil_db_init(&test_db);
   7313 
   7314 	test_ast_node->parent = test_db->ast->root;
   7315 	test_ast_node->line = 1;
   7316 
   7317 	struct cil_tree_node *parse_current = test_tree->root->cl_head->cl_head;
   7318 
   7319 	struct cil_constrain *cons;
   7320 	cil_constrain_init(&cons);
   7321 	cil_classpermset_init(&cons->classpermset);
   7322 	cil_fill_classpermset(parse_current->next->cl_head, cons->classpermset);
   7323 
   7324 	int rc = cil_gen_expr_stack(parse_current->next->next, CIL_MLSCONSTRAIN, &cons->expr);
   7325 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   7326 }
   7327 
   7328 void test_cil_gen_constrain_expr_stack_dom_noexpr1_neg(CuTest *tc) {
   7329 	char *line[] = {"(", "mlsconstrain", "(", "file", "(", "create", "relabelto", ")", ")", "(", "dom", ")", ")", ")", NULL};
   7330 	struct cil_tree *test_tree;
   7331 	gen_test_tree(&test_tree, line);
   7332 
   7333 	struct cil_tree_node *test_ast_node;
   7334 	cil_tree_node_init(&test_ast_node);
   7335 
   7336 	struct cil_db *test_db;
   7337 	cil_db_init(&test_db);
   7338 
   7339 	test_ast_node->parent = test_db->ast->root;
   7340 	test_ast_node->line = 1;
   7341 
   7342 	struct cil_tree_node *parse_current = test_tree->root->cl_head->cl_head;
   7343 
   7344 	struct cil_constrain *cons;
   7345 	cil_constrain_init(&cons);
   7346 	cil_classpermset_init(&cons->classpermset);
   7347 	cil_fill_classpermset(parse_current->next->cl_head, cons->classpermset);
   7348 
   7349 	int rc = cil_gen_expr_stack(parse_current->next->next, CIL_MLSCONSTRAIN, &cons->expr);
   7350 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   7351 }
   7352 
   7353 void test_cil_gen_constrain_expr_stack_dom_expr1inparens_neg(CuTest *tc) {
   7354 	char *line[] = {"(", "mlsconstrain", "(", "file", "(", "create", "relabelto", ")", ")", "(", "dom", "(", "l1", ")", ")", ")", NULL};
   7355 	struct cil_tree *test_tree;
   7356 	gen_test_tree(&test_tree, line);
   7357 
   7358 	struct cil_tree_node *test_ast_node;
   7359 	cil_tree_node_init(&test_ast_node);
   7360 
   7361 	struct cil_db *test_db;
   7362 	cil_db_init(&test_db);
   7363 
   7364 	test_ast_node->parent = test_db->ast->root;
   7365 	test_ast_node->line = 1;
   7366 
   7367 	struct cil_tree_node *parse_current = test_tree->root->cl_head->cl_head;
   7368 
   7369 	struct cil_constrain *cons;
   7370 	cil_constrain_init(&cons);
   7371 	cil_classpermset_init(&cons->classpermset);
   7372 	cil_fill_classpermset(parse_current->next->cl_head, cons->classpermset);
   7373 
   7374 	int rc = cil_gen_expr_stack(parse_current->next->next, CIL_MLSCONSTRAIN, &cons->expr);
   7375 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   7376 }
   7377 
   7378 void test_cil_gen_constrain_expr_stack_dom_noexpr2_neg(CuTest *tc) {
   7379 	char *line[] = {"(", "mlsconstrain", "(", "file", "(", "create", "relabelto", ")", ")", "(", "dom", "l1", ")", ")", ")", NULL};
   7380 	struct cil_tree *test_tree;
   7381 	gen_test_tree(&test_tree, line);
   7382 
   7383 	struct cil_tree_node *test_ast_node;
   7384 	cil_tree_node_init(&test_ast_node);
   7385 
   7386 	struct cil_db *test_db;
   7387 	cil_db_init(&test_db);
   7388 
   7389 	test_ast_node->parent = test_db->ast->root;
   7390 	test_ast_node->line = 1;
   7391 
   7392 	struct cil_tree_node *parse_current = test_tree->root->cl_head->cl_head;
   7393 
   7394 	struct cil_constrain *cons;
   7395 	cil_constrain_init(&cons);
   7396 	cil_classpermset_init(&cons->classpermset);
   7397 	cil_fill_classpermset(parse_current->next->cl_head, cons->classpermset);
   7398 
   7399 	int rc = cil_gen_expr_stack(parse_current->next->next, CIL_MLSCONSTRAIN, &cons->expr);
   7400 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   7401 }
   7402 
   7403 void test_cil_gen_constrain_expr_stack_dom_expr2inparens_neg(CuTest *tc) {
   7404 	char *line[] = {"(", "mlsconstrain", "(", "file", "(", "create", "relabelto", ")", ")", "(", "dom", "l1", "(", "h2", ")", ")", ")", NULL};
   7405 	struct cil_tree *test_tree;
   7406 	gen_test_tree(&test_tree, line);
   7407 
   7408 	struct cil_tree_node *test_ast_node;
   7409 	cil_tree_node_init(&test_ast_node);
   7410 
   7411 	struct cil_db *test_db;
   7412 	cil_db_init(&test_db);
   7413 
   7414 	test_ast_node->parent = test_db->ast->root;
   7415 	test_ast_node->line = 1;
   7416 
   7417 	struct cil_tree_node *parse_current = test_tree->root->cl_head->cl_head;
   7418 
   7419 	struct cil_constrain *cons;
   7420 	cil_constrain_init(&cons);
   7421 	cil_classpermset_init(&cons->classpermset);
   7422 	cil_fill_classpermset(parse_current->next->cl_head, cons->classpermset);
   7423 
   7424 	int rc = cil_gen_expr_stack(parse_current->next->next, CIL_MLSCONSTRAIN, &cons->expr);
   7425 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   7426 }
   7427 
   7428 void test_cil_gen_constrain_expr_stack_dom_extraexpr_neg(CuTest *tc) {
   7429 	char *line[] = {"(", "mlsconstrain", "(", "file", "(", "create", "relabelto", ")", ")", "(", "dom", "foo", "foo", "extra", ")", ")", NULL};
   7430 	struct cil_tree *test_tree;
   7431 	gen_test_tree(&test_tree, line);
   7432 
   7433 	struct cil_tree_node *test_ast_node;
   7434 	cil_tree_node_init(&test_ast_node);
   7435 
   7436 	struct cil_db *test_db;
   7437 	cil_db_init(&test_db);
   7438 
   7439 	test_ast_node->parent = test_db->ast->root;
   7440 	test_ast_node->line = 1;
   7441 
   7442 	struct cil_tree_node *parse_current = test_tree->root->cl_head->cl_head;
   7443 
   7444 	struct cil_constrain *cons;
   7445 	cil_constrain_init(&cons);
   7446 	cil_classpermset_init(&cons->classpermset);
   7447 	cil_fill_classpermset(parse_current->next->cl_head, cons->classpermset);
   7448 
   7449 	int rc = cil_gen_expr_stack(parse_current->next->next, CIL_MLSCONSTRAIN, &cons->expr);
   7450 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   7451 }
   7452 
   7453 void test_cil_gen_constrain_expr_stack_domby(CuTest *tc) {
   7454 	char *line[] = {"(", "mlsconstrain", "(", "file", "(", "create", "relabelto", ")", ")", "(", "domby", "l2", "h2", ")", ")", NULL};
   7455 	struct cil_tree *test_tree;
   7456 	gen_test_tree(&test_tree, line);
   7457 
   7458 	struct cil_tree_node *test_ast_node;
   7459 	cil_tree_node_init(&test_ast_node);
   7460 
   7461 	struct cil_db *test_db;
   7462 	cil_db_init(&test_db);
   7463 
   7464 	test_ast_node->parent = test_db->ast->root;
   7465 	test_ast_node->line = 1;
   7466 
   7467 	struct cil_tree_node *parse_current = test_tree->root->cl_head->cl_head;
   7468 
   7469 	struct cil_constrain *cons;
   7470 	cil_constrain_init(&cons);
   7471 	cil_classpermset_init(&cons->classpermset);
   7472 	cil_fill_classpermset(parse_current->next->cl_head, cons->classpermset);
   7473 
   7474 	int rc = cil_gen_expr_stack(parse_current->next->next, CIL_MLSCONSTRAIN, &cons->expr);
   7475 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   7476 }
   7477 
   7478 void test_cil_gen_constrain_expr_stack_domby_noexpr1_neg(CuTest *tc) {
   7479 	char *line[] = {"(", "mlsconstrain", "(", "file", "(", "create", "relabelto", ")", ")", "(", "domby", ")", ")", ")", NULL};
   7480 	struct cil_tree *test_tree;
   7481 	gen_test_tree(&test_tree, line);
   7482 
   7483 	struct cil_tree_node *test_ast_node;
   7484 	cil_tree_node_init(&test_ast_node);
   7485 
   7486 	struct cil_db *test_db;
   7487 	cil_db_init(&test_db);
   7488 
   7489 	test_ast_node->parent = test_db->ast->root;
   7490 	test_ast_node->line = 1;
   7491 
   7492 	struct cil_tree_node *parse_current = test_tree->root->cl_head->cl_head;
   7493 
   7494 	struct cil_constrain *cons;
   7495 	cil_constrain_init(&cons);
   7496 	cil_classpermset_init(&cons->classpermset);
   7497 	cil_fill_classpermset(parse_current->next->cl_head, cons->classpermset);
   7498 
   7499 	int rc = cil_gen_expr_stack(parse_current->next->next, CIL_MLSCONSTRAIN, &cons->expr);
   7500 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   7501 }
   7502 
   7503 void test_cil_gen_constrain_expr_stack_domby_expr1inparens_neg(CuTest *tc) {
   7504 	char *line[] = {"(", "mlsconstrain", "(", "file", "(", "create", "relabelto", ")", ")", "(", "domby", "(", "l1", ")", ")", ")", NULL};
   7505 	struct cil_tree *test_tree;
   7506 	gen_test_tree(&test_tree, line);
   7507 
   7508 	struct cil_tree_node *test_ast_node;
   7509 	cil_tree_node_init(&test_ast_node);
   7510 
   7511 	struct cil_db *test_db;
   7512 	cil_db_init(&test_db);
   7513 
   7514 	test_ast_node->parent = test_db->ast->root;
   7515 	test_ast_node->line = 1;
   7516 
   7517 	struct cil_tree_node *parse_current = test_tree->root->cl_head->cl_head;
   7518 
   7519 	struct cil_constrain *cons;
   7520 	cil_constrain_init(&cons);
   7521 	cil_classpermset_init(&cons->classpermset);
   7522 	cil_fill_classpermset(parse_current->next->cl_head, cons->classpermset);
   7523 
   7524 	int rc = cil_gen_expr_stack(parse_current->next->next, CIL_MLSCONSTRAIN, &cons->expr);
   7525 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   7526 }
   7527 
   7528 void test_cil_gen_constrain_expr_stack_domby_noexpr2_neg(CuTest *tc) {
   7529 	char *line[] = {"(", "mlsconstrain", "(", "file", "(", "create", "relabelto", ")", ")", "(", "domby", "l1", ")", ")", ")", NULL};
   7530 	struct cil_tree *test_tree;
   7531 	gen_test_tree(&test_tree, line);
   7532 
   7533 	struct cil_tree_node *test_ast_node;
   7534 	cil_tree_node_init(&test_ast_node);
   7535 
   7536 	struct cil_db *test_db;
   7537 	cil_db_init(&test_db);
   7538 
   7539 	test_ast_node->parent = test_db->ast->root;
   7540 	test_ast_node->line = 1;
   7541 
   7542 	struct cil_tree_node *parse_current = test_tree->root->cl_head->cl_head;
   7543 
   7544 	struct cil_constrain *cons;
   7545 	cil_constrain_init(&cons);
   7546 	cil_classpermset_init(&cons->classpermset);
   7547 	cil_fill_classpermset(parse_current->next->cl_head, cons->classpermset);
   7548 
   7549 	int rc = cil_gen_expr_stack(parse_current->next->next, CIL_MLSCONSTRAIN, &cons->expr);
   7550 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   7551 }
   7552 
   7553 void test_cil_gen_constrain_expr_stack_domby_expr2inparens_neg(CuTest *tc) {
   7554 	char *line[] = {"(", "mlsconstrain", "(", "file", "(", "create", "relabelto", ")", ")", "(", "domby", "l1", "(", "h2", ")", ")", ")", NULL};
   7555 	struct cil_tree *test_tree;
   7556 	gen_test_tree(&test_tree, line);
   7557 
   7558 	struct cil_tree_node *test_ast_node;
   7559 	cil_tree_node_init(&test_ast_node);
   7560 
   7561 	struct cil_db *test_db;
   7562 	cil_db_init(&test_db);
   7563 
   7564 	test_ast_node->parent = test_db->ast->root;
   7565 	test_ast_node->line = 1;
   7566 
   7567 	struct cil_tree_node *parse_current = test_tree->root->cl_head->cl_head;
   7568 
   7569 	struct cil_constrain *cons;
   7570 	cil_constrain_init(&cons);
   7571 	cil_classpermset_init(&cons->classpermset);
   7572 	cil_fill_classpermset(parse_current->next->cl_head, cons->classpermset);
   7573 
   7574 	int rc = cil_gen_expr_stack(parse_current->next->next, CIL_MLSCONSTRAIN, &cons->expr);
   7575 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   7576 }
   7577 
   7578 void test_cil_gen_constrain_expr_stack_domby_extraexpr_neg(CuTest *tc) {
   7579 	char *line[] = {"(", "mlsconstrain", "(", "file", "(", "create", "relabelto", ")", ")", "(", "domby", "foo", "foo", "extra", ")", ")", NULL};
   7580 	struct cil_tree *test_tree;
   7581 	gen_test_tree(&test_tree, line);
   7582 
   7583 	struct cil_tree_node *test_ast_node;
   7584 	cil_tree_node_init(&test_ast_node);
   7585 
   7586 	struct cil_db *test_db;
   7587 	cil_db_init(&test_db);
   7588 
   7589 	test_ast_node->parent = test_db->ast->root;
   7590 	test_ast_node->line = 1;
   7591 
   7592 	struct cil_tree_node *parse_current = test_tree->root->cl_head->cl_head;
   7593 
   7594 	struct cil_constrain *cons;
   7595 	cil_constrain_init(&cons);
   7596 	cil_classpermset_init(&cons->classpermset);
   7597 	cil_fill_classpermset(parse_current->next->cl_head, cons->classpermset);
   7598 
   7599 	int rc = cil_gen_expr_stack(parse_current->next->next, CIL_MLSCONSTRAIN, &cons->expr);
   7600 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   7601 }
   7602 
   7603 void test_cil_gen_constrain_expr_stack_incomp(CuTest *tc) {
   7604 	char *line[] = {"(", "mlsconstrain", "(", "file", "(", "create", "relabelto", ")", ")", "(", "incomp", "l2", "h2", ")", ")", NULL};
   7605 	struct cil_tree *test_tree;
   7606 	gen_test_tree(&test_tree, line);
   7607 
   7608 	struct cil_tree_node *test_ast_node;
   7609 	cil_tree_node_init(&test_ast_node);
   7610 
   7611 	struct cil_db *test_db;
   7612 	cil_db_init(&test_db);
   7613 
   7614 	test_ast_node->parent = test_db->ast->root;
   7615 	test_ast_node->line = 1;
   7616 
   7617 	struct cil_tree_node *parse_current = test_tree->root->cl_head->cl_head;
   7618 
   7619 	struct cil_constrain *cons;
   7620 	cil_constrain_init(&cons);
   7621 	cil_classpermset_init(&cons->classpermset);
   7622 	cil_fill_classpermset(parse_current->next->cl_head, cons->classpermset);
   7623 
   7624 	int rc = cil_gen_expr_stack(parse_current->next->next, CIL_MLSCONSTRAIN, &cons->expr);
   7625 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   7626 }
   7627 
   7628 void test_cil_gen_constrain_expr_stack_incomp_noexpr1_neg(CuTest *tc) {
   7629 	char *line[] = {"(", "mlsconstrain", "(", "file", "(", "create", "relabelto", ")", ")", "(", "incomp", ")", ")", ")", NULL};
   7630 	struct cil_tree *test_tree;
   7631 	gen_test_tree(&test_tree, line);
   7632 
   7633 	struct cil_tree_node *test_ast_node;
   7634 	cil_tree_node_init(&test_ast_node);
   7635 
   7636 	struct cil_db *test_db;
   7637 	cil_db_init(&test_db);
   7638 
   7639 	test_ast_node->parent = test_db->ast->root;
   7640 	test_ast_node->line = 1;
   7641 
   7642 	struct cil_tree_node *parse_current = test_tree->root->cl_head->cl_head;
   7643 
   7644 	struct cil_constrain *cons;
   7645 	cil_constrain_init(&cons);
   7646 	cil_classpermset_init(&cons->classpermset);
   7647 	cil_fill_classpermset(parse_current->next->cl_head, cons->classpermset);
   7648 
   7649 	int rc = cil_gen_expr_stack(parse_current->next->next, CIL_MLSCONSTRAIN, &cons->expr);
   7650 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   7651 }
   7652 
   7653 void test_cil_gen_constrain_expr_stack_incomp_expr1inparens_neg(CuTest *tc) {
   7654 	char *line[] = {"(", "mlsconstrain", "(", "file", "(", "create", "relabelto", ")", ")", "(", "incomp", "(", "l1", ")", ")", ")", NULL};
   7655 	struct cil_tree *test_tree;
   7656 	gen_test_tree(&test_tree, line);
   7657 
   7658 	struct cil_tree_node *test_ast_node;
   7659 	cil_tree_node_init(&test_ast_node);
   7660 
   7661 	struct cil_db *test_db;
   7662 	cil_db_init(&test_db);
   7663 
   7664 	test_ast_node->parent = test_db->ast->root;
   7665 	test_ast_node->line = 1;
   7666 
   7667 	struct cil_tree_node *parse_current = test_tree->root->cl_head->cl_head;
   7668 
   7669 	struct cil_constrain *cons;
   7670 	cil_constrain_init(&cons);
   7671 	cil_classpermset_init(&cons->classpermset);
   7672 	cil_fill_classpermset(parse_current->next->cl_head, cons->classpermset);
   7673 
   7674 	int rc = cil_gen_expr_stack(parse_current->next->next, CIL_MLSCONSTRAIN, &cons->expr);
   7675 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   7676 }
   7677 
   7678 void test_cil_gen_constrain_expr_stack_incomp_noexpr2_neg(CuTest *tc) {
   7679 	char *line[] = {"(", "mlsconstrain", "(", "file", "(", "create", "relabelto", ")", ")", "(", "incomp", "l1", ")", ")", ")", NULL};
   7680 	struct cil_tree *test_tree;
   7681 	gen_test_tree(&test_tree, line);
   7682 
   7683 	struct cil_tree_node *test_ast_node;
   7684 	cil_tree_node_init(&test_ast_node);
   7685 
   7686 	struct cil_db *test_db;
   7687 	cil_db_init(&test_db);
   7688 
   7689 	test_ast_node->parent = test_db->ast->root;
   7690 	test_ast_node->line = 1;
   7691 
   7692 	struct cil_tree_node *parse_current = test_tree->root->cl_head->cl_head;
   7693 
   7694 	struct cil_constrain *cons;
   7695 	cil_constrain_init(&cons);
   7696 	cil_classpermset_init(&cons->classpermset);
   7697 	cil_fill_classpermset(parse_current->next->cl_head, cons->classpermset);
   7698 
   7699 	int rc = cil_gen_expr_stack(parse_current->next->next, CIL_MLSCONSTRAIN, &cons->expr);
   7700 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   7701 }
   7702 
   7703 void test_cil_gen_constrain_expr_stack_incomp_expr2inparens_neg(CuTest *tc) {
   7704 	char *line[] = {"(", "mlsconstrain", "(", "file", "(", "create", "relabelto", ")", ")", "(", "incomp", "l1", "(", "h2", ")", ")", ")", NULL};
   7705 	struct cil_tree *test_tree;
   7706 	gen_test_tree(&test_tree, line);
   7707 
   7708 	struct cil_tree_node *test_ast_node;
   7709 	cil_tree_node_init(&test_ast_node);
   7710 
   7711 	struct cil_db *test_db;
   7712 	cil_db_init(&test_db);
   7713 
   7714 	test_ast_node->parent = test_db->ast->root;
   7715 	test_ast_node->line = 1;
   7716 
   7717 	struct cil_tree_node *parse_current = test_tree->root->cl_head->cl_head;
   7718 
   7719 	struct cil_constrain *cons;
   7720 	cil_constrain_init(&cons);
   7721 	cil_classpermset_init(&cons->classpermset);
   7722 	cil_fill_classpermset(parse_current->next->cl_head, cons->classpermset);
   7723 
   7724 	int rc = cil_gen_expr_stack(parse_current->next->next, CIL_MLSCONSTRAIN, &cons->expr);
   7725 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   7726 }
   7727 
   7728 void test_cil_gen_constrain_expr_stack_incomp_extraexpr_neg(CuTest *tc) {
   7729 	char *line[] = {"(", "mlsconstrain", "(", "file", "(", "create", "relabelto", ")", ")", "(", "incomp", "foo", "foo", "extra", ")", ")", NULL};
   7730 	struct cil_tree *test_tree;
   7731 	gen_test_tree(&test_tree, line);
   7732 
   7733 	struct cil_tree_node *test_ast_node;
   7734 	cil_tree_node_init(&test_ast_node);
   7735 
   7736 	struct cil_db *test_db;
   7737 	cil_db_init(&test_db);
   7738 
   7739 	test_ast_node->parent = test_db->ast->root;
   7740 	test_ast_node->line = 1;
   7741 
   7742 	struct cil_tree_node *parse_current = test_tree->root->cl_head->cl_head;
   7743 
   7744 	struct cil_constrain *cons;
   7745 	cil_constrain_init(&cons);
   7746 	cil_classpermset_init(&cons->classpermset);
   7747 	cil_fill_classpermset(parse_current->next->cl_head, cons->classpermset);
   7748 
   7749 	int rc = cil_gen_expr_stack(parse_current->next->next, CIL_MLSCONSTRAIN, &cons->expr);
   7750 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   7751 }
   7752 
   7753 void test_cil_gen_constrain_expr_stack_currnull_neg(CuTest *tc) {
   7754 	char *line[] = {"(", "mlsconstrain", "(", "file", "(", "create", "relabelto", ")", ")", "(", ")", ")", NULL};
   7755 	struct cil_tree *test_tree;
   7756 	gen_test_tree(&test_tree, line);
   7757 
   7758 	struct cil_tree_node *test_ast_node;
   7759 	cil_tree_node_init(&test_ast_node);
   7760 
   7761 	struct cil_db *test_db;
   7762 	cil_db_init(&test_db);
   7763 
   7764 	test_ast_node->parent = test_db->ast->root;
   7765 	test_ast_node->line = 1;
   7766 
   7767 	struct cil_tree_node *parse_current = test_tree->root->cl_head->cl_head;
   7768 
   7769 	struct cil_constrain *cons;
   7770 	cil_constrain_init(&cons);
   7771 	cil_classpermset_init(&cons->classpermset);
   7772 	cil_fill_classpermset(parse_current->next->cl_head, cons->classpermset);
   7773 
   7774 	int rc = cil_gen_expr_stack(parse_current->next->next, CIL_MLSCONSTRAIN, &cons->expr);
   7775 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   7776 }
   7777 
   7778 void test_cil_gen_constrain_expr_stack_stacknull_neg(CuTest *tc) {
   7779 	char *line[] = {"(", "mlsconstrain", "(", "file", "(", "create", "relabelto", ")", ")", "(", "eq", "t1", "type_t", ")", ")", NULL};
   7780 	struct cil_tree *test_tree;
   7781 	gen_test_tree(&test_tree, line);
   7782 
   7783 	struct cil_tree_node *test_ast_node;
   7784 	cil_tree_node_init(&test_ast_node);
   7785 
   7786 	struct cil_db *test_db;
   7787 	cil_db_init(&test_db);
   7788 
   7789 	test_ast_node->parent = test_db->ast->root;
   7790 	test_ast_node->line = 1;
   7791 
   7792 	struct cil_tree_node *parse_current = test_tree->root->cl_head->cl_head;
   7793 
   7794 	struct cil_constrain *cons;
   7795 	cil_constrain_init(&cons);
   7796 	cil_classpermset_init(&cons->classpermset);
   7797 	cil_fill_classpermset(parse_current->next->cl_head, cons->classpermset);
   7798 
   7799 	int rc = cil_gen_expr_stack(parse_current->next->next, CIL_MLSCONSTRAIN, NULL);
   7800 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   7801 }
   7802 
   7803 void test_cil_gen_constrain_expr_stack_operatorinparens_neg(CuTest *tc) {
   7804 	char *line[] = {"(", "mlsconstrain", "(", "file", "(", "create", "relabelto", ")", ")", "(", "(", "eq", ")", "t1", "type_t", ")", ")", NULL};
   7805 	struct cil_tree *test_tree;
   7806 	gen_test_tree(&test_tree, line);
   7807 
   7808 	struct cil_tree_node *test_ast_node;
   7809 	cil_tree_node_init(&test_ast_node);
   7810 
   7811 	struct cil_db *test_db;
   7812 	cil_db_init(&test_db);
   7813 
   7814 	test_ast_node->parent = test_db->ast->root;
   7815 	test_ast_node->line = 1;
   7816 
   7817 	struct cil_tree_node *parse_current = test_tree->root->cl_head->cl_head;
   7818 
   7819 	struct cil_constrain *cons;
   7820 	cil_constrain_init(&cons);
   7821 	cil_classpermset_init(&cons->classpermset);
   7822 	cil_fill_classpermset(parse_current->next->cl_head, cons->classpermset);
   7823 
   7824 	int rc = cil_gen_expr_stack(parse_current->next->next, CIL_MLSCONSTRAIN, &cons->expr);
   7825 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   7826 }
   7827 
   7828 void test_cil_gen_constrain_expr_stack_incorrectcall_neg(CuTest *tc) {
   7829 	char *line[] = {"(", "mlsconstrain", "(", "file", "(", "create", "relabelto", ")", ")", "(", "eq", "t1", "type_t", ")", ")", NULL};
   7830 	struct cil_tree *test_tree;
   7831 	gen_test_tree(&test_tree, line);
   7832 
   7833 	struct cil_tree_node *test_ast_node;
   7834 	cil_tree_node_init(&test_ast_node);
   7835 
   7836 	struct cil_db *test_db;
   7837 	cil_db_init(&test_db);
   7838 
   7839 	test_ast_node->parent = test_db->ast->root;
   7840 	test_ast_node->line = 1;
   7841 
   7842 	struct cil_tree_node *parse_current = test_tree->root->cl_head->cl_head;
   7843 
   7844 	struct cil_constrain *cons;
   7845 	cil_constrain_init(&cons);
   7846 	cil_classpermset_init(&cons->classpermset);
   7847 	cil_fill_classpermset(parse_current->next->cl_head, cons->classpermset);
   7848 
   7849 	int rc = cil_gen_expr_stack(parse_current->next->next->cl_head->next->next, CIL_MLSCONSTRAIN, &cons->expr);
   7850 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   7851 }
   7852 
   7853 void test_cil_gen_roleallow(CuTest *tc) {
   7854 	char *line[] = {"(", "roleallow", "staff_r", "sysadm_r", NULL};
   7855 
   7856 	struct cil_tree *test_tree;
   7857 	gen_test_tree(&test_tree, line);
   7858 
   7859 	struct cil_tree_node *test_ast_node;
   7860 	cil_tree_node_init(&test_ast_node);
   7861 
   7862 	struct cil_db *test_db;
   7863 	cil_db_init(&test_db);
   7864 
   7865 	struct cil_tree_node *test_current;
   7866 	test_current = test_tree->root->cl_head->cl_head;
   7867 
   7868 	test_ast_node->parent = test_db->ast->root;
   7869 	test_ast_node->line = 1;
   7870 
   7871 	int rc = cil_gen_roleallow(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   7872 	CuAssertPtrNotNull(tc, test_ast_node->data);
   7873 	CuAssertStrEquals(tc, ((struct cil_roleallow*)test_ast_node->data)->src_str, test_current->next->data);
   7874 	CuAssertStrEquals(tc, ((struct cil_roleallow*)test_ast_node->data)->tgt_str, test_current->next->next->data);
   7875 	CuAssertIntEquals(tc, test_ast_node->flavor, CIL_ROLEALLOW);
   7876 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   7877 }
   7878 
   7879 void test_cil_gen_roleallow_dbnull_neg(CuTest *tc) {
   7880 	char *line[] = {"(", "roleallow", "foo", "bar", ")", NULL};
   7881 
   7882 	struct cil_tree *test_tree;
   7883 	gen_test_tree(&test_tree, line);
   7884 
   7885 	struct cil_tree_node *test_ast_node;
   7886 	cil_tree_node_init(&test_ast_node);
   7887 
   7888 	struct cil_db *test_db = NULL;
   7889 
   7890 	int rc = cil_gen_roleallow(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   7891 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   7892 }
   7893 
   7894 void test_cil_gen_roleallow_currnull_neg(CuTest *tc) {
   7895 	struct cil_tree_node *test_ast_node;
   7896 	cil_tree_node_init(&test_ast_node);
   7897 
   7898 	struct cil_db *test_db;
   7899 	cil_db_init(&test_db);
   7900 
   7901 	int rc = cil_gen_roleallow(test_db, NULL, test_ast_node);
   7902 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   7903 }
   7904 
   7905 void test_cil_gen_roleallow_astnull_neg(CuTest *tc) {
   7906 	char *line[] = {"(", "roleallow", "foo", "bar", ")", NULL};
   7907 
   7908 	struct cil_tree *test_tree;
   7909 	gen_test_tree(&test_tree, line);
   7910 
   7911 	struct cil_db *test_db;
   7912 	cil_db_init(&test_db);
   7913 
   7914 	struct cil_tree_node *test_ast_node = NULL;
   7915 
   7916 	int rc = cil_gen_roleallow(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   7917 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   7918 }
   7919 
   7920 void test_cil_gen_roleallow_srcnull_neg(CuTest *tc) {
   7921 	char *line[] = {"(", "roleallow", "foo", "bar", ")", NULL};
   7922 
   7923 	struct cil_tree *test_tree;
   7924 	gen_test_tree(&test_tree, line);
   7925 
   7926 	test_tree->root->cl_head->cl_head->next = NULL;
   7927 
   7928 	struct cil_db *test_db;
   7929 	cil_db_init(&test_db);
   7930 
   7931 	struct cil_tree_node *test_ast_node;
   7932 	cil_tree_node_init(&test_ast_node);
   7933 
   7934 	int rc = cil_gen_roleallow(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   7935 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   7936 }
   7937 
   7938 void test_cil_gen_roleallow_tgtnull_neg(CuTest *tc) {
   7939 	char *line[] = {"(", "roleallow", "foo", "bar", ")", NULL};
   7940 
   7941 	struct cil_tree *test_tree;
   7942 	gen_test_tree(&test_tree, line);
   7943 
   7944 	test_tree->root->cl_head->cl_head->next->next = NULL;
   7945 
   7946 	struct cil_db *test_db;
   7947 	cil_db_init(&test_db);
   7948 
   7949 	struct cil_tree_node *test_ast_node;
   7950 	cil_tree_node_init(&test_ast_node);
   7951 
   7952 	int rc = cil_gen_roleallow(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   7953 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   7954 }
   7955 
   7956 void test_cil_gen_roleallow_extra_neg(CuTest *tc) {
   7957 	char *line[] = {"(", "roleallow", "foo", "bar", "extra", ")", NULL};
   7958 
   7959 	struct cil_tree *test_tree;
   7960 	gen_test_tree(&test_tree, line);
   7961 
   7962 	struct cil_db *test_db;
   7963 	cil_db_init(&test_db);
   7964 
   7965 	struct cil_tree_node *test_ast_node;
   7966 	cil_tree_node_init(&test_ast_node);
   7967 
   7968 	int rc = cil_gen_roleallow(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   7969 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   7970 }
   7971 
   7972 void test_cil_gen_rolebounds(CuTest *tc) {
   7973 	char *line[] = {"(", "rolebounds", "role1", "role2", ")", NULL};
   7974 
   7975 	struct cil_tree *test_tree;
   7976 	gen_test_tree(&test_tree, line);
   7977 
   7978 	struct cil_tree_node *test_ast_node;
   7979 	cil_tree_node_init(&test_ast_node);
   7980 
   7981 	struct cil_db *test_db;
   7982 	cil_db_init(&test_db);
   7983 
   7984 	test_ast_node->parent = test_db->ast->root;
   7985 	test_ast_node->line = 1;
   7986 
   7987 	int rc = cil_gen_rolebounds(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   7988 	CuAssertIntEquals(tc, rc, SEPOL_OK);
   7989 }
   7990 
   7991 void test_cil_gen_rolebounds_norole1_neg(CuTest *tc) {
   7992 	char *line[] = {"(", "rolebounds", ")", NULL};
   7993 
   7994 	struct cil_tree *test_tree;
   7995 	gen_test_tree(&test_tree, line);
   7996 
   7997 	struct cil_tree_node *test_ast_node;
   7998 	cil_tree_node_init(&test_ast_node);
   7999 
   8000 	struct cil_db *test_db;
   8001 	cil_db_init(&test_db);
   8002 
   8003 	test_ast_node->parent = test_db->ast->root;
   8004 	test_ast_node->line = 1;
   8005 
   8006 	int rc = cil_gen_rolebounds(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   8007 	CuAssertIntEquals(tc, rc, SEPOL_ERR);
   8008 }
   8009 
   8010 void test_cil_gen_rolebounds_role1_inparens_neg(CuTest *tc) {
   8011 	char *line[] = {"(", "rolebounds", "(", "role1", ")", "role2", ")", NULL};
   8012 
   8013 	struct cil_tree *test_tree;
   8014 	gen_test_tree(&test_tree, line);
   8015 
   8016 	struct cil_tree_node *test_ast_node;
   8017 	cil_tree_node_init(&test_ast_node);
   8018 
   8019 	struct cil_db *test_db;
   8020 	cil_db_init(&test_db);
   8021 
   8022 	test_ast_node->parent = test_db->ast->root;
   8023 	test_ast_node->line = 1;
   8024 
   8025 	int rc = cil_gen_rolebounds(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   8026 	CuAssertIntEquals(tc, rc, SEPOL_ERR);
   8027 }
   8028 
   8029 void test_cil_gen_rolebounds_norole2_neg(CuTest *tc) {
   8030 	char *line[] = {"(", "rolebounds", "role1", ")", NULL};
   8031 
   8032 	struct cil_tree *test_tree;
   8033 	gen_test_tree(&test_tree, line);
   8034 
   8035 	struct cil_tree_node *test_ast_node;
   8036 	cil_tree_node_init(&test_ast_node);
   8037 
   8038 	struct cil_db *test_db;
   8039 	cil_db_init(&test_db);
   8040 
   8041 	test_ast_node->parent = test_db->ast->root;
   8042 	test_ast_node->line = 1;
   8043 
   8044 	int rc = cil_gen_rolebounds(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   8045 	CuAssertIntEquals(tc, rc, SEPOL_ERR);
   8046 }
   8047 
   8048 void test_cil_gen_rolebounds_role2_inparens_neg(CuTest *tc) {
   8049 	char *line[] = {"(", "rolebounds", "role1", "(", "role2", ")", ")", NULL};
   8050 
   8051 	struct cil_tree *test_tree;
   8052 	gen_test_tree(&test_tree, line);
   8053 
   8054 	struct cil_tree_node *test_ast_node;
   8055 	cil_tree_node_init(&test_ast_node);
   8056 
   8057 	struct cil_db *test_db;
   8058 	cil_db_init(&test_db);
   8059 
   8060 	test_ast_node->parent = test_db->ast->root;
   8061 	test_ast_node->line = 1;
   8062 
   8063 	int rc = cil_gen_rolebounds(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   8064 	CuAssertIntEquals(tc, rc, SEPOL_ERR);
   8065 }
   8066 
   8067 void test_cil_gen_rolebounds_extra_neg(CuTest *tc) {
   8068 	char *line[] = {"(", "rolebounds", "role1", "role2", "extra", ")", NULL};
   8069 
   8070 	struct cil_tree *test_tree;
   8071 	gen_test_tree(&test_tree, line);
   8072 
   8073 	struct cil_tree_node *test_ast_node;
   8074 	cil_tree_node_init(&test_ast_node);
   8075 
   8076 	struct cil_db *test_db;
   8077 	cil_db_init(&test_db);
   8078 
   8079 	test_ast_node->parent = test_db->ast->root;
   8080 	test_ast_node->line = 1;
   8081 
   8082 	int rc = cil_gen_rolebounds(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   8083 	CuAssertIntEquals(tc, rc, SEPOL_ERR);
   8084 }
   8085 
   8086 void test_cil_gen_rolebounds_dbnull_neg(CuTest *tc) {
   8087 	char *line[] = {"(", "rolebounds", "role1", "role2", ")", NULL};
   8088 
   8089 	struct cil_tree *test_tree;
   8090 	gen_test_tree(&test_tree, line);
   8091 
   8092 	struct cil_tree_node *test_ast_node;
   8093 	cil_tree_node_init(&test_ast_node);
   8094 
   8095 	struct cil_db *test_db = NULL;
   8096 
   8097 	int rc = cil_gen_rolebounds(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   8098 	CuAssertIntEquals(tc, rc, SEPOL_ERR);
   8099 }
   8100 
   8101 void test_cil_gen_rolebounds_currnull_neg(CuTest *tc) {
   8102 	char *line[] = {"(", ")", NULL};
   8103 
   8104 	struct cil_tree *test_tree;
   8105 	gen_test_tree(&test_tree, line);
   8106 
   8107 	struct cil_tree_node *test_ast_node;
   8108 	cil_tree_node_init(&test_ast_node);
   8109 
   8110 	struct cil_db *test_db;
   8111 	cil_db_init(&test_db);
   8112 
   8113 	test_ast_node->parent = test_db->ast->root;
   8114 	test_ast_node->line = 1;
   8115 
   8116 	int rc = cil_gen_rolebounds(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   8117 	CuAssertIntEquals(tc, rc, SEPOL_ERR);
   8118 }
   8119 
   8120 void test_cil_gen_rolebounds_astnull_neg(CuTest *tc) {
   8121 	char *line[] = {"(", "rolebounds", "role1", "role2", ")", NULL};
   8122 
   8123 	struct cil_tree *test_tree;
   8124 	gen_test_tree(&test_tree, line);
   8125 
   8126 	struct cil_tree_node *test_ast_node = NULL;
   8127 
   8128 	struct cil_db *test_db;
   8129 	cil_db_init(&test_db);
   8130 
   8131 	int rc = cil_gen_rolebounds(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   8132 	CuAssertIntEquals(tc, rc, SEPOL_ERR);
   8133 }
   8134 
   8135 void test_cil_gen_avrule(CuTest *tc) {
   8136 	char *line[] = {"(", "allow", "test", "foo", "(", "bar", "(", "read", "write", ")", ")", ")", NULL};
   8137 
   8138 	struct cil_tree *test_tree;
   8139 	gen_test_tree(&test_tree, line);
   8140 
   8141 	struct cil_tree_node *test_ast_node;
   8142 	cil_tree_node_init(&test_ast_node);
   8143 
   8144 	struct cil_db *test_db;
   8145 	cil_db_init(&test_db);
   8146 
   8147 	test_ast_node->parent = test_db->ast->root;
   8148 	test_ast_node->line = 1;
   8149 
   8150 	struct cil_tree_node *test_current;
   8151 	test_current = test_tree->root->cl_head->cl_head;
   8152 
   8153 	int rc = cil_gen_avrule(test_current, test_ast_node, CIL_AVRULE_ALLOWED);
   8154 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   8155 	CuAssertPtrNotNull(tc, test_ast_node->data);
   8156 	CuAssertStrEquals(tc, ((struct cil_avrule*)test_ast_node->data)->src_str, test_current->next->data);
   8157 	CuAssertStrEquals(tc, ((struct cil_avrule*)test_ast_node->data)->tgt_str, test_current->next->next->data);
   8158 	CuAssertStrEquals(tc, ((struct cil_avrule*)test_ast_node->data)->classpermset->class_str, test_current->next->next->next->cl_head->data);
   8159 	CuAssertIntEquals(tc, test_ast_node->flavor, CIL_AVRULE);
   8160 	CuAssertPtrNotNull(tc, ((struct cil_avrule*)test_ast_node->data)->classpermset->permset->perms_list_str);
   8161 
   8162 	struct cil_list_item *test_list = ((struct cil_avrule*)test_ast_node->data)->classpermset->permset->perms_list_str->head;
   8163 	test_current = test_current->next->next->next->cl_head->next->cl_head;
   8164 
   8165 	while(test_list != NULL) {
   8166 	    CuAssertIntEquals(tc, test_list->flavor, CIL_AST_STR);
   8167 	    CuAssertStrEquals(tc, test_list->data, test_current->data );
   8168 	    test_list = test_list->next;
   8169 	    test_current = test_current->next;
   8170 	}
   8171 }
   8172 
   8173 void test_cil_gen_avrule_permset(CuTest *tc) {
   8174 	char *line[] = {"(", "allow", "test", "foo", "(", "bar", "permset", ")", ")", NULL};
   8175 
   8176 	struct cil_tree *test_tree;
   8177 	gen_test_tree(&test_tree, line);
   8178 
   8179 	struct cil_tree_node *test_ast_node;
   8180 	cil_tree_node_init(&test_ast_node);
   8181 
   8182 	struct cil_db *test_db;
   8183 	cil_db_init(&test_db);
   8184 
   8185 	test_ast_node->parent = test_db->ast->root;
   8186 	test_ast_node->line = 1;
   8187 
   8188 	struct cil_tree_node *test_current;
   8189 	test_current = test_tree->root->cl_head->cl_head;
   8190 
   8191 	int rc = cil_gen_avrule(test_current, test_ast_node, CIL_AVRULE_ALLOWED);
   8192 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   8193 }
   8194 
   8195 void test_cil_gen_avrule_permset_anon(CuTest *tc) {
   8196 	char *line[] = {"(", "allow", "test", "foo", "(", "bar", "(", "read", "write", ")", ")", ")", NULL};
   8197 
   8198 	struct cil_tree *test_tree;
   8199 	gen_test_tree(&test_tree, line);
   8200 
   8201 	struct cil_tree_node *test_ast_node;
   8202 	cil_tree_node_init(&test_ast_node);
   8203 
   8204 	struct cil_db *test_db;
   8205 	cil_db_init(&test_db);
   8206 
   8207 	test_ast_node->parent = test_db->ast->root;
   8208 	test_ast_node->line = 1;
   8209 
   8210 	struct cil_tree_node *test_current;
   8211 	test_current = test_tree->root->cl_head->cl_head;
   8212 
   8213 	int rc = cil_gen_avrule(test_current, test_ast_node, CIL_AVRULE_ALLOWED);
   8214 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   8215 }
   8216 
   8217 void test_cil_gen_avrule_extra_neg(CuTest *tc) {
   8218 	char *line[] = {"(", "allow", "test", "foo", "(", "bar", "permset", ")", "extra", ")", NULL};
   8219 
   8220 	struct cil_tree *test_tree;
   8221 	gen_test_tree(&test_tree, line);
   8222 
   8223 	struct cil_tree_node *test_ast_node;
   8224 	cil_tree_node_init(&test_ast_node);
   8225 
   8226 	struct cil_db *test_db;
   8227 	cil_db_init(&test_db);
   8228 
   8229 	test_ast_node->parent = test_db->ast->root;
   8230 	test_ast_node->line = 1;
   8231 
   8232 	struct cil_tree_node *test_current;
   8233 	test_current = test_tree->root->cl_head->cl_head;
   8234 
   8235 	int rc = cil_gen_avrule(test_current, test_ast_node, CIL_AVRULE_ALLOWED);
   8236 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   8237 }
   8238 
   8239 void test_cil_gen_avrule_sourceparens(CuTest *tc) {
   8240 	char *line[] = {"(", "allow", "(", "test", ")", "foo", "(", "bar", "(", "read", "write", ")", ")", ")", NULL};
   8241 
   8242 	struct cil_tree *test_tree;
   8243 	gen_test_tree(&test_tree, line);
   8244 
   8245 	struct cil_tree_node *test_ast_node;
   8246 	cil_tree_node_init(&test_ast_node);
   8247 
   8248 	struct cil_db *test_db;
   8249 	cil_db_init(&test_db);
   8250 
   8251 	test_ast_node->parent = test_db->ast->root;
   8252 	test_ast_node->line = 1;
   8253 
   8254 	struct cil_tree_node *test_current;
   8255 	test_current = test_tree->root->cl_head->cl_head;
   8256 
   8257 	int rc = cil_gen_avrule(test_current, test_ast_node, CIL_AVRULE_ALLOWED);
   8258 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   8259 }
   8260 
   8261 void test_cil_gen_avrule_sourceemptyparen_neg(CuTest *tc) {
   8262 	char *line[] = {"(", "allow", "(", ")", "bar", "file", "(", "read", ")", ")", NULL};
   8263 
   8264 	struct cil_tree *test_tree;
   8265 	gen_test_tree(&test_tree, line);
   8266 
   8267 	struct cil_tree_node *test_ast_node;
   8268 	cil_tree_node_init(&test_ast_node);
   8269 
   8270 	struct cil_db *test_db;
   8271 	cil_db_init(&test_db);
   8272 
   8273 	test_ast_node->parent = test_db->ast->root;
   8274 	test_ast_node->line = 1;
   8275 
   8276 	struct cil_tree_node *test_current;
   8277 	test_current = test_tree->root->cl_head->cl_head;
   8278 
   8279 	int rc = cil_gen_avrule(test_current, test_ast_node, CIL_AVRULE_ALLOWED);
   8280 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   8281 }
   8282 
   8283 void test_cil_gen_avrule_targetparens(CuTest *tc) {
   8284 	char *line[] = {"(", "allow", "test", "(", "foo", ")", "bar", "(", "read", "write", ")", ")", NULL};
   8285 
   8286 	struct cil_tree *test_tree;
   8287 	gen_test_tree(&test_tree, line);
   8288 
   8289 	struct cil_tree_node *test_ast_node;
   8290 	cil_tree_node_init(&test_ast_node);
   8291 
   8292 	struct cil_db *test_db;
   8293 	cil_db_init(&test_db);
   8294 
   8295 	test_ast_node->parent = test_db->ast->root;
   8296 	test_ast_node->line = 1;
   8297 
   8298 	struct cil_tree_node *test_current;
   8299 	test_current = test_tree->root->cl_head->cl_head;
   8300 
   8301 	int rc = cil_gen_avrule(test_current, test_ast_node, CIL_AVRULE_ALLOWED);
   8302 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   8303 }
   8304 
   8305 void test_cil_gen_avrule_targetemptyparen_neg(CuTest *tc) {
   8306 	char *line[] = {"(", "allow", "bar", "(", ")", "file", "(", "read", ")", ")", NULL};
   8307 
   8308 	struct cil_tree *test_tree;
   8309 	gen_test_tree(&test_tree, line);
   8310 
   8311 	struct cil_tree_node *test_ast_node;
   8312 	cil_tree_node_init(&test_ast_node);
   8313 
   8314 	struct cil_db *test_db;
   8315 	cil_db_init(&test_db);
   8316 
   8317 	test_ast_node->parent = test_db->ast->root;
   8318 	test_ast_node->line = 1;
   8319 
   8320 	struct cil_tree_node *test_current;
   8321 	test_current = test_tree->root->cl_head->cl_head;
   8322 
   8323 	int rc = cil_gen_avrule(test_current, test_ast_node, CIL_AVRULE_ALLOWED);
   8324 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   8325 }
   8326 
   8327 void test_cil_gen_avrule_currnull_neg(CuTest *tc) {
   8328 	char *line[] = {"(", ")", NULL};
   8329 
   8330 	struct cil_tree *test_tree;
   8331 	gen_test_tree(&test_tree, line);
   8332 
   8333 	struct cil_tree_node *test_ast_node;
   8334 	cil_tree_node_init(&test_ast_node);
   8335 
   8336 	struct cil_db *test_db;
   8337 	cil_db_init(&test_db);
   8338 
   8339 	test_ast_node->parent = test_db->ast->root;
   8340 	test_ast_node->line = 1;
   8341 
   8342 	struct cil_tree_node *test_current;
   8343 	test_current = test_tree->root->cl_head->cl_head;
   8344 
   8345 	int rc = cil_gen_avrule(test_current, test_ast_node, CIL_AVRULE_ALLOWED);
   8346 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   8347 }
   8348 
   8349 void test_cil_gen_avrule_astnull_neg(CuTest *tc) {
   8350 	char *line[] = {"(", "allow", "test", "foo", "bar", "(", "read", "write", ")", ")", NULL};
   8351 
   8352 	struct cil_tree *test_tree;
   8353 	gen_test_tree(&test_tree, line);
   8354 
   8355 	struct cil_tree_node *test_ast_node = NULL;
   8356 
   8357 	struct cil_tree_node *test_current;
   8358 	test_current = test_tree->root->cl_head->cl_head;
   8359 
   8360 	int rc = cil_gen_avrule(test_current, test_ast_node, CIL_AVRULE_ALLOWED);
   8361 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   8362 }
   8363 
   8364 void test_cil_gen_avrule_sourcedomainnull_neg(CuTest *tc) {
   8365 	char *line[] = {"(", "allow", ")", NULL};
   8366 
   8367 	struct cil_tree *test_tree;
   8368 	gen_test_tree(&test_tree, line);
   8369 
   8370 	struct cil_tree_node *test_ast_node;
   8371 	cil_tree_node_init(&test_ast_node);
   8372 
   8373 	struct cil_db *test_db;
   8374 	cil_db_init(&test_db);
   8375 
   8376 	test_ast_node->parent = test_db->ast->root;
   8377 	test_ast_node->line = 1;
   8378 
   8379 	struct cil_tree_node *test_current;
   8380 	test_current = test_tree->root->cl_head->cl_head;
   8381 
   8382 	int rc = cil_gen_avrule(test_current, test_ast_node, CIL_AVRULE_ALLOWED);
   8383 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   8384 }
   8385 
   8386 void test_cil_gen_avrule_targetdomainnull_neg(CuTest *tc) {
   8387 	char *line[] = {"(", "allow", "foo", ")", NULL};
   8388 
   8389 	struct cil_tree *test_tree;
   8390 	gen_test_tree(&test_tree, line);
   8391 
   8392 	struct cil_tree_node *test_ast_node;
   8393 	cil_tree_node_init(&test_ast_node);
   8394 
   8395 	struct cil_db *test_db;
   8396 	cil_db_init(&test_db);
   8397 
   8398 	test_ast_node->parent = test_db->ast->root;
   8399 	test_ast_node->line = 1;
   8400 
   8401 	struct cil_tree_node *test_current;
   8402 	test_current = test_tree->root->cl_head->cl_head;
   8403 
   8404 	int rc = cil_gen_avrule(test_current, test_ast_node, CIL_AVRULE_ALLOWED);
   8405 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   8406 }
   8407 
   8408 void test_cil_gen_avrule_objectclassnull_neg(CuTest *tc) {
   8409 	char *line[] = {"(", "allow", "foo", "bar", ")", NULL};
   8410 
   8411 	struct cil_tree *test_tree;
   8412 	gen_test_tree(&test_tree, line);
   8413 
   8414 	struct cil_tree_node *test_ast_node;
   8415 	cil_tree_node_init(&test_ast_node);
   8416 
   8417 	struct cil_db *test_db;
   8418 	cil_db_init(&test_db);
   8419 
   8420 	test_ast_node->parent = test_db->ast->root;
   8421 	test_ast_node->line = 1;
   8422 
   8423 	struct cil_tree_node *test_current;
   8424 	test_current = test_tree->root->cl_head->cl_head;
   8425 
   8426 	int rc = cil_gen_avrule(test_current, test_ast_node, CIL_AVRULE_ALLOWED);
   8427 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   8428 }
   8429 
   8430 void test_cil_gen_avrule_permsnull_neg(CuTest *tc) {
   8431 	char *line[] = {"(", "allow", "foo", "bar", "(", "baz", ")", ")", NULL};
   8432 
   8433 	struct cil_tree *test_tree;
   8434 	gen_test_tree(&test_tree, line);
   8435 
   8436 	struct cil_tree_node *test_ast_node;
   8437 	cil_tree_node_init(&test_ast_node);
   8438 
   8439 	struct cil_db *test_db;
   8440 	cil_db_init(&test_db);
   8441 
   8442 	test_ast_node->parent = test_db->ast->root;
   8443 	test_ast_node->line = 1;
   8444 
   8445 	struct cil_tree_node *test_current;
   8446 	test_current = test_tree->root->cl_head->cl_head;
   8447 
   8448 	int rc = cil_gen_avrule(test_current, test_ast_node, CIL_AVRULE_ALLOWED);
   8449 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   8450 }
   8451 
   8452 void test_cil_gen_avrule_twolists_neg(CuTest *tc) {
   8453 	char *line[] = {"(", "allow", "test", "foo", "bar", "(", "write", ")", "(", "read", ")",  NULL};
   8454 
   8455 	struct cil_tree *test_tree;
   8456 	gen_test_tree(&test_tree, line);
   8457 
   8458 	struct cil_tree_node *test_ast_node;
   8459 	cil_tree_node_init(&test_ast_node);
   8460 
   8461 	struct cil_db *test_db;
   8462 	cil_db_init(&test_db);
   8463 
   8464 	test_ast_node->parent = test_db->ast->root;
   8465 	test_ast_node->line = 1;
   8466 
   8467 	struct cil_tree_node *test_current;
   8468 	test_current = test_tree->root->cl_head->cl_head;
   8469 
   8470 	int rc = cil_gen_avrule(test_current, test_ast_node, CIL_AVRULE_ALLOWED);
   8471 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   8472 }
   8473 
   8474 void test_cil_gen_type_rule_transition(CuTest *tc) {
   8475 	char *line[] = {"(", "typetransition", "foo", "bar", "file", "foobar", ")", NULL};
   8476 
   8477 	struct cil_tree *test_tree;
   8478 	gen_test_tree(&test_tree, line);
   8479 
   8480 	struct cil_tree_node *test_ast_node;
   8481 	cil_tree_node_init(&test_ast_node);
   8482 
   8483 	struct cil_db *test_db;
   8484 	cil_db_init(&test_db);
   8485 
   8486 	test_ast_node->parent = test_db->ast->root;
   8487 	test_ast_node->line = 1;
   8488 
   8489 	int rc = cil_gen_type_rule(test_tree->root->cl_head->cl_head, test_ast_node, CIL_TYPE_TRANSITION);
   8490 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   8491 	CuAssertStrEquals(tc, ((struct cil_type_rule*)test_ast_node->data)->src_str, test_tree->root->cl_head->cl_head->next->data);
   8492 	CuAssertStrEquals(tc, ((struct cil_type_rule*)test_ast_node->data)->tgt_str, test_tree->root->cl_head->cl_head->next->next->data);
   8493 	CuAssertStrEquals(tc, ((struct cil_type_rule*)test_ast_node->data)->obj_str, test_tree->root->cl_head->cl_head->next->next->next->data);
   8494 	CuAssertStrEquals(tc, ((struct cil_type_rule*)test_ast_node->data)->result_str, test_tree->root->cl_head->cl_head->next->next->next->next->data);
   8495 	CuAssertIntEquals(tc, ((struct cil_type_rule*)test_ast_node->data)->rule_kind, CIL_TYPE_TRANSITION);
   8496 	CuAssertIntEquals(tc, test_ast_node->flavor, CIL_TYPE_RULE);
   8497 }
   8498 
   8499 void test_cil_gen_type_rule_transition_currnull_neg(CuTest *tc) {
   8500 	struct cil_tree_node *test_ast_node;
   8501 	cil_tree_node_init(&test_ast_node);
   8502 
   8503 	int rc = cil_gen_type_rule(NULL, test_ast_node, CIL_TYPE_TRANSITION);
   8504 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   8505 }
   8506 
   8507 void test_cil_gen_type_rule_transition_astnull_neg(CuTest *tc) {
   8508 	char *line[] = {"(", "typetransition", "foo", "bar", "file", "foobar", ")", NULL};
   8509 
   8510 	struct cil_tree *test_tree;
   8511 	gen_test_tree(&test_tree, line);
   8512 
   8513 	struct cil_tree_node *test_ast_node = NULL;
   8514 
   8515 	int rc = cil_gen_type_rule(test_tree->root->cl_head->cl_head, test_ast_node, CIL_TYPE_TRANSITION);
   8516 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   8517 }
   8518 
   8519 void test_cil_gen_type_rule_transition_srcnull_neg(CuTest *tc) {
   8520 	char *line[] = {"(", "typetransition", "foo", "bar", "file", "foobar", ")", NULL};
   8521 
   8522 	struct cil_tree *test_tree;
   8523 	gen_test_tree(&test_tree, line);
   8524 
   8525 	struct cil_tree_node *test_ast_node;
   8526 	cil_tree_node_init(&test_ast_node);
   8527 
   8528 	struct cil_db *test_db;
   8529 	cil_db_init(&test_db);
   8530 
   8531 	test_ast_node->parent = test_db->ast->root;
   8532 	test_ast_node->line = 1;
   8533 
   8534 	test_tree->root->cl_head->cl_head->next = NULL;
   8535 
   8536 	int rc = cil_gen_type_rule(test_tree->root->cl_head->cl_head, test_ast_node, CIL_TYPE_TRANSITION);
   8537 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   8538 }
   8539 
   8540 void test_cil_gen_type_rule_transition_tgtnull_neg(CuTest *tc) {
   8541 	char *line[] = {"(", "typetransition", "foo", "bar", "file", "foobar", ")", NULL};
   8542 
   8543 	struct cil_tree *test_tree;
   8544 	gen_test_tree(&test_tree, line);
   8545 
   8546 	struct cil_tree_node *test_ast_node;
   8547 	cil_tree_node_init(&test_ast_node);
   8548 
   8549 	struct cil_db *test_db;
   8550 	cil_db_init(&test_db);
   8551 
   8552 	test_ast_node->parent = test_db->ast->root;
   8553 	test_ast_node->line = 1;
   8554 
   8555 	test_tree->root->cl_head->cl_head->next->next = NULL;
   8556 
   8557 	int rc = cil_gen_type_rule(test_tree->root->cl_head->cl_head, test_ast_node, CIL_TYPE_TRANSITION);
   8558 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   8559 }
   8560 
   8561 void test_cil_gen_type_rule_transition_objnull_neg(CuTest *tc) {
   8562 	char *line[] = {"(", "typetransition", "foo", "bar", "file", "foobar", ")", NULL};
   8563 
   8564 	struct cil_tree *test_tree;
   8565 	gen_test_tree(&test_tree, line);
   8566 
   8567 	struct cil_tree_node *test_ast_node;
   8568 	cil_tree_node_init(&test_ast_node);
   8569 
   8570 	struct cil_db *test_db;
   8571 	cil_db_init(&test_db);
   8572 
   8573 	test_ast_node->parent = test_db->ast->root;
   8574 	test_ast_node->line = 1;
   8575 
   8576 	test_tree->root->cl_head->cl_head->next->next->next = NULL;
   8577 
   8578 	int rc = cil_gen_type_rule(test_tree->root->cl_head->cl_head, test_ast_node, CIL_TYPE_TRANSITION);
   8579 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   8580 }
   8581 
   8582 void test_cil_gen_type_rule_transition_resultnull_neg(CuTest *tc) {
   8583 	char *line[] = {"(", "typetransition", "foo", "bar", "file", "foobar", ")", NULL};
   8584 
   8585 	struct cil_tree *test_tree;
   8586 	gen_test_tree(&test_tree, line);
   8587 
   8588 	struct cil_tree_node *test_ast_node;
   8589 	cil_tree_node_init(&test_ast_node);
   8590 
   8591 	struct cil_db *test_db;
   8592 	cil_db_init(&test_db);
   8593 
   8594 	test_ast_node->parent = test_db->ast->root;
   8595 	test_ast_node->line = 1;
   8596 
   8597 	test_tree->root->cl_head->cl_head->next->next->next->next = NULL;
   8598 
   8599 	int rc = cil_gen_type_rule(test_tree->root->cl_head->cl_head, test_ast_node, CIL_TYPE_TRANSITION);
   8600 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   8601 }
   8602 
   8603 void test_cil_gen_type_rule_transition_extra_neg(CuTest *tc) {
   8604 	char *line[] = {"(", "typetransition", "foo", "bar", "file", "foobar", "extra", ")", NULL};
   8605 
   8606 	struct cil_tree *test_tree;
   8607 	gen_test_tree(&test_tree, line);
   8608 
   8609 	struct cil_tree_node *test_ast_node;
   8610 	cil_tree_node_init(&test_ast_node);
   8611 
   8612 	struct cil_db *test_db;
   8613 	cil_db_init(&test_db);
   8614 
   8615 	test_ast_node->parent = test_db->ast->root;
   8616 	test_ast_node->line = 1;
   8617 
   8618 	int rc = cil_gen_type_rule(test_tree->root->cl_head->cl_head, test_ast_node, CIL_TYPE_TRANSITION);
   8619 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   8620 }
   8621 
   8622 void test_cil_gen_type_rule_change(CuTest *tc) {
   8623 	char *line[] = {"(", "typechange", "foo", "bar", "file", "foobar", ")", NULL};
   8624 
   8625 	struct cil_tree *test_tree;
   8626 	gen_test_tree(&test_tree, line);
   8627 
   8628 	struct cil_tree_node *test_ast_node;
   8629 	cil_tree_node_init(&test_ast_node);
   8630 
   8631 	struct cil_db *test_db;
   8632 	cil_db_init(&test_db);
   8633 
   8634 	test_ast_node->parent = test_db->ast->root;
   8635 	test_ast_node->line = 1;
   8636 
   8637 	int rc = cil_gen_type_rule(test_tree->root->cl_head->cl_head, test_ast_node, CIL_TYPE_CHANGE);
   8638 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   8639 	CuAssertStrEquals(tc, ((struct cil_type_rule*)test_ast_node->data)->src_str, test_tree->root->cl_head->cl_head->next->data);
   8640 	CuAssertStrEquals(tc, ((struct cil_type_rule*)test_ast_node->data)->tgt_str, test_tree->root->cl_head->cl_head->next->next->data);
   8641 	CuAssertStrEquals(tc, ((struct cil_type_rule*)test_ast_node->data)->obj_str, test_tree->root->cl_head->cl_head->next->next->next->data);
   8642 	CuAssertStrEquals(tc, ((struct cil_type_rule*)test_ast_node->data)->result_str, test_tree->root->cl_head->cl_head->next->next->next->next->data);
   8643 	CuAssertIntEquals(tc, ((struct cil_type_rule*)test_ast_node->data)->rule_kind, CIL_TYPE_CHANGE);
   8644 	CuAssertIntEquals(tc, test_ast_node->flavor, CIL_TYPE_RULE);
   8645 }
   8646 
   8647 void test_cil_gen_type_rule_change_currnull_neg(CuTest *tc) {
   8648 	struct cil_tree_node *test_ast_node;
   8649 	cil_tree_node_init(&test_ast_node);
   8650 
   8651 	int rc = cil_gen_type_rule(NULL, test_ast_node, CIL_TYPE_CHANGE);
   8652 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   8653 }
   8654 
   8655 void test_cil_gen_type_rule_change_astnull_neg(CuTest *tc) {
   8656 	char *line[] = {"(", "typechange", "foo", "bar", "file", "foobar", ")", NULL};
   8657 
   8658 	struct cil_tree *test_tree;
   8659 	gen_test_tree(&test_tree, line);
   8660 
   8661 	struct cil_tree_node *test_ast_node = NULL;
   8662 
   8663 	int rc = cil_gen_type_rule(test_tree->root->cl_head->cl_head, test_ast_node, CIL_TYPE_CHANGE);
   8664 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   8665 }
   8666 
   8667 void test_cil_gen_type_rule_change_srcnull_neg(CuTest *tc) {
   8668 	char *line[] = {"(", "typechange", "foo", "bar", "file", "foobar", ")", NULL};
   8669 
   8670 	struct cil_tree *test_tree;
   8671 	gen_test_tree(&test_tree, line);
   8672 
   8673 	struct cil_tree_node *test_ast_node;
   8674 	cil_tree_node_init(&test_ast_node);
   8675 
   8676 	struct cil_db *test_db;
   8677 	cil_db_init(&test_db);
   8678 
   8679 	test_ast_node->parent = test_db->ast->root;
   8680 	test_ast_node->line = 1;
   8681 
   8682 	test_tree->root->cl_head->cl_head->next = NULL;
   8683 
   8684 	int rc = cil_gen_type_rule(test_tree->root->cl_head->cl_head, test_ast_node, CIL_TYPE_CHANGE);
   8685 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   8686 }
   8687 
   8688 void test_cil_gen_type_rule_change_tgtnull_neg(CuTest *tc) {
   8689 	char *line[] = {"(", "typechange", "foo", "bar", "file", "foobar", ")", NULL};
   8690 
   8691 	struct cil_tree *test_tree;
   8692 	gen_test_tree(&test_tree, line);
   8693 
   8694 	struct cil_tree_node *test_ast_node;
   8695 	cil_tree_node_init(&test_ast_node);
   8696 
   8697 	struct cil_db *test_db;
   8698 	cil_db_init(&test_db);
   8699 
   8700 	test_ast_node->parent = test_db->ast->root;
   8701 	test_ast_node->line = 1;
   8702 
   8703 	test_tree->root->cl_head->cl_head->next->next = NULL;
   8704 
   8705 	int rc = cil_gen_type_rule(test_tree->root->cl_head->cl_head, test_ast_node, CIL_TYPE_CHANGE);
   8706 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   8707 }
   8708 
   8709 void test_cil_gen_type_rule_change_objnull_neg(CuTest *tc) {
   8710 	char *line[] = {"(", "typechange", "foo", "bar", "file", "foobar", ")", NULL};
   8711 
   8712 	struct cil_tree *test_tree;
   8713 	gen_test_tree(&test_tree, line);
   8714 
   8715 	struct cil_tree_node *test_ast_node;
   8716 	cil_tree_node_init(&test_ast_node);
   8717 
   8718 	struct cil_db *test_db;
   8719 	cil_db_init(&test_db);
   8720 
   8721 	test_ast_node->parent = test_db->ast->root;
   8722 	test_ast_node->line = 1;
   8723 
   8724 	test_tree->root->cl_head->cl_head->next->next->next = NULL;
   8725 
   8726 	int rc = cil_gen_type_rule(test_tree->root->cl_head->cl_head, test_ast_node, CIL_TYPE_CHANGE);
   8727 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   8728 }
   8729 
   8730 void test_cil_gen_type_rule_change_resultnull_neg(CuTest *tc) {
   8731 	char *line[] = {"(", "typechange", "foo", "bar", "file", "foobar", ")", NULL};
   8732 
   8733 	struct cil_tree *test_tree;
   8734 	gen_test_tree(&test_tree, line);
   8735 
   8736 	struct cil_tree_node *test_ast_node;
   8737 	cil_tree_node_init(&test_ast_node);
   8738 
   8739 	struct cil_db *test_db;
   8740 	cil_db_init(&test_db);
   8741 
   8742 	test_ast_node->parent = test_db->ast->root;
   8743 	test_ast_node->line = 1;
   8744 
   8745 	test_tree->root->cl_head->cl_head->next->next->next->next = NULL;
   8746 
   8747 	int rc = cil_gen_type_rule(test_tree->root->cl_head->cl_head, test_ast_node, CIL_TYPE_CHANGE);
   8748 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   8749 }
   8750 
   8751 void test_cil_gen_type_rule_change_extra_neg(CuTest *tc) {
   8752 	char *line[] = {"(", "typechange", "foo", "bar", "file", "foobar", "extra", ")", NULL};
   8753 
   8754 	struct cil_tree *test_tree;
   8755 	gen_test_tree(&test_tree, line);
   8756 
   8757 	struct cil_tree_node *test_ast_node;
   8758 	cil_tree_node_init(&test_ast_node);
   8759 
   8760 	struct cil_db *test_db;
   8761 	cil_db_init(&test_db);
   8762 
   8763 	test_ast_node->parent = test_db->ast->root;
   8764 	test_ast_node->line = 1;
   8765 
   8766 	int rc = cil_gen_type_rule(test_tree->root->cl_head->cl_head, test_ast_node, CIL_TYPE_CHANGE);
   8767 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   8768 }
   8769 
   8770 void test_cil_gen_type_rule_member(CuTest *tc) {
   8771 	char *line[] = {"(", "typemember", "foo", "bar", "file", "foobar", ")", NULL};
   8772 
   8773 	struct cil_tree *test_tree;
   8774 	gen_test_tree(&test_tree, line);
   8775 
   8776 	struct cil_tree_node *test_ast_node;
   8777 	cil_tree_node_init(&test_ast_node);
   8778 
   8779 	struct cil_db *test_db;
   8780 	cil_db_init(&test_db);
   8781 
   8782 	test_ast_node->parent = test_db->ast->root;
   8783 	test_ast_node->line = 1;
   8784 
   8785 	int rc = cil_gen_type_rule(test_tree->root->cl_head->cl_head, test_ast_node, CIL_TYPE_MEMBER);
   8786 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   8787 	CuAssertStrEquals(tc, ((struct cil_type_rule*)test_ast_node->data)->src_str, test_tree->root->cl_head->cl_head->next->data);
   8788 	CuAssertStrEquals(tc, ((struct cil_type_rule*)test_ast_node->data)->tgt_str, test_tree->root->cl_head->cl_head->next->next->data);
   8789 	CuAssertStrEquals(tc, ((struct cil_type_rule*)test_ast_node->data)->obj_str, test_tree->root->cl_head->cl_head->next->next->next->data);
   8790 	CuAssertStrEquals(tc, ((struct cil_type_rule*)test_ast_node->data)->result_str, test_tree->root->cl_head->cl_head->next->next->next->next->data);
   8791 	CuAssertIntEquals(tc, ((struct cil_type_rule*)test_ast_node->data)->rule_kind, CIL_TYPE_MEMBER);
   8792 	CuAssertIntEquals(tc, test_ast_node->flavor, CIL_TYPE_RULE);
   8793 }
   8794 
   8795 void test_cil_gen_type_rule_member_currnull_neg(CuTest *tc) {
   8796 	struct cil_tree_node *test_ast_node;
   8797 	cil_tree_node_init(&test_ast_node);
   8798 
   8799 	int rc = cil_gen_type_rule(NULL, test_ast_node, CIL_TYPE_MEMBER);
   8800 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   8801 }
   8802 
   8803 void test_cil_gen_type_rule_member_astnull_neg(CuTest *tc) {
   8804 	char *line[] = {"(", "typemember", "foo", "bar", "file", "foobar", ")", NULL};
   8805 
   8806 	struct cil_tree *test_tree;
   8807 	gen_test_tree(&test_tree, line);
   8808 
   8809 	struct cil_tree_node *test_ast_node = NULL;
   8810 
   8811 	int rc = cil_gen_type_rule(test_tree->root->cl_head->cl_head, test_ast_node, CIL_TYPE_MEMBER);
   8812 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   8813 }
   8814 
   8815 void test_cil_gen_type_rule_member_srcnull_neg(CuTest *tc) {
   8816 	char *line[] = {"(", "typemember", "foo", "bar", "file", "foobar", ")", NULL};
   8817 
   8818 	struct cil_tree *test_tree;
   8819 	gen_test_tree(&test_tree, line);
   8820 
   8821 	struct cil_tree_node *test_ast_node;
   8822 	cil_tree_node_init(&test_ast_node);
   8823 
   8824 	struct cil_db *test_db;
   8825 	cil_db_init(&test_db);
   8826 
   8827 	test_ast_node->parent = test_db->ast->root;
   8828 	test_ast_node->line = 1;
   8829 
   8830 	test_tree->root->cl_head->cl_head->next = NULL;
   8831 
   8832 	int rc = cil_gen_type_rule(test_tree->root->cl_head->cl_head, test_ast_node, CIL_TYPE_MEMBER);
   8833 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   8834 }
   8835 
   8836 void test_cil_gen_type_rule_member_tgtnull_neg(CuTest *tc) {
   8837 	char *line[] = {"(", "typemember", "foo", "bar", "file", "foobar", ")", NULL};
   8838 
   8839 	struct cil_tree *test_tree;
   8840 	gen_test_tree(&test_tree, line);
   8841 
   8842 	struct cil_tree_node *test_ast_node;
   8843 	cil_tree_node_init(&test_ast_node);
   8844 
   8845 	struct cil_db *test_db;
   8846 	cil_db_init(&test_db);
   8847 
   8848 	test_ast_node->parent = test_db->ast->root;
   8849 	test_ast_node->line = 1;
   8850 
   8851 	test_tree->root->cl_head->cl_head->next->next = NULL;
   8852 
   8853 	int rc = cil_gen_type_rule(test_tree->root->cl_head->cl_head, test_ast_node, CIL_TYPE_MEMBER);
   8854 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   8855 }
   8856 
   8857 void test_cil_gen_type_rule_member_objnull_neg(CuTest *tc) {
   8858 	char *line[] = {"(", "typemember", "foo", "bar", "file", "foobar", ")", NULL};
   8859 
   8860 	struct cil_tree *test_tree;
   8861 	gen_test_tree(&test_tree, line);
   8862 
   8863 	struct cil_tree_node *test_ast_node;
   8864 	cil_tree_node_init(&test_ast_node);
   8865 
   8866 	struct cil_db *test_db;
   8867 	cil_db_init(&test_db);
   8868 
   8869 	test_ast_node->parent = test_db->ast->root;
   8870 	test_ast_node->line = 1;
   8871 
   8872 	test_tree->root->cl_head->cl_head->next->next->next = NULL;
   8873 
   8874 	int rc = cil_gen_type_rule(test_tree->root->cl_head->cl_head, test_ast_node, CIL_TYPE_MEMBER);
   8875 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   8876 }
   8877 
   8878 void test_cil_gen_type_rule_member_resultnull_neg(CuTest *tc) {
   8879 	char *line[] = {"(", "typemember", "foo", "bar", "file", "foobar", ")", NULL};
   8880 
   8881 	struct cil_tree *test_tree;
   8882 	gen_test_tree(&test_tree, line);
   8883 
   8884 	struct cil_tree_node *test_ast_node;
   8885 	cil_tree_node_init(&test_ast_node);
   8886 
   8887 	struct cil_db *test_db;
   8888 	cil_db_init(&test_db);
   8889 
   8890 	test_ast_node->parent = test_db->ast->root;
   8891 	test_ast_node->line = 1;
   8892 
   8893 	test_tree->root->cl_head->cl_head->next->next->next->next = NULL;
   8894 
   8895 	int rc = cil_gen_type_rule(test_tree->root->cl_head->cl_head, test_ast_node, CIL_TYPE_MEMBER);
   8896 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   8897 }
   8898 
   8899 void test_cil_gen_type_rule_member_extra_neg(CuTest *tc) {
   8900 	char *line[] = {"(", "typemember", "foo", "bar", "file", "foobar", "extra", ")", NULL};
   8901 
   8902 	struct cil_tree *test_tree;
   8903 	gen_test_tree(&test_tree, line);
   8904 
   8905 	struct cil_tree_node *test_ast_node;
   8906 	cil_tree_node_init(&test_ast_node);
   8907 
   8908 	struct cil_db *test_db;
   8909 	cil_db_init(&test_db);
   8910 
   8911 	test_ast_node->parent = test_db->ast->root;
   8912 	test_ast_node->line = 1;
   8913 
   8914 	int rc = cil_gen_type_rule(test_tree->root->cl_head->cl_head, test_ast_node, CIL_TYPE_MEMBER);
   8915 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   8916 }
   8917 
   8918 void test_cil_gen_user(CuTest *tc) {
   8919 	char *line[] = {"(", "user", "sysadm", ")", NULL};
   8920 
   8921 	struct cil_tree *test_tree;
   8922 	gen_test_tree(&test_tree, line);
   8923 
   8924 	struct cil_tree_node *test_ast_node;
   8925 	cil_tree_node_init(&test_ast_node);
   8926 
   8927 	struct cil_db *test_db;
   8928 	cil_db_init(&test_db);
   8929 
   8930 	test_ast_node->parent = test_db->ast->root;
   8931 	test_ast_node->line = 1;
   8932 
   8933 	int rc = cil_gen_user(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   8934 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   8935 	CuAssertIntEquals(tc, CIL_USER, test_ast_node->flavor);
   8936 	CuAssertPtrNotNull(tc, test_ast_node->data);
   8937 	CuAssertPtrEquals(tc, test_ast_node, ((struct cil_symtab_datum*)test_ast_node->data)->node);
   8938 	CuAssertStrEquals(tc, test_tree->root->cl_head->cl_head->next->data, ((struct cil_symtab_datum*)test_ast_node->data)->name);
   8939 }
   8940 
   8941 void test_cil_gen_user_dbnull_neg(CuTest *tc) {
   8942 	char *line[] = {"(", "user", ")", NULL};
   8943 
   8944 	struct cil_tree *test_tree;
   8945 	gen_test_tree(&test_tree, line);
   8946 
   8947 	struct cil_tree_node *test_ast_node;
   8948 	cil_tree_node_init(&test_ast_node);
   8949 
   8950 	struct cil_db *test_db = NULL;
   8951 
   8952 	int rc = cil_gen_user(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   8953 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   8954 }
   8955 
   8956 void test_cil_gen_user_currnull_neg(CuTest *tc) {
   8957 	char *line[] = {"(", ")", NULL};
   8958 
   8959 	struct cil_tree *test_tree;
   8960 	gen_test_tree(&test_tree, line);
   8961 
   8962 	struct cil_tree_node *test_ast_node;
   8963 	cil_tree_node_init(&test_ast_node);
   8964 
   8965 	struct cil_db *test_db;
   8966 	cil_db_init(&test_db);
   8967 
   8968 	test_ast_node->parent = test_db->ast->root;
   8969 	test_ast_node->line = 1;
   8970 
   8971 	int rc = cil_gen_user(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   8972 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   8973 }
   8974 
   8975 void test_cil_gen_user_astnull_neg(CuTest *tc) {
   8976 	char *line[] = {"(", "user", ")", NULL};
   8977 
   8978 	struct cil_tree *test_tree;
   8979 	gen_test_tree(&test_tree, line);
   8980 
   8981 	struct cil_tree_node *test_ast_node = NULL;
   8982 
   8983 	struct cil_db *test_db;
   8984 	cil_db_init(&test_db);
   8985 
   8986 	int rc = cil_gen_user(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   8987 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   8988 }
   8989 
   8990 void test_cil_gen_user_nouser_neg(CuTest *tc) {
   8991 	char *line[] = {"(", "user", ")", NULL};
   8992 
   8993 	struct cil_tree *test_tree;
   8994 	gen_test_tree(&test_tree, line);
   8995 
   8996 	struct cil_tree_node *test_ast_node;
   8997 	cil_tree_node_init(&test_ast_node);
   8998 
   8999 	struct cil_db *test_db;
   9000 	cil_db_init(&test_db);
   9001 
   9002 	test_ast_node->parent = test_db->ast->root;
   9003 	test_ast_node->line = 1;
   9004 
   9005 	int rc = cil_gen_user(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   9006 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   9007 }
   9008 
   9009 void test_cil_gen_user_xsinfo_neg(CuTest *tc) {
   9010 	char *line[] = {"(", "user", "sysadm", "xsinfo", ")", NULL};
   9011 
   9012 	struct cil_tree *test_tree;
   9013 	gen_test_tree(&test_tree, line);
   9014 
   9015 	struct cil_tree_node *test_ast_node;
   9016 	cil_tree_node_init(&test_ast_node);
   9017 
   9018 	struct cil_db *test_db;
   9019 	cil_db_init(&test_db);
   9020 
   9021 	test_ast_node->parent = test_db->ast->root;
   9022 	test_ast_node->line = 1;
   9023 
   9024 	int rc = cil_gen_user(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   9025 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   9026 }
   9027 
   9028 void test_cil_gen_userlevel(CuTest *tc) {
   9029 	char *line[] = {"(", "userlevel", "user_u", "lvl_l", ")", NULL};
   9030 
   9031 	struct cil_tree *test_tree;
   9032 	gen_test_tree(&test_tree, line);
   9033 
   9034 	struct cil_tree_node *test_ast_node;
   9035 	cil_tree_node_init(&test_ast_node);
   9036 
   9037 	struct cil_db *test_db;
   9038 	cil_db_init(&test_db);
   9039 
   9040 	test_ast_node->parent = test_db->ast->root;
   9041 	test_ast_node->line = 1;
   9042 
   9043 	int rc = cil_gen_userlevel(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   9044 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   9045 }
   9046 
   9047 void test_cil_gen_userlevel_anon_level(CuTest *tc) {
   9048 	char *line[] = {"(", "userlevel", "user_u", "(", "s0", "(", "c0", ")", ")", ")", NULL};
   9049 
   9050 	struct cil_tree *test_tree;
   9051 	gen_test_tree(&test_tree, line);
   9052 
   9053 	struct cil_tree_node *test_ast_node;
   9054 	cil_tree_node_init(&test_ast_node);
   9055 
   9056 	struct cil_db *test_db;
   9057 	cil_db_init(&test_db);
   9058 
   9059 	test_ast_node->parent = test_db->ast->root;
   9060 	test_ast_node->line = 1;
   9061 
   9062 	int rc = cil_gen_userlevel(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   9063 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   9064 }
   9065 
   9066 void test_cil_gen_userlevel_anon_level_neg(CuTest *tc) {
   9067 	char *line[] = {"(", "userlevel", "user_u", "(", "s0", "(", ")", ")", ")", NULL};
   9068 
   9069 	struct cil_tree *test_tree;
   9070 	gen_test_tree(&test_tree, line);
   9071 
   9072 	struct cil_tree_node *test_ast_node;
   9073 	cil_tree_node_init(&test_ast_node);
   9074 
   9075 	struct cil_db *test_db;
   9076 	cil_db_init(&test_db);
   9077 
   9078 	test_ast_node->parent = test_db->ast->root;
   9079 	test_ast_node->line = 1;
   9080 
   9081 	int rc = cil_gen_userlevel(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   9082 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   9083 }
   9084 
   9085 void test_cil_gen_userlevel_usernull_neg(CuTest *tc) {
   9086 	char *line[] = {"(", "userlevel", ")", NULL};
   9087 
   9088 	struct cil_tree *test_tree;
   9089 	gen_test_tree(&test_tree, line);
   9090 
   9091 	struct cil_tree_node *test_ast_node;
   9092 	cil_tree_node_init(&test_ast_node);
   9093 
   9094 	struct cil_db *test_db;
   9095 	cil_db_init(&test_db);
   9096 
   9097 	test_ast_node->parent = test_db->ast->root;
   9098 	test_ast_node->line = 1;
   9099 
   9100 	int rc = cil_gen_userlevel(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   9101 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   9102 }
   9103 
   9104 void test_cil_gen_userlevel_userrange_neg(CuTest *tc) {
   9105 	char *line[] = {"(", "userlevel", "(", "user", ")", "level", ")", NULL};
   9106 
   9107 	struct cil_tree *test_tree;
   9108 	gen_test_tree(&test_tree, line);
   9109 
   9110 	struct cil_tree_node *test_ast_node;
   9111 	cil_tree_node_init(&test_ast_node);
   9112 
   9113 	struct cil_db *test_db;
   9114 	cil_db_init(&test_db);
   9115 
   9116 	test_ast_node->parent = test_db->ast->root;
   9117 	test_ast_node->line = 1;
   9118 
   9119 	int rc = cil_gen_userlevel(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   9120 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   9121 }
   9122 
   9123 void test_cil_gen_userlevel_levelnull_neg(CuTest *tc) {
   9124 	char *line[] = {"(", "userlevel", "user_u", ")", NULL};
   9125 
   9126 	struct cil_tree *test_tree;
   9127 	gen_test_tree(&test_tree, line);
   9128 
   9129 	struct cil_tree_node *test_ast_node;
   9130 	cil_tree_node_init(&test_ast_node);
   9131 
   9132 	struct cil_db *test_db;
   9133 	cil_db_init(&test_db);
   9134 
   9135 	test_ast_node->parent = test_db->ast->root;
   9136 	test_ast_node->line = 1;
   9137 
   9138 	int rc = cil_gen_userlevel(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   9139 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   9140 }
   9141 
   9142 void test_cil_gen_userlevel_levelrangeempty_neg(CuTest *tc) {
   9143 	char *line[] = {"(", "userlevel", "user_u", "(", ")", ")", NULL};
   9144 
   9145 	struct cil_tree *test_tree;
   9146 	gen_test_tree(&test_tree, line);
   9147 
   9148 	struct cil_tree_node *test_ast_node;
   9149 	cil_tree_node_init(&test_ast_node);
   9150 
   9151 	struct cil_db *test_db;
   9152 	cil_db_init(&test_db);
   9153 
   9154 	test_ast_node->parent = test_db->ast->root;
   9155 	test_ast_node->line = 1;
   9156 
   9157 	int rc = cil_gen_userlevel(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   9158 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   9159 }
   9160 
   9161 void test_cil_gen_userlevel_extra_neg(CuTest *tc) {
   9162 	char *line[] = {"(", "userlevel", "user_u", "level", "extra", ")", NULL};
   9163 
   9164 	struct cil_tree *test_tree;
   9165 	gen_test_tree(&test_tree, line);
   9166 
   9167 	struct cil_tree_node *test_ast_node;
   9168 	cil_tree_node_init(&test_ast_node);
   9169 
   9170 	struct cil_db *test_db;
   9171 	cil_db_init(&test_db);
   9172 
   9173 	test_ast_node->parent = test_db->ast->root;
   9174 	test_ast_node->line = 1;
   9175 
   9176 	int rc = cil_gen_userlevel(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   9177 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   9178 }
   9179 
   9180 void test_cil_gen_userlevel_dbnull_neg(CuTest *tc) {
   9181 	char *line[] = {"(", "userlevel", "user", "level", ")", NULL};
   9182 
   9183 	struct cil_tree *test_tree;
   9184 	gen_test_tree(&test_tree, line);
   9185 
   9186 	struct cil_tree_node *test_ast_node;
   9187 	cil_tree_node_init(&test_ast_node);
   9188 
   9189 	struct cil_db *test_db = NULL;
   9190 
   9191 	int rc = cil_gen_userlevel(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   9192 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   9193 }
   9194 
   9195 void test_cil_gen_userlevel_currnull_neg(CuTest *tc) {
   9196 	char *line[] = {"(", ")", NULL};
   9197 
   9198 	struct cil_tree *test_tree;
   9199 	gen_test_tree(&test_tree, line);
   9200 
   9201 	struct cil_tree_node *test_ast_node;
   9202 	cil_tree_node_init(&test_ast_node);
   9203 
   9204 	struct cil_db *test_db;
   9205 	cil_db_init(&test_db);
   9206 
   9207 	test_ast_node->parent = test_db->ast->root;
   9208 	test_ast_node->line = 1;
   9209 
   9210 	int rc = cil_gen_userlevel(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   9211 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   9212 }
   9213 
   9214 void test_cil_gen_userlevel_astnull_neg(CuTest *tc) {
   9215 	char *line[] = {"(", "userlevel", "user", "level", ")", NULL};
   9216 
   9217 	struct cil_tree *test_tree;
   9218 	gen_test_tree(&test_tree, line);
   9219 
   9220 	struct cil_tree_node *test_ast_node = NULL;
   9221 
   9222 	struct cil_db *test_db;
   9223 	cil_db_init(&test_db);
   9224 
   9225 	int rc = cil_gen_userlevel(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   9226 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   9227 }
   9228 
   9229 void test_cil_gen_userrange_named(CuTest *tc) {
   9230 	char *line[] = {"(", "userrange", "user_u", "range", ")", NULL};
   9231 
   9232 	struct cil_tree *test_tree;
   9233 	gen_test_tree(&test_tree, line);
   9234 
   9235 	struct cil_tree_node *test_ast_node;
   9236 	cil_tree_node_init(&test_ast_node);
   9237 
   9238 	struct cil_db *test_db;
   9239 	cil_db_init(&test_db);
   9240 
   9241 	test_ast_node->parent = test_db->ast->root;
   9242 	test_ast_node->line = 1;
   9243 
   9244 	int rc = cil_gen_userrange(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   9245 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   9246 }
   9247 
   9248 void test_cil_gen_userrange_anon(CuTest *tc) {
   9249 	char *line[] = {"(", "userrange", "user_u", "(", "low", "high", ")", ")", NULL};
   9250 
   9251 	struct cil_tree *test_tree;
   9252 	gen_test_tree(&test_tree, line);
   9253 
   9254 	struct cil_tree_node *test_ast_node;
   9255 	cil_tree_node_init(&test_ast_node);
   9256 
   9257 	struct cil_db *test_db;
   9258 	cil_db_init(&test_db);
   9259 
   9260 	test_ast_node->parent = test_db->ast->root;
   9261 	test_ast_node->line = 1;
   9262 
   9263 	int rc = cil_gen_userrange(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   9264 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   9265 }
   9266 
   9267 void test_cil_gen_userrange_usernull_neg(CuTest *tc) {
   9268 	char *line[] = {"(", "userrange", ")", NULL};
   9269 
   9270 	struct cil_tree *test_tree;
   9271 	gen_test_tree(&test_tree, line);
   9272 
   9273 	struct cil_tree_node *test_ast_node;
   9274 	cil_tree_node_init(&test_ast_node);
   9275 
   9276 	struct cil_db *test_db;
   9277 	cil_db_init(&test_db);
   9278 
   9279 	test_ast_node->parent = test_db->ast->root;
   9280 	test_ast_node->line = 1;
   9281 
   9282 	int rc = cil_gen_userrange(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   9283 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   9284 }
   9285 
   9286 void test_cil_gen_userrange_anonuser_neg(CuTest *tc) {
   9287 	char *line[] = {"(", "userrange", "(", "user_u", ")", "(", "low", "high", ")", ")", NULL};
   9288 
   9289 	struct cil_tree *test_tree;
   9290 	gen_test_tree(&test_tree, line);
   9291 
   9292 	struct cil_tree_node *test_ast_node;
   9293 	cil_tree_node_init(&test_ast_node);
   9294 
   9295 	struct cil_db *test_db;
   9296 	cil_db_init(&test_db);
   9297 
   9298 	test_ast_node->parent = test_db->ast->root;
   9299 	test_ast_node->line = 1;
   9300 
   9301 	int rc = cil_gen_userrange(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   9302 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   9303 }
   9304 
   9305 void test_cil_gen_userrange_rangenamenull_neg(CuTest *tc) {
   9306 	char *line[] = {"(", "userrange", "user_u", ")", NULL};
   9307 
   9308 	struct cil_tree *test_tree;
   9309 	gen_test_tree(&test_tree, line);
   9310 
   9311 	struct cil_tree_node *test_ast_node;
   9312 	cil_tree_node_init(&test_ast_node);
   9313 
   9314 	struct cil_db *test_db;
   9315 	cil_db_init(&test_db);
   9316 
   9317 	test_ast_node->parent = test_db->ast->root;
   9318 	test_ast_node->line = 1;
   9319 
   9320 	int rc = cil_gen_userrange(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   9321 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   9322 }
   9323 
   9324 void test_cil_gen_userrange_anonrangeinvalid_neg(CuTest *tc) {
   9325 	char *line[] = {"(", "userrange", "user_u", "(", "low", ")", ")", NULL};
   9326 
   9327 	struct cil_tree *test_tree;
   9328 	gen_test_tree(&test_tree, line);
   9329 
   9330 	struct cil_tree_node *test_ast_node;
   9331 	cil_tree_node_init(&test_ast_node);
   9332 
   9333 	struct cil_db *test_db;
   9334 	cil_db_init(&test_db);
   9335 
   9336 	test_ast_node->parent = test_db->ast->root;
   9337 	test_ast_node->line = 1;
   9338 
   9339 	int rc = cil_gen_userrange(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   9340 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   9341 }
   9342 
   9343 void test_cil_gen_userrange_anonrangeempty_neg(CuTest *tc) {
   9344 	char *line[] = {"(", "userrange", "user_u", "(", ")", ")", NULL};
   9345 
   9346 	struct cil_tree *test_tree;
   9347 	gen_test_tree(&test_tree, line);
   9348 
   9349 	struct cil_tree_node *test_ast_node;
   9350 	cil_tree_node_init(&test_ast_node);
   9351 
   9352 	struct cil_db *test_db;
   9353 	cil_db_init(&test_db);
   9354 
   9355 	test_ast_node->parent = test_db->ast->root;
   9356 	test_ast_node->line = 1;
   9357 
   9358 	int rc = cil_gen_userrange(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   9359 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   9360 }
   9361 
   9362 void test_cil_gen_userrange_extra_neg(CuTest *tc) {
   9363 	char *line[] = {"(", "userrange", "user_u", "(", "low", "high", ")", "extra", ")", NULL};
   9364 
   9365 	struct cil_tree *test_tree;
   9366 	gen_test_tree(&test_tree, line);
   9367 
   9368 	struct cil_tree_node *test_ast_node;
   9369 	cil_tree_node_init(&test_ast_node);
   9370 
   9371 	struct cil_db *test_db;
   9372 	cil_db_init(&test_db);
   9373 
   9374 	test_ast_node->parent = test_db->ast->root;
   9375 	test_ast_node->line = 1;
   9376 
   9377 	int rc = cil_gen_userrange(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   9378 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   9379 }
   9380 
   9381 void test_cil_gen_userrange_dbnull_neg(CuTest *tc) {
   9382 	char *line[] = {"(", "userrange", "user", "range", ")", NULL};
   9383 
   9384 	struct cil_tree *test_tree;
   9385 	gen_test_tree(&test_tree, line);
   9386 
   9387 	struct cil_tree_node *test_ast_node;
   9388 	cil_tree_node_init(&test_ast_node);
   9389 
   9390 	struct cil_db *test_db = NULL;
   9391 
   9392 	int rc = cil_gen_userrange(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   9393 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   9394 }
   9395 
   9396 void test_cil_gen_userrange_currnull_neg(CuTest *tc) {
   9397 	char *line[] = {"(", ")", NULL};
   9398 
   9399 	struct cil_tree *test_tree;
   9400 	gen_test_tree(&test_tree, line);
   9401 
   9402 	struct cil_tree_node *test_ast_node;
   9403 	cil_tree_node_init(&test_ast_node);
   9404 
   9405 	struct cil_db *test_db;
   9406 	cil_db_init(&test_db);
   9407 
   9408 	test_ast_node->parent = test_db->ast->root;
   9409 	test_ast_node->line = 1;
   9410 
   9411 	int rc = cil_gen_userrange(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   9412 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   9413 }
   9414 
   9415 void test_cil_gen_userrange_astnull_neg(CuTest *tc) {
   9416 	char *line[] = {"(", "userrange", "user", "range", ")", NULL};
   9417 
   9418 	struct cil_tree *test_tree;
   9419 	gen_test_tree(&test_tree, line);
   9420 
   9421 	struct cil_tree_node *test_ast_node = NULL;
   9422 
   9423 	struct cil_db *test_db;
   9424 	cil_db_init(&test_db);
   9425 
   9426 	int rc = cil_gen_userrange(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   9427 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   9428 }
   9429 
   9430 void test_cil_gen_sensitivity(CuTest *tc) {
   9431 	char *line[] = {"(", "sensitivity", "s0", ")", NULL};
   9432 
   9433 	struct cil_tree *test_tree;
   9434 	gen_test_tree(&test_tree, line);
   9435 
   9436 	struct cil_tree_node *test_ast_node;
   9437 	cil_tree_node_init(&test_ast_node);
   9438 
   9439 	struct cil_db *test_db;
   9440 	cil_db_init(&test_db);
   9441 
   9442 	test_ast_node->parent = test_db->ast->root;
   9443 	test_ast_node->line = 1;
   9444 
   9445 	int rc = cil_gen_sensitivity(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   9446 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   9447 	CuAssertPtrNotNull(tc, test_ast_node->data);
   9448 	CuAssertIntEquals(tc, test_ast_node->flavor, CIL_SENS);
   9449 
   9450 }
   9451 
   9452 void test_cil_gen_sensitivity_dbnull_neg(CuTest *tc) {
   9453 	char *line[] = {"(", "sensitivity", "s0", ")", NULL};
   9454 
   9455 	struct cil_tree *test_tree;
   9456 	gen_test_tree(&test_tree, line);
   9457 
   9458 	struct cil_tree_node *test_ast_node;
   9459 	cil_tree_node_init(&test_ast_node);
   9460 
   9461 	struct cil_db *test_db = NULL;
   9462 
   9463 	int rc = cil_gen_sensitivity(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   9464 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   9465 }
   9466 
   9467 void test_cil_gen_sensitivity_currnull_neg(CuTest *tc) {
   9468 	struct cil_tree_node *test_ast_node;
   9469 	cil_tree_node_init(&test_ast_node);
   9470 
   9471 	struct cil_db *test_db;
   9472 	cil_db_init(&test_db);
   9473 
   9474 	int rc = cil_gen_sensitivity(test_db, NULL, test_ast_node);
   9475 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   9476 }
   9477 
   9478 void test_cil_gen_sensitivity_astnull_neg(CuTest *tc) {
   9479 	char *line[] = {"(", "sensitivity", "s0", ")", NULL};
   9480 
   9481 	struct cil_tree *test_tree;
   9482 	gen_test_tree(&test_tree, line);
   9483 
   9484 	struct cil_db *test_db;
   9485 	cil_db_init(&test_db);
   9486 
   9487 	struct cil_tree_node *test_ast_node = NULL;
   9488 
   9489 	int rc = cil_gen_sensitivity(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   9490 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   9491 }
   9492 
   9493 void test_cil_gen_sensitivity_sensnull_neg(CuTest *tc) {
   9494 	char *line[] = {"(", "sensitivity", "s0", ")", NULL};
   9495 
   9496 	struct cil_tree *test_tree;
   9497 	gen_test_tree(&test_tree, line);
   9498 
   9499 	test_tree->root->cl_head->cl_head->next = NULL;
   9500 
   9501 	struct cil_db *test_db;
   9502 	cil_db_init(&test_db);
   9503 
   9504 	struct cil_tree_node *test_ast_node;
   9505 	cil_tree_node_init(&test_ast_node);
   9506 
   9507 	int rc = cil_gen_sensitivity(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   9508 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   9509 }
   9510 
   9511 void test_cil_gen_sensitivity_senslist_neg(CuTest *tc) {
   9512 	char *line[] = {"(", "sensitivity", "(", "s0", ")", ")", NULL};
   9513 
   9514 	struct cil_tree *test_tree;
   9515 	gen_test_tree(&test_tree, line);
   9516 
   9517 	struct cil_db *test_db;
   9518 	cil_db_init(&test_db);
   9519 
   9520 	struct cil_tree_node *test_ast_node;
   9521 	cil_tree_node_init(&test_ast_node);
   9522 
   9523 	int rc = cil_gen_sensitivity(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   9524 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   9525 }
   9526 
   9527 void test_cil_gen_sensitivity_extra_neg(CuTest *tc) {
   9528 	char *line[] = {"(", "sensitivity", "s0", "extra", ")", NULL};
   9529 
   9530 	struct cil_tree *test_tree;
   9531 	gen_test_tree(&test_tree, line);
   9532 
   9533 	struct cil_db *test_db;
   9534 	cil_db_init(&test_db);
   9535 
   9536 	struct cil_tree_node *test_ast_node;
   9537 	cil_tree_node_init(&test_ast_node);
   9538 
   9539 	int rc = cil_gen_sensitivity(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   9540 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   9541 }
   9542 
   9543 void test_cil_gen_sensalias(CuTest *tc) {
   9544 	char *line[] = {"(", "sensitivityalias", "s0", "alias", ")", NULL};
   9545 
   9546 	struct cil_tree *test_tree;
   9547 	gen_test_tree(&test_tree, line);
   9548 
   9549 	struct cil_db *test_db;
   9550 	cil_db_init(&test_db);
   9551 
   9552 	struct cil_tree_node *test_ast_node;
   9553 	cil_tree_node_init(&test_ast_node);
   9554 
   9555 	test_ast_node->parent = test_db->ast->root;
   9556 	test_ast_node->line = 1;
   9557 
   9558 	int rc = cil_gen_sensalias(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   9559 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   9560 }
   9561 
   9562 void test_cil_gen_sensalias_dbnull_neg(CuTest *tc) {
   9563 	char *line[] = {"(", "sensitivityalias", "s0", "alias", ")", NULL};
   9564 
   9565 	struct cil_tree *test_tree;
   9566 	gen_test_tree(&test_tree, line);
   9567 
   9568 	struct cil_db *test_db = NULL;
   9569 
   9570 	struct cil_tree_node *test_ast_node;
   9571 	cil_tree_node_init(&test_ast_node);
   9572 
   9573 	int rc = cil_gen_sensalias(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   9574 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   9575 }
   9576 
   9577 void test_cil_gen_sensalias_currnull_neg(CuTest *tc) {
   9578 	struct cil_tree_node *test_ast_node;
   9579 	cil_tree_node_init(&test_ast_node);
   9580 
   9581 	struct cil_db *test_db;
   9582 	cil_db_init(&test_db);
   9583 
   9584 	int rc = cil_gen_sensalias(test_db, NULL, test_ast_node);
   9585 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   9586 }
   9587 
   9588 void test_cil_gen_sensalias_astnull_neg(CuTest *tc) {
   9589 	char *line[] = {"(", "sensitivityalias", "s0", "alias", ")", NULL};
   9590 
   9591 	struct cil_tree *test_tree;
   9592 	gen_test_tree(&test_tree, line);
   9593 
   9594 	struct cil_db *test_db;
   9595 	cil_db_init (&test_db);
   9596 
   9597 	struct cil_tree_node *test_ast_node = NULL;
   9598 
   9599 	int rc = cil_gen_sensalias(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   9600 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   9601 }
   9602 
   9603 void test_cil_gen_sensalias_sensnull_neg(CuTest *tc) {
   9604 	char *line[] = {"(", "sensitivityalias", "s0", "alias", ")", NULL};
   9605 
   9606 	struct cil_tree *test_tree;
   9607 	gen_test_tree(&test_tree, line);
   9608 
   9609 	test_tree->root->cl_head->cl_head->next = NULL;
   9610 
   9611 	struct cil_db *test_db;
   9612 	cil_db_init(&test_db);
   9613 	struct cil_tree_node *test_ast_node;
   9614 	cil_tree_node_init(&test_ast_node);
   9615 
   9616 	int rc = cil_gen_sensalias(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   9617 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   9618 }
   9619 
   9620 void test_cil_gen_sensalias_senslist_neg(CuTest *tc) {
   9621 	char *line[] = {"(", "sensitivityalias", "(", "s0", "s1", ")", "alias", ")", NULL};
   9622 
   9623 	struct cil_tree *test_tree;
   9624 	gen_test_tree(&test_tree, line);
   9625 
   9626 	struct cil_db *test_db;
   9627 	cil_db_init(&test_db);
   9628 
   9629 	struct cil_tree_node *test_ast_node;
   9630 	cil_tree_node_init(&test_ast_node);
   9631 
   9632 	int rc = cil_gen_sensalias(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   9633 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   9634 }
   9635 
   9636 void test_cil_gen_sensalias_aliasnull_neg(CuTest *tc) {
   9637 	char *line[] = {"(", "sensitivityalias", "s0", "alias", ")", NULL};
   9638 
   9639 	struct cil_tree *test_tree;
   9640 	gen_test_tree(&test_tree, line);
   9641 
   9642 	test_tree->root->cl_head->cl_head->next->next = NULL;
   9643 
   9644 	struct cil_db *test_db;
   9645 	cil_db_init(&test_db);
   9646 
   9647 	struct cil_tree_node *test_ast_node;
   9648 	cil_tree_node_init(&test_ast_node);
   9649 
   9650 	int rc = cil_gen_sensalias(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   9651 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   9652 }
   9653 
   9654 void test_cil_gen_sensalias_aliaslist_neg(CuTest *tc) {
   9655 	char *line[] = {"(", "sensitivityalias", "s0", "(", "alias", "alias2", ")", ")", NULL};
   9656 
   9657 	struct cil_tree *test_tree;
   9658 	gen_test_tree(&test_tree, line);
   9659 
   9660 	struct cil_db *test_db;
   9661 	cil_db_init(&test_db);
   9662 
   9663 	struct cil_tree_node *test_ast_node;
   9664 	cil_tree_node_init(&test_ast_node);
   9665 
   9666 	int rc = cil_gen_sensalias(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   9667 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   9668 }
   9669 
   9670 void test_cil_gen_sensalias_extra_neg(CuTest *tc) {
   9671 	char *line[] = {"(", "sensitivityalias", "s0", "alias", "extra", ")", NULL};
   9672 
   9673 	struct cil_tree *test_tree;
   9674 	gen_test_tree(&test_tree, line);
   9675 
   9676 	struct cil_db *test_db;
   9677 	cil_db_init(&test_db);
   9678 
   9679 	struct cil_tree_node *test_ast_node;
   9680 	cil_tree_node_init(&test_ast_node);
   9681 
   9682 	int rc = cil_gen_sensalias(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   9683 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   9684 }
   9685 
   9686 void test_cil_gen_category(CuTest *tc) {
   9687 	char *line[] = {"(", "category", "c0", ")", NULL};
   9688 
   9689 	struct cil_tree *test_tree;
   9690 	gen_test_tree(&test_tree, line);
   9691 
   9692 	struct cil_db *test_db;
   9693 	cil_db_init(&test_db);
   9694 
   9695 	struct cil_tree_node *test_ast_node;
   9696 	cil_tree_node_init(&test_ast_node);
   9697 
   9698 	test_ast_node->parent = test_db->ast->root;
   9699 	test_ast_node->line = 1;
   9700 
   9701 	int rc = cil_gen_category(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   9702 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   9703 }
   9704 
   9705 void test_cil_gen_category_dbnull_neg(CuTest *tc) {
   9706 	char *line[] = {"(", "category", "c0", ")", NULL};
   9707 
   9708 	struct cil_tree *test_tree;
   9709 	gen_test_tree(&test_tree, line);
   9710 
   9711 	struct cil_db *test_db = NULL;
   9712 
   9713 	struct cil_tree_node *test_ast_node;
   9714 	cil_tree_node_init(&test_ast_node);
   9715 
   9716 	int rc = cil_gen_category(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   9717 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   9718 }
   9719 
   9720 void test_cil_gen_category_astnull_neg(CuTest *tc) {
   9721 	char *line[] = {"(", "category", "c0", ")", NULL};
   9722 
   9723 	struct cil_tree *test_tree;
   9724 	gen_test_tree(&test_tree, line);
   9725 
   9726 	struct cil_db *test_db;
   9727 	cil_db_init(&test_db);
   9728 
   9729 	struct cil_tree_node *test_ast_node = NULL;
   9730 
   9731 	int rc = cil_gen_category(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   9732 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   9733 }
   9734 
   9735 void test_cil_gen_category_currnull_neg(CuTest *tc) {
   9736 	char *line[] = {"(", "category", "c0", ")", NULL};
   9737 
   9738 	struct cil_tree *test_tree;
   9739 	gen_test_tree(&test_tree, line);
   9740 
   9741 	struct cil_db *test_db;
   9742 	cil_db_init(&test_db);
   9743 
   9744 	struct cil_tree_node *test_ast_node;
   9745 	cil_tree_node_init(&test_ast_node);
   9746 
   9747 	test_ast_node->parent = test_db->ast->root;
   9748 	test_ast_node->line = 1;
   9749 
   9750 	int rc = cil_gen_category(test_db, NULL, test_ast_node);
   9751 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   9752 }
   9753 
   9754 void test_cil_gen_category_catnull_neg(CuTest *tc){
   9755 	char *line[] = {"(", "category", "c0", ")", NULL};
   9756 
   9757 	struct cil_tree *test_tree;
   9758 	gen_test_tree(&test_tree, line);
   9759 
   9760 	test_tree->root->cl_head->cl_head->next = NULL;
   9761 
   9762 	struct cil_db *test_db;
   9763 	cil_db_init(&test_db);
   9764 
   9765 	struct cil_tree_node *test_ast_node;
   9766 	cil_tree_node_init(&test_ast_node);
   9767 
   9768 	test_ast_node->parent = test_db->ast->root;
   9769 	test_ast_node->line = 1;
   9770 
   9771 	int rc = cil_gen_category(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   9772 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   9773 }
   9774 
   9775 void test_cil_gen_category_catlist_neg(CuTest *tc){
   9776 	char *line[] = {"(", "category", "(", "c0", ")", ")", NULL};
   9777 
   9778 	struct cil_tree *test_tree;
   9779 	gen_test_tree(&test_tree, line);
   9780 
   9781 	struct cil_db *test_db;
   9782 	cil_db_init(&test_db);
   9783 
   9784 	struct cil_tree_node *test_ast_node;
   9785 	cil_tree_node_init(&test_ast_node);
   9786 
   9787 	test_ast_node->parent = test_db->ast->root;
   9788 	test_ast_node->line = 1;
   9789 
   9790 	int rc = cil_gen_category(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   9791 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   9792 }
   9793 
   9794 void test_cil_gen_category_extra_neg(CuTest *tc) {
   9795 	char *line[] = {"(", "category", "c0", "extra", ")", NULL};
   9796 
   9797 	struct cil_tree *test_tree;
   9798 	gen_test_tree(&test_tree, line);
   9799 
   9800 	struct cil_db *test_db;
   9801 	cil_db_init(&test_db);
   9802 
   9803 	struct cil_tree_node *test_ast_node;
   9804 	cil_tree_node_init(&test_ast_node);
   9805 
   9806 	test_ast_node->parent = test_db->ast->root;
   9807 	test_ast_node->line = 1;
   9808 
   9809 	int rc = cil_gen_category(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   9810 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   9811 }
   9812 
   9813 void test_cil_gen_catset(CuTest *tc) {
   9814 	char *line[] = {"(", "categoryset", "somecats", "(", "c0", "c1", "c2", "(", "c3", "c4", ")", ")", ")", NULL};
   9815 
   9816 	struct cil_tree *test_tree;
   9817 	gen_test_tree(&test_tree, line);
   9818 
   9819 	struct cil_db *test_db;
   9820 	cil_db_init(&test_db);
   9821 
   9822 	struct cil_tree_node *test_ast_node;
   9823 	cil_tree_node_init(&test_ast_node);
   9824 
   9825 	test_ast_node->parent = test_db->ast->root;
   9826 	test_ast_node->line = 1;
   9827 
   9828 	int rc = cil_gen_catset(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   9829 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   9830 }
   9831 
   9832 void test_cil_gen_catset_dbnull_neg(CuTest *tc) {
   9833 	char *line[] = {"(", "categoryset", "somecats", "(", "c0", "c1", "c2", "(", "c3", "c4", ")", ")", ")", NULL};
   9834 
   9835 	struct cil_tree *test_tree;
   9836 	gen_test_tree(&test_tree, line);
   9837 
   9838 	struct cil_db *test_db = NULL;
   9839 
   9840 	struct cil_tree_node *test_ast_node;
   9841 	cil_tree_node_init(&test_ast_node);
   9842 
   9843 	int rc = cil_gen_catset(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   9844 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   9845 }
   9846 
   9847 void test_cil_gen_catset_currnull_neg(CuTest *tc) {
   9848 	char *line[] = {"(", "categoryset", "somecats", "(", "c0", "c1", "c2", "(", "c3", "c4", ")", ")", ")", NULL};
   9849 
   9850 	struct cil_tree *test_tree;
   9851 	gen_test_tree(&test_tree, line);
   9852 
   9853 	struct cil_db *test_db;
   9854 	cil_db_init(&test_db);
   9855 
   9856 	struct cil_tree_node *test_ast_node;
   9857 	cil_tree_node_init(&test_ast_node);
   9858 
   9859 	test_ast_node->parent = test_db->ast->root;
   9860 	test_ast_node->line = 1;
   9861 
   9862 	int rc = cil_gen_catset(test_db, NULL, test_ast_node);
   9863 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   9864 }
   9865 
   9866 void test_cil_gen_catset_astnull_neg(CuTest *tc) {
   9867 	char *line[] = {"(", "categoryset", "somecats", "(", "c0", "c1", "c2", "(", "c3", "c4", ")", ")", ")", NULL};
   9868 
   9869 	struct cil_tree *test_tree;
   9870 	gen_test_tree(&test_tree, line);
   9871 
   9872 	struct cil_db *test_db;
   9873 	cil_db_init(&test_db);
   9874 
   9875 	struct cil_tree_node *test_ast_node = NULL;
   9876 
   9877 	int rc = cil_gen_catset(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   9878 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   9879 }
   9880 
   9881 void test_cil_gen_catset_namenull_neg(CuTest *tc) {
   9882 	char *line[] = {"(", "categoryset", "somecats", "(", "c0", "c1", "c2", "(", "c3", "c4", ")", ")", ")", NULL};
   9883 
   9884 	struct cil_tree *test_tree;
   9885 	gen_test_tree(&test_tree, line);
   9886 
   9887 	test_tree->root->cl_head->cl_head->next = NULL;
   9888 
   9889 	struct cil_db *test_db;
   9890 	cil_db_init(&test_db);
   9891 
   9892 	struct cil_tree_node *test_ast_node;
   9893 	cil_tree_node_init(&test_ast_node);
   9894 
   9895 	test_ast_node->parent = test_db->ast->root;
   9896 	test_ast_node->line = 1;
   9897 
   9898 	int rc = cil_gen_catset(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   9899 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   9900 }
   9901 
   9902 void test_cil_gen_catset_setnull_neg(CuTest *tc) {
   9903 	char *line[] = {"(", "categoryset", "somecats", ")", NULL};
   9904 
   9905 	struct cil_tree *test_tree;
   9906 	gen_test_tree(&test_tree, line);
   9907 
   9908 	struct cil_db *test_db;
   9909 	cil_db_init(&test_db);
   9910 
   9911 	struct cil_tree_node *test_ast_node;
   9912 	cil_tree_node_init(&test_ast_node);
   9913 
   9914 	test_ast_node->parent = test_db->ast->root;
   9915 	test_ast_node->line = 1;
   9916 
   9917 	int rc = cil_gen_catset(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   9918 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   9919 }
   9920 
   9921 void test_cil_gen_catset_namelist_neg(CuTest *tc) { //This should fail before gen_node call - additional syntax checks are needed
   9922 	char *line[] = {"(", "categoryset", "(", "somecats", ")", "(", "c0", "c1", "c2", "(", "c3", "c4", ")", ")", ")", NULL};
   9923 
   9924 	struct cil_tree *test_tree;
   9925 	gen_test_tree(&test_tree, line);
   9926 
   9927 	struct cil_db *test_db;
   9928 	cil_db_init(&test_db);
   9929 
   9930 	struct cil_tree_node *test_ast_node;
   9931 	cil_tree_node_init(&test_ast_node);
   9932 
   9933 	test_ast_node->parent = test_db->ast->root;
   9934 	test_ast_node->line = 1;
   9935 
   9936 	int rc = cil_gen_catset(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   9937 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   9938 }
   9939 
   9940 void test_cil_gen_catset_extra_neg(CuTest *tc) {
   9941 	char *line[] = {"(", "categoryset", "somecats", "(", "c0", "c1", "c2", "(", "c3", "c4", ")", ")", "extra",  ")", NULL};
   9942 
   9943 	struct cil_tree *test_tree;
   9944 	gen_test_tree(&test_tree, line);
   9945 
   9946 	struct cil_db *test_db;
   9947 	cil_db_init(&test_db);
   9948 
   9949 	struct cil_tree_node *test_ast_node;
   9950 	cil_tree_node_init(&test_ast_node);
   9951 
   9952 	test_ast_node->parent = test_db->ast->root;
   9953 	test_ast_node->line = 1;
   9954 
   9955 	int rc = cil_gen_catset(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   9956 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   9957 }
   9958 
   9959 void test_cil_gen_catset_notset_neg(CuTest *tc) {
   9960 	char *line[] = {"(", "categoryset", "somecats", "blah", ")", NULL};
   9961 
   9962 	struct cil_tree *test_tree;
   9963 	gen_test_tree(&test_tree, line);
   9964 
   9965 	struct cil_db *test_db;
   9966 	cil_db_init(&test_db);
   9967 
   9968 	struct cil_tree_node *test_ast_node;
   9969 	cil_tree_node_init(&test_ast_node);
   9970 
   9971 	test_ast_node->parent = test_db->ast->root;
   9972 	test_ast_node->line = 1;
   9973 
   9974 	int rc = cil_gen_catset(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   9975 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   9976 }
   9977 
   9978 // TODO: This doesn't actually test failure of gen_node
   9979 void test_cil_gen_catset_nodefail_neg(CuTest *tc) {
   9980 	char *line[] = {"(", "categoryset", "somecats", "(", "c0", "c1", "c2", "(", "c3", "c4", ")", ")", ")", NULL};
   9981 
   9982 	struct cil_tree *test_tree;
   9983 	gen_test_tree(&test_tree, line);
   9984 
   9985 	struct cil_db *test_db = NULL;
   9986 
   9987 	struct cil_tree_node *test_ast_node;
   9988 	cil_tree_node_init(&test_ast_node);
   9989 
   9990 	int rc = cil_gen_catset(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   9991 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   9992 }
   9993 
   9994 void test_cil_gen_catset_settolistfail_neg(CuTest *tc) {
   9995 	char *line[] = {"(", "categoryset", "somecats", "(", ")", NULL};
   9996 
   9997 	struct cil_tree *test_tree;
   9998 	gen_test_tree(&test_tree, line);
   9999 
   10000 	struct cil_db *test_db;
   10001 	cil_db_init(&test_db);
   10002 
   10003 	struct cil_tree_node *test_ast_node;
   10004 	cil_tree_node_init(&test_ast_node);
   10005 
   10006 	test_ast_node->parent = test_db->ast->root;
   10007 	test_ast_node->line = 1;
   10008 
   10009 	int rc = cil_gen_catset(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   10010 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   10011 }
   10012 
   10013 void test_cil_gen_catalias(CuTest *tc) {
   10014 	char *line[] = {"(", "categoryalias", "c0", "red", ")", NULL};
   10015 
   10016 	struct cil_tree *test_tree;
   10017 	gen_test_tree(&test_tree, line);
   10018 
   10019 	struct cil_db *test_db;
   10020 	cil_db_init(&test_db);
   10021 
   10022 	struct cil_tree_node *test_ast_node;
   10023 	cil_tree_node_init(&test_ast_node);
   10024 
   10025 	test_ast_node->parent = test_db->ast->root;
   10026 	test_ast_node->line = 1;
   10027 
   10028 	int rc = cil_gen_catalias(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   10029 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   10030 }
   10031 
   10032 void test_cil_gen_catalias_dbnull_neg(CuTest *tc) {
   10033 	char *line[] = {"(", "categoryalias", "c0", "red", ")", NULL};
   10034 
   10035 	struct cil_tree *test_tree;
   10036 	gen_test_tree(&test_tree, line);
   10037 
   10038 	struct cil_db *test_db = NULL;
   10039 
   10040 	struct cil_tree_node *test_ast_node;
   10041 	cil_tree_node_init(&test_ast_node);
   10042 
   10043 	int rc = cil_gen_catalias(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   10044 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   10045 }
   10046 
   10047 void test_cil_gen_catalias_currnull_neg(CuTest *tc) {
   10048 	char *line[] = {"(", "categoryalias", "c0", "red", ")", NULL};
   10049 
   10050 	struct cil_tree *test_tree;
   10051 	gen_test_tree(&test_tree, line);
   10052 
   10053 	struct cil_db *test_db;
   10054 	cil_db_init(&test_db);
   10055 
   10056 	struct cil_tree_node *test_ast_node;
   10057 	cil_tree_node_init(&test_ast_node);
   10058 
   10059 	test_ast_node->parent = test_db->ast->root;
   10060 	test_ast_node->line = 1;
   10061 
   10062 	int rc = cil_gen_catalias(test_db, NULL, test_ast_node);
   10063 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   10064 }
   10065 
   10066 void test_cil_gen_catalias_astnull_neg(CuTest *tc) {
   10067 	char *line[] = {"(", "categoryalias", "c0", "red", ")", NULL};
   10068 
   10069 	struct cil_tree *test_tree;
   10070 	gen_test_tree(&test_tree, line);
   10071 
   10072 	struct cil_db *test_db;
   10073 	cil_db_init(&test_db);
   10074 
   10075 	struct cil_tree_node *test_ast_node = NULL;
   10076 
   10077 	int rc = cil_gen_catalias(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   10078 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   10079 }
   10080 
   10081 void test_cil_gen_catalias_catnull_neg(CuTest *tc) {
   10082 	char *line[] = {"(", "categoryalias", "c0", "red", ")", NULL};
   10083 
   10084 	struct cil_tree *test_tree;
   10085 	gen_test_tree(&test_tree, line);
   10086 
   10087 	test_tree->root->cl_head->cl_head->next = NULL;
   10088 
   10089 	struct cil_db *test_db;
   10090 	cil_db_init(&test_db);
   10091 
   10092 	struct cil_tree_node *test_ast_node;
   10093 	cil_tree_node_init(&test_ast_node);
   10094 
   10095 	test_ast_node->parent = test_db->ast->root;
   10096 	test_ast_node->line = 1;
   10097 
   10098 	int rc = cil_gen_catalias(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   10099 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   10100 }
   10101 
   10102 void test_cil_gen_catalias_aliasnull_neg(CuTest *tc) {
   10103 	char *line[] = {"(", "categoryalias", "c0", "red", ")", NULL};
   10104 
   10105 	struct cil_tree *test_tree;
   10106 	gen_test_tree(&test_tree, line);
   10107 
   10108 	test_tree->root->cl_head->cl_head->next->next = NULL;
   10109 
   10110 	struct cil_db *test_db;
   10111 	cil_db_init(&test_db);
   10112 
   10113 	struct cil_tree_node *test_ast_node;
   10114 	cil_tree_node_init(&test_ast_node);
   10115 
   10116 	test_ast_node->parent = test_db->ast->root;
   10117 	test_ast_node->line = 1;
   10118 
   10119 	int rc = cil_gen_catalias(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   10120 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   10121 }
   10122 
   10123 void test_cil_gen_catalias_extra_neg(CuTest *tc) {
   10124 	char *line[] = {"(", "categoryalias", "c0", "red", "extra", ")", NULL};
   10125 
   10126 	struct cil_tree *test_tree;
   10127 	gen_test_tree(&test_tree, line);
   10128 
   10129 	struct cil_db *test_db;
   10130 	cil_db_init(&test_db);
   10131 
   10132 	struct cil_tree_node *test_ast_node;
   10133 	cil_tree_node_init(&test_ast_node);
   10134 
   10135 	test_ast_node->parent = test_db->ast->root;
   10136 	test_ast_node->line = 1;
   10137 
   10138 	int rc = cil_gen_catalias(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   10139 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   10140 }
   10141 
   10142 void test_cil_gen_catrange(CuTest *tc) {
   10143 	char *line[] = {"(", "categoryrange", "range", "(", "c0", "c1", ")", ")", NULL};
   10144 
   10145 	struct cil_tree *test_tree;
   10146 	gen_test_tree(&test_tree, line);
   10147 
   10148 	struct cil_db *test_db;
   10149 	cil_db_init(&test_db);
   10150 
   10151 	struct cil_tree_node *test_ast_node;
   10152 	cil_tree_node_init(&test_ast_node);
   10153 
   10154 	test_ast_node->parent = test_db->ast->root;
   10155 	test_ast_node->line = 1;
   10156 
   10157 	int rc = cil_gen_catrange(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   10158 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   10159 }
   10160 
   10161 void test_cil_gen_catrange_noname_neg(CuTest *tc) {
   10162 	char *line[] = {"(", "categoryrange", ")", NULL};
   10163 
   10164 	struct cil_tree *test_tree;
   10165 	gen_test_tree(&test_tree, line);
   10166 
   10167 	struct cil_db *test_db;
   10168 	cil_db_init(&test_db);
   10169 
   10170 	struct cil_tree_node *test_ast_node;
   10171 	cil_tree_node_init(&test_ast_node);
   10172 
   10173 	test_ast_node->parent = test_db->ast->root;
   10174 	test_ast_node->line = 1;
   10175 
   10176 	int rc = cil_gen_catrange(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   10177 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   10178 }
   10179 
   10180 void test_cil_gen_catrange_norange_neg(CuTest *tc) {
   10181 	char *line[] = {"(", "categoryrange", "range", ")", NULL};
   10182 
   10183 	struct cil_tree *test_tree;
   10184 	gen_test_tree(&test_tree, line);
   10185 
   10186 	struct cil_db *test_db;
   10187 	cil_db_init(&test_db);
   10188 
   10189 	struct cil_tree_node *test_ast_node;
   10190 	cil_tree_node_init(&test_ast_node);
   10191 
   10192 	test_ast_node->parent = test_db->ast->root;
   10193 	test_ast_node->line = 1;
   10194 
   10195 	int rc = cil_gen_catrange(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   10196 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   10197 }
   10198 
   10199 void test_cil_gen_catrange_emptyrange_neg(CuTest *tc) {
   10200 	char *line[] = {"(", "categoryrange", "range", "(", ")", ")", NULL};
   10201 
   10202 	struct cil_tree *test_tree;
   10203 	gen_test_tree(&test_tree, line);
   10204 
   10205 	struct cil_db *test_db;
   10206 	cil_db_init(&test_db);
   10207 
   10208 	struct cil_tree_node *test_ast_node;
   10209 	cil_tree_node_init(&test_ast_node);
   10210 
   10211 	test_ast_node->parent = test_db->ast->root;
   10212 	test_ast_node->line = 1;
   10213 
   10214 	int rc = cil_gen_catrange(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   10215 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   10216 }
   10217 
   10218 void test_cil_gen_catrange_extrarange_neg(CuTest *tc) {
   10219 	char *line[] = {"(", "categoryrange", "range", "(", "c0", "c1", "c2", ")", ")", NULL};
   10220 
   10221 	struct cil_tree *test_tree;
   10222 	gen_test_tree(&test_tree, line);
   10223 
   10224 	struct cil_db *test_db;
   10225 	cil_db_init(&test_db);
   10226 
   10227 	struct cil_tree_node *test_ast_node;
   10228 	cil_tree_node_init(&test_ast_node);
   10229 
   10230 	test_ast_node->parent = test_db->ast->root;
   10231 	test_ast_node->line = 1;
   10232 
   10233 	int rc = cil_gen_catrange(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   10234 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   10235 }
   10236 
   10237 void test_cil_gen_catrange_dbnull_neg(CuTest *tc) {
   10238 	char *line[] = {"(", "categoryrange", "range", "(", "c0", "c1", ")", ")", NULL};
   10239 
   10240 	struct cil_tree *test_tree;
   10241 	gen_test_tree(&test_tree, line);
   10242 
   10243 	struct cil_db *test_db = NULL;
   10244 
   10245 	struct cil_tree_node *test_ast_node;
   10246 	cil_tree_node_init(&test_ast_node);
   10247 
   10248 	int rc = cil_gen_catrange(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   10249 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   10250 }
   10251 
   10252 void test_cil_gen_catrange_currnull_neg(CuTest *tc) {
   10253 	char *line[] = {"(", ")", NULL};
   10254 
   10255 	struct cil_tree *test_tree;
   10256 	gen_test_tree(&test_tree, line);
   10257 
   10258 	struct cil_db *test_db;
   10259 	cil_db_init(&test_db);
   10260 
   10261 	struct cil_tree_node *test_ast_node;
   10262 	cil_tree_node_init(&test_ast_node);
   10263 
   10264 	test_ast_node->parent = test_db->ast->root;
   10265 	test_ast_node->line = 1;
   10266 
   10267 	int rc = cil_gen_catrange(test_db, NULL, test_ast_node);
   10268 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   10269 }
   10270 
   10271 void test_cil_gen_catrange_astnull_neg(CuTest *tc) {
   10272 	char *line[] = {"(", "categoryrange", "range", "(", "c0", "c1", ")", ")", NULL};
   10273 
   10274 	struct cil_tree *test_tree;
   10275 	gen_test_tree(&test_tree, line);
   10276 
   10277 	struct cil_db *test_db;
   10278 	cil_db_init(&test_db);
   10279 
   10280 	struct cil_tree_node *test_ast_node = NULL;
   10281 
   10282 	int rc = cil_gen_catrange(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   10283 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   10284 }
   10285 
   10286 void test_cil_gen_catrange_extra_neg(CuTest *tc) {
   10287 	char *line[] = {"(", "categoryrange", "range", "(", "c0", "c1", ")", "extra", ")", NULL};
   10288 
   10289 	struct cil_tree *test_tree;
   10290 	gen_test_tree(&test_tree, line);
   10291 
   10292 	struct cil_db *test_db;
   10293 	cil_db_init(&test_db);
   10294 
   10295 	struct cil_tree_node *test_ast_node;
   10296 	cil_tree_node_init(&test_ast_node);
   10297 
   10298 	test_ast_node->parent = test_db->ast->root;
   10299 	test_ast_node->line = 1;
   10300 
   10301 	int rc = cil_gen_catrange(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   10302 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   10303 }
   10304 
   10305 void test_cil_gen_roletype(CuTest *tc) {
   10306 	char *line[] = {"(", "roletype", "admin_r", "admin_t", ")", NULL};
   10307 
   10308 	struct cil_tree *test_tree;
   10309 	gen_test_tree(&test_tree, line);
   10310 
   10311 	struct cil_db *test_db;
   10312 	cil_db_init(&test_db);
   10313 
   10314 	struct cil_tree_node *test_ast_node;
   10315 	cil_tree_node_init(&test_ast_node);
   10316 
   10317 	int rc = cil_gen_roletype(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   10318 
   10319 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   10320 }
   10321 
   10322 void test_cil_gen_roletype_currnull_neg(CuTest *tc) {
   10323 	char *line[] = {"(", ")", NULL};
   10324 
   10325 	struct cil_tree *test_tree;
   10326 	gen_test_tree(&test_tree, line);
   10327 
   10328 	struct cil_db *test_db;
   10329 	cil_db_init(&test_db);
   10330 
   10331 	struct cil_tree_node *test_ast_node;
   10332 	cil_tree_node_init(&test_ast_node);
   10333 
   10334 	int rc = cil_gen_roletype(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   10335 
   10336 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   10337 }
   10338 
   10339 void test_cil_gen_roletype_dbnull_neg(CuTest *tc) {
   10340 	char *line[] = {"(", "roletype", "admin_r", "admin_t", ")", NULL};
   10341 
   10342 	struct cil_tree *test_tree;
   10343 	gen_test_tree(&test_tree, line);
   10344 
   10345 	struct cil_db *test_db = NULL;
   10346 
   10347 	struct cil_tree_node *test_ast_node;
   10348 	cil_tree_node_init(&test_ast_node);
   10349 
   10350 	int rc = cil_gen_roletype(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   10351 
   10352 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   10353 }
   10354 
   10355 void test_cil_gen_roletype_astnull_neg(CuTest *tc) {
   10356 	char *line[] = {"(", "roletype", "admin_r", "admin_t", ")", NULL};
   10357 
   10358 	struct cil_tree *test_tree;
   10359 	gen_test_tree(&test_tree, line);
   10360 
   10361 	struct cil_db *test_db;
   10362 	cil_db_init(&test_db);
   10363 
   10364 	struct cil_tree_node *test_ast_node = NULL;
   10365 
   10366 	int rc = cil_gen_roletype(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   10367 
   10368 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   10369 }
   10370 
   10371 
   10372 void test_cil_gen_roletype_empty_neg(CuTest *tc) {
   10373 	char *line[] = {"(", "roletype", ")", NULL};
   10374 
   10375 	struct cil_tree *test_tree;
   10376 	gen_test_tree(&test_tree, line);
   10377 
   10378 	struct cil_db *test_db;
   10379 	cil_db_init(&test_db);
   10380 
   10381 	struct cil_tree_node *test_ast_node;
   10382 	cil_tree_node_init(&test_ast_node);
   10383 
   10384 	int rc = cil_gen_roletype(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   10385 
   10386 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   10387 }
   10388 
   10389 void test_cil_gen_roletype_rolelist_neg(CuTest *tc) {
   10390 	char *line[] = {"(", "roletype", "(", "admin_r", ")", "admin_t", ")", NULL};
   10391 
   10392 	struct cil_tree *test_tree;
   10393 	gen_test_tree(&test_tree, line);
   10394 
   10395 	struct cil_db *test_db;
   10396 	cil_db_init(&test_db);
   10397 
   10398 	struct cil_tree_node *test_ast_node;
   10399 	cil_tree_node_init(&test_ast_node);
   10400 
   10401 	int rc = cil_gen_roletype(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   10402 
   10403 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   10404 }
   10405 
   10406 // TODO
   10407 // Not sure this is actually testing roletype
   10408 // I think this will just test that type is null
   10409 void test_cil_gen_roletype_roletype_sublist_neg(CuTest *tc) {
   10410 	char *line[] = {"(", "(", "roletype", "admin_r", ")", "admin_t", ")", NULL};
   10411 
   10412 	struct cil_tree *test_tree;
   10413 	gen_test_tree(&test_tree, line);
   10414 
   10415 	struct cil_db *test_db;
   10416 	cil_db_init(&test_db);
   10417 
   10418 	struct cil_tree_node *test_ast_node;
   10419 	cil_tree_node_init(&test_ast_node);
   10420 
   10421 	int rc = cil_gen_roletype(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   10422 
   10423 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   10424 }
   10425 
   10426 void test_cil_gen_roletype_typelist_neg(CuTest *tc) {
   10427 	char *line[] = {"(", "roletype", "admin_r", "(", "admin_t", ")", ")", NULL};
   10428 
   10429 	struct cil_tree *test_tree;
   10430 	gen_test_tree(&test_tree, line);
   10431 
   10432 	struct cil_db *test_db;
   10433 	cil_db_init(&test_db);
   10434 
   10435 	struct cil_tree_node *test_ast_node;
   10436 	cil_tree_node_init(&test_ast_node);
   10437 
   10438 	int rc = cil_gen_roletype(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   10439 
   10440 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   10441 }
   10442 
   10443 void test_cil_gen_userrole(CuTest *tc) {
   10444 	char *line[] = {"(", "userrole", "staff_u", "staff_r", ")", NULL};
   10445 
   10446 	struct cil_tree *test_tree;
   10447 	gen_test_tree(&test_tree, line);
   10448 
   10449 	struct cil_db *test_db;
   10450 	cil_db_init(&test_db);
   10451 
   10452 	struct cil_tree_node *test_ast_node;
   10453 	cil_tree_node_init(&test_ast_node);
   10454 
   10455 	int rc = cil_gen_userrole(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   10456 
   10457 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   10458 }
   10459 
   10460 void test_cil_gen_userrole_currnull_neg(CuTest *tc) {
   10461 	char *line[] = {"(", ")", NULL};
   10462 
   10463 	struct cil_tree *test_tree;
   10464 	gen_test_tree(&test_tree, line);
   10465 
   10466 	struct cil_db *test_db;
   10467 	cil_db_init(&test_db);
   10468 
   10469 	struct cil_tree_node *test_ast_node;
   10470 	cil_tree_node_init(&test_ast_node);
   10471 
   10472 	int rc = cil_gen_userrole(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   10473 
   10474 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   10475 }
   10476 
   10477 void test_cil_gen_userrole_dbnull_neg(CuTest *tc) {
   10478 	char *line[] = {"(", "userrole", "staff_u", "staff_r", ")", NULL};
   10479 
   10480 	struct cil_tree *test_tree;
   10481 	gen_test_tree(&test_tree, line);
   10482 
   10483 	struct cil_db *test_db = NULL;
   10484 
   10485 	struct cil_tree_node *test_ast_node;
   10486 	cil_tree_node_init(&test_ast_node);
   10487 
   10488 	int rc = cil_gen_userrole(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   10489 
   10490 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   10491 }
   10492 
   10493 void test_cil_gen_userrole_astnull_neg(CuTest *tc) {
   10494 	char *line[] = {"(", "userrole", "staff_u", "staff_r", ")", NULL};
   10495 
   10496 	struct cil_tree *test_tree;
   10497 	gen_test_tree(&test_tree, line);
   10498 
   10499 	struct cil_db *test_db;
   10500 	cil_db_init(&test_db);
   10501 
   10502 	struct cil_tree_node *test_ast_node = NULL;
   10503 
   10504 	int rc = cil_gen_userrole(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   10505 
   10506 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   10507 }
   10508 
   10509 void test_cil_gen_userrole_empty_neg(CuTest *tc) {
   10510 	char *line[] = {"(", "userrole", ")", NULL};
   10511 
   10512 	struct cil_tree *test_tree;
   10513 	gen_test_tree(&test_tree, line);
   10514 
   10515 	struct cil_db *test_db;
   10516 	cil_db_init(&test_db);
   10517 
   10518 	struct cil_tree_node *test_ast_node;
   10519 	cil_tree_node_init(&test_ast_node);
   10520 
   10521 	int rc = cil_gen_userrole(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   10522 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   10523 }
   10524 
   10525 void test_cil_gen_userrole_userlist_neg(CuTest *tc) {
   10526 	char *line[] = {"(", "userrole", "(", "staff_u", ")", "staff_r", ")", NULL};
   10527 
   10528 	struct cil_tree *test_tree;
   10529 	gen_test_tree(&test_tree, line);
   10530 
   10531 	struct cil_db *test_db;
   10532 	cil_db_init(&test_db);
   10533 
   10534 	struct cil_tree_node *test_ast_node;
   10535 	cil_tree_node_init(&test_ast_node);
   10536 
   10537 	int rc = cil_gen_userrole(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   10538 
   10539 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   10540 }
   10541 
   10542 
   10543 //TODO: see above
   10544 void test_cil_gen_userrole_userrole_sublist_neg(CuTest *tc) {
   10545 	char *line[] = {"(", "(", "userrole", "staff_u", ")", "staff_r", ")", NULL};
   10546 
   10547 	struct cil_tree *test_tree;
   10548 	gen_test_tree(&test_tree, line);
   10549 
   10550 	struct cil_db *test_db;
   10551 	cil_db_init(&test_db);
   10552 
   10553 	struct cil_tree_node *test_ast_node;
   10554 	cil_tree_node_init(&test_ast_node);
   10555 
   10556 	int rc = cil_gen_userrole(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   10557 
   10558 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   10559 }
   10560 
   10561 void test_cil_gen_userrole_rolelist_neg(CuTest *tc) {
   10562 	char *line[] = {"(", "userrole", "staff_u", "(", "staff_r", ")", ")", NULL};
   10563 
   10564 	struct cil_tree *test_tree;
   10565 	gen_test_tree(&test_tree, line);
   10566 
   10567 	struct cil_db *test_db;
   10568 	cil_db_init(&test_db);
   10569 
   10570 	struct cil_tree_node *test_ast_node;
   10571 	cil_tree_node_init(&test_ast_node);
   10572 
   10573 	int rc = cil_gen_userrole(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   10574 
   10575 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   10576 }
   10577 
   10578 void test_cil_gen_classcommon(CuTest *tc) {
   10579 	char *line[] = {"(", "classcommon", "file", "file", NULL};
   10580 
   10581         struct cil_tree *test_tree;
   10582         gen_test_tree(&test_tree, line);
   10583 
   10584         struct cil_tree_node *test_ast_node;
   10585         cil_tree_node_init(&test_ast_node);
   10586 
   10587         struct cil_db *test_db;
   10588         cil_db_init(&test_db);
   10589 
   10590         char *test_key = test_tree->root->cl_head->cl_head->next->data;
   10591         struct cil_class *test_cls;
   10592 		cil_class_init(&test_cls);
   10593 
   10594         test_ast_node->parent = test_db->ast->root;
   10595         test_ast_node->line = 1;
   10596 
   10597         cil_symtab_insert(&test_db->symtab[CIL_SYM_CLASSES], (hashtab_key_t)test_key, (struct cil_symtab_datum*)test_cls, test_ast_node);
   10598 
   10599         test_ast_node->data = test_cls;
   10600         test_ast_node->flavor = CIL_CLASS;
   10601 
   10602         int rc = cil_gen_classcommon(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   10603         CuAssertIntEquals(tc, SEPOL_OK, rc);
   10604 }
   10605 
   10606 void test_cil_gen_classcommon_dbnull_neg(CuTest *tc) {
   10607 	char *line[] = {"(", "classcommon", "file", "file", NULL};
   10608 
   10609         struct cil_tree *test_tree;
   10610         gen_test_tree(&test_tree, line);
   10611 
   10612         struct cil_tree_node *test_ast_node;
   10613         cil_tree_node_init(&test_ast_node);
   10614 
   10615         struct cil_db *test_db = NULL;
   10616 
   10617         int rc = cil_gen_classcommon(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   10618         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   10619 }
   10620 
   10621 void test_cil_gen_classcommon_currnull_neg(CuTest *tc) {
   10622 	char *line[] = {"(", ")", NULL};
   10623 
   10624         struct cil_tree *test_tree;
   10625         gen_test_tree(&test_tree, line);
   10626 
   10627         struct cil_tree_node *test_ast_node;
   10628         cil_tree_node_init(&test_ast_node);
   10629 
   10630         struct cil_db *test_db;
   10631         cil_db_init(&test_db);
   10632 
   10633         int rc = cil_gen_classcommon(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   10634         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   10635 }
   10636 
   10637 void test_cil_gen_classcommon_astnull_neg(CuTest *tc) {
   10638 	char *line[] = {"(", "classcommon", "file", "file", NULL};
   10639 
   10640         struct cil_tree *test_tree;
   10641         gen_test_tree(&test_tree, line);
   10642 
   10643         struct cil_tree_node *test_ast_node = NULL;
   10644 
   10645         struct cil_db *test_db;
   10646         cil_db_init(&test_db);
   10647 
   10648         int rc = cil_gen_classcommon(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   10649         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   10650 }
   10651 
   10652 void test_cil_gen_classcommon_missingclassname_neg(CuTest *tc) {
   10653 	char *line[] = {"(", "classcommon", ")", NULL};
   10654 
   10655         struct cil_tree *test_tree;
   10656         gen_test_tree(&test_tree, line);
   10657 
   10658         struct cil_tree_node *test_ast_node;
   10659         cil_tree_node_init(&test_ast_node);
   10660 
   10661         struct cil_db *test_db;
   10662         cil_db_init(&test_db);
   10663 
   10664         int rc = cil_gen_classcommon(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   10665         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   10666 }
   10667 
   10668 void test_cil_gen_classcommon_noperms_neg(CuTest *tc) {
   10669 	char *line[] = {"(", "classcommon", "file", ")", NULL};
   10670 
   10671         struct cil_tree *test_tree;
   10672         gen_test_tree(&test_tree, line);
   10673 
   10674         struct cil_tree_node *test_ast_node;
   10675         cil_tree_node_init(&test_ast_node);
   10676 
   10677         struct cil_db *test_db;
   10678         cil_db_init(&test_db);
   10679 
   10680         char *test_key = test_tree->root->cl_head->cl_head->next->data;
   10681         struct cil_class *test_cls;
   10682 		cil_class_init(&test_cls);
   10683 
   10684         test_ast_node->parent = test_db->ast->root;
   10685         test_ast_node->line = 1;
   10686 
   10687         cil_symtab_insert(&test_db->symtab[CIL_SYM_CLASSES], (hashtab_key_t)test_key, (struct cil_symtab_datum*)test_cls, test_ast_node);
   10688 
   10689         test_ast_node->data = test_cls;
   10690         test_ast_node->flavor = CIL_CLASS;
   10691 
   10692         int rc = cil_gen_classcommon(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   10693         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   10694 }
   10695 
   10696 void test_cil_gen_classcommon_extraperms_neg(CuTest *tc) {
   10697 	char *line[] = {"(", "classcommon", "file", "file", "file", NULL};
   10698 
   10699         struct cil_tree *test_tree;
   10700         gen_test_tree(&test_tree, line);
   10701 
   10702         struct cil_tree_node *test_ast_node;
   10703         cil_tree_node_init(&test_ast_node);
   10704 
   10705         struct cil_db *test_db;
   10706         cil_db_init(&test_db);
   10707 
   10708         char *test_key = test_tree->root->cl_head->cl_head->next->data;
   10709         struct cil_class *test_cls;
   10710 		cil_class_init(&test_cls);
   10711 
   10712         test_ast_node->parent = test_db->ast->root;
   10713         test_ast_node->line = 1;
   10714 
   10715         cil_symtab_insert(&test_db->symtab[CIL_SYM_CLASSES], (hashtab_key_t)test_key, (struct cil_symtab_datum*)test_cls, test_ast_node);
   10716 
   10717         test_ast_node->data = test_cls;
   10718         test_ast_node->flavor = CIL_CLASS;
   10719 
   10720         int rc = cil_gen_classcommon(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   10721         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   10722 }
   10723 
   10724 void test_cil_gen_catorder(CuTest *tc) {
   10725 	char *line[] = {"(", "category", "c0", ")",
   10726 			"(", "category", "c255", ")",
   10727 			"(", "categoryorder", "(", "c0", "c255", ")", ")", NULL};
   10728 
   10729 	struct cil_tree *test_tree;
   10730 	gen_test_tree(&test_tree, line);
   10731 
   10732 	struct cil_db *test_db;
   10733 	cil_db_init(&test_db);
   10734 
   10735 	struct cil_tree_node *test_ast_node;
   10736 	cil_tree_node_init(&test_ast_node);
   10737 
   10738 	test_ast_node->parent = test_db->ast->root;
   10739 	test_ast_node->line = 1;
   10740 
   10741 	int rc = cil_gen_catorder(test_db, test_tree->root->cl_head->next->next->cl_head, test_ast_node);
   10742 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   10743 }
   10744 
   10745 void test_cil_gen_catorder_dbnull_neg(CuTest *tc) {
   10746 	char *line[] = {"(", "category", "c0", ")",
   10747 			"(", "category", "c255", ")",
   10748 			"(", "categoryorder", "(", "c0", "c255", ")", ")", NULL};
   10749 
   10750 	struct cil_tree *test_tree;
   10751 	gen_test_tree(&test_tree, line);
   10752 
   10753 	struct cil_db *test_db = NULL;
   10754 
   10755 	struct cil_tree_node *test_ast_node;
   10756 	cil_tree_node_init(&test_ast_node);
   10757 
   10758 	int rc = cil_gen_catorder(test_db, test_tree->root->cl_head->next->next->cl_head, test_ast_node);
   10759 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   10760 }
   10761 
   10762 void test_cil_gen_catorder_currnull_neg(CuTest *tc) {
   10763 	char *line[] = {"(", "category", "c0", ")",
   10764 			"(", "category", "c255", ")",
   10765 			"(", ")", NULL};
   10766 
   10767 	struct cil_tree *test_tree;
   10768 	gen_test_tree(&test_tree, line);
   10769 
   10770 	struct cil_db *test_db;
   10771 	cil_db_init(&test_db);
   10772 
   10773 	struct cil_tree_node *test_ast_node;
   10774 	cil_tree_node_init(&test_ast_node);
   10775 
   10776 	test_ast_node->parent = test_db->ast->root;
   10777 	test_ast_node->line = 1;
   10778 
   10779 	int rc = cil_gen_catorder(test_db, test_tree->root->cl_head->next->next->cl_head, test_ast_node);
   10780 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   10781 }
   10782 
   10783 void test_cil_gen_catorder_astnull_neg(CuTest *tc) {
   10784 	char *line[] = {"(", "category", "c0", ")",
   10785 			"(", "category", "c255", ")",
   10786 			"(", "categoryorder", "(", "c0", "c255", ")", ")", NULL};
   10787 
   10788 	struct cil_tree *test_tree;
   10789 	gen_test_tree(&test_tree, line);
   10790 
   10791 	struct cil_db *test_db;
   10792 	cil_db_init(&test_db);
   10793 
   10794 	struct cil_tree_node *test_ast_node = NULL;
   10795 
   10796 	int rc = cil_gen_catorder(test_db, test_tree->root->cl_head->next->next->cl_head, test_ast_node);
   10797 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   10798 }
   10799 
   10800 void test_cil_gen_catorder_missingcats_neg(CuTest *tc) {
   10801 	char *line[] = {"(", "category", "c0", ")",
   10802 			"(", "category", "c255", ")",
   10803 			"(", "categoryorder", ")", NULL};
   10804 
   10805 	struct cil_tree *test_tree;
   10806 	gen_test_tree(&test_tree, line);
   10807 
   10808 	struct cil_db *test_db;
   10809 	cil_db_init(&test_db);
   10810 
   10811 	struct cil_tree_node *test_ast_node;
   10812 	cil_tree_node_init(&test_ast_node);
   10813 
   10814 	test_ast_node->parent = test_db->ast->root;
   10815 	test_ast_node->line = 1;
   10816 
   10817 	int rc = cil_gen_catorder(test_db, test_tree->root->cl_head->next->next->cl_head, test_ast_node);
   10818 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   10819 }
   10820 
   10821 void test_cil_gen_catorder_nosublist_neg(CuTest *tc) {
   10822 	char *line[] = {"(", "category", "c0", ")",
   10823 			"(", "category", "c255", ")",
   10824 			"(", "categoryorder", "c0", "c255", ")", NULL};
   10825 
   10826 	struct cil_tree *test_tree;
   10827 	gen_test_tree(&test_tree, line);
   10828 
   10829 	struct cil_db *test_db;
   10830 	cil_db_init(&test_db);
   10831 
   10832 	struct cil_tree_node *test_ast_node;
   10833 	cil_tree_node_init(&test_ast_node);
   10834 
   10835 	test_ast_node->parent = test_db->ast->root;
   10836 	test_ast_node->line = 1;
   10837 
   10838 	int rc = cil_gen_catorder(test_db, test_tree->root->cl_head->next->next->cl_head, test_ast_node);
   10839 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   10840 }
   10841 
   10842 void test_cil_gen_catorder_nestedcat_neg(CuTest *tc) {
   10843 	char *line[] = {"(", "category", "c0", ")",
   10844 			"(", "category", "c255", ")",
   10845 			"(", "categoryorder", "(", "c0", "(", "c255", ")", ")", ")", NULL};
   10846 
   10847 	struct cil_tree *test_tree;
   10848 	gen_test_tree(&test_tree, line);
   10849 
   10850 	struct cil_db *test_db;
   10851 	cil_db_init(&test_db);
   10852 
   10853 	struct cil_tree_node *test_ast_node;
   10854 	cil_tree_node_init(&test_ast_node);
   10855 
   10856 	test_ast_node->parent = test_db->ast->root;
   10857 	test_ast_node->line = 1;
   10858 
   10859 	int rc = cil_gen_catorder(test_db, test_tree->root->cl_head->next->next->cl_head, test_ast_node);
   10860 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   10861 }
   10862 
   10863 void test_cil_gen_dominance(CuTest *tc) {
   10864         char *line[] = {"(", "sensitivity", "s0", ")",
   10865                         "(", "sensitivity", "s1", ")",
   10866                         "(", "sensitivity", "s2", ")",
   10867                         "(", "dominance", "(", "s0", "s1", ")", ")", NULL};
   10868 
   10869         struct cil_tree *test_tree;
   10870         gen_test_tree(&test_tree, line);
   10871 
   10872         struct cil_tree_node *test_ast_node;
   10873         cil_tree_node_init(&test_ast_node);
   10874 
   10875         struct cil_db *test_db;
   10876         cil_db_init(&test_db);
   10877 
   10878         test_ast_node->parent = test_db->ast->root;
   10879         test_ast_node->line = 1;
   10880 
   10881         int rc = cil_gen_dominance(test_db, test_tree->root->cl_head->next->next->next->cl_head, test_ast_node);
   10882         CuAssertIntEquals(tc, SEPOL_OK, rc);
   10883 }
   10884 
   10885 void test_cil_gen_dominance_dbnull_neg(CuTest *tc) {
   10886 	char *line[] = {"(", "sensitivity", "s0", ")",
   10887 			"(", "sensitivity", "s1", ")",
   10888 			"(", "sensitivity", "s2", ")",
   10889 			"(", "dominance", "(", "s0", "s1", ")", ")", NULL};
   10890 
   10891         struct cil_tree *test_tree;
   10892         gen_test_tree(&test_tree, line);
   10893 
   10894         struct cil_tree_node *test_ast_node;
   10895         cil_tree_node_init(&test_ast_node);
   10896 
   10897         struct cil_db *test_db = NULL;
   10898 
   10899         int rc = cil_gen_dominance(test_db, test_tree->root->cl_head->next->next->next->cl_head, test_ast_node);
   10900         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   10901 }
   10902 
   10903 void test_cil_gen_dominance_currnull_neg(CuTest *tc) {
   10904 	char *line[] = {"(", "sensitivity", "s0", ")",
   10905 			"(", "sensitivity", "s1", ")",
   10906 			"(", "sensitivity", "s2", ")",
   10907 			"(", ")", NULL};
   10908 
   10909         struct cil_tree *test_tree;
   10910         gen_test_tree(&test_tree, line);
   10911 
   10912         struct cil_tree_node *test_ast_node;
   10913         cil_tree_node_init(&test_ast_node);
   10914 
   10915         struct cil_db *test_db;
   10916         cil_db_init(&test_db);
   10917 
   10918         test_ast_node->parent = test_db->ast->root;
   10919         test_ast_node->line = 1;
   10920 
   10921         int rc = cil_gen_dominance(test_db, test_tree->root->cl_head->next->next->next->cl_head, test_ast_node);
   10922         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   10923 }
   10924 
   10925 void test_cil_gen_dominance_astnull_neg(CuTest *tc) {
   10926 	char *line[] = {"(", "sensitivity", "s0", ")",
   10927 			"(", "sensitivity", "s1", ")",
   10928 			"(", "sensitivity", "s2", ")",
   10929 			"(", "dominance", "(", "s0", "s1", ")", ")", NULL};
   10930 
   10931         struct cil_tree *test_tree;
   10932         gen_test_tree(&test_tree, line);
   10933 
   10934         struct cil_tree_node *test_ast_node = NULL;
   10935 
   10936         struct cil_db *test_db;
   10937         cil_db_init(&test_db);
   10938 
   10939         int rc = cil_gen_dominance(test_db, test_tree->root->cl_head->next->next->next->cl_head, test_ast_node);
   10940         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   10941 }
   10942 
   10943 void test_cil_gen_dominance_nosensitivities_neg(CuTest *tc) {
   10944 	char *line[] = {"(", "sensitivity", "s0", ")",
   10945 			"(", "sensitivity", "s1", ")",
   10946 			"(", "sensitivity", "s2", ")",
   10947 			"(", "dominance", ")", NULL};
   10948 
   10949         struct cil_tree *test_tree;
   10950         gen_test_tree(&test_tree, line);
   10951 
   10952         struct cil_tree_node *test_ast_node;
   10953         cil_tree_node_init(&test_ast_node);
   10954 
   10955         struct cil_db *test_db;
   10956         cil_db_init(&test_db);
   10957 
   10958         test_ast_node->parent = test_db->ast->root;
   10959         test_ast_node->line = 1;
   10960 
   10961         int rc = cil_gen_dominance(test_db, test_tree->root->cl_head->next->next->next->cl_head, test_ast_node);
   10962         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   10963 }
   10964 
   10965 void test_cil_gen_dominance_nosublist_neg(CuTest *tc) {
   10966 	char *line[] = {"(", "sensitivity", "s0", ")",
   10967 			"(", "sensitivity", "s1", ")",
   10968 			"(", "sensitivity", "s2", ")",
   10969 			"(", "dominance", "s0", "s2", ")", NULL};
   10970 
   10971         struct cil_tree *test_tree;
   10972         gen_test_tree(&test_tree, line);
   10973 
   10974         struct cil_tree_node *test_ast_node;
   10975         cil_tree_node_init(&test_ast_node);
   10976 
   10977         struct cil_db *test_db;
   10978         cil_db_init(&test_db);
   10979 
   10980         test_ast_node->parent = test_db->ast->root;
   10981         test_ast_node->line = 1;
   10982 
   10983         int rc = cil_gen_dominance(test_db, test_tree->root->cl_head->next->next->next->cl_head, test_ast_node);
   10984         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   10985 }
   10986 
   10987 void test_cil_gen_senscat(CuTest *tc) {
   10988 	char *line[] = {"(", "sensitivity", "s0", ")",
   10989                         "(", "sensitivity", "s1", ")",
   10990                         "(", "dominance", "(", "s0", "s1", ")", ")",
   10991 			"(", "category", "c0", ")",
   10992 			"(", "category", "c255", ")",
   10993 			"(", "categoryorder", "(", "c0", "c255", ")", ")",
   10994 			"(", "sensitivitycategory", "s1", "(", "c0", "c255", ")", ")", NULL};
   10995 
   10996         struct cil_tree *test_tree;
   10997         gen_test_tree(&test_tree, line);
   10998 
   10999         struct cil_tree_node *test_ast_node;
   11000         cil_tree_node_init(&test_ast_node);
   11001 
   11002         struct cil_db *test_db;
   11003         cil_db_init(&test_db);
   11004 
   11005         test_ast_node->parent = test_db->ast->root;
   11006         test_ast_node->line = 1;
   11007 
   11008         int rc = cil_gen_senscat(test_db, test_tree->root->cl_head->next->next->next->next->next->next->cl_head, test_ast_node);
   11009         CuAssertIntEquals(tc, SEPOL_OK, rc);
   11010 }
   11011 
   11012 void test_cil_gen_senscat_nosublist(CuTest *tc) {
   11013 	char *line[] = {"(", "sensitivitycategory", "s1", "c0", "c255", ")", NULL};
   11014 
   11015         struct cil_tree *test_tree;
   11016         gen_test_tree(&test_tree, line);
   11017 
   11018         struct cil_tree_node *test_ast_node;
   11019         cil_tree_node_init(&test_ast_node);
   11020 
   11021         struct cil_db *test_db;
   11022         cil_db_init(&test_db);
   11023 
   11024         test_ast_node->parent = test_db->ast->root;
   11025         test_ast_node->line = 1;
   11026 
   11027         int rc = cil_gen_senscat(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   11028         CuAssertIntEquals(tc, SEPOL_OK, rc);
   11029 }
   11030 
   11031 void test_cil_gen_senscat_dbnull_neg(CuTest *tc) {
   11032 	char *line[] = {"(", "sensitivity", "s0", ")",
   11033                         "(", "sensitivity", "s1", ")",
   11034                         "(", "dominance", "(", "s0", "s1", ")", ")",
   11035 			"(", "category", "c0", ")",
   11036 			"(", "category", "c255", ")",
   11037 			"(", "categoryorder", "(", "c0", "c255", ")", ")",
   11038 			"(", "sensitivitycategory", "s1", "(", "c0", "c255", ")", ")", NULL};
   11039 
   11040         struct cil_tree *test_tree;
   11041         gen_test_tree(&test_tree, line);
   11042 
   11043         struct cil_tree_node *test_ast_node;
   11044         cil_tree_node_init(&test_ast_node);
   11045 
   11046         struct cil_db *test_db = NULL;
   11047 
   11048         int rc = cil_gen_senscat(test_db, test_tree->root->cl_head->next->next->next->next->next->next->cl_head, test_ast_node);
   11049         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   11050 }
   11051 
   11052 void test_cil_gen_senscat_currnull_neg(CuTest *tc) {
   11053 	char *line[] = {"(", "sensitivity", "s0", ")",
   11054                         "(", "sensitivity", "s1", ")",
   11055                         "(", "dominance", "(", "s0", "s1", ")", ")",
   11056 			"(", "category", "c0", ")",
   11057 			"(", "category", "c255", ")",
   11058 			"(", "categoryorder", "(", "c0", "c255", ")", ")",
   11059 			"(", ")", NULL};
   11060 
   11061         struct cil_tree *test_tree;
   11062         gen_test_tree(&test_tree, line);
   11063 
   11064         struct cil_tree_node *test_ast_node;
   11065         cil_tree_node_init(&test_ast_node);
   11066 
   11067         struct cil_db *test_db;
   11068         cil_db_init(&test_db);
   11069 
   11070         test_ast_node->parent = test_db->ast->root;
   11071         test_ast_node->line = 1;
   11072 
   11073         int rc = cil_gen_senscat(test_db, test_tree->root->cl_head->next->next->next->next->next->next->cl_head, test_ast_node);
   11074         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   11075 }
   11076 
   11077 void test_cil_gen_senscat_astnull_neg(CuTest *tc) {
   11078 	char *line[] = {"(", "sensitivity", "s0", ")",
   11079                         "(", "sensitivity", "s1", ")",
   11080                         "(", "dominance", "(", "s0", "s1", ")", ")",
   11081 			"(", "category", "c0", ")",
   11082 			"(", "category", "c255", ")",
   11083 			"(", "categoryorder", "(", "c0", "c255", ")", ")",
   11084 			"(", "sensitivitycategory", "s1", "(", "c0", "c255", ")", ")", NULL};
   11085 
   11086         struct cil_tree *test_tree;
   11087         gen_test_tree(&test_tree, line);
   11088 
   11089         struct cil_tree_node *test_ast_node = NULL;
   11090 
   11091         struct cil_db *test_db;
   11092         cil_db_init(&test_db);
   11093 
   11094         int rc = cil_gen_senscat(test_db, test_tree->root->cl_head->next->next->next->next->next->next->cl_head, test_ast_node);
   11095         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   11096 }
   11097 
   11098 void test_cil_gen_senscat_nosensitivities_neg(CuTest *tc) {
   11099 	char *line[] = {"(", "sensitivity", "s0", ")",
   11100                         "(", "sensitivity", "s1", ")",
   11101                         "(", "dominance", "(", "s0", "s1", ")", ")",
   11102 			"(", "category", "c0", ")",
   11103 			"(", "category", "c255", ")",
   11104 			"(", "categoryorder", "(", "c0", "c255", ")", ")",
   11105 			"(", "sensitivitycategory", ")", NULL};
   11106 
   11107         struct cil_tree *test_tree;
   11108         gen_test_tree(&test_tree, line);
   11109 
   11110         struct cil_tree_node *test_ast_node;
   11111         cil_tree_node_init(&test_ast_node);
   11112 
   11113         struct cil_db *test_db;
   11114         cil_db_init(&test_db);
   11115 
   11116         test_ast_node->parent = test_db->ast->root;
   11117         test_ast_node->line = 1;
   11118 
   11119         int rc = cil_gen_senscat(test_db, test_tree->root->cl_head->next->next->next->next->next->next->cl_head, test_ast_node);
   11120         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   11121 }
   11122 
   11123 void test_cil_gen_senscat_sublist_neg(CuTest *tc) {
   11124       char *line[] = {"(", "sensitivity", "s0", ")",
   11125                         "(", "sensitivity", "s1", ")",
   11126                         "(", "dominance", "(", "s0", "s1", ")", ")",
   11127                         "(", "category", "c0", ")",
   11128                         "(", "category", "c255", ")",
   11129                         "(", "categoryorder", "(", "c0", "c255", ")", ")",
   11130                         "(", "sensitivitycategory", "s1", "(", "c0", "(", "c255", ")", ")", ")", NULL};
   11131 
   11132 	struct cil_tree *test_tree;
   11133 	gen_test_tree(&test_tree, line);
   11134 
   11135 	struct cil_tree_node *test_ast_node;
   11136 	cil_tree_node_init(&test_ast_node);
   11137 
   11138 	struct cil_db *test_db;
   11139 	cil_db_init(&test_db);
   11140 
   11141 	int rc = cil_gen_senscat(test_db, test_tree->root->cl_head->next->next->next->next->next->next->cl_head, test_ast_node);
   11142 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   11143 }
   11144 
   11145 void test_cil_gen_senscat_nocat_neg(CuTest *tc) {
   11146       char *line[] = {"(", "sensitivitycategory", "s1", ")", NULL};
   11147 
   11148 	struct cil_tree *test_tree;
   11149 	gen_test_tree(&test_tree, line);
   11150 
   11151 	struct cil_tree_node *test_ast_node;
   11152 	cil_tree_node_init(&test_ast_node);
   11153 
   11154 	struct cil_db *test_db;
   11155 	cil_db_init(&test_db);
   11156 
   11157 	int rc = cil_gen_senscat(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   11158 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   11159 }
   11160 
   11161 void test_cil_fill_level(CuTest *tc) {
   11162 	char *line[] = {"(", "sensitivity", "s0", ")",
   11163 			"(", "category", "c1", ")",
   11164 			"(", "level", "low", "(", "s0", "(", "c1", ")", ")", ")", NULL};
   11165 
   11166         struct cil_tree *test_tree;
   11167         gen_test_tree(&test_tree, line);
   11168 
   11169         struct cil_tree_node *test_ast_node;
   11170         cil_tree_node_init(&test_ast_node);
   11171 
   11172         struct cil_db *test_db;
   11173         cil_db_init(&test_db);
   11174 
   11175         test_ast_node->parent = test_db->ast->root;
   11176         test_ast_node->line = 1;
   11177 
   11178 	struct cil_level *test_level;
   11179 	cil_level_init(&test_level);
   11180 
   11181         int rc = cil_fill_level(test_tree->root->cl_head->next->next->cl_head->next->next->cl_head, test_level);
   11182         CuAssertIntEquals(tc, SEPOL_OK, rc);
   11183 }
   11184 
   11185 void test_cil_fill_level_sensnull_neg(CuTest *tc) {
   11186 	char *line[] = {"(", "sensitivity", "s0", ")",
   11187 			"(", "category", "c1", ")",
   11188 			"(", "level", "low", ")", NULL};
   11189 
   11190         struct cil_tree *test_tree;
   11191         gen_test_tree(&test_tree, line);
   11192 
   11193         struct cil_tree_node *test_ast_node;
   11194         cil_tree_node_init(&test_ast_node);
   11195 
   11196         struct cil_db *test_db;
   11197         cil_db_init(&test_db);
   11198 
   11199         test_ast_node->parent = test_db->ast->root;
   11200         test_ast_node->line = 1;
   11201 
   11202 	struct cil_level *test_level;
   11203 	cil_level_init(&test_level);
   11204 
   11205         int rc = cil_fill_level(test_tree->root->cl_head->next->next->cl_head->next->next, test_level);
   11206         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   11207 }
   11208 
   11209 void test_cil_fill_level_levelnull_neg(CuTest *tc) {
   11210 	char *line[] = {"(", "sensitivity", "s0", ")",
   11211 			"(", "category", "c1", ")",
   11212 			"(", "level", "low", "(", "s0", "(", "c1", ")", ")", ")", NULL};
   11213 
   11214         struct cil_tree *test_tree;
   11215         gen_test_tree(&test_tree, line);
   11216 
   11217         struct cil_tree_node *test_ast_node;
   11218         cil_tree_node_init(&test_ast_node);
   11219 
   11220         struct cil_db *test_db;
   11221         cil_db_init(&test_db);
   11222 
   11223         test_ast_node->parent = test_db->ast->root;
   11224         test_ast_node->line = 1;
   11225 
   11226 	struct cil_level *test_level = NULL;
   11227 
   11228         int rc = cil_fill_level(test_tree->root->cl_head->next->next->cl_head->next->next->cl_head, test_level);
   11229         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   11230 }
   11231 
   11232 void test_cil_fill_level_nocat(CuTest *tc) {
   11233 	char *line[] = {"(", "sensitivity", "s0", ")",
   11234 			"(", "category", "c1", ")",
   11235 			"(", "level", "low", "(", "s0", ")", ")", NULL};
   11236 
   11237         struct cil_tree *test_tree;
   11238         gen_test_tree(&test_tree, line);
   11239 
   11240         struct cil_tree_node *test_ast_node;
   11241         cil_tree_node_init(&test_ast_node);
   11242 
   11243         struct cil_db *test_db;
   11244         cil_db_init(&test_db);
   11245 
   11246         test_ast_node->parent = test_db->ast->root;
   11247         test_ast_node->line = 1;
   11248 
   11249 	struct cil_level *test_level;
   11250 	cil_level_init(&test_level);
   11251 
   11252         int rc = cil_fill_level(test_tree->root->cl_head->next->next->cl_head->next->next->cl_head, test_level);
   11253         CuAssertIntEquals(tc, SEPOL_OK, rc);
   11254 }
   11255 
   11256 void test_cil_fill_level_emptycat_neg(CuTest *tc) {
   11257 	char *line[] = {"(", "sensitivity", "s0", ")",
   11258 			"(", "category", "c1", ")",
   11259 			"(", "level", "low", "(", "s0", "(", ")", ")", ")", NULL};
   11260 
   11261         struct cil_tree *test_tree;
   11262         gen_test_tree(&test_tree, line);
   11263 
   11264         struct cil_tree_node *test_ast_node;
   11265         cil_tree_node_init(&test_ast_node);
   11266 
   11267         struct cil_db *test_db;
   11268         cil_db_init(&test_db);
   11269 
   11270         test_ast_node->parent = test_db->ast->root;
   11271         test_ast_node->line = 1;
   11272 
   11273 	struct cil_level *test_level;
   11274 	cil_level_init(&test_level);
   11275 
   11276         int rc = cil_fill_level(test_tree->root->cl_head->next->next->cl_head->next->next->cl_head, test_level);
   11277         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   11278 }
   11279 
   11280 void test_cil_gen_level(CuTest *tc) {
   11281 	char *line[] = {"(", "sensitivity", "s0", ")",
   11282 			"(", "category", "c1", ")",
   11283 			"(", "level", "low", "(", "s0", "(", "c1", ")", ")", ")", NULL};
   11284 
   11285         struct cil_tree *test_tree;
   11286         gen_test_tree(&test_tree, line);
   11287 
   11288         struct cil_tree_node *test_ast_node;
   11289         cil_tree_node_init(&test_ast_node);
   11290 
   11291         struct cil_db *test_db;
   11292         cil_db_init(&test_db);
   11293 
   11294         test_ast_node->parent = test_db->ast->root;
   11295         test_ast_node->line = 1;
   11296 
   11297         int rc = cil_gen_level(test_db, test_tree->root->cl_head->next->next->cl_head, test_ast_node);
   11298         CuAssertIntEquals(tc, SEPOL_OK, rc);
   11299 }
   11300 
   11301 void test_cil_gen_level_nameinparens_neg(CuTest *tc) {
   11302 	char *line[] = {"(", "level", "(", "low", ")", ")", NULL};
   11303 
   11304         struct cil_tree *test_tree;
   11305         gen_test_tree(&test_tree, line);
   11306 
   11307         struct cil_tree_node *test_ast_node;
   11308         cil_tree_node_init(&test_ast_node);
   11309 
   11310         struct cil_db *test_db;
   11311         cil_db_init(&test_db);
   11312 
   11313         test_ast_node->parent = test_db->ast->root;
   11314         test_ast_node->line = 1;
   11315 
   11316         int rc = cil_gen_level(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   11317         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   11318 }
   11319 
   11320 void test_cil_gen_level_emptysensparens_neg(CuTest *tc) {
   11321 	char *line[] = {"(", "level", "low", "(", ")", ")", NULL};
   11322 
   11323         struct cil_tree *test_tree;
   11324         gen_test_tree(&test_tree, line);
   11325 
   11326         struct cil_tree_node *test_ast_node;
   11327         cil_tree_node_init(&test_ast_node);
   11328 
   11329         struct cil_db *test_db;
   11330         cil_db_init(&test_db);
   11331 
   11332         test_ast_node->parent = test_db->ast->root;
   11333         test_ast_node->line = 1;
   11334 
   11335         int rc = cil_gen_level(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   11336         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   11337 }
   11338 
   11339 void test_cil_gen_level_extra_neg(CuTest *tc) {
   11340 	char *line[] = {"(", "level", "low", "(", "s0", "(", "c0", ")", ")", "extra", ")", NULL};
   11341 
   11342         struct cil_tree *test_tree;
   11343         gen_test_tree(&test_tree, line);
   11344 
   11345         struct cil_tree_node *test_ast_node;
   11346         cil_tree_node_init(&test_ast_node);
   11347 
   11348         struct cil_db *test_db;
   11349         cil_db_init(&test_db);
   11350 
   11351         test_ast_node->parent = test_db->ast->root;
   11352         test_ast_node->line = 1;
   11353 
   11354         int rc = cil_gen_level(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   11355         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   11356 }
   11357 
   11358 void test_cil_gen_level_emptycat_neg(CuTest *tc) {
   11359 	char *line[] = {"(", "sensitivity", "s0", ")",
   11360 			"(", "category", "c1", ")",
   11361 			"(", "level", "low", "(", "s0", "(", ")", ")", ")", NULL};
   11362 
   11363         struct cil_tree *test_tree;
   11364         gen_test_tree(&test_tree, line);
   11365 
   11366         struct cil_tree_node *test_ast_node;
   11367         cil_tree_node_init(&test_ast_node);
   11368 
   11369         struct cil_db *test_db;
   11370         cil_db_init(&test_db);
   11371 
   11372         test_ast_node->parent = test_db->ast->root;
   11373         test_ast_node->line = 1;
   11374 
   11375         int rc = cil_gen_level(test_db, test_tree->root->cl_head->next->next->cl_head, test_ast_node);
   11376         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   11377 }
   11378 
   11379 void test_cil_gen_level_noname_neg(CuTest *tc) {
   11380 	char *line[] = {"(", "sensitivity", "s0", ")",
   11381 			"(", "category", "c1", ")",
   11382 			"(", "level", ")", NULL};
   11383 
   11384         struct cil_tree *test_tree;
   11385         gen_test_tree(&test_tree, line);
   11386 
   11387         struct cil_tree_node *test_ast_node;
   11388         cil_tree_node_init(&test_ast_node);
   11389 
   11390         struct cil_db *test_db;
   11391         cil_db_init(&test_db);
   11392 
   11393         test_ast_node->parent = test_db->ast->root;
   11394         test_ast_node->line = 1;
   11395 
   11396         int rc = cil_gen_level(test_db, test_tree->root->cl_head->next->next->cl_head, test_ast_node);
   11397         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   11398 }
   11399 
   11400 void test_cil_gen_level_nosens_neg(CuTest *tc) {
   11401 	char *line[] = {"(", "sensitivity", "s0", ")",
   11402 			"(", "category", "c1", ")",
   11403 			"(", "level", "low", NULL};
   11404 
   11405         struct cil_tree *test_tree;
   11406         gen_test_tree(&test_tree, line);
   11407 
   11408         struct cil_tree_node *test_ast_node;
   11409         cil_tree_node_init(&test_ast_node);
   11410 
   11411         struct cil_db *test_db;
   11412         cil_db_init(&test_db);
   11413 
   11414         test_ast_node->parent = test_db->ast->root;
   11415         test_ast_node->line = 1;
   11416 
   11417         int rc = cil_gen_level(test_db, test_tree->root->cl_head->next->next->cl_head, test_ast_node);
   11418         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   11419 }
   11420 
   11421 void test_cil_gen_level_dbnull_neg(CuTest *tc) {
   11422 	char *line[] = {"(", "sensitivity", "s0", ")",
   11423 			"(", "category", "c1", ")",
   11424 			"(", "level", "low", "(", "s0", "(", "c1", ")", ")", ")", NULL};
   11425 
   11426         struct cil_tree *test_tree;
   11427         gen_test_tree(&test_tree, line);
   11428 
   11429         struct cil_tree_node *test_ast_node;
   11430         cil_tree_node_init(&test_ast_node);
   11431 
   11432         struct cil_db *test_db = NULL;
   11433 
   11434         int rc = cil_gen_level(test_db, test_tree->root->cl_head->next->next->cl_head, test_ast_node);
   11435         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   11436 }
   11437 
   11438 void test_cil_gen_level_currnull_neg(CuTest *tc) {
   11439 	char *line[] = {"(", "sensitivity", "s0", ")",
   11440 			"(", "category", "c1", ")",
   11441 			"(", ")", NULL};
   11442 
   11443         struct cil_tree *test_tree;
   11444         gen_test_tree(&test_tree, line);
   11445 
   11446         struct cil_tree_node *test_ast_node;
   11447         cil_tree_node_init(&test_ast_node);
   11448 
   11449         struct cil_db *test_db;
   11450         cil_db_init(&test_db);
   11451 
   11452         test_ast_node->parent = test_db->ast->root;
   11453         test_ast_node->line = 1;
   11454 
   11455         int rc = cil_gen_level(test_db, test_tree->root->cl_head->next->next->cl_head, test_ast_node);
   11456         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   11457 }
   11458 
   11459 void test_cil_gen_level_astnull_neg(CuTest *tc) {
   11460 	char *line[] = {"(", "sensitivity", "s0", ")",
   11461 			"(", "category", "c1", ")",
   11462 			"(", "level", "low", "(", "s0", "(", "c1", ")", ")", ")", NULL};
   11463 
   11464         struct cil_tree *test_tree;
   11465         gen_test_tree(&test_tree, line);
   11466 
   11467         struct cil_tree_node *test_ast_node = NULL;
   11468 
   11469         struct cil_db *test_db;
   11470         cil_db_init(&test_db);
   11471 
   11472         int rc = cil_gen_level(test_db, test_tree->root->cl_head->next->next->cl_head, test_ast_node);
   11473         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   11474 }
   11475 
   11476 void test_cil_gen_levelrange(CuTest *tc) {
   11477 	char *line[] = {"(", "levelrange", "range", "(", "low", "high", ")", ")", NULL};
   11478 
   11479         struct cil_tree *test_tree;
   11480         gen_test_tree(&test_tree, line);
   11481 
   11482         struct cil_tree_node *test_ast_node;
   11483         cil_tree_node_init(&test_ast_node);
   11484 
   11485         struct cil_db *test_db;
   11486         cil_db_init(&test_db);
   11487 
   11488         test_ast_node->parent = test_db->ast->root;
   11489         test_ast_node->line = 1;
   11490 
   11491         int rc = cil_gen_levelrange(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   11492         CuAssertIntEquals(tc, SEPOL_OK, rc);
   11493 }
   11494 
   11495 void test_cil_gen_levelrange_rangeinvalid_neg(CuTest *tc) {
   11496 	char *line[] = {"(", "levelrange", "range", "(", "low", "high", "extra", ")", ")", NULL};
   11497 
   11498         struct cil_tree *test_tree;
   11499         gen_test_tree(&test_tree, line);
   11500 
   11501         struct cil_tree_node *test_ast_node;
   11502         cil_tree_node_init(&test_ast_node);
   11503 
   11504         struct cil_db *test_db;
   11505         cil_db_init(&test_db);
   11506 
   11507         test_ast_node->parent = test_db->ast->root;
   11508         test_ast_node->line = 1;
   11509 
   11510         int rc = cil_gen_levelrange(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   11511         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   11512 }
   11513 
   11514 void test_cil_gen_levelrange_namenull_neg(CuTest *tc) {
   11515 	char *line[] = {"(", "levelrange", ")", NULL};
   11516 
   11517         struct cil_tree *test_tree;
   11518         gen_test_tree(&test_tree, line);
   11519 
   11520         struct cil_tree_node *test_ast_node;
   11521         cil_tree_node_init(&test_ast_node);
   11522 
   11523         struct cil_db *test_db;
   11524         cil_db_init(&test_db);
   11525 
   11526         test_ast_node->parent = test_db->ast->root;
   11527         test_ast_node->line = 1;
   11528 
   11529         int rc = cil_gen_levelrange(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   11530         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   11531 }
   11532 
   11533 void test_cil_gen_levelrange_rangenull_neg(CuTest *tc) {
   11534 	char *line[] = {"(", "levelrange", "range", ")", NULL};
   11535 
   11536         struct cil_tree *test_tree;
   11537         gen_test_tree(&test_tree, line);
   11538 
   11539         struct cil_tree_node *test_ast_node;
   11540         cil_tree_node_init(&test_ast_node);
   11541 
   11542         struct cil_db *test_db;
   11543         cil_db_init(&test_db);
   11544 
   11545         test_ast_node->parent = test_db->ast->root;
   11546         test_ast_node->line = 1;
   11547 
   11548         int rc = cil_gen_levelrange(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   11549         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   11550 }
   11551 
   11552 void test_cil_gen_levelrange_rangeempty_neg(CuTest *tc) {
   11553 	char *line[] = {"(", "levelrange", "range", "(", ")", ")", NULL};
   11554 
   11555         struct cil_tree *test_tree;
   11556         gen_test_tree(&test_tree, line);
   11557 
   11558         struct cil_tree_node *test_ast_node;
   11559         cil_tree_node_init(&test_ast_node);
   11560 
   11561         struct cil_db *test_db;
   11562         cil_db_init(&test_db);
   11563 
   11564         test_ast_node->parent = test_db->ast->root;
   11565         test_ast_node->line = 1;
   11566 
   11567         int rc = cil_gen_levelrange(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   11568         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   11569 }
   11570 
   11571 void test_cil_gen_levelrange_extra_neg(CuTest *tc) {
   11572 	char *line[] = {"(", "levelrange", "range", "(", "low", "high", ")", "extra", ")", NULL};
   11573 
   11574         struct cil_tree *test_tree;
   11575         gen_test_tree(&test_tree, line);
   11576 
   11577         struct cil_tree_node *test_ast_node;
   11578         cil_tree_node_init(&test_ast_node);
   11579 
   11580         struct cil_db *test_db;
   11581         cil_db_init(&test_db);
   11582 
   11583         test_ast_node->parent = test_db->ast->root;
   11584         test_ast_node->line = 1;
   11585 
   11586         int rc = cil_gen_levelrange(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   11587         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   11588 }
   11589 
   11590 void test_cil_gen_levelrange_dbnull_neg(CuTest *tc) {
   11591 	char *line[] = {"(", "levelrange", "range", "(", "low", "high", ")", ")", NULL};
   11592 
   11593         struct cil_tree *test_tree;
   11594         gen_test_tree(&test_tree, line);
   11595 
   11596         struct cil_tree_node *test_ast_node;
   11597         cil_tree_node_init(&test_ast_node);
   11598 
   11599         struct cil_db *test_db = NULL;
   11600 
   11601         int rc = cil_gen_levelrange(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   11602         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   11603 }
   11604 
   11605 void test_cil_gen_levelrange_currnull_neg(CuTest *tc) {
   11606 	char *line[] = {"(", ")", NULL};
   11607 
   11608         struct cil_tree *test_tree;
   11609         gen_test_tree(&test_tree, line);
   11610 
   11611         struct cil_tree_node *test_ast_node;
   11612         cil_tree_node_init(&test_ast_node);
   11613 
   11614         struct cil_db *test_db;
   11615         cil_db_init(&test_db);
   11616 
   11617         test_ast_node->parent = test_db->ast->root;
   11618         test_ast_node->line = 1;
   11619 
   11620         int rc = cil_gen_levelrange(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   11621         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   11622 }
   11623 
   11624 void test_cil_gen_levelrange_astnull_neg(CuTest *tc) {
   11625 	char *line[] = {"(", "levelrange", "range", "(", "low", "high", ")", ")", NULL};
   11626 
   11627         struct cil_tree *test_tree;
   11628         gen_test_tree(&test_tree, line);
   11629 
   11630         struct cil_tree_node *test_ast_node = NULL;
   11631 
   11632         struct cil_db *test_db;
   11633         cil_db_init(&test_db);
   11634 
   11635         int rc = cil_gen_levelrange(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   11636         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   11637 }
   11638 
   11639 void test_cil_gen_constrain(CuTest *tc) {
   11640 	char *line[] = {"(", "mlsconstrain", "(", "file", "(", "create", "relabelto", ")", ")", "(", "eq", "l2", "h2", ")", ")", NULL};
   11641 
   11642         struct cil_tree *test_tree;
   11643         gen_test_tree(&test_tree, line);
   11644 
   11645         struct cil_tree_node *test_ast_node;
   11646         cil_tree_node_init(&test_ast_node);
   11647 
   11648         struct cil_db *test_db;
   11649         cil_db_init(&test_db);
   11650 
   11651         test_ast_node->parent = test_db->ast->root;
   11652         test_ast_node->line = 1;
   11653 
   11654         int rc = cil_gen_constrain(test_db, test_tree->root->cl_head->cl_head, test_ast_node, CIL_MLSCONSTRAIN);
   11655         CuAssertIntEquals(tc, SEPOL_OK, rc);
   11656 }
   11657 
   11658 void test_cil_gen_constrain_neg(CuTest *tc) {
   11659 	char *line[] = {"(", "mlsconstrain", "(", "file", "(", "create", "relabelto", ")", ")", "(", "dne", "l1", "l2", ")", ")", NULL};
   11660 
   11661         struct cil_tree *test_tree;
   11662         gen_test_tree(&test_tree, line);
   11663 
   11664         struct cil_tree_node *test_ast_node;
   11665         cil_tree_node_init(&test_ast_node);
   11666 
   11667         struct cil_db *test_db;
   11668         cil_db_init(&test_db);
   11669 
   11670         test_ast_node->parent = test_db->ast->root;
   11671         test_ast_node->line = 1;
   11672 
   11673         int rc = cil_gen_constrain(test_db, test_tree->root->cl_head->cl_head, test_ast_node, CIL_MLSCONSTRAIN);
   11674         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   11675 }
   11676 
   11677 void test_cil_gen_constrain_classset_neg(CuTest *tc) {
   11678 	char *line[] = {"(", "mlsconstrain", ")", NULL};
   11679 
   11680         struct cil_tree *test_tree;
   11681         gen_test_tree(&test_tree, line);
   11682 
   11683         struct cil_tree_node *test_ast_node;
   11684         cil_tree_node_init(&test_ast_node);
   11685 
   11686         struct cil_db *test_db;
   11687         cil_db_init(&test_db);
   11688 
   11689         test_ast_node->parent = test_db->ast->root;
   11690         test_ast_node->line = 1;
   11691 
   11692         int rc = cil_gen_constrain(test_db, test_tree->root->cl_head->cl_head, test_ast_node, CIL_MLSCONSTRAIN);
   11693         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   11694 }
   11695 
   11696 void test_cil_gen_constrain_classset_noclass_neg(CuTest *tc) {
   11697 	char *line[] = {"(", "mlsconstrain", "(", ")", ")", NULL};
   11698 
   11699         struct cil_tree *test_tree;
   11700         gen_test_tree(&test_tree, line);
   11701 
   11702         struct cil_tree_node *test_ast_node;
   11703         cil_tree_node_init(&test_ast_node);
   11704 
   11705         struct cil_db *test_db;
   11706         cil_db_init(&test_db);
   11707 
   11708         test_ast_node->parent = test_db->ast->root;
   11709         test_ast_node->line = 1;
   11710 
   11711         int rc = cil_gen_constrain(test_db, test_tree->root->cl_head->cl_head, test_ast_node, CIL_MLSCONSTRAIN);
   11712         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   11713 }
   11714 
   11715 void test_cil_gen_constrain_classset_noperm_neg(CuTest *tc) {
   11716 	char *line[] = {"(", "mlsconstrain", "(", "file", ")", ")", NULL};
   11717 
   11718         struct cil_tree *test_tree;
   11719         gen_test_tree(&test_tree, line);
   11720 
   11721         struct cil_tree_node *test_ast_node;
   11722         cil_tree_node_init(&test_ast_node);
   11723 
   11724         struct cil_db *test_db;
   11725         cil_db_init(&test_db);
   11726 
   11727         test_ast_node->parent = test_db->ast->root;
   11728         test_ast_node->line = 1;
   11729 
   11730         int rc = cil_gen_constrain(test_db, test_tree->root->cl_head->cl_head, test_ast_node, CIL_MLSCONSTRAIN);
   11731         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   11732 }
   11733 
   11734 void test_cil_gen_constrain_permset_neg(CuTest *tc) {
   11735 	char *line[] = {"(", "mlsconstrain", "(", "file", "dir", ")", ")", NULL};
   11736 
   11737         struct cil_tree *test_tree;
   11738         gen_test_tree(&test_tree, line);
   11739 
   11740         struct cil_tree_node *test_ast_node;
   11741         cil_tree_node_init(&test_ast_node);
   11742 
   11743         struct cil_db *test_db;
   11744         cil_db_init(&test_db);
   11745 
   11746         test_ast_node->parent = test_db->ast->root;
   11747         test_ast_node->line = 1;
   11748 
   11749         int rc = cil_gen_constrain(test_db, test_tree->root->cl_head->cl_head, test_ast_node, CIL_MLSCONSTRAIN);
   11750         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   11751 }
   11752 
   11753 void test_cil_gen_constrain_permset_noclass_neg(CuTest *tc) {
   11754 	char *line[] = {"(", "mlsconstrain", "(", "file", "dir", ")", "(", ")", ")", NULL};
   11755 
   11756         struct cil_tree *test_tree;
   11757         gen_test_tree(&test_tree, line);
   11758 
   11759         struct cil_tree_node *test_ast_node;
   11760         cil_tree_node_init(&test_ast_node);
   11761 
   11762         struct cil_db *test_db;
   11763         cil_db_init(&test_db);
   11764 
   11765         test_ast_node->parent = test_db->ast->root;
   11766         test_ast_node->line = 1;
   11767 
   11768         int rc = cil_gen_constrain(test_db, test_tree->root->cl_head->cl_head, test_ast_node, CIL_MLSCONSTRAIN);
   11769         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   11770 }
   11771 
   11772 void test_cil_gen_constrain_permset_noperm_neg(CuTest *tc) {
   11773 	char *line[] = {"(", "mlsconstrain", "(", "file", "dir", ")", "(", "create", ")", ")", NULL};
   11774 
   11775         struct cil_tree *test_tree;
   11776         gen_test_tree(&test_tree, line);
   11777 
   11778         struct cil_tree_node *test_ast_node;
   11779         cil_tree_node_init(&test_ast_node);
   11780 
   11781         struct cil_db *test_db;
   11782         cil_db_init(&test_db);
   11783 
   11784         test_ast_node->parent = test_db->ast->root;
   11785         test_ast_node->line = 1;
   11786 
   11787         int rc = cil_gen_constrain(test_db, test_tree->root->cl_head->cl_head, test_ast_node, CIL_MLSCONSTRAIN);
   11788         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   11789 }
   11790 
   11791 void test_cil_gen_constrain_expression_neg(CuTest *tc) {
   11792 	char *line[] = {"(", "mlsconstrain", "(", "file", "(", "create", "relabelto", ")", ")", "(", ")", ")", NULL};
   11793 
   11794         struct cil_tree *test_tree;
   11795         gen_test_tree(&test_tree, line);
   11796 
   11797         struct cil_tree_node *test_ast_node;
   11798         cil_tree_node_init(&test_ast_node);
   11799 
   11800         struct cil_db *test_db;
   11801         cil_db_init(&test_db);
   11802 
   11803         test_ast_node->parent = test_db->ast->root;
   11804         test_ast_node->line = 1;
   11805 
   11806         int rc = cil_gen_constrain(test_db, test_tree->root->cl_head->cl_head, test_ast_node, CIL_MLSCONSTRAIN);
   11807         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   11808 }
   11809 
   11810 void test_cil_gen_constrain_dbnull_neg(CuTest *tc) {
   11811 	char *line[] = {"(", "mlsconstrain", "(", "file", "(", "create", "relabelto", ")", ")", "(", "eq", "12", "h2", ")", ")", NULL};
   11812 
   11813         struct cil_tree *test_tree;
   11814         gen_test_tree(&test_tree, line);
   11815 
   11816         struct cil_tree_node *test_ast_node;
   11817         cil_tree_node_init(&test_ast_node);
   11818 
   11819         struct cil_db *test_db = NULL;
   11820 
   11821         int rc = cil_gen_constrain(test_db, test_tree->root->cl_head->cl_head, test_ast_node, CIL_MLSCONSTRAIN);
   11822         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   11823 }
   11824 
   11825 void test_cil_gen_constrain_currnull_neg(CuTest *tc) {
   11826 	char *line[] = {"(", ")", NULL};
   11827 
   11828         struct cil_tree *test_tree;
   11829         gen_test_tree(&test_tree, line);
   11830 
   11831         struct cil_tree_node *test_ast_node;
   11832         cil_tree_node_init(&test_ast_node);
   11833 
   11834         struct cil_db *test_db;
   11835         cil_db_init(&test_db);
   11836 
   11837         test_ast_node->parent = test_db->ast->root;
   11838         test_ast_node->line = 1;
   11839 
   11840         int rc = cil_gen_constrain(test_db, test_tree->root->cl_head->cl_head, test_ast_node, CIL_MLSCONSTRAIN);
   11841         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   11842 }
   11843 
   11844 void test_cil_gen_constrain_astnull_neg(CuTest *tc) {
   11845 	char *line[] = {"(", "mlsconstrain", "(", "file", "(", "create", "relabelto", ")", ")", "(", "eq", "12", "h2", ")", ")", NULL};
   11846 
   11847         struct cil_tree *test_tree;
   11848         gen_test_tree(&test_tree, line);
   11849 
   11850         struct cil_tree_node *test_ast_node = NULL;
   11851 
   11852         struct cil_db *test_db;
   11853         cil_db_init(&test_db);
   11854 
   11855         int rc = cil_gen_constrain(test_db, test_tree->root->cl_head->cl_head, test_ast_node, CIL_MLSCONSTRAIN);
   11856         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   11857 }
   11858 
   11859 void test_cil_fill_context(CuTest *tc) {
   11860 	char *line[] = {"(", "context", "localhost_node_label", "(", "system_u", "object_r", "node_lo_t", "(", "low", "high", ")", ")", ")", NULL};
   11861 
   11862         struct cil_tree *test_tree;
   11863         gen_test_tree(&test_tree, line);
   11864 
   11865         struct cil_tree_node *test_ast_node;
   11866         cil_tree_node_init(&test_ast_node);
   11867 
   11868         struct cil_db *test_db;
   11869         cil_db_init(&test_db);
   11870 
   11871         test_ast_node->parent = test_db->ast->root;
   11872         test_ast_node->line = 1;
   11873 
   11874 	struct cil_context *test_context;
   11875 	cil_context_init(&test_context);
   11876 
   11877         int rc = cil_fill_context(test_tree->root->cl_head->cl_head->next->next->cl_head, test_context);
   11878         CuAssertIntEquals(tc, SEPOL_OK, rc);
   11879 }
   11880 
   11881 void test_cil_fill_context_unnamedlvl(CuTest *tc) {
   11882 	char *line[] = {"(", "context", "localhost_node_label", "(", "system_u", "object_r", "node_lo_t", "(", "(", "s0", ")", "(", "s0", ")", ")", ")", ")", NULL};
   11883 
   11884         struct cil_tree *test_tree;
   11885         gen_test_tree(&test_tree, line);
   11886 
   11887         struct cil_tree_node *test_ast_node;
   11888         cil_tree_node_init(&test_ast_node);
   11889 
   11890         struct cil_db *test_db;
   11891         cil_db_init(&test_db);
   11892 
   11893         test_ast_node->parent = test_db->ast->root;
   11894         test_ast_node->line = 1;
   11895 
   11896 	struct cil_context *test_context;
   11897 	cil_context_init(&test_context);
   11898 
   11899         int rc = cil_fill_context(test_tree->root->cl_head->cl_head->next->next->cl_head, test_context);
   11900         CuAssertIntEquals(tc, SEPOL_OK, rc);
   11901 }
   11902 
   11903 void test_cil_fill_context_nocontext_neg(CuTest *tc) {
   11904 	char *line[] = {"(", "context", "localhost_node_label", "(", "system_u", "object_r", "node_lo_t", "(", "low", "high", ")", ")", ")", NULL};
   11905 
   11906         struct cil_tree *test_tree;
   11907         gen_test_tree(&test_tree, line);
   11908 
   11909         struct cil_tree_node *test_ast_node;
   11910         cil_tree_node_init(&test_ast_node);
   11911 
   11912         struct cil_db *test_db;
   11913         cil_db_init(&test_db);
   11914 
   11915         test_ast_node->parent = test_db->ast->root;
   11916         test_ast_node->line = 1;
   11917 
   11918 	struct cil_context *test_context = NULL;
   11919 
   11920         int rc = cil_fill_context(test_tree->root->cl_head->cl_head->next->next->cl_head, test_context);
   11921         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   11922 }
   11923 
   11924 void test_cil_fill_context_nouser_neg(CuTest *tc) {
   11925 	char *line[] = {"(", "context", "localhost_node_label", "(", ")", ")", NULL};
   11926 
   11927         struct cil_tree *test_tree;
   11928         gen_test_tree(&test_tree, line);
   11929 
   11930         struct cil_tree_node *test_ast_node;
   11931         cil_tree_node_init(&test_ast_node);
   11932 
   11933         struct cil_db *test_db;
   11934         cil_db_init(&test_db);
   11935 
   11936         test_ast_node->parent = test_db->ast->root;
   11937         test_ast_node->line = 1;
   11938 
   11939 	struct cil_context *test_context;
   11940 	cil_context_init(&test_context);
   11941 
   11942 	int rc = cil_fill_context(test_tree->root->cl_head->cl_head->next->next->cl_head, test_context);
   11943 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   11944 }
   11945 
   11946 void test_cil_fill_context_norole_neg(CuTest *tc) {
   11947 	char *line[] = {"(", "context", "localhost_node_label", "(", "system_u", ")", ")", NULL};
   11948 
   11949         struct cil_tree *test_tree;
   11950         gen_test_tree(&test_tree, line);
   11951 
   11952         struct cil_tree_node *test_ast_node;
   11953         cil_tree_node_init(&test_ast_node);
   11954 
   11955         struct cil_db *test_db;
   11956         cil_db_init(&test_db);
   11957 
   11958         test_ast_node->parent = test_db->ast->root;
   11959         test_ast_node->line = 1;
   11960 
   11961 	struct cil_context *test_context;
   11962 	cil_context_init(&test_context);
   11963 
   11964 	int rc = cil_fill_context(test_tree->root->cl_head->cl_head->next->next->cl_head, test_context);
   11965         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   11966 }
   11967 
   11968 void test_cil_fill_context_notype_neg(CuTest *tc) {
   11969 	char *line[] = {"(", "context", "localhost_node_label", "(", "system_u", "object_r", ")", ")", NULL};
   11970 
   11971         struct cil_tree *test_tree;
   11972         gen_test_tree(&test_tree, line);
   11973 
   11974         struct cil_tree_node *test_ast_node;
   11975         cil_tree_node_init(&test_ast_node);
   11976 
   11977         struct cil_db *test_db;
   11978         cil_db_init(&test_db);
   11979 
   11980         test_ast_node->parent = test_db->ast->root;
   11981         test_ast_node->line = 1;
   11982 
   11983 	struct cil_context *test_context;
   11984 	cil_context_init(&test_context);
   11985 
   11986 	int rc = cil_fill_context(test_tree->root->cl_head->cl_head->next->next->cl_head, test_context);
   11987         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   11988 }
   11989 
   11990 void test_cil_fill_context_nolowlvl_neg(CuTest *tc) {
   11991 	char *line[] = {"(", "context", "localhost_node_label", "(", "system_u", "object_r", "type_t", ")", ")", NULL};
   11992 
   11993         struct cil_tree *test_tree;
   11994         gen_test_tree(&test_tree, line);
   11995 
   11996         struct cil_tree_node *test_ast_node;
   11997         cil_tree_node_init(&test_ast_node);
   11998 
   11999         struct cil_db *test_db;
   12000         cil_db_init(&test_db);
   12001 
   12002         test_ast_node->parent = test_db->ast->root;
   12003         test_ast_node->line = 1;
   12004 
   12005 	struct cil_context *test_context;
   12006 	cil_context_init(&test_context);
   12007 
   12008 	int rc = cil_fill_context(test_tree->root->cl_head->cl_head->next->next->cl_head, test_context);
   12009         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   12010 }
   12011 
   12012 void test_cil_fill_context_nohighlvl_neg(CuTest *tc) {
   12013 	char *line[] = {"(", "context", "localhost_node_label", "(", "system_u", "object_r", "type_t", "(", "low", ")", ")", ")", NULL};
   12014 
   12015         struct cil_tree *test_tree;
   12016         gen_test_tree(&test_tree, line);
   12017 
   12018         struct cil_tree_node *test_ast_node;
   12019         cil_tree_node_init(&test_ast_node);
   12020 
   12021         struct cil_db *test_db;
   12022         cil_db_init(&test_db);
   12023 
   12024         test_ast_node->parent = test_db->ast->root;
   12025         test_ast_node->line = 1;
   12026 
   12027 	struct cil_context *test_context;
   12028 	cil_context_init(&test_context);
   12029 
   12030 	int rc = cil_fill_context(test_tree->root->cl_head->cl_head->next->next->cl_head, test_context);
   12031         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   12032 }
   12033 
   12034 void test_cil_fill_context_unnamedlvl_nocontextlow_neg(CuTest *tc) {
   12035 	char *line[] = {"(", "context", "localhost_node_label", "(", "system_u", "object_r", "type_t", "(", "s0", "(", ")", ")", "high", ")", ")", NULL};
   12036 
   12037         struct cil_tree *test_tree;
   12038         gen_test_tree(&test_tree, line);
   12039 
   12040         struct cil_tree_node *test_ast_node;
   12041         cil_tree_node_init(&test_ast_node);
   12042 
   12043         struct cil_db *test_db;
   12044         cil_db_init(&test_db);
   12045 
   12046         test_ast_node->parent = test_db->ast->root;
   12047         test_ast_node->line = 1;
   12048 
   12049 	struct cil_context *test_context;
   12050 	cil_context_init(&test_context);
   12051 
   12052 	int rc = cil_fill_context(test_tree->root->cl_head->cl_head->next->next->cl_head, test_context);
   12053         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   12054 }
   12055 
   12056 void test_cil_fill_context_unnamedlvl_nocontexthigh_neg(CuTest *tc) {
   12057 	char *line[] = {"(", "context", "localhost_node_label", "(", "system_u", "object_r", "type_t", "low", "(", "s0", "(", ")", ")", ")", ")", NULL};
   12058 
   12059         struct cil_tree *test_tree;
   12060         gen_test_tree(&test_tree, line);
   12061 
   12062         struct cil_tree_node *test_ast_node;
   12063         cil_tree_node_init(&test_ast_node);
   12064 
   12065         struct cil_db *test_db;
   12066         cil_db_init(&test_db);
   12067 
   12068         test_ast_node->parent = test_db->ast->root;
   12069         test_ast_node->line = 1;
   12070 
   12071 	struct cil_context *test_context;
   12072 	cil_context_init(&test_context);
   12073 
   12074 	int rc = cil_fill_context(test_tree->root->cl_head->cl_head->next->next->cl_head, test_context);
   12075         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   12076 }
   12077 
   12078 void test_cil_gen_context(CuTest *tc) {
   12079 	char *line[] = {"(", "context", "packet_default", "(", "system_u", "object_r", "etc_t", "(", "low", "high", ")", ")", ")", NULL};
   12080 
   12081         struct cil_tree *test_tree;
   12082         gen_test_tree(&test_tree, line);
   12083 
   12084         struct cil_tree_node *test_ast_node;
   12085         cil_tree_node_init(&test_ast_node);
   12086 
   12087         struct cil_db *test_db;
   12088         cil_db_init(&test_db);
   12089 
   12090         test_ast_node->parent = test_db->ast->root;
   12091         test_ast_node->line = 1;
   12092 
   12093         int rc = cil_gen_context(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   12094         CuAssertIntEquals(tc, SEPOL_OK, rc);
   12095 }
   12096 
   12097 void test_cil_gen_context_notinparens_neg(CuTest *tc) {
   12098 	char *line[] = {"(", "context", "packet_default", "system_u", "object_r", "etc_t", "(", "low", "high", ")", ")", NULL};
   12099 
   12100         struct cil_tree *test_tree;
   12101         gen_test_tree(&test_tree, line);
   12102 
   12103         struct cil_tree_node *test_ast_node;
   12104         cil_tree_node_init(&test_ast_node);
   12105 
   12106         struct cil_db *test_db;
   12107         cil_db_init(&test_db);
   12108 
   12109         test_ast_node->parent = test_db->ast->root;
   12110         test_ast_node->line = 1;
   12111 
   12112         int rc = cil_gen_context(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   12113         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   12114 }
   12115 
   12116 void test_cil_gen_context_extralevel_neg(CuTest *tc) {
   12117 	char *line[] = {"(", "context", "packet_default", "(", "system_u", "object_r", "etc_t", "(", "low", "high", ")", "extra", ")", ")", NULL};
   12118 
   12119         struct cil_tree *test_tree;
   12120         gen_test_tree(&test_tree, line);
   12121 
   12122         struct cil_tree_node *test_ast_node;
   12123         cil_tree_node_init(&test_ast_node);
   12124 
   12125         struct cil_db *test_db;
   12126         cil_db_init(&test_db);
   12127 
   12128         test_ast_node->parent = test_db->ast->root;
   12129         test_ast_node->line = 1;
   12130 
   12131         int rc = cil_gen_context(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   12132         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   12133 }
   12134 
   12135 void test_cil_gen_context_emptycontext_neg(CuTest *tc) {
   12136 	char *line[] = {"(", "context", "packet_default", "(", ")", ")", NULL};
   12137 
   12138         struct cil_tree *test_tree;
   12139         gen_test_tree(&test_tree, line);
   12140 
   12141         struct cil_tree_node *test_ast_node;
   12142         cil_tree_node_init(&test_ast_node);
   12143 
   12144         struct cil_db *test_db;
   12145         cil_db_init(&test_db);
   12146 
   12147         test_ast_node->parent = test_db->ast->root;
   12148         test_ast_node->line = 1;
   12149 
   12150         int rc = cil_gen_context(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   12151         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   12152 }
   12153 
   12154 void test_cil_gen_context_extra_neg(CuTest *tc) {
   12155 	char *line[] = {"(", "context", "packet_default", "(", "system_u", "object_r", "etc_t", "(", "low", "high", ")", ")", "(", "extra", ")", ")", NULL};
   12156 
   12157         struct cil_tree *test_tree;
   12158         gen_test_tree(&test_tree, line);
   12159 
   12160         struct cil_tree_node *test_ast_node;
   12161         cil_tree_node_init(&test_ast_node);
   12162 
   12163         struct cil_db *test_db;
   12164         cil_db_init(&test_db);
   12165 
   12166         test_ast_node->parent = test_db->ast->root;
   12167         test_ast_node->line = 1;
   12168 
   12169         int rc = cil_gen_context(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   12170         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   12171 }
   12172 
   12173 void test_cil_gen_context_doubleparen_neg(CuTest *tc) {
   12174 	char *line[] = {"(", "context", "packet_default", "(", "(", "system_u", ")", ")", ")", NULL};
   12175 
   12176         struct cil_tree *test_tree;
   12177         gen_test_tree(&test_tree, line);
   12178 
   12179         struct cil_tree_node *test_ast_node;
   12180         cil_tree_node_init(&test_ast_node);
   12181 
   12182         struct cil_db *test_db;
   12183         cil_db_init(&test_db);
   12184 
   12185         test_ast_node->parent = test_db->ast->root;
   12186         test_ast_node->line = 1;
   12187 
   12188         int rc = cil_gen_context(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   12189         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   12190 }
   12191 
   12192 void test_cil_gen_context_norole_neg(CuTest *tc) {
   12193 	char *line[] = {"(", "context", "packet_default", "(", "system_u", ")", ")", NULL};
   12194 
   12195         struct cil_tree *test_tree;
   12196         gen_test_tree(&test_tree, line);
   12197 
   12198         struct cil_tree_node *test_ast_node;
   12199         cil_tree_node_init(&test_ast_node);
   12200 
   12201         struct cil_db *test_db;
   12202         cil_db_init(&test_db);
   12203 
   12204         test_ast_node->parent = test_db->ast->root;
   12205         test_ast_node->line = 1;
   12206 
   12207         int rc = cil_gen_context(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   12208         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   12209 }
   12210 
   12211 void test_cil_gen_context_roleinparens_neg(CuTest *tc) {
   12212 	char *line[] = {"(", "context", "packet_default", "(", "system_u", "(", "role_r", ")", ")", ")", NULL};
   12213 
   12214         struct cil_tree *test_tree;
   12215         gen_test_tree(&test_tree, line);
   12216 
   12217         struct cil_tree_node *test_ast_node;
   12218         cil_tree_node_init(&test_ast_node);
   12219 
   12220         struct cil_db *test_db;
   12221         cil_db_init(&test_db);
   12222 
   12223         test_ast_node->parent = test_db->ast->root;
   12224         test_ast_node->line = 1;
   12225 
   12226         int rc = cil_gen_context(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   12227         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   12228 }
   12229 
   12230 void test_cil_gen_context_notype_neg(CuTest *tc) {
   12231 	char *line[] = {"(", "context", "packet_default", "(", "system_u", "role_r", ")", ")", NULL};
   12232 
   12233         struct cil_tree *test_tree;
   12234         gen_test_tree(&test_tree, line);
   12235 
   12236         struct cil_tree_node *test_ast_node;
   12237         cil_tree_node_init(&test_ast_node);
   12238 
   12239         struct cil_db *test_db;
   12240         cil_db_init(&test_db);
   12241 
   12242         test_ast_node->parent = test_db->ast->root;
   12243         test_ast_node->line = 1;
   12244 
   12245         int rc = cil_gen_context(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   12246         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   12247 }
   12248 
   12249 void test_cil_gen_context_typeinparens_neg(CuTest *tc) {
   12250 	char *line[] = {"(", "context", "packet_default", "(", "system_u", "role_r", "(", "type_t", ")", ")", ")", NULL};
   12251 
   12252         struct cil_tree *test_tree;
   12253         gen_test_tree(&test_tree, line);
   12254 
   12255         struct cil_tree_node *test_ast_node;
   12256         cil_tree_node_init(&test_ast_node);
   12257 
   12258         struct cil_db *test_db;
   12259         cil_db_init(&test_db);
   12260 
   12261         test_ast_node->parent = test_db->ast->root;
   12262         test_ast_node->line = 1;
   12263 
   12264         int rc = cil_gen_context(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   12265         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   12266 }
   12267 
   12268 void test_cil_gen_context_nolevels_neg(CuTest *tc) {
   12269 	char *line[] = {"(", "context", "packet_default", "(", "system_u", "role_r", "type_t", ")", ")", NULL};
   12270 
   12271         struct cil_tree *test_tree;
   12272         gen_test_tree(&test_tree, line);
   12273 
   12274         struct cil_tree_node *test_ast_node;
   12275         cil_tree_node_init(&test_ast_node);
   12276 
   12277         struct cil_db *test_db;
   12278         cil_db_init(&test_db);
   12279 
   12280         test_ast_node->parent = test_db->ast->root;
   12281         test_ast_node->line = 1;
   12282 
   12283         int rc = cil_gen_context(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   12284         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   12285 }
   12286 
   12287 void test_cil_gen_context_nosecondlevel_neg(CuTest *tc) {
   12288 	char *line[] = {"(", "context", "packet_default", "(", "system_u", "role_r", "type_t", "(", "low", ")", ")", ")", NULL};
   12289 
   12290         struct cil_tree *test_tree;
   12291         gen_test_tree(&test_tree, line);
   12292 
   12293         struct cil_tree_node *test_ast_node;
   12294         cil_tree_node_init(&test_ast_node);
   12295 
   12296         struct cil_db *test_db;
   12297         cil_db_init(&test_db);
   12298 
   12299         test_ast_node->parent = test_db->ast->root;
   12300         test_ast_node->line = 1;
   12301 
   12302         int rc = cil_gen_context(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   12303         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   12304 }
   12305 
   12306 void test_cil_gen_context_noname_neg(CuTest *tc) {
   12307 	char *line[] = {"(", "context", ")", NULL};
   12308 
   12309         struct cil_tree *test_tree;
   12310         gen_test_tree(&test_tree, line);
   12311 
   12312         struct cil_tree_node *test_ast_node;
   12313         cil_tree_node_init(&test_ast_node);
   12314 
   12315         struct cil_db *test_db;
   12316         cil_db_init(&test_db);
   12317 
   12318         test_ast_node->parent = test_db->ast->root;
   12319         test_ast_node->line = 1;
   12320 
   12321         int rc = cil_gen_context(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   12322         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   12323 }
   12324 
   12325 void test_cil_gen_context_nouser_neg(CuTest *tc) {
   12326 	char *line[] = {"(", "context", "localhost_node_label", ")", NULL};
   12327 
   12328         struct cil_tree *test_tree;
   12329         gen_test_tree(&test_tree, line);
   12330 
   12331         struct cil_tree_node *test_ast_node;
   12332         cil_tree_node_init(&test_ast_node);
   12333 
   12334         struct cil_db *test_db;
   12335         cil_db_init(&test_db);
   12336 
   12337         test_ast_node->parent = test_db->ast->root;
   12338         test_ast_node->line = 1;
   12339 
   12340         int rc = cil_gen_context(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   12341         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   12342 }
   12343 
   12344 void test_cil_gen_context_dbnull_neg(CuTest *tc) {
   12345 	char *line[] = {"(", "context", "localhost_node_label", "(", "system_u", "object_r", "node_lo_t", "(", "s0", ")", "(", "s0", ")", ")", ")", NULL};
   12346 
   12347         struct cil_tree *test_tree;
   12348         gen_test_tree(&test_tree, line);
   12349 
   12350         struct cil_tree_node *test_ast_node;
   12351         cil_tree_node_init(&test_ast_node);
   12352 
   12353         struct cil_db *test_db = NULL;
   12354 
   12355         int rc = cil_gen_context(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   12356         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   12357 }
   12358 
   12359 void test_cil_gen_context_currnull_neg(CuTest *tc) {
   12360 	char *line[] = {"(", ")", NULL};
   12361 
   12362         struct cil_tree *test_tree;
   12363         gen_test_tree(&test_tree, line);
   12364 
   12365         struct cil_tree_node *test_ast_node;
   12366         cil_tree_node_init(&test_ast_node);
   12367 
   12368         struct cil_db *test_db;
   12369         cil_db_init(&test_db);
   12370 
   12371         test_ast_node->parent = test_db->ast->root;
   12372         test_ast_node->line = 1;
   12373 
   12374         int rc = cil_gen_context(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   12375         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   12376 }
   12377 
   12378 void test_cil_gen_context_astnull_neg(CuTest *tc) {
   12379 	char *line[] = {"(", "context", "localhost_node_label", "system_u", "object_r", "node_lo_t", "(", "s0", ")", "(", "s0", ")", ")", ")", NULL};
   12380 
   12381         struct cil_tree *test_tree;
   12382         gen_test_tree(&test_tree, line);
   12383 
   12384         struct cil_tree_node *test_ast_node = NULL;
   12385 
   12386         struct cil_db *test_db;
   12387         cil_db_init(&test_db);
   12388 
   12389         int rc = cil_gen_context(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   12390         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   12391 }
   12392 
   12393 void test_cil_gen_filecon_dir(CuTest *tc) {
   12394 	char *line[] = {"(", "filecon", "root", "path", "dir", "context", NULL};
   12395 
   12396         struct cil_tree *test_tree;
   12397         gen_test_tree(&test_tree, line);
   12398 
   12399         struct cil_tree_node *test_ast_node;
   12400         cil_tree_node_init(&test_ast_node);
   12401 
   12402         struct cil_db *test_db;
   12403         cil_db_init(&test_db);
   12404 
   12405         test_ast_node->parent = test_db->ast->root;
   12406         test_ast_node->line = 1;
   12407 
   12408         int rc = cil_gen_filecon(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   12409         CuAssertIntEquals(tc, SEPOL_OK, rc);
   12410 }
   12411 
   12412 void test_cil_gen_filecon_file(CuTest *tc) {
   12413 	char *line[] = {"(", "filecon", "root", "path", "file", "context", NULL};
   12414 
   12415         struct cil_tree *test_tree;
   12416         gen_test_tree(&test_tree, line);
   12417 
   12418         struct cil_tree_node *test_ast_node;
   12419         cil_tree_node_init(&test_ast_node);
   12420 
   12421         struct cil_db *test_db;
   12422         cil_db_init(&test_db);
   12423 
   12424         test_ast_node->parent = test_db->ast->root;
   12425         test_ast_node->line = 1;
   12426 
   12427         int rc = cil_gen_filecon(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   12428         CuAssertIntEquals(tc, SEPOL_OK, rc);
   12429 }
   12430 
   12431 void test_cil_gen_filecon_char(CuTest *tc) {
   12432 	char *line[] = {"(", "filecon", "root", "path", "char", "context", NULL};
   12433 
   12434         struct cil_tree *test_tree;
   12435         gen_test_tree(&test_tree, line);
   12436 
   12437         struct cil_tree_node *test_ast_node;
   12438         cil_tree_node_init(&test_ast_node);
   12439 
   12440         struct cil_db *test_db;
   12441         cil_db_init(&test_db);
   12442 
   12443         test_ast_node->parent = test_db->ast->root;
   12444         test_ast_node->line = 1;
   12445 
   12446         int rc = cil_gen_filecon(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   12447         CuAssertIntEquals(tc, SEPOL_OK, rc);
   12448 }
   12449 
   12450 void test_cil_gen_filecon_block(CuTest *tc) {
   12451 	char *line[] = {"(", "filecon", "root", "path", "block", "context", NULL};
   12452 
   12453         struct cil_tree *test_tree;
   12454         gen_test_tree(&test_tree, line);
   12455 
   12456         struct cil_tree_node *test_ast_node;
   12457         cil_tree_node_init(&test_ast_node);
   12458 
   12459         struct cil_db *test_db;
   12460         cil_db_init(&test_db);
   12461 
   12462         test_ast_node->parent = test_db->ast->root;
   12463         test_ast_node->line = 1;
   12464 
   12465         int rc = cil_gen_filecon(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   12466         CuAssertIntEquals(tc, SEPOL_OK, rc);
   12467 }
   12468 
   12469 void test_cil_gen_filecon_socket(CuTest *tc) {
   12470 	char *line[] = {"(", "filecon", "root", "path", "socket", "context", NULL};
   12471 
   12472         struct cil_tree *test_tree;
   12473         gen_test_tree(&test_tree, line);
   12474 
   12475         struct cil_tree_node *test_ast_node;
   12476         cil_tree_node_init(&test_ast_node);
   12477 
   12478         struct cil_db *test_db;
   12479         cil_db_init(&test_db);
   12480 
   12481         test_ast_node->parent = test_db->ast->root;
   12482         test_ast_node->line = 1;
   12483 
   12484         int rc = cil_gen_filecon(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   12485         CuAssertIntEquals(tc, SEPOL_OK, rc);
   12486 }
   12487 
   12488 void test_cil_gen_filecon_pipe(CuTest *tc) {
   12489 	char *line[] = {"(", "filecon", "root", "path", "pipe", "context", NULL};
   12490 
   12491         struct cil_tree *test_tree;
   12492         gen_test_tree(&test_tree, line);
   12493 
   12494         struct cil_tree_node *test_ast_node;
   12495         cil_tree_node_init(&test_ast_node);
   12496 
   12497         struct cil_db *test_db;
   12498         cil_db_init(&test_db);
   12499 
   12500         test_ast_node->parent = test_db->ast->root;
   12501         test_ast_node->line = 1;
   12502 
   12503         int rc = cil_gen_filecon(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   12504         CuAssertIntEquals(tc, SEPOL_OK, rc);
   12505 }
   12506 
   12507 void test_cil_gen_filecon_symlink(CuTest *tc) {
   12508 	char *line[] = {"(", "filecon", "root", "path", "symlink", "context", NULL};
   12509 
   12510         struct cil_tree *test_tree;
   12511         gen_test_tree(&test_tree, line);
   12512 
   12513         struct cil_tree_node *test_ast_node;
   12514         cil_tree_node_init(&test_ast_node);
   12515 
   12516         struct cil_db *test_db;
   12517         cil_db_init(&test_db);
   12518 
   12519         test_ast_node->parent = test_db->ast->root;
   12520         test_ast_node->line = 1;
   12521 
   12522         int rc = cil_gen_filecon(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   12523         CuAssertIntEquals(tc, SEPOL_OK, rc);
   12524 }
   12525 
   12526 void test_cil_gen_filecon_any(CuTest *tc) {
   12527 	char *line[] = {"(", "filecon", "root", "path", "any", "context", NULL};
   12528 
   12529         struct cil_tree *test_tree;
   12530         gen_test_tree(&test_tree, line);
   12531 
   12532         struct cil_tree_node *test_ast_node;
   12533         cil_tree_node_init(&test_ast_node);
   12534 
   12535         struct cil_db *test_db;
   12536         cil_db_init(&test_db);
   12537 
   12538         test_ast_node->parent = test_db->ast->root;
   12539         test_ast_node->line = 1;
   12540 
   12541         int rc = cil_gen_filecon(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   12542         CuAssertIntEquals(tc, SEPOL_OK, rc);
   12543 }
   12544 
   12545 void test_cil_gen_filecon_neg(CuTest *tc) {
   12546 	char *line[] = {"(", "filecon", "root", "path", "dne", "context", NULL};
   12547 
   12548         struct cil_tree *test_tree;
   12549         gen_test_tree(&test_tree, line);
   12550 
   12551         struct cil_tree_node *test_ast_node;
   12552         cil_tree_node_init(&test_ast_node);
   12553 
   12554         struct cil_db *test_db;
   12555         cil_db_init(&test_db);
   12556 
   12557         test_ast_node->parent = test_db->ast->root;
   12558         test_ast_node->line = 1;
   12559 
   12560         int rc = cil_gen_filecon(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   12561         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   12562 }
   12563 
   12564 void test_cil_gen_filecon_anon_context(CuTest *tc) {
   12565 	char *line[] = {"(", "filecon", "root", "path", "file", "(", "system_u", "object_r", "etc_t", "(", "low", "high", ")", ")", ")", NULL};
   12566 
   12567         struct cil_tree *test_tree;
   12568         gen_test_tree(&test_tree, line);
   12569 
   12570         struct cil_tree_node *test_ast_node;
   12571         cil_tree_node_init(&test_ast_node);
   12572 
   12573         struct cil_db *test_db;
   12574         cil_db_init(&test_db);
   12575 
   12576         test_ast_node->parent = test_db->ast->root;
   12577         test_ast_node->line = 1;
   12578 
   12579         int rc = cil_gen_filecon(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   12580         CuAssertIntEquals(tc, SEPOL_OK, rc);
   12581 }
   12582 
   12583 void test_cil_gen_filecon_dbnull_neg(CuTest *tc) {
   12584 	char *line[] = {"(", "filecon", "root", "path", "file", "(", "system_u", "object_r", "etc_t", "(", "low", "high", ")", ")", ")", NULL};
   12585 
   12586         struct cil_tree *test_tree;
   12587         gen_test_tree(&test_tree, line);
   12588 
   12589         struct cil_tree_node *test_ast_node;
   12590         cil_tree_node_init(&test_ast_node);
   12591 
   12592         struct cil_db *test_db = NULL;
   12593 
   12594         int rc = cil_gen_filecon(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   12595         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   12596 }
   12597 
   12598 void test_cil_gen_filecon_currnull_neg(CuTest *tc) {
   12599 	char *line[] = {"(", ")", NULL};
   12600 
   12601         struct cil_tree *test_tree;
   12602         gen_test_tree(&test_tree, line);
   12603 
   12604         struct cil_tree_node *test_ast_node;
   12605         cil_tree_node_init(&test_ast_node);
   12606 
   12607         struct cil_db *test_db;
   12608         cil_db_init(&test_db);
   12609 
   12610         test_ast_node->parent = test_db->ast->root;
   12611         test_ast_node->line = 1;
   12612 
   12613         int rc = cil_gen_filecon(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   12614         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   12615 }
   12616 
   12617 void test_cil_gen_filecon_astnull_neg(CuTest *tc) {
   12618 	char *line[] = {"(", "filecon", "root", "path", "file", "(", "system_u", "object_r", "etc_t", "(", "low", "high", ")", ")", ")", NULL};
   12619 
   12620         struct cil_tree *test_tree;
   12621         gen_test_tree(&test_tree, line);
   12622 
   12623         struct cil_tree_node *test_ast_node = NULL;
   12624 
   12625         struct cil_db *test_db;
   12626         cil_db_init(&test_db);
   12627 
   12628         int rc = cil_gen_filecon(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   12629         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   12630 }
   12631 
   12632 void test_cil_gen_filecon_str1null_neg(CuTest *tc) {
   12633 	char *line[] = {"(", "filecon", ")", NULL};
   12634 
   12635         struct cil_tree *test_tree;
   12636         gen_test_tree(&test_tree, line);
   12637 
   12638         struct cil_tree_node *test_ast_node;
   12639         cil_tree_node_init(&test_ast_node);
   12640 
   12641         struct cil_db *test_db;
   12642         cil_db_init(&test_db);
   12643 
   12644         test_ast_node->parent = test_db->ast->root;
   12645         test_ast_node->line = 1;
   12646 
   12647         int rc = cil_gen_filecon(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   12648         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   12649 }
   12650 
   12651 void test_cil_gen_filecon_str1_inparens_neg(CuTest *tc) {
   12652 	char *line[] = {"(", "filecon", "(", "root", ")", ")", NULL};
   12653 
   12654         struct cil_tree *test_tree;
   12655         gen_test_tree(&test_tree, line);
   12656 
   12657         struct cil_tree_node *test_ast_node;
   12658         cil_tree_node_init(&test_ast_node);
   12659 
   12660         struct cil_db *test_db;
   12661         cil_db_init(&test_db);
   12662 
   12663         test_ast_node->parent = test_db->ast->root;
   12664         test_ast_node->line = 1;
   12665 
   12666         int rc = cil_gen_filecon(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   12667         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   12668 }
   12669 
   12670 void test_cil_gen_filecon_str2null_neg(CuTest *tc) {
   12671 	char *line[] = {"(", "filecon", "root", ")", NULL};
   12672 
   12673         struct cil_tree *test_tree;
   12674         gen_test_tree(&test_tree, line);
   12675 
   12676         struct cil_tree_node *test_ast_node;
   12677         cil_tree_node_init(&test_ast_node);
   12678 
   12679         struct cil_db *test_db;
   12680         cil_db_init(&test_db);
   12681 
   12682         test_ast_node->parent = test_db->ast->root;
   12683         test_ast_node->line = 1;
   12684 
   12685         int rc = cil_gen_filecon(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   12686         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   12687 }
   12688 
   12689 void test_cil_gen_filecon_str2_inparens_neg(CuTest *tc) {
   12690 	char *line[] = {"(", "filecon", "root", "(", "path", ")", ")", NULL};
   12691 
   12692         struct cil_tree *test_tree;
   12693         gen_test_tree(&test_tree, line);
   12694 
   12695         struct cil_tree_node *test_ast_node;
   12696         cil_tree_node_init(&test_ast_node);
   12697 
   12698         struct cil_db *test_db;
   12699         cil_db_init(&test_db);
   12700 
   12701         test_ast_node->parent = test_db->ast->root;
   12702         test_ast_node->line = 1;
   12703 
   12704         int rc = cil_gen_filecon(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   12705         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   12706 }
   12707 
   12708 void test_cil_gen_filecon_classnull_neg(CuTest *tc) {
   12709 	char *line[] = {"(", "filecon", "root", "path", ")", NULL};
   12710 
   12711         struct cil_tree *test_tree;
   12712         gen_test_tree(&test_tree, line);
   12713 
   12714         struct cil_tree_node *test_ast_node;
   12715         cil_tree_node_init(&test_ast_node);
   12716 
   12717         struct cil_db *test_db;
   12718         cil_db_init(&test_db);
   12719 
   12720         test_ast_node->parent = test_db->ast->root;
   12721         test_ast_node->line = 1;
   12722 
   12723         int rc = cil_gen_filecon(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   12724         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   12725 }
   12726 
   12727 void test_cil_gen_filecon_class_inparens_neg(CuTest *tc) {
   12728 	char *line[] = {"(", "filecon", "root", "path", "(", "file", ")", ")", NULL};
   12729 
   12730         struct cil_tree *test_tree;
   12731         gen_test_tree(&test_tree, line);
   12732 
   12733         struct cil_tree_node *test_ast_node;
   12734         cil_tree_node_init(&test_ast_node);
   12735 
   12736         struct cil_db *test_db;
   12737         cil_db_init(&test_db);
   12738 
   12739         test_ast_node->parent = test_db->ast->root;
   12740         test_ast_node->line = 1;
   12741 
   12742         int rc = cil_gen_filecon(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   12743         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   12744 }
   12745 
   12746 void test_cil_gen_filecon_contextnull_neg(CuTest *tc) {
   12747 	char *line[] = {"(", "filecon", "root", "path", "file", ")", NULL};
   12748 
   12749         struct cil_tree *test_tree;
   12750         gen_test_tree(&test_tree, line);
   12751 
   12752         struct cil_tree_node *test_ast_node;
   12753         cil_tree_node_init(&test_ast_node);
   12754 
   12755         struct cil_db *test_db;
   12756         cil_db_init(&test_db);
   12757 
   12758         test_ast_node->parent = test_db->ast->root;
   12759         test_ast_node->line = 1;
   12760 
   12761         int rc = cil_gen_filecon(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   12762         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   12763 }
   12764 
   12765 void test_cil_gen_filecon_context_neg(CuTest *tc) {
   12766 	char *line[] = {"(", "filecon", "root", "path", "file", "(", "system_u", "object_r", "(", "low", "high", ")", ")", ")", NULL};
   12767 
   12768         struct cil_tree *test_tree;
   12769         gen_test_tree(&test_tree, line);
   12770 
   12771         struct cil_tree_node *test_ast_node;
   12772         cil_tree_node_init(&test_ast_node);
   12773 
   12774         struct cil_db *test_db;
   12775         cil_db_init(&test_db);
   12776 
   12777         test_ast_node->parent = test_db->ast->root;
   12778         test_ast_node->line = 1;
   12779 
   12780         int rc = cil_gen_filecon(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   12781         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   12782 }
   12783 
   12784 void test_cil_gen_filecon_extra_neg(CuTest *tc) {
   12785 	char *line[] = {"(", "filecon", "root", "path", "file", "context", "extra", ")", NULL};
   12786 
   12787         struct cil_tree *test_tree;
   12788         gen_test_tree(&test_tree, line);
   12789 
   12790         struct cil_tree_node *test_ast_node;
   12791         cil_tree_node_init(&test_ast_node);
   12792 
   12793         struct cil_db *test_db;
   12794         cil_db_init(&test_db);
   12795 
   12796         test_ast_node->parent = test_db->ast->root;
   12797         test_ast_node->line = 1;
   12798 
   12799         int rc = cil_gen_filecon(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   12800         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   12801 }
   12802 
   12803 void test_cil_gen_portcon_udp(CuTest *tc) {
   12804 	char *line[] = {"(", "portcon", "udp", "80", "con", ")", NULL};
   12805 
   12806         struct cil_tree *test_tree;
   12807         gen_test_tree(&test_tree, line);
   12808 
   12809         struct cil_tree_node *test_ast_node;
   12810         cil_tree_node_init(&test_ast_node);
   12811 
   12812         struct cil_db *test_db;
   12813         cil_db_init(&test_db);
   12814 
   12815         test_ast_node->parent = test_db->ast->root;
   12816         test_ast_node->line = 1;
   12817 
   12818         int rc = cil_gen_portcon(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   12819         CuAssertIntEquals(tc, SEPOL_OK, rc);
   12820 }
   12821 
   12822 void test_cil_gen_portcon_tcp(CuTest *tc) {
   12823 	char *line[] = {"(", "portcon", "tcp", "80", "con", ")", NULL};
   12824 
   12825         struct cil_tree *test_tree;
   12826         gen_test_tree(&test_tree, line);
   12827 
   12828         struct cil_tree_node *test_ast_node;
   12829         cil_tree_node_init(&test_ast_node);
   12830 
   12831         struct cil_db *test_db;
   12832         cil_db_init(&test_db);
   12833 
   12834         test_ast_node->parent = test_db->ast->root;
   12835         test_ast_node->line = 1;
   12836 
   12837         int rc = cil_gen_portcon(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   12838         CuAssertIntEquals(tc, SEPOL_OK, rc);
   12839 }
   12840 
   12841 void test_cil_gen_portcon_unknownprotocol_neg(CuTest *tc) {
   12842 	char *line[] = {"(", "portcon", "unknown", "80", "con", ")", NULL};
   12843 
   12844         struct cil_tree *test_tree;
   12845         gen_test_tree(&test_tree, line);
   12846 
   12847         struct cil_tree_node *test_ast_node;
   12848         cil_tree_node_init(&test_ast_node);
   12849 
   12850         struct cil_db *test_db;
   12851         cil_db_init(&test_db);
   12852 
   12853         test_ast_node->parent = test_db->ast->root;
   12854         test_ast_node->line = 1;
   12855 
   12856         int rc = cil_gen_portcon(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   12857         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   12858 }
   12859 
   12860 void test_cil_gen_portcon_anon_context(CuTest *tc) {
   12861 	char *line[] = {"(", "portcon", "udp", "80", "(", "system_u", "object_r", "etc_t", "(", "low", "high", ")", ")", ")", NULL};
   12862 
   12863         struct cil_tree *test_tree;
   12864         gen_test_tree(&test_tree, line);
   12865 
   12866         struct cil_tree_node *test_ast_node;
   12867         cil_tree_node_init(&test_ast_node);
   12868 
   12869         struct cil_db *test_db;
   12870         cil_db_init(&test_db);
   12871 
   12872         test_ast_node->parent = test_db->ast->root;
   12873         test_ast_node->line = 1;
   12874 
   12875         int rc = cil_gen_portcon(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   12876         CuAssertIntEquals(tc, SEPOL_OK, rc);
   12877 }
   12878 
   12879 void test_cil_gen_portcon_portrange(CuTest *tc) {
   12880 	char *line[] = {"(", "portcon", "udp", "(", "25", "75", ")", "con", ")", NULL};
   12881 
   12882         struct cil_tree *test_tree;
   12883         gen_test_tree(&test_tree, line);
   12884 
   12885         struct cil_tree_node *test_ast_node;
   12886         cil_tree_node_init(&test_ast_node);
   12887 
   12888         struct cil_db *test_db;
   12889         cil_db_init(&test_db);
   12890 
   12891         test_ast_node->parent = test_db->ast->root;
   12892         test_ast_node->line = 1;
   12893 
   12894         int rc = cil_gen_portcon(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   12895         CuAssertIntEquals(tc, SEPOL_OK, rc);
   12896 }
   12897 
   12898 void test_cil_gen_portcon_portrange_one_neg(CuTest *tc) {
   12899 	char *line[] = {"(", "portcon", "udp", "(", "0", ")", "con", ")", NULL};
   12900 
   12901         struct cil_tree *test_tree;
   12902         gen_test_tree(&test_tree, line);
   12903 
   12904         struct cil_tree_node *test_ast_node;
   12905         cil_tree_node_init(&test_ast_node);
   12906 
   12907         struct cil_db *test_db;
   12908         cil_db_init(&test_db);
   12909 
   12910         test_ast_node->parent = test_db->ast->root;
   12911         test_ast_node->line = 1;
   12912 
   12913         int rc = cil_gen_portcon(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   12914         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   12915 }
   12916 
   12917 void test_cil_gen_portcon_portrange_morethanone_neg(CuTest *tc) {
   12918 	char *line[] = {"(", "portcon", "udp", "(", "0", "1", "2", ")", "con", ")", NULL};
   12919 
   12920         struct cil_tree *test_tree;
   12921         gen_test_tree(&test_tree, line);
   12922 
   12923         struct cil_tree_node *test_ast_node;
   12924         cil_tree_node_init(&test_ast_node);
   12925 
   12926         struct cil_db *test_db;
   12927         cil_db_init(&test_db);
   12928 
   12929         test_ast_node->parent = test_db->ast->root;
   12930         test_ast_node->line = 1;
   12931 
   12932         int rc = cil_gen_portcon(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   12933         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   12934 }
   12935 
   12936 void test_cil_gen_portcon_singleport_neg(CuTest *tc) {
   12937 	char *line[] = {"(", "portcon", "udp", "foo", "con", ")", NULL};
   12938 
   12939         struct cil_tree *test_tree;
   12940         gen_test_tree(&test_tree, line);
   12941 
   12942         struct cil_tree_node *test_ast_node;
   12943         cil_tree_node_init(&test_ast_node);
   12944 
   12945         struct cil_db *test_db;
   12946         cil_db_init(&test_db);
   12947 
   12948         test_ast_node->parent = test_db->ast->root;
   12949         test_ast_node->line = 1;
   12950 
   12951         int rc = cil_gen_portcon(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   12952         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   12953 }
   12954 
   12955 void test_cil_gen_portcon_lowport_neg(CuTest *tc) {
   12956 	char *line[] = {"(", "portcon", "udp", "(", "foo", "90", ")", "con", ")", NULL};
   12957 
   12958         struct cil_tree *test_tree;
   12959         gen_test_tree(&test_tree, line);
   12960 
   12961         struct cil_tree_node *test_ast_node;
   12962         cil_tree_node_init(&test_ast_node);
   12963 
   12964         struct cil_db *test_db;
   12965         cil_db_init(&test_db);
   12966 
   12967         test_ast_node->parent = test_db->ast->root;
   12968         test_ast_node->line = 1;
   12969 
   12970         int rc = cil_gen_portcon(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   12971         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   12972 }
   12973 
   12974 void test_cil_gen_portcon_highport_neg(CuTest *tc) {
   12975 	char *line[] = {"(", "portcon", "udp", "(", "80", "foo", ")", "con", ")", NULL};
   12976 
   12977         struct cil_tree *test_tree;
   12978         gen_test_tree(&test_tree, line);
   12979 
   12980         struct cil_tree_node *test_ast_node;
   12981         cil_tree_node_init(&test_ast_node);
   12982 
   12983         struct cil_db *test_db;
   12984         cil_db_init(&test_db);
   12985 
   12986         test_ast_node->parent = test_db->ast->root;
   12987         test_ast_node->line = 1;
   12988 
   12989         int rc = cil_gen_portcon(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   12990         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   12991 }
   12992 
   12993 void test_cil_gen_portcon_dbnull_neg(CuTest *tc) {
   12994 	char *line[] = {"(", "portcon", "udp", "(", "0", "1", ")", "con", ")", NULL};
   12995 
   12996         struct cil_tree *test_tree;
   12997         gen_test_tree(&test_tree, line);
   12998 
   12999         struct cil_tree_node *test_ast_node;
   13000         cil_tree_node_init(&test_ast_node);
   13001 
   13002         struct cil_db *test_db = NULL;
   13003 
   13004         int rc = cil_gen_portcon(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   13005         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   13006 }
   13007 
   13008 void test_cil_gen_portcon_currnull_neg(CuTest *tc) {
   13009 	char *line[] = {"(", ")", NULL};
   13010 
   13011         struct cil_tree *test_tree;
   13012         gen_test_tree(&test_tree, line);
   13013 
   13014         struct cil_tree_node *test_ast_node;
   13015         cil_tree_node_init(&test_ast_node);
   13016 
   13017         struct cil_db *test_db;
   13018         cil_db_init(&test_db);
   13019 
   13020         test_ast_node->parent = test_db->ast->root;
   13021         test_ast_node->line = 1;
   13022 
   13023         int rc = cil_gen_portcon(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   13024         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   13025 }
   13026 
   13027 void test_cil_gen_portcon_astnull_neg(CuTest *tc) {
   13028 	char *line[] = {"(", "portcon", "udp", "(", "0", "1", ")", "con", ")", NULL};
   13029 
   13030         struct cil_tree *test_tree;
   13031         gen_test_tree(&test_tree, line);
   13032 
   13033         struct cil_tree_node *test_ast_node = NULL;
   13034 
   13035         struct cil_db *test_db;
   13036         cil_db_init(&test_db);
   13037 
   13038         int rc = cil_gen_portcon(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   13039         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   13040 }
   13041 
   13042 void test_cil_gen_portcon_str1null_neg(CuTest *tc) {
   13043 	char *line[] = {"(", "portcon", ")", NULL};
   13044 
   13045         struct cil_tree *test_tree;
   13046         gen_test_tree(&test_tree, line);
   13047 
   13048         struct cil_tree_node *test_ast_node;
   13049         cil_tree_node_init(&test_ast_node);
   13050 
   13051         struct cil_db *test_db;
   13052         cil_db_init(&test_db);
   13053 
   13054         test_ast_node->parent = test_db->ast->root;
   13055         test_ast_node->line = 1;
   13056 
   13057         int rc = cil_gen_portcon(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   13058         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   13059 }
   13060 
   13061 void test_cil_gen_portcon_str1parens_neg(CuTest *tc) {
   13062 	char *line[] = {"(", "portcon", "(", "80", ")", "port", "con", ")", NULL};
   13063 
   13064         struct cil_tree *test_tree;
   13065         gen_test_tree(&test_tree, line);
   13066 
   13067         struct cil_tree_node *test_ast_node;
   13068         cil_tree_node_init(&test_ast_node);
   13069 
   13070         struct cil_db *test_db;
   13071         cil_db_init(&test_db);
   13072 
   13073         test_ast_node->parent = test_db->ast->root;
   13074         test_ast_node->line = 1;
   13075 
   13076         int rc = cil_gen_portcon(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   13077         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   13078 }
   13079 
   13080 void test_cil_gen_portcon_portnull_neg(CuTest *tc) {
   13081 	char *line[] = {"(", "portcon", "udp", ")", NULL};
   13082 
   13083         struct cil_tree *test_tree;
   13084         gen_test_tree(&test_tree, line);
   13085 
   13086         struct cil_tree_node *test_ast_node;
   13087         cil_tree_node_init(&test_ast_node);
   13088 
   13089         struct cil_db *test_db;
   13090         cil_db_init(&test_db);
   13091 
   13092         test_ast_node->parent = test_db->ast->root;
   13093         test_ast_node->line = 1;
   13094 
   13095         int rc = cil_gen_portcon(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   13096         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   13097 }
   13098 
   13099 void test_cil_gen_portcon_contextnull_neg(CuTest *tc) {
   13100 	char *line[] = {"(", "portcon", "udp", "port", ")", NULL};
   13101 
   13102         struct cil_tree *test_tree;
   13103         gen_test_tree(&test_tree, line);
   13104 
   13105         struct cil_tree_node *test_ast_node;
   13106         cil_tree_node_init(&test_ast_node);
   13107 
   13108         struct cil_db *test_db;
   13109         cil_db_init(&test_db);
   13110 
   13111         test_ast_node->parent = test_db->ast->root;
   13112         test_ast_node->line = 1;
   13113 
   13114         int rc = cil_gen_portcon(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   13115         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   13116 }
   13117 
   13118 void test_cil_gen_portcon_context_neg(CuTest *tc) {
   13119 	char *line[] = {"(", "portcon", "udp", "80", "(", "system_u", "object_r", "(", "low", "high", ")", ")", ")", NULL};
   13120 
   13121         struct cil_tree *test_tree;
   13122         gen_test_tree(&test_tree, line);
   13123 
   13124         struct cil_tree_node *test_ast_node;
   13125         cil_tree_node_init(&test_ast_node);
   13126 
   13127         struct cil_db *test_db;
   13128         cil_db_init(&test_db);
   13129 
   13130         test_ast_node->parent = test_db->ast->root;
   13131         test_ast_node->line = 1;
   13132 
   13133         int rc = cil_gen_portcon(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   13134         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   13135 }
   13136 
   13137 void test_cil_gen_portcon_extra_neg(CuTest *tc) {
   13138 	char *line[] = {"(", "portcon", "udp", "80", "con", "extra", ")", NULL};
   13139 
   13140         struct cil_tree *test_tree;
   13141         gen_test_tree(&test_tree, line);
   13142 
   13143         struct cil_tree_node *test_ast_node;
   13144         cil_tree_node_init(&test_ast_node);
   13145 
   13146         struct cil_db *test_db;
   13147         cil_db_init(&test_db);
   13148 
   13149         test_ast_node->parent = test_db->ast->root;
   13150         test_ast_node->line = 1;
   13151 
   13152         int rc = cil_gen_portcon(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   13153         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   13154 }
   13155 
   13156 void test_cil_fill_ipaddr(CuTest *tc) {
   13157 	char *line[] = {"(", "nodecon", "(", "192.168.1.1", ")", "ipaddr", "con", ")", NULL};
   13158 
   13159         struct cil_tree *test_tree;
   13160         gen_test_tree(&test_tree, line);
   13161 
   13162         struct cil_tree_node *test_ast_node;
   13163         cil_tree_node_init(&test_ast_node);
   13164 
   13165         struct cil_db *test_db;
   13166         cil_db_init(&test_db);
   13167 
   13168         test_ast_node->parent = test_db->ast->root;
   13169         test_ast_node->line = 1;
   13170 
   13171 	struct cil_nodecon *nodecon;
   13172 	cil_nodecon_init(&nodecon);
   13173 	cil_ipaddr_init(&nodecon->addr);
   13174 
   13175         int rc = cil_fill_ipaddr(test_tree->root->cl_head->cl_head->next->cl_head, nodecon->addr);
   13176         CuAssertIntEquals(tc, SEPOL_OK, rc);
   13177 }
   13178 
   13179 void test_cil_fill_ipaddr_addrnodenull_neg(CuTest *tc) {
   13180 	char *line[] = {"(", "nodecon", "(", "192.168.1.1", ")", "ipaddr", "con", ")", NULL};
   13181 
   13182         struct cil_tree *test_tree;
   13183         gen_test_tree(&test_tree, line);
   13184 
   13185         struct cil_tree_node *test_ast_node;
   13186         cil_tree_node_init(&test_ast_node);
   13187 
   13188         struct cil_db *test_db;
   13189         cil_db_init(&test_db);
   13190 
   13191         test_ast_node->parent = test_db->ast->root;
   13192         test_ast_node->line = 1;
   13193 
   13194 	struct cil_nodecon *nodecon;
   13195 	cil_nodecon_init(&nodecon);
   13196 	cil_ipaddr_init(&nodecon->addr);
   13197 
   13198         int rc = cil_fill_ipaddr(NULL, nodecon->addr);
   13199         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   13200 }
   13201 
   13202 void test_cil_fill_ipaddr_addrnull_neg(CuTest *tc) {
   13203 	char *line[] = {"(", "nodecon", "(", "192.168.1.1", ")", "ipaddr", "con", ")", NULL};
   13204 
   13205         struct cil_tree *test_tree;
   13206         gen_test_tree(&test_tree, line);
   13207 
   13208         struct cil_tree_node *test_ast_node;
   13209         cil_tree_node_init(&test_ast_node);
   13210 
   13211         struct cil_db *test_db;
   13212         cil_db_init(&test_db);
   13213 
   13214         test_ast_node->parent = test_db->ast->root;
   13215         test_ast_node->line = 1;
   13216 
   13217 	struct cil_nodecon *nodecon;
   13218 	cil_nodecon_init(&nodecon);
   13219 	nodecon->addr = NULL;
   13220 
   13221         int rc = cil_fill_ipaddr(test_tree->root->cl_head->cl_head->next->cl_head, nodecon->addr);
   13222         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   13223 }
   13224 
   13225 void test_cil_fill_ipaddr_addrinparens_neg(CuTest *tc) {
   13226 	char *line[] = {"(", "nodecon", "(", "(", "192.168.1.1", ")", ")", "ipaddr", "con", ")", NULL};
   13227 
   13228         struct cil_tree *test_tree;
   13229         gen_test_tree(&test_tree, line);
   13230 
   13231         struct cil_tree_node *test_ast_node;
   13232         cil_tree_node_init(&test_ast_node);
   13233 
   13234         struct cil_db *test_db;
   13235         cil_db_init(&test_db);
   13236 
   13237         test_ast_node->parent = test_db->ast->root;
   13238         test_ast_node->line = 1;
   13239 
   13240 	struct cil_nodecon *nodecon;
   13241 	cil_nodecon_init(&nodecon);
   13242 	cil_ipaddr_init(&nodecon->addr);
   13243 
   13244         int rc = cil_fill_ipaddr(test_tree->root->cl_head->cl_head->next->cl_head, nodecon->addr);
   13245         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   13246 }
   13247 
   13248 void test_cil_fill_ipaddr_extra_neg(CuTest *tc) {
   13249 	char *line[] = {"(", "nodecon", "(", "192.168.1.1", "extra", ")", "ipaddr", "con", ")", NULL};
   13250 
   13251         struct cil_tree *test_tree;
   13252         gen_test_tree(&test_tree, line);
   13253 
   13254         struct cil_tree_node *test_ast_node;
   13255         cil_tree_node_init(&test_ast_node);
   13256 
   13257         struct cil_db *test_db;
   13258         cil_db_init(&test_db);
   13259 
   13260         test_ast_node->parent = test_db->ast->root;
   13261         test_ast_node->line = 1;
   13262 
   13263 	struct cil_nodecon *nodecon;
   13264 	cil_nodecon_init(&nodecon);
   13265 	cil_ipaddr_init(&nodecon->addr);
   13266 
   13267         int rc = cil_fill_ipaddr(test_tree->root->cl_head->cl_head->next->cl_head, nodecon->addr);
   13268         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   13269 }
   13270 
   13271 void test_cil_gen_nodecon(CuTest *tc) {
   13272 	char *line[] = {"(", "nodecon", "ipaddr", "ipaddr", "con", ")", NULL};
   13273 
   13274         struct cil_tree *test_tree;
   13275         gen_test_tree(&test_tree, line);
   13276 
   13277         struct cil_tree_node *test_ast_node;
   13278         cil_tree_node_init(&test_ast_node);
   13279 
   13280         struct cil_db *test_db;
   13281         cil_db_init(&test_db);
   13282 
   13283         test_ast_node->parent = test_db->ast->root;
   13284         test_ast_node->line = 1;
   13285 
   13286         int rc = cil_gen_nodecon(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   13287         CuAssertIntEquals(tc, SEPOL_OK, rc);
   13288 }
   13289 
   13290 void test_cil_gen_nodecon_anon_context(CuTest *tc) {
   13291 	char *line[] = {"(", "nodecon", "ipaddr", "ipaddr", "(", "system_u", "object_r", "etc_t", "(", "low", "high", ")", ")", ")", NULL};
   13292 
   13293         struct cil_tree *test_tree;
   13294         gen_test_tree(&test_tree, line);
   13295 
   13296         struct cil_tree_node *test_ast_node;
   13297         cil_tree_node_init(&test_ast_node);
   13298 
   13299         struct cil_db *test_db;
   13300         cil_db_init(&test_db);
   13301 
   13302         test_ast_node->parent = test_db->ast->root;
   13303         test_ast_node->line = 1;
   13304 
   13305         int rc = cil_gen_nodecon(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   13306         CuAssertIntEquals(tc, SEPOL_OK, rc);
   13307 }
   13308 
   13309 void test_cil_gen_nodecon_dbnull_neg(CuTest *tc) {
   13310 	char *line[] = {"(", "nodecon", "ipaddr", "ipaddr", "con", NULL};
   13311 
   13312         struct cil_tree *test_tree;
   13313         gen_test_tree(&test_tree, line);
   13314 
   13315         struct cil_tree_node *test_ast_node;
   13316         cil_tree_node_init(&test_ast_node);
   13317 
   13318         struct cil_db *test_db = NULL;
   13319 
   13320         int rc = cil_gen_nodecon(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   13321         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   13322 }
   13323 
   13324 void test_cil_gen_nodecon_currnull_neg(CuTest *tc) {
   13325 	char *line[] = {"(", ")", NULL};
   13326 
   13327         struct cil_tree *test_tree;
   13328         gen_test_tree(&test_tree, line);
   13329 
   13330         struct cil_tree_node *test_ast_node;
   13331         cil_tree_node_init(&test_ast_node);
   13332 
   13333         struct cil_db *test_db;
   13334         cil_db_init(&test_db);
   13335 
   13336         test_ast_node->parent = test_db->ast->root;
   13337         test_ast_node->line = 1;
   13338 
   13339         int rc = cil_gen_nodecon(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   13340         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   13341 }
   13342 
   13343 void test_cil_gen_nodecon_astnull_neg(CuTest *tc) {
   13344 	char *line[] = {"(", "nodecon", "ipaddr", "ipaddr", "con", NULL};
   13345 
   13346         struct cil_tree *test_tree;
   13347         gen_test_tree(&test_tree, line);
   13348 
   13349         struct cil_tree_node *test_ast_node = NULL;
   13350 
   13351         struct cil_db *test_db;
   13352         cil_db_init(&test_db);
   13353 
   13354         int rc = cil_gen_nodecon(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   13355         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   13356 }
   13357 
   13358 void test_cil_gen_nodecon_ipnull_neg(CuTest *tc) {
   13359 	char *line[] = {"(", "nodecon", ")", NULL};
   13360 
   13361         struct cil_tree *test_tree;
   13362         gen_test_tree(&test_tree, line);
   13363 
   13364         struct cil_tree_node *test_ast_node;
   13365         cil_tree_node_init(&test_ast_node);
   13366 
   13367         struct cil_db *test_db;
   13368         cil_db_init(&test_db);
   13369 
   13370         test_ast_node->parent = test_db->ast->root;
   13371         test_ast_node->line = 1;
   13372 
   13373         int rc = cil_gen_nodecon(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   13374         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   13375 }
   13376 
   13377 void test_cil_gen_nodecon_ipanon(CuTest *tc) {
   13378 	char *line[] = {"(", "nodecon", "(", "192.168.1.1", ")", "ipaddr", "con", ")", NULL};
   13379 
   13380         struct cil_tree *test_tree;
   13381         gen_test_tree(&test_tree, line);
   13382 
   13383         struct cil_tree_node *test_ast_node;
   13384         cil_tree_node_init(&test_ast_node);
   13385 
   13386         struct cil_db *test_db;
   13387         cil_db_init(&test_db);
   13388 
   13389         test_ast_node->parent = test_db->ast->root;
   13390         test_ast_node->line = 1;
   13391 
   13392         int rc = cil_gen_nodecon(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   13393         CuAssertIntEquals(tc, SEPOL_OK, rc);
   13394 }
   13395 
   13396 void test_cil_gen_nodecon_ipanon_neg(CuTest *tc) {
   13397 	char *line[] = {"(", "nodecon", "(", "192.1.1", ")", "ipaddr", "con", ")", NULL};
   13398 
   13399         struct cil_tree *test_tree;
   13400         gen_test_tree(&test_tree, line);
   13401 
   13402         struct cil_tree_node *test_ast_node;
   13403         cil_tree_node_init(&test_ast_node);
   13404 
   13405         struct cil_db *test_db;
   13406         cil_db_init(&test_db);
   13407 
   13408         test_ast_node->parent = test_db->ast->root;
   13409         test_ast_node->line = 1;
   13410 
   13411         int rc = cil_gen_nodecon(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   13412         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   13413 }
   13414 
   13415 void test_cil_gen_nodecon_netmasknull_neg(CuTest *tc) {
   13416 	char *line[] = {"(", "nodecon", "ipaddr", ")", NULL};
   13417 
   13418         struct cil_tree *test_tree;
   13419         gen_test_tree(&test_tree, line);
   13420 
   13421         struct cil_tree_node *test_ast_node;
   13422         cil_tree_node_init(&test_ast_node);
   13423 
   13424         struct cil_db *test_db;
   13425         cil_db_init(&test_db);
   13426 
   13427         test_ast_node->parent = test_db->ast->root;
   13428         test_ast_node->line = 1;
   13429 
   13430         int rc = cil_gen_nodecon(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   13431         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   13432 }
   13433 
   13434 void test_cil_gen_nodecon_netmaskanon(CuTest *tc) {
   13435 	char *line[] = {"(", "nodecon", "ipaddr", "(", "255.255.255.4", ")", "con", ")", NULL};
   13436 
   13437         struct cil_tree *test_tree;
   13438         gen_test_tree(&test_tree, line);
   13439 
   13440         struct cil_tree_node *test_ast_node;
   13441         cil_tree_node_init(&test_ast_node);
   13442 
   13443         struct cil_db *test_db;
   13444         cil_db_init(&test_db);
   13445 
   13446         test_ast_node->parent = test_db->ast->root;
   13447         test_ast_node->line = 1;
   13448 
   13449         int rc = cil_gen_nodecon(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   13450         CuAssertIntEquals(tc, SEPOL_OK, rc);
   13451 }
   13452 
   13453 void test_cil_gen_nodecon_netmaskanon_neg(CuTest *tc) {
   13454 	char *line[] = {"(", "nodecon", "ipaddr", "(", "str0", ")", "con", ")", NULL};
   13455 
   13456         struct cil_tree *test_tree;
   13457         gen_test_tree(&test_tree, line);
   13458 
   13459         struct cil_tree_node *test_ast_node;
   13460         cil_tree_node_init(&test_ast_node);
   13461 
   13462         struct cil_db *test_db;
   13463         cil_db_init(&test_db);
   13464 
   13465         test_ast_node->parent = test_db->ast->root;
   13466         test_ast_node->line = 1;
   13467 
   13468         int rc = cil_gen_nodecon(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   13469         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   13470 }
   13471 
   13472 void test_cil_gen_nodecon_contextnull_neg(CuTest *tc) {
   13473 	char *line[] = {"(", "nodecon", "ipaddr", "ipaddr", ")", NULL};
   13474 
   13475         struct cil_tree *test_tree;
   13476         gen_test_tree(&test_tree, line);
   13477 
   13478         struct cil_tree_node *test_ast_node;
   13479         cil_tree_node_init(&test_ast_node);
   13480 
   13481         struct cil_db *test_db;
   13482         cil_db_init(&test_db);
   13483 
   13484         test_ast_node->parent = test_db->ast->root;
   13485         test_ast_node->line = 1;
   13486 
   13487         int rc = cil_gen_nodecon(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   13488         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   13489 }
   13490 
   13491 void test_cil_gen_nodecon_context_neg(CuTest *tc) {
   13492 	char *line[] = {"(", "nodecon", "ipaddr", "ipaddr", "(", "system_u", "object_r", "(", "low", "high", ")", ")", ")", NULL};
   13493 
   13494         struct cil_tree *test_tree;
   13495         gen_test_tree(&test_tree, line);
   13496 
   13497         struct cil_tree_node *test_ast_node;
   13498         cil_tree_node_init(&test_ast_node);
   13499 
   13500         struct cil_db *test_db;
   13501         cil_db_init(&test_db);
   13502 
   13503         test_ast_node->parent = test_db->ast->root;
   13504         test_ast_node->line = 1;
   13505 
   13506         int rc = cil_gen_nodecon(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   13507         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   13508 }
   13509 
   13510 void test_cil_gen_nodecon_extra_neg(CuTest *tc) {
   13511 	char *line[] = {"(", "nodecon", "ipaddr", "ipaddr", "(", "system_u", "object_r", "type_t", "(", "low", "high", ")", ")", "extra", ")", NULL};
   13512 
   13513         struct cil_tree *test_tree;
   13514         gen_test_tree(&test_tree, line);
   13515 
   13516         struct cil_tree_node *test_ast_node;
   13517         cil_tree_node_init(&test_ast_node);
   13518 
   13519         struct cil_db *test_db;
   13520         cil_db_init(&test_db);
   13521 
   13522         test_ast_node->parent = test_db->ast->root;
   13523         test_ast_node->line = 1;
   13524 
   13525         int rc = cil_gen_nodecon(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   13526         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   13527 }
   13528 
   13529 void test_cil_gen_genfscon(CuTest *tc) {
   13530 	char *line[] = {"(", "genfscon", "type", "path", "con", ")", NULL};
   13531 
   13532         struct cil_tree *test_tree;
   13533         gen_test_tree(&test_tree, line);
   13534 
   13535         struct cil_tree_node *test_ast_node;
   13536         cil_tree_node_init(&test_ast_node);
   13537 
   13538         struct cil_db *test_db;
   13539         cil_db_init(&test_db);
   13540 
   13541         test_ast_node->parent = test_db->ast->root;
   13542         test_ast_node->line = 1;
   13543 
   13544         int rc = cil_gen_genfscon(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   13545         CuAssertIntEquals(tc, SEPOL_OK, rc);
   13546 }
   13547 
   13548 void test_cil_gen_genfscon_anon_context(CuTest *tc) {
   13549 	char *line[] = {"(", "genfscon", "type", "path", "(", "system_u", "object_r", "etc_t", "(", "low", "high", ")", ")", ")", NULL};
   13550 
   13551         struct cil_tree *test_tree;
   13552         gen_test_tree(&test_tree, line);
   13553 
   13554         struct cil_tree_node *test_ast_node;
   13555         cil_tree_node_init(&test_ast_node);
   13556 
   13557         struct cil_db *test_db;
   13558         cil_db_init(&test_db);
   13559 
   13560         test_ast_node->parent = test_db->ast->root;
   13561         test_ast_node->line = 1;
   13562 
   13563         int rc = cil_gen_genfscon(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   13564         CuAssertIntEquals(tc, SEPOL_OK, rc);
   13565 }
   13566 
   13567 void test_cil_gen_genfscon_dbnull_neg(CuTest *tc) {
   13568 	char *line[] = {"(", "genfscon", "type", "path", "con", ")", NULL};
   13569 
   13570         struct cil_tree *test_tree;
   13571         gen_test_tree(&test_tree, line);
   13572 
   13573         struct cil_tree_node *test_ast_node;
   13574         cil_tree_node_init(&test_ast_node);
   13575 
   13576         struct cil_db *test_db = NULL;
   13577 
   13578         int rc = cil_gen_genfscon(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   13579         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   13580 }
   13581 
   13582 void test_cil_gen_genfscon_currnull_neg(CuTest *tc) {
   13583 	char *line[] = {"(", ")", NULL};
   13584 
   13585         struct cil_tree *test_tree;
   13586         gen_test_tree(&test_tree, line);
   13587 
   13588         struct cil_tree_node *test_ast_node;
   13589         cil_tree_node_init(&test_ast_node);
   13590 
   13591         struct cil_db *test_db;
   13592         cil_db_init(&test_db);
   13593 
   13594         test_ast_node->parent = test_db->ast->root;
   13595         test_ast_node->line = 1;
   13596 
   13597         int rc = cil_gen_genfscon(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   13598         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   13599 }
   13600 
   13601 void test_cil_gen_genfscon_astnull_neg(CuTest *tc) {
   13602 	char *line[] = {"(", "genfscon", "type", "path", "con", ")", NULL};
   13603 
   13604         struct cil_tree *test_tree;
   13605         gen_test_tree(&test_tree, line);
   13606 
   13607         struct cil_tree_node *test_ast_node = NULL;
   13608 
   13609         struct cil_db *test_db;
   13610         cil_db_init(&test_db);
   13611 
   13612         int rc = cil_gen_genfscon(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   13613         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   13614 }
   13615 
   13616 void test_cil_gen_genfscon_typenull_neg(CuTest *tc) {
   13617 	char *line[] = {"(", "genfscon", ")", NULL};
   13618 
   13619         struct cil_tree *test_tree;
   13620         gen_test_tree(&test_tree, line);
   13621 
   13622         struct cil_tree_node *test_ast_node;
   13623         cil_tree_node_init(&test_ast_node);
   13624 
   13625         struct cil_db *test_db;
   13626         cil_db_init(&test_db);
   13627 
   13628         test_ast_node->parent = test_db->ast->root;
   13629         test_ast_node->line = 1;
   13630 
   13631         int rc = cil_gen_genfscon(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   13632         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   13633 }
   13634 
   13635 void test_cil_gen_genfscon_typeparens_neg(CuTest *tc) {
   13636 	char *line[] = {"(", "genfscon", "(", "type", ")", "path", "con", ")", NULL};
   13637 
   13638         struct cil_tree *test_tree;
   13639         gen_test_tree(&test_tree, line);
   13640 
   13641         struct cil_tree_node *test_ast_node;
   13642         cil_tree_node_init(&test_ast_node);
   13643 
   13644         struct cil_db *test_db;
   13645         cil_db_init(&test_db);
   13646 
   13647         test_ast_node->parent = test_db->ast->root;
   13648         test_ast_node->line = 1;
   13649 
   13650         int rc = cil_gen_genfscon(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   13651         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   13652 }
   13653 
   13654 void test_cil_gen_genfscon_pathnull_neg(CuTest *tc) {
   13655 	char *line[] = {"(", "genfscon", "type", ")", NULL};
   13656 
   13657         struct cil_tree *test_tree;
   13658         gen_test_tree(&test_tree, line);
   13659 
   13660         struct cil_tree_node *test_ast_node;
   13661         cil_tree_node_init(&test_ast_node);
   13662 
   13663         struct cil_db *test_db;
   13664         cil_db_init(&test_db);
   13665 
   13666         test_ast_node->parent = test_db->ast->root;
   13667         test_ast_node->line = 1;
   13668 
   13669         int rc = cil_gen_genfscon(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   13670         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   13671 }
   13672 
   13673 void test_cil_gen_genfscon_pathparens_neg(CuTest *tc) {
   13674 	char *line[] = {"(", "genfscon", "type", "(", "path", ")", "con", ")", NULL};
   13675 
   13676         struct cil_tree *test_tree;
   13677         gen_test_tree(&test_tree, line);
   13678 
   13679         struct cil_tree_node *test_ast_node;
   13680         cil_tree_node_init(&test_ast_node);
   13681 
   13682         struct cil_db *test_db;
   13683         cil_db_init(&test_db);
   13684 
   13685         test_ast_node->parent = test_db->ast->root;
   13686         test_ast_node->line = 1;
   13687 
   13688         int rc = cil_gen_genfscon(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   13689         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   13690 }
   13691 
   13692 void test_cil_gen_genfscon_contextnull_neg(CuTest *tc) {
   13693 	char *line[] = {"(", "genfscon", "type", "path", ")", NULL};
   13694 
   13695         struct cil_tree *test_tree;
   13696         gen_test_tree(&test_tree, line);
   13697 
   13698         struct cil_tree_node *test_ast_node;
   13699         cil_tree_node_init(&test_ast_node);
   13700 
   13701         struct cil_db *test_db;
   13702         cil_db_init(&test_db);
   13703 
   13704         test_ast_node->parent = test_db->ast->root;
   13705         test_ast_node->line = 1;
   13706 
   13707         int rc = cil_gen_genfscon(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   13708         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   13709 }
   13710 
   13711 void test_cil_gen_genfscon_context_neg(CuTest *tc) {
   13712 	char *line[] = {"(", "genfscon", "type", "path", "(", "system_u", "object_r", "(", "low", "high", ")", ")", ")", NULL};
   13713 
   13714         struct cil_tree *test_tree;
   13715         gen_test_tree(&test_tree, line);
   13716 
   13717         struct cil_tree_node *test_ast_node;
   13718         cil_tree_node_init(&test_ast_node);
   13719 
   13720         struct cil_db *test_db;
   13721         cil_db_init(&test_db);
   13722 
   13723         test_ast_node->parent = test_db->ast->root;
   13724         test_ast_node->line = 1;
   13725 
   13726         int rc = cil_gen_genfscon(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   13727         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   13728 }
   13729 
   13730 void test_cil_gen_genfscon_extra_neg(CuTest *tc) {
   13731 	char *line[] = {"(", "genfscon", "type", "path", "con", "extra", ")", NULL};
   13732 
   13733         struct cil_tree *test_tree;
   13734         gen_test_tree(&test_tree, line);
   13735 
   13736         struct cil_tree_node *test_ast_node;
   13737         cil_tree_node_init(&test_ast_node);
   13738 
   13739         struct cil_db *test_db;
   13740         cil_db_init(&test_db);
   13741 
   13742         test_ast_node->parent = test_db->ast->root;
   13743         test_ast_node->line = 1;
   13744 
   13745         int rc = cil_gen_genfscon(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   13746         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   13747 }
   13748 
   13749 void test_cil_gen_netifcon(CuTest *tc) {
   13750 	char *line[] = {"(", "netifcon", "eth0", "if_default", "packet_default", ")", NULL};
   13751 
   13752         struct cil_tree *test_tree;
   13753         gen_test_tree(&test_tree, line);
   13754 
   13755         struct cil_tree_node *test_ast_node;
   13756         cil_tree_node_init(&test_ast_node);
   13757 
   13758         struct cil_db *test_db;
   13759         cil_db_init(&test_db);
   13760 
   13761         test_ast_node->parent = test_db->ast->root;
   13762         test_ast_node->line = 1;
   13763 
   13764         int rc = cil_gen_netifcon(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   13765         CuAssertIntEquals(tc, SEPOL_OK, rc);
   13766 }
   13767 
   13768 void test_cil_gen_netifcon_nested(CuTest *tc) {
   13769 	char *line[] = {"(", "netifcon", "eth1",
   13770 			"(", "system_u", "object_r", "netif_t", "(", "low", "high", ")", ")",
   13771 			"(", "system_u", "object_r", "netif_t", "(", "low", "high", ")", ")", ")", NULL};
   13772 
   13773         struct cil_tree *test_tree;
   13774         gen_test_tree(&test_tree, line);
   13775 
   13776         struct cil_tree_node *test_ast_node;
   13777         cil_tree_node_init(&test_ast_node);
   13778 
   13779         struct cil_db *test_db;
   13780         cil_db_init(&test_db);
   13781 
   13782         test_ast_node->parent = test_db->ast->root;
   13783         test_ast_node->line = 1;
   13784 
   13785         int rc = cil_gen_netifcon(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   13786         CuAssertIntEquals(tc, SEPOL_OK, rc);
   13787 }
   13788 
   13789 void test_cil_gen_netifcon_nested_neg(CuTest *tc) {
   13790 	char *line[] = {"(", "netifcon", "(", "eth1", ")", ")", NULL};
   13791 
   13792         struct cil_tree *test_tree;
   13793         gen_test_tree(&test_tree, line);
   13794 
   13795         struct cil_tree_node *test_ast_node;
   13796         cil_tree_node_init(&test_ast_node);
   13797 
   13798         struct cil_db *test_db;
   13799         cil_db_init(&test_db);
   13800 
   13801         test_ast_node->parent = test_db->ast->root;
   13802         test_ast_node->line = 1;
   13803 
   13804         int rc = cil_gen_netifcon(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   13805         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   13806 }
   13807 
   13808 void test_cil_gen_netifcon_nested_emptysecondlist_neg(CuTest *tc) {
   13809 	char *line[] = {"(", "netifcon", "eth1",
   13810 			"(", "system_u", "object_r", "netif_t", "(", "low", "high", ")", ")",
   13811 			"(", ")", ")", NULL};
   13812 
   13813         struct cil_tree *test_tree;
   13814         gen_test_tree(&test_tree, line);
   13815 
   13816         struct cil_tree_node *test_ast_node;
   13817         cil_tree_node_init(&test_ast_node);
   13818 
   13819         struct cil_db *test_db;
   13820         cil_db_init(&test_db);
   13821 
   13822         test_ast_node->parent = test_db->ast->root;
   13823         test_ast_node->line = 1;
   13824 
   13825         int rc = cil_gen_netifcon(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   13826         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   13827 }
   13828 
   13829 void test_cil_gen_netifcon_extra_nested_secondlist_neg(CuTest *tc) {
   13830 	char *line[] = {"(", "netifcon", "eth0", "extra",
   13831 			"(", "system_u", "object_r", "netif_t", "(", "low", "high", ")", ")",
   13832 			"(", "foo", ")", ")", NULL};
   13833 
   13834         struct cil_tree *test_tree;
   13835         gen_test_tree(&test_tree, line);
   13836 
   13837         struct cil_tree_node *test_ast_node;
   13838         cil_tree_node_init(&test_ast_node);
   13839 
   13840         struct cil_db *test_db;
   13841         cil_db_init(&test_db);
   13842 
   13843         test_ast_node->parent = test_db->ast->root;
   13844         test_ast_node->line = 1;
   13845 
   13846         int rc = cil_gen_netifcon(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   13847         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   13848 }
   13849 
   13850 void test_cil_gen_netifcon_nested_missingobjects_neg(CuTest *tc) {
   13851 	char *line[] = {"(", "netifcon", "eth1",
   13852 			"(", "system_u", ")",
   13853 			"(", "system_u", "object_r", "netif_t", "(", "low", "high", ")", ")", ")", NULL};
   13854 
   13855         struct cil_tree *test_tree;
   13856         gen_test_tree(&test_tree, line);
   13857 
   13858         struct cil_tree_node *test_ast_node;
   13859         cil_tree_node_init(&test_ast_node);
   13860 
   13861         struct cil_db *test_db;
   13862         cil_db_init(&test_db);
   13863 
   13864         test_ast_node->parent = test_db->ast->root;
   13865         test_ast_node->line = 1;
   13866 
   13867         int rc = cil_gen_netifcon(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   13868         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   13869 }
   13870 
   13871 void test_cil_gen_netifcon_nested_secondnested_missingobjects_neg(CuTest *tc) {
   13872 	char *line[] = {"(", "netifcon", "eth1",
   13873 			"(", "system_u", "object_r", "netif_t", "(", "low", "high", ")", ")",
   13874 			"(", "system_u", ")", ")", NULL};
   13875 
   13876         struct cil_tree *test_tree;
   13877         gen_test_tree(&test_tree, line);
   13878 
   13879         struct cil_tree_node *test_ast_node;
   13880         cil_tree_node_init(&test_ast_node);
   13881 
   13882         struct cil_db *test_db;
   13883         cil_db_init(&test_db);
   13884 
   13885         test_ast_node->parent = test_db->ast->root;
   13886         test_ast_node->line = 1;
   13887 
   13888         int rc = cil_gen_netifcon(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   13889         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   13890 }
   13891 
   13892 void test_cil_gen_netifcon_dbnull_neg(CuTest *tc) {
   13893 	char *line[] = {"(", "netifcon", "eth0", "if_default", "packet_default", ")", NULL};
   13894 
   13895         struct cil_tree *test_tree;
   13896         gen_test_tree(&test_tree, line);
   13897 
   13898         struct cil_tree_node *test_ast_node;
   13899         cil_tree_node_init(&test_ast_node);
   13900 
   13901         struct cil_db *test_db = NULL;
   13902 
   13903         int rc = cil_gen_netifcon(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   13904         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   13905 }
   13906 
   13907 void test_cil_gen_netifcon_currnull_neg(CuTest *tc) {
   13908 	char *line[] = {"(", ")", NULL};
   13909 
   13910         struct cil_tree *test_tree;
   13911         gen_test_tree(&test_tree, line);
   13912 
   13913         struct cil_tree_node *test_ast_node;
   13914         cil_tree_node_init(&test_ast_node);
   13915 
   13916         struct cil_db *test_db;
   13917         cil_db_init(&test_db);
   13918 
   13919         test_ast_node->parent = test_db->ast->root;
   13920         test_ast_node->line = 1;
   13921 
   13922         int rc = cil_gen_netifcon(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   13923         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   13924 }
   13925 
   13926 void test_cil_gen_netifcon_astnull_neg(CuTest *tc) {
   13927 	char *line[] = {"(", "netifcon", "eth0", "if_default", "packet_default", ")", NULL};
   13928 
   13929         struct cil_tree *test_tree;
   13930         gen_test_tree(&test_tree, line);
   13931 
   13932         struct cil_tree_node *test_ast_node = NULL;
   13933 
   13934         struct cil_db *test_db;
   13935         cil_db_init(&test_db);
   13936 
   13937         int rc = cil_gen_netifcon(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   13938         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   13939 }
   13940 
   13941 void test_cil_gen_netifcon_ethmissing_neg(CuTest *tc) {
   13942 	char *line[] = {"(", "netifcon", ")", NULL};
   13943 
   13944         struct cil_tree *test_tree;
   13945         gen_test_tree(&test_tree, line);
   13946 
   13947         struct cil_tree_node *test_ast_node;
   13948         cil_tree_node_init(&test_ast_node);
   13949 
   13950         struct cil_db *test_db;
   13951         cil_db_init(&test_db);
   13952 
   13953         test_ast_node->parent = test_db->ast->root;
   13954         test_ast_node->line = 1;
   13955 
   13956         int rc = cil_gen_netifcon(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   13957         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   13958 }
   13959 
   13960 void test_cil_gen_netifcon_interfacemissing_neg(CuTest *tc) {
   13961 	char *line[] = {"(", "netifcon", "eth0", ")", NULL};
   13962 
   13963         struct cil_tree *test_tree;
   13964         gen_test_tree(&test_tree, line);
   13965 
   13966         struct cil_tree_node *test_ast_node;
   13967         cil_tree_node_init(&test_ast_node);
   13968 
   13969         struct cil_db *test_db;
   13970         cil_db_init(&test_db);
   13971 
   13972         test_ast_node->parent = test_db->ast->root;
   13973         test_ast_node->line = 1;
   13974 
   13975         int rc = cil_gen_netifcon(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   13976         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   13977 }
   13978 
   13979 void test_cil_gen_netifcon_packetmissing_neg(CuTest *tc) {
   13980 	char *line[] = {"(", "netifcon", "eth0", "if_default", ")", NULL};
   13981 
   13982         struct cil_tree *test_tree;
   13983         gen_test_tree(&test_tree, line);
   13984 
   13985         struct cil_tree_node *test_ast_node;
   13986         cil_tree_node_init(&test_ast_node);
   13987 
   13988         struct cil_db *test_db;
   13989         cil_db_init(&test_db);
   13990 
   13991         test_ast_node->parent = test_db->ast->root;
   13992         test_ast_node->line = 1;
   13993 
   13994         int rc = cil_gen_netifcon(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   13995         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   13996 }
   13997 
   13998 void test_cil_gen_pirqcon(CuTest *tc) {
   13999 	char *line[] = {"(", "pirqcon", "1", "con", ")", NULL};
   14000 
   14001         struct cil_tree *test_tree;
   14002         gen_test_tree(&test_tree, line);
   14003 
   14004         struct cil_tree_node *test_ast_node;
   14005         cil_tree_node_init(&test_ast_node);
   14006 
   14007         struct cil_db *test_db;
   14008         cil_db_init(&test_db);
   14009 
   14010         test_ast_node->parent = test_db->ast->root;
   14011         test_ast_node->line = 1;
   14012 
   14013         int rc = cil_gen_pirqcon(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   14014         CuAssertIntEquals(tc, SEPOL_OK, rc);
   14015 }
   14016 
   14017 void test_cil_gen_pirqcon_pirqnotint_neg(CuTest *tc) {
   14018 	char *line[] = {"(", "pirqcon", "notint", "con", ")", NULL};
   14019 
   14020         struct cil_tree *test_tree;
   14021         gen_test_tree(&test_tree, line);
   14022 
   14023         struct cil_tree_node *test_ast_node;
   14024         cil_tree_node_init(&test_ast_node);
   14025 
   14026         struct cil_db *test_db;
   14027         cil_db_init(&test_db);
   14028 
   14029         test_ast_node->parent = test_db->ast->root;
   14030         test_ast_node->line = 1;
   14031 
   14032         int rc = cil_gen_pirqcon(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   14033         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   14034 }
   14035 
   14036 void test_cil_gen_pirqcon_nopirq_neg(CuTest *tc) {
   14037 	char *line[] = {"(", "pirqcon", ")", NULL};
   14038 
   14039         struct cil_tree *test_tree;
   14040         gen_test_tree(&test_tree, line);
   14041 
   14042         struct cil_tree_node *test_ast_node;
   14043         cil_tree_node_init(&test_ast_node);
   14044 
   14045         struct cil_db *test_db;
   14046         cil_db_init(&test_db);
   14047 
   14048         test_ast_node->parent = test_db->ast->root;
   14049         test_ast_node->line = 1;
   14050 
   14051         int rc = cil_gen_pirqcon(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   14052         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   14053 }
   14054 
   14055 void test_cil_gen_pirqcon_pirqrange_neg(CuTest *tc) {
   14056 	char *line[] = {"(", "pirqcon", "(", "1", ")", "con", ")", NULL};
   14057 
   14058         struct cil_tree *test_tree;
   14059         gen_test_tree(&test_tree, line);
   14060 
   14061         struct cil_tree_node *test_ast_node;
   14062         cil_tree_node_init(&test_ast_node);
   14063 
   14064         struct cil_db *test_db;
   14065         cil_db_init(&test_db);
   14066 
   14067         test_ast_node->parent = test_db->ast->root;
   14068         test_ast_node->line = 1;
   14069 
   14070         int rc = cil_gen_pirqcon(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   14071         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   14072 }
   14073 
   14074 void test_cil_gen_pirqcon_nocontext_neg(CuTest *tc) {
   14075 	char *line[] = {"(", "pirqcon", "1", ")", NULL};
   14076 
   14077         struct cil_tree *test_tree;
   14078         gen_test_tree(&test_tree, line);
   14079 
   14080         struct cil_tree_node *test_ast_node;
   14081         cil_tree_node_init(&test_ast_node);
   14082 
   14083         struct cil_db *test_db;
   14084         cil_db_init(&test_db);
   14085 
   14086         test_ast_node->parent = test_db->ast->root;
   14087         test_ast_node->line = 1;
   14088 
   14089         int rc = cil_gen_pirqcon(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   14090         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   14091 }
   14092 
   14093 void test_cil_gen_pirqcon_anoncontext_neg(CuTest *tc) {
   14094 	char *line[] = {"(", "pirqcon", "1", "(", "con", ")", ")", NULL};
   14095 
   14096         struct cil_tree *test_tree;
   14097         gen_test_tree(&test_tree, line);
   14098 
   14099         struct cil_tree_node *test_ast_node;
   14100         cil_tree_node_init(&test_ast_node);
   14101 
   14102         struct cil_db *test_db;
   14103         cil_db_init(&test_db);
   14104 
   14105         test_ast_node->parent = test_db->ast->root;
   14106         test_ast_node->line = 1;
   14107 
   14108         int rc = cil_gen_pirqcon(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   14109         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   14110 }
   14111 
   14112 void test_cil_gen_pirqcon_extra_neg(CuTest *tc) {
   14113 	char *line[] = {"(", "pirqcon", "1", "con", "extra", ")", NULL};
   14114 
   14115         struct cil_tree *test_tree;
   14116         gen_test_tree(&test_tree, line);
   14117 
   14118         struct cil_tree_node *test_ast_node;
   14119         cil_tree_node_init(&test_ast_node);
   14120 
   14121         struct cil_db *test_db;
   14122         cil_db_init(&test_db);
   14123 
   14124         test_ast_node->parent = test_db->ast->root;
   14125         test_ast_node->line = 1;
   14126 
   14127         int rc = cil_gen_pirqcon(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   14128         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   14129 }
   14130 
   14131 void test_cil_gen_pirqcon_dbnull_neg(CuTest *tc) {
   14132 	char *line[] = {"(", "pirqcon", "1", "con", ")", NULL};
   14133 
   14134         struct cil_tree *test_tree;
   14135         gen_test_tree(&test_tree, line);
   14136 
   14137         struct cil_tree_node *test_ast_node;
   14138         cil_tree_node_init(&test_ast_node);
   14139 
   14140         struct cil_db *test_db = NULL;
   14141 
   14142         int rc = cil_gen_pirqcon(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   14143         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   14144 }
   14145 
   14146 void test_cil_gen_pirqcon_currnull_neg(CuTest *tc) {
   14147 	char *line[] = {"(", ")", NULL};
   14148 
   14149         struct cil_tree *test_tree;
   14150         gen_test_tree(&test_tree, line);
   14151 
   14152         struct cil_tree_node *test_ast_node;
   14153         cil_tree_node_init(&test_ast_node);
   14154 
   14155         struct cil_db *test_db;
   14156         cil_db_init(&test_db);
   14157 
   14158         test_ast_node->parent = test_db->ast->root;
   14159         test_ast_node->line = 1;
   14160 
   14161         int rc = cil_gen_pirqcon(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   14162         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   14163 }
   14164 
   14165 void test_cil_gen_pirqcon_astnull_neg(CuTest *tc) {
   14166 	char *line[] = {"(", "pirqcon", "1", "con", ")", NULL};
   14167 
   14168         struct cil_tree *test_tree;
   14169         gen_test_tree(&test_tree, line);
   14170 
   14171         struct cil_tree_node *test_ast_node = NULL;
   14172 
   14173         struct cil_db *test_db;
   14174         cil_db_init(&test_db);
   14175 
   14176         int rc = cil_gen_pirqcon(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   14177         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   14178 }
   14179 
   14180 void test_cil_gen_iomemcon(CuTest *tc) {
   14181 	char *line[] = {"(", "iomemcon", "1", "con", ")", NULL};
   14182 
   14183         struct cil_tree *test_tree;
   14184         gen_test_tree(&test_tree, line);
   14185 
   14186         struct cil_tree_node *test_ast_node;
   14187         cil_tree_node_init(&test_ast_node);
   14188 
   14189         struct cil_db *test_db;
   14190         cil_db_init(&test_db);
   14191 
   14192         test_ast_node->parent = test_db->ast->root;
   14193         test_ast_node->line = 1;
   14194 
   14195         int rc = cil_gen_iomemcon(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   14196         CuAssertIntEquals(tc, SEPOL_OK, rc);
   14197 }
   14198 
   14199 void test_cil_gen_iomemcon_iomemrange(CuTest *tc) {
   14200 	char *line[] = {"(", "iomemcon", "(", "1", "2", ")", "con", ")", NULL};
   14201 
   14202         struct cil_tree *test_tree;
   14203         gen_test_tree(&test_tree, line);
   14204 
   14205         struct cil_tree_node *test_ast_node;
   14206         cil_tree_node_init(&test_ast_node);
   14207 
   14208         struct cil_db *test_db;
   14209         cil_db_init(&test_db);
   14210 
   14211         test_ast_node->parent = test_db->ast->root;
   14212         test_ast_node->line = 1;
   14213 
   14214         int rc = cil_gen_iomemcon(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   14215         CuAssertIntEquals(tc, SEPOL_OK, rc);
   14216 }
   14217 
   14218 void test_cil_gen_iomemcon_iomemrange_firstnotint_neg(CuTest *tc) {
   14219 	char *line[] = {"(", "iomemcon", "(", "foo", "2", ")", "con", ")", NULL};
   14220 
   14221         struct cil_tree *test_tree;
   14222         gen_test_tree(&test_tree, line);
   14223 
   14224         struct cil_tree_node *test_ast_node;
   14225         cil_tree_node_init(&test_ast_node);
   14226 
   14227         struct cil_db *test_db;
   14228         cil_db_init(&test_db);
   14229 
   14230         test_ast_node->parent = test_db->ast->root;
   14231         test_ast_node->line = 1;
   14232 
   14233         int rc = cil_gen_iomemcon(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   14234         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   14235 }
   14236 
   14237 void test_cil_gen_iomemcon_iomemrange_secondnotint_neg(CuTest *tc) {
   14238 	char *line[] = {"(", "iomemcon", "(", "1", "foo", ")", "con", ")", NULL};
   14239 
   14240         struct cil_tree *test_tree;
   14241         gen_test_tree(&test_tree, line);
   14242 
   14243         struct cil_tree_node *test_ast_node;
   14244         cil_tree_node_init(&test_ast_node);
   14245 
   14246         struct cil_db *test_db;
   14247         cil_db_init(&test_db);
   14248 
   14249         test_ast_node->parent = test_db->ast->root;
   14250         test_ast_node->line = 1;
   14251 
   14252         int rc = cil_gen_iomemcon(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   14253         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   14254 }
   14255 
   14256 void test_cil_gen_iomemcon_iomemrange_empty_neg(CuTest *tc) {
   14257 	char *line[] = {"(", "iomemcon", "(", ")", "con", ")", NULL};
   14258 
   14259         struct cil_tree *test_tree;
   14260         gen_test_tree(&test_tree, line);
   14261 
   14262         struct cil_tree_node *test_ast_node;
   14263         cil_tree_node_init(&test_ast_node);
   14264 
   14265         struct cil_db *test_db;
   14266         cil_db_init(&test_db);
   14267 
   14268         test_ast_node->parent = test_db->ast->root;
   14269         test_ast_node->line = 1;
   14270 
   14271         int rc = cil_gen_iomemcon(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   14272         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   14273 }
   14274 
   14275 void test_cil_gen_iomemcon_iomemrange_singleiomem_neg(CuTest *tc) {
   14276 	char *line[] = {"(", "iomemcon", "(", "1", ")", "con", ")", NULL};
   14277 
   14278         struct cil_tree *test_tree;
   14279         gen_test_tree(&test_tree, line);
   14280 
   14281         struct cil_tree_node *test_ast_node;
   14282         cil_tree_node_init(&test_ast_node);
   14283 
   14284         struct cil_db *test_db;
   14285         cil_db_init(&test_db);
   14286 
   14287         test_ast_node->parent = test_db->ast->root;
   14288         test_ast_node->line = 1;
   14289 
   14290         int rc = cil_gen_iomemcon(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   14291         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   14292 }
   14293 
   14294 void test_cil_gen_iomemcon_iomemrange_morethantwoiomem_neg(CuTest *tc) {
   14295 	char *line[] = {"(", "iomemcon", "(", "1", "2", "3", ")", "con", ")", NULL};
   14296 
   14297         struct cil_tree *test_tree;
   14298         gen_test_tree(&test_tree, line);
   14299 
   14300         struct cil_tree_node *test_ast_node;
   14301         cil_tree_node_init(&test_ast_node);
   14302 
   14303         struct cil_db *test_db;
   14304         cil_db_init(&test_db);
   14305 
   14306         test_ast_node->parent = test_db->ast->root;
   14307         test_ast_node->line = 1;
   14308 
   14309         int rc = cil_gen_iomemcon(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   14310         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   14311 }
   14312 
   14313 void test_cil_gen_iomemcon_iomemnotint_neg(CuTest *tc) {
   14314 	char *line[] = {"(", "iomemcon", "notint", "con", ")", NULL};
   14315 
   14316         struct cil_tree *test_tree;
   14317         gen_test_tree(&test_tree, line);
   14318 
   14319         struct cil_tree_node *test_ast_node;
   14320         cil_tree_node_init(&test_ast_node);
   14321 
   14322         struct cil_db *test_db;
   14323         cil_db_init(&test_db);
   14324 
   14325         test_ast_node->parent = test_db->ast->root;
   14326         test_ast_node->line = 1;
   14327 
   14328         int rc = cil_gen_iomemcon(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   14329         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   14330 }
   14331 
   14332 void test_cil_gen_iomemcon_noiomem_neg(CuTest *tc) {
   14333 	char *line[] = {"(", "iomemcon", ")", NULL};
   14334 
   14335         struct cil_tree *test_tree;
   14336         gen_test_tree(&test_tree, line);
   14337 
   14338         struct cil_tree_node *test_ast_node;
   14339         cil_tree_node_init(&test_ast_node);
   14340 
   14341         struct cil_db *test_db;
   14342         cil_db_init(&test_db);
   14343 
   14344         test_ast_node->parent = test_db->ast->root;
   14345         test_ast_node->line = 1;
   14346 
   14347         int rc = cil_gen_iomemcon(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   14348         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   14349 }
   14350 
   14351 void test_cil_gen_iomemcon_nocontext_neg(CuTest *tc) {
   14352 	char *line[] = {"(", "iomemcon", "1", ")", NULL};
   14353 
   14354         struct cil_tree *test_tree;
   14355         gen_test_tree(&test_tree, line);
   14356 
   14357         struct cil_tree_node *test_ast_node;
   14358         cil_tree_node_init(&test_ast_node);
   14359 
   14360         struct cil_db *test_db;
   14361         cil_db_init(&test_db);
   14362 
   14363         test_ast_node->parent = test_db->ast->root;
   14364         test_ast_node->line = 1;
   14365 
   14366         int rc = cil_gen_iomemcon(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   14367         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   14368 }
   14369 
   14370 void test_cil_gen_iomemcon_anoncontext_neg(CuTest *tc) {
   14371 	char *line[] = {"(", "iomemcon", "1", "(", "con", ")", ")", NULL};
   14372 
   14373         struct cil_tree *test_tree;
   14374         gen_test_tree(&test_tree, line);
   14375 
   14376         struct cil_tree_node *test_ast_node;
   14377         cil_tree_node_init(&test_ast_node);
   14378 
   14379         struct cil_db *test_db;
   14380         cil_db_init(&test_db);
   14381 
   14382         test_ast_node->parent = test_db->ast->root;
   14383         test_ast_node->line = 1;
   14384 
   14385         int rc = cil_gen_iomemcon(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   14386         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   14387 }
   14388 
   14389 void test_cil_gen_iomemcon_extra_neg(CuTest *tc) {
   14390 	char *line[] = {"(", "iomemcon", "1", "con", "extra", ")", NULL};
   14391 
   14392         struct cil_tree *test_tree;
   14393         gen_test_tree(&test_tree, line);
   14394 
   14395         struct cil_tree_node *test_ast_node;
   14396         cil_tree_node_init(&test_ast_node);
   14397 
   14398         struct cil_db *test_db;
   14399         cil_db_init(&test_db);
   14400 
   14401         test_ast_node->parent = test_db->ast->root;
   14402         test_ast_node->line = 1;
   14403 
   14404         int rc = cil_gen_iomemcon(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   14405         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   14406 }
   14407 
   14408 void test_cil_gen_iomemcon_dbnull_neg(CuTest *tc) {
   14409 	char *line[] = {"(", "iomemcon", "1", "con", ")", NULL};
   14410 
   14411         struct cil_tree *test_tree;
   14412         gen_test_tree(&test_tree, line);
   14413 
   14414         struct cil_tree_node *test_ast_node;
   14415         cil_tree_node_init(&test_ast_node);
   14416 
   14417         struct cil_db *test_db = NULL;
   14418 
   14419         int rc = cil_gen_iomemcon(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   14420         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   14421 }
   14422 
   14423 void test_cil_gen_iomemcon_currnull_neg(CuTest *tc) {
   14424 	char *line[] = {"(", ")", NULL};
   14425 
   14426         struct cil_tree *test_tree;
   14427         gen_test_tree(&test_tree, line);
   14428 
   14429         struct cil_tree_node *test_ast_node;
   14430         cil_tree_node_init(&test_ast_node);
   14431 
   14432         struct cil_db *test_db;
   14433         cil_db_init(&test_db);
   14434 
   14435         test_ast_node->parent = test_db->ast->root;
   14436         test_ast_node->line = 1;
   14437 
   14438         int rc = cil_gen_iomemcon(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   14439         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   14440 }
   14441 
   14442 void test_cil_gen_iomemcon_astnull_neg(CuTest *tc) {
   14443 	char *line[] = {"(", "iomemcon", "1", "con", ")", NULL};
   14444 
   14445         struct cil_tree *test_tree;
   14446         gen_test_tree(&test_tree, line);
   14447 
   14448         struct cil_tree_node *test_ast_node = NULL;
   14449 
   14450         struct cil_db *test_db;
   14451         cil_db_init(&test_db);
   14452 
   14453         int rc = cil_gen_iomemcon(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   14454         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   14455 }
   14456 
   14457 void test_cil_gen_ioportcon(CuTest *tc) {
   14458 	char *line[] = {"(", "ioportcon", "1", "con", ")", NULL};
   14459 
   14460         struct cil_tree *test_tree;
   14461         gen_test_tree(&test_tree, line);
   14462 
   14463         struct cil_tree_node *test_ast_node;
   14464         cil_tree_node_init(&test_ast_node);
   14465 
   14466         struct cil_db *test_db;
   14467         cil_db_init(&test_db);
   14468 
   14469         test_ast_node->parent = test_db->ast->root;
   14470         test_ast_node->line = 1;
   14471 
   14472         int rc = cil_gen_ioportcon(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   14473         CuAssertIntEquals(tc, SEPOL_OK, rc);
   14474 }
   14475 
   14476 void test_cil_gen_ioportcon_ioportrange(CuTest *tc) {
   14477 	char *line[] = {"(", "ioportcon", "(", "1", "2", ")", "con", ")", NULL};
   14478 
   14479         struct cil_tree *test_tree;
   14480         gen_test_tree(&test_tree, line);
   14481 
   14482         struct cil_tree_node *test_ast_node;
   14483         cil_tree_node_init(&test_ast_node);
   14484 
   14485         struct cil_db *test_db;
   14486         cil_db_init(&test_db);
   14487 
   14488         test_ast_node->parent = test_db->ast->root;
   14489         test_ast_node->line = 1;
   14490 
   14491         int rc = cil_gen_ioportcon(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   14492         CuAssertIntEquals(tc, SEPOL_OK, rc);
   14493 }
   14494 
   14495 void test_cil_gen_ioportcon_ioportrange_firstnotint_neg(CuTest *tc) {
   14496 	char *line[] = {"(", "ioportcon", "(", "foo", "2", ")", "con", ")", NULL};
   14497 
   14498         struct cil_tree *test_tree;
   14499         gen_test_tree(&test_tree, line);
   14500 
   14501         struct cil_tree_node *test_ast_node;
   14502         cil_tree_node_init(&test_ast_node);
   14503 
   14504         struct cil_db *test_db;
   14505         cil_db_init(&test_db);
   14506 
   14507         test_ast_node->parent = test_db->ast->root;
   14508         test_ast_node->line = 1;
   14509 
   14510         int rc = cil_gen_ioportcon(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   14511         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   14512 }
   14513 
   14514 void test_cil_gen_ioportcon_ioportrange_secondnotint_neg(CuTest *tc) {
   14515 	char *line[] = {"(", "ioportcon", "(", "1", "foo", ")", "con", ")", NULL};
   14516 
   14517         struct cil_tree *test_tree;
   14518         gen_test_tree(&test_tree, line);
   14519 
   14520         struct cil_tree_node *test_ast_node;
   14521         cil_tree_node_init(&test_ast_node);
   14522 
   14523         struct cil_db *test_db;
   14524         cil_db_init(&test_db);
   14525 
   14526         test_ast_node->parent = test_db->ast->root;
   14527         test_ast_node->line = 1;
   14528 
   14529         int rc = cil_gen_ioportcon(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   14530         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   14531 }
   14532 
   14533 void test_cil_gen_ioportcon_ioportrange_empty_neg(CuTest *tc) {
   14534 	char *line[] = {"(", "ioportcon", "(", ")", "con", ")", NULL};
   14535 
   14536         struct cil_tree *test_tree;
   14537         gen_test_tree(&test_tree, line);
   14538 
   14539         struct cil_tree_node *test_ast_node;
   14540         cil_tree_node_init(&test_ast_node);
   14541 
   14542         struct cil_db *test_db;
   14543         cil_db_init(&test_db);
   14544 
   14545         test_ast_node->parent = test_db->ast->root;
   14546         test_ast_node->line = 1;
   14547 
   14548         int rc = cil_gen_ioportcon(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   14549         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   14550 }
   14551 
   14552 void test_cil_gen_ioportcon_ioportrange_singleioport_neg(CuTest *tc) {
   14553 	char *line[] = {"(", "ioportcon", "(", "1", ")", "con", ")", NULL};
   14554 
   14555         struct cil_tree *test_tree;
   14556         gen_test_tree(&test_tree, line);
   14557 
   14558         struct cil_tree_node *test_ast_node;
   14559         cil_tree_node_init(&test_ast_node);
   14560 
   14561         struct cil_db *test_db;
   14562         cil_db_init(&test_db);
   14563 
   14564         test_ast_node->parent = test_db->ast->root;
   14565         test_ast_node->line = 1;
   14566 
   14567         int rc = cil_gen_ioportcon(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   14568         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   14569 }
   14570 
   14571 void test_cil_gen_ioportcon_ioportrange_morethantwoioport_neg(CuTest *tc) {
   14572 	char *line[] = {"(", "ioportcon", "(", "1", "2", "3", ")", "con", ")", NULL};
   14573 
   14574         struct cil_tree *test_tree;
   14575         gen_test_tree(&test_tree, line);
   14576 
   14577         struct cil_tree_node *test_ast_node;
   14578         cil_tree_node_init(&test_ast_node);
   14579 
   14580         struct cil_db *test_db;
   14581         cil_db_init(&test_db);
   14582 
   14583         test_ast_node->parent = test_db->ast->root;
   14584         test_ast_node->line = 1;
   14585 
   14586         int rc = cil_gen_ioportcon(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   14587         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   14588 }
   14589 
   14590 void test_cil_gen_ioportcon_ioportnotint_neg(CuTest *tc) {
   14591 	char *line[] = {"(", "ioportcon", "notint", "con", ")", NULL};
   14592 
   14593         struct cil_tree *test_tree;
   14594         gen_test_tree(&test_tree, line);
   14595 
   14596         struct cil_tree_node *test_ast_node;
   14597         cil_tree_node_init(&test_ast_node);
   14598 
   14599         struct cil_db *test_db;
   14600         cil_db_init(&test_db);
   14601 
   14602         test_ast_node->parent = test_db->ast->root;
   14603         test_ast_node->line = 1;
   14604 
   14605         int rc = cil_gen_ioportcon(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   14606         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   14607 }
   14608 
   14609 void test_cil_gen_ioportcon_noioport_neg(CuTest *tc) {
   14610 	char *line[] = {"(", "ioportcon", ")", NULL};
   14611 
   14612         struct cil_tree *test_tree;
   14613         gen_test_tree(&test_tree, line);
   14614 
   14615         struct cil_tree_node *test_ast_node;
   14616         cil_tree_node_init(&test_ast_node);
   14617 
   14618         struct cil_db *test_db;
   14619         cil_db_init(&test_db);
   14620 
   14621         test_ast_node->parent = test_db->ast->root;
   14622         test_ast_node->line = 1;
   14623 
   14624         int rc = cil_gen_ioportcon(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   14625         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   14626 }
   14627 
   14628 void test_cil_gen_ioportcon_nocontext_neg(CuTest *tc) {
   14629 	char *line[] = {"(", "ioportcon", "1", ")", NULL};
   14630 
   14631         struct cil_tree *test_tree;
   14632         gen_test_tree(&test_tree, line);
   14633 
   14634         struct cil_tree_node *test_ast_node;
   14635         cil_tree_node_init(&test_ast_node);
   14636 
   14637         struct cil_db *test_db;
   14638         cil_db_init(&test_db);
   14639 
   14640         test_ast_node->parent = test_db->ast->root;
   14641         test_ast_node->line = 1;
   14642 
   14643         int rc = cil_gen_ioportcon(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   14644         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   14645 }
   14646 
   14647 void test_cil_gen_ioportcon_anoncontext_neg(CuTest *tc) {
   14648 	char *line[] = {"(", "ioportcon", "1", "(", "con", ")", ")", NULL};
   14649 
   14650         struct cil_tree *test_tree;
   14651         gen_test_tree(&test_tree, line);
   14652 
   14653         struct cil_tree_node *test_ast_node;
   14654         cil_tree_node_init(&test_ast_node);
   14655 
   14656         struct cil_db *test_db;
   14657         cil_db_init(&test_db);
   14658 
   14659         test_ast_node->parent = test_db->ast->root;
   14660         test_ast_node->line = 1;
   14661 
   14662         int rc = cil_gen_ioportcon(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   14663         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   14664 }
   14665 
   14666 void test_cil_gen_ioportcon_extra_neg(CuTest *tc) {
   14667 	char *line[] = {"(", "ioportcon", "1", "con", "extra", ")", NULL};
   14668 
   14669         struct cil_tree *test_tree;
   14670         gen_test_tree(&test_tree, line);
   14671 
   14672         struct cil_tree_node *test_ast_node;
   14673         cil_tree_node_init(&test_ast_node);
   14674 
   14675         struct cil_db *test_db;
   14676         cil_db_init(&test_db);
   14677 
   14678         test_ast_node->parent = test_db->ast->root;
   14679         test_ast_node->line = 1;
   14680 
   14681         int rc = cil_gen_ioportcon(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   14682         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   14683 }
   14684 
   14685 void test_cil_gen_ioportcon_dbnull_neg(CuTest *tc) {
   14686 	char *line[] = {"(", "ioportcon", "1", "con", ")", NULL};
   14687 
   14688         struct cil_tree *test_tree;
   14689         gen_test_tree(&test_tree, line);
   14690 
   14691         struct cil_tree_node *test_ast_node;
   14692         cil_tree_node_init(&test_ast_node);
   14693 
   14694         struct cil_db *test_db = NULL;
   14695 
   14696         int rc = cil_gen_ioportcon(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   14697         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   14698 }
   14699 
   14700 void test_cil_gen_ioportcon_currnull_neg(CuTest *tc) {
   14701 	char *line[] = {"(", ")", NULL};
   14702 
   14703         struct cil_tree *test_tree;
   14704         gen_test_tree(&test_tree, line);
   14705 
   14706         struct cil_tree_node *test_ast_node;
   14707         cil_tree_node_init(&test_ast_node);
   14708 
   14709         struct cil_db *test_db;
   14710         cil_db_init(&test_db);
   14711 
   14712         test_ast_node->parent = test_db->ast->root;
   14713         test_ast_node->line = 1;
   14714 
   14715         int rc = cil_gen_ioportcon(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   14716         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   14717 }
   14718 
   14719 void test_cil_gen_ioportcon_astnull_neg(CuTest *tc) {
   14720 	char *line[] = {"(", "ioportcon", "1", "con", ")", NULL};
   14721 
   14722         struct cil_tree *test_tree;
   14723         gen_test_tree(&test_tree, line);
   14724 
   14725         struct cil_tree_node *test_ast_node = NULL;
   14726 
   14727         struct cil_db *test_db;
   14728         cil_db_init(&test_db);
   14729 
   14730         int rc = cil_gen_ioportcon(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   14731         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   14732 }
   14733 
   14734 void test_cil_gen_pcidevicecon(CuTest *tc) {
   14735 	char *line[] = {"(", "pcidevicecon", "1", "con", ")", NULL};
   14736 
   14737         struct cil_tree *test_tree;
   14738         gen_test_tree(&test_tree, line);
   14739 
   14740         struct cil_tree_node *test_ast_node;
   14741         cil_tree_node_init(&test_ast_node);
   14742 
   14743         struct cil_db *test_db;
   14744         cil_db_init(&test_db);
   14745 
   14746         test_ast_node->parent = test_db->ast->root;
   14747         test_ast_node->line = 1;
   14748 
   14749         int rc = cil_gen_pcidevicecon(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   14750         CuAssertIntEquals(tc, SEPOL_OK, rc);
   14751 }
   14752 
   14753 void test_cil_gen_pcidevicecon_pcidevicenotint_neg(CuTest *tc) {
   14754 	char *line[] = {"(", "pcidevicecon", "notint", "con", ")", NULL};
   14755 
   14756         struct cil_tree *test_tree;
   14757         gen_test_tree(&test_tree, line);
   14758 
   14759         struct cil_tree_node *test_ast_node;
   14760         cil_tree_node_init(&test_ast_node);
   14761 
   14762         struct cil_db *test_db;
   14763         cil_db_init(&test_db);
   14764 
   14765         test_ast_node->parent = test_db->ast->root;
   14766         test_ast_node->line = 1;
   14767 
   14768         int rc = cil_gen_pcidevicecon(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   14769         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   14770 }
   14771 
   14772 void test_cil_gen_pcidevicecon_nopcidevice_neg(CuTest *tc) {
   14773 	char *line[] = {"(", "pcidevicecon", ")", NULL};
   14774 
   14775         struct cil_tree *test_tree;
   14776         gen_test_tree(&test_tree, line);
   14777 
   14778         struct cil_tree_node *test_ast_node;
   14779         cil_tree_node_init(&test_ast_node);
   14780 
   14781         struct cil_db *test_db;
   14782         cil_db_init(&test_db);
   14783 
   14784         test_ast_node->parent = test_db->ast->root;
   14785         test_ast_node->line = 1;
   14786 
   14787         int rc = cil_gen_pcidevicecon(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   14788         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   14789 }
   14790 
   14791 void test_cil_gen_pcidevicecon_pcidevicerange_neg(CuTest *tc) {
   14792 	char *line[] = {"(", "pcidevicecon", "(", "1", ")", "con", ")", NULL};
   14793 
   14794         struct cil_tree *test_tree;
   14795         gen_test_tree(&test_tree, line);
   14796 
   14797         struct cil_tree_node *test_ast_node;
   14798         cil_tree_node_init(&test_ast_node);
   14799 
   14800         struct cil_db *test_db;
   14801         cil_db_init(&test_db);
   14802 
   14803         test_ast_node->parent = test_db->ast->root;
   14804         test_ast_node->line = 1;
   14805 
   14806         int rc = cil_gen_pcidevicecon(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   14807         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   14808 }
   14809 
   14810 void test_cil_gen_pcidevicecon_nocontext_neg(CuTest *tc) {
   14811 	char *line[] = {"(", "pcidevicecon", "1", ")", NULL};
   14812 
   14813         struct cil_tree *test_tree;
   14814         gen_test_tree(&test_tree, line);
   14815 
   14816         struct cil_tree_node *test_ast_node;
   14817         cil_tree_node_init(&test_ast_node);
   14818 
   14819         struct cil_db *test_db;
   14820         cil_db_init(&test_db);
   14821 
   14822         test_ast_node->parent = test_db->ast->root;
   14823         test_ast_node->line = 1;
   14824 
   14825         int rc = cil_gen_pcidevicecon(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   14826         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   14827 }
   14828 
   14829 void test_cil_gen_pcidevicecon_anoncontext_neg(CuTest *tc) {
   14830 	char *line[] = {"(", "pcidevicecon", "1", "(", "con", ")", ")", NULL};
   14831 
   14832         struct cil_tree *test_tree;
   14833         gen_test_tree(&test_tree, line);
   14834 
   14835         struct cil_tree_node *test_ast_node;
   14836         cil_tree_node_init(&test_ast_node);
   14837 
   14838         struct cil_db *test_db;
   14839         cil_db_init(&test_db);
   14840 
   14841         test_ast_node->parent = test_db->ast->root;
   14842         test_ast_node->line = 1;
   14843 
   14844         int rc = cil_gen_pcidevicecon(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   14845         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   14846 }
   14847 
   14848 void test_cil_gen_pcidevicecon_extra_neg(CuTest *tc) {
   14849 	char *line[] = {"(", "pcidevicecon", "1", "con", "extra", ")", NULL};
   14850 
   14851         struct cil_tree *test_tree;
   14852         gen_test_tree(&test_tree, line);
   14853 
   14854         struct cil_tree_node *test_ast_node;
   14855         cil_tree_node_init(&test_ast_node);
   14856 
   14857         struct cil_db *test_db;
   14858         cil_db_init(&test_db);
   14859 
   14860         test_ast_node->parent = test_db->ast->root;
   14861         test_ast_node->line = 1;
   14862 
   14863         int rc = cil_gen_pcidevicecon(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   14864         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   14865 }
   14866 
   14867 void test_cil_gen_pcidevicecon_dbnull_neg(CuTest *tc) {
   14868 	char *line[] = {"(", "pcidevicecon", "1", "con", ")", NULL};
   14869 
   14870         struct cil_tree *test_tree;
   14871         gen_test_tree(&test_tree, line);
   14872 
   14873         struct cil_tree_node *test_ast_node;
   14874         cil_tree_node_init(&test_ast_node);
   14875 
   14876         struct cil_db *test_db = NULL;
   14877 
   14878         int rc = cil_gen_pcidevicecon(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   14879         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   14880 }
   14881 
   14882 void test_cil_gen_pcidevicecon_currnull_neg(CuTest *tc) {
   14883 	char *line[] = {"(", ")", NULL};
   14884 
   14885         struct cil_tree *test_tree;
   14886         gen_test_tree(&test_tree, line);
   14887 
   14888         struct cil_tree_node *test_ast_node;
   14889         cil_tree_node_init(&test_ast_node);
   14890 
   14891         struct cil_db *test_db;
   14892         cil_db_init(&test_db);
   14893 
   14894         test_ast_node->parent = test_db->ast->root;
   14895         test_ast_node->line = 1;
   14896 
   14897         int rc = cil_gen_pcidevicecon(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   14898         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   14899 }
   14900 
   14901 void test_cil_gen_pcidevicecon_astnull_neg(CuTest *tc) {
   14902 	char *line[] = {"(", "pcidevicecon", "1", "con", ")", NULL};
   14903 
   14904         struct cil_tree *test_tree;
   14905         gen_test_tree(&test_tree, line);
   14906 
   14907         struct cil_tree_node *test_ast_node = NULL;
   14908 
   14909         struct cil_db *test_db;
   14910         cil_db_init(&test_db);
   14911 
   14912         int rc = cil_gen_pcidevicecon(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   14913         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   14914 }
   14915 
   14916 void test_cil_gen_fsuse_anoncontext(CuTest *tc) {
   14917 	char *line[] = {"(", "fsuse", "xattr", "ext3", "(", "system_u", "object_r", "etc_t", "(", "low", "high", ")", ")", ")", NULL};
   14918 
   14919         struct cil_tree *test_tree;
   14920         gen_test_tree(&test_tree, line);
   14921 
   14922         struct cil_tree_node *test_ast_node;
   14923         cil_tree_node_init(&test_ast_node);
   14924 
   14925         struct cil_db *test_db;
   14926         cil_db_init(&test_db);
   14927 
   14928         test_ast_node->parent = test_db->ast->root;
   14929         test_ast_node->line = 1;
   14930 
   14931         int rc = cil_gen_fsuse(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   14932         CuAssertIntEquals(tc, SEPOL_OK, rc);
   14933 }
   14934 
   14935 void test_cil_gen_fsuse_anoncontext_neg(CuTest *tc) {
   14936 	char *line[] = {"(", "fsuse", "xattr", "ext3", "(", "system_u", "etc_t", "(", "low", "high", ")", ")", ")", NULL};
   14937 
   14938         struct cil_tree *test_tree;
   14939         gen_test_tree(&test_tree, line);
   14940 
   14941         struct cil_tree_node *test_ast_node;
   14942         cil_tree_node_init(&test_ast_node);
   14943 
   14944         struct cil_db *test_db;
   14945         cil_db_init(&test_db);
   14946 
   14947         test_ast_node->parent = test_db->ast->root;
   14948         test_ast_node->line = 1;
   14949 
   14950         int rc = cil_gen_fsuse(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   14951         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   14952 }
   14953 
   14954 void test_cil_gen_fsuse_xattr(CuTest *tc) {
   14955 	char *line[] = {"(", "fsuse", "xattr", "ext3", "con", ")", NULL};
   14956 
   14957         struct cil_tree *test_tree;
   14958         gen_test_tree(&test_tree, line);
   14959 
   14960         struct cil_tree_node *test_ast_node;
   14961         cil_tree_node_init(&test_ast_node);
   14962 
   14963         struct cil_db *test_db;
   14964         cil_db_init(&test_db);
   14965 
   14966         test_ast_node->parent = test_db->ast->root;
   14967         test_ast_node->line = 1;
   14968 
   14969         int rc = cil_gen_fsuse(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   14970         CuAssertIntEquals(tc, SEPOL_OK, rc);
   14971 }
   14972 
   14973 void test_cil_gen_fsuse_task(CuTest *tc) {
   14974 	char *line[] = {"(", "fsuse", "task", "ext3", "con", ")", NULL};
   14975 
   14976         struct cil_tree *test_tree;
   14977         gen_test_tree(&test_tree, line);
   14978 
   14979         struct cil_tree_node *test_ast_node;
   14980         cil_tree_node_init(&test_ast_node);
   14981 
   14982         struct cil_db *test_db;
   14983         cil_db_init(&test_db);
   14984 
   14985         test_ast_node->parent = test_db->ast->root;
   14986         test_ast_node->line = 1;
   14987 
   14988         int rc = cil_gen_fsuse(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   14989         CuAssertIntEquals(tc, SEPOL_OK, rc);
   14990 }
   14991 
   14992 void test_cil_gen_fsuse_transition(CuTest *tc) {
   14993 	char *line[] = {"(", "fsuse", "trans", "ext3", "con", ")", NULL};
   14994 
   14995         struct cil_tree *test_tree;
   14996         gen_test_tree(&test_tree, line);
   14997 
   14998         struct cil_tree_node *test_ast_node;
   14999         cil_tree_node_init(&test_ast_node);
   15000 
   15001         struct cil_db *test_db;
   15002         cil_db_init(&test_db);
   15003 
   15004         test_ast_node->parent = test_db->ast->root;
   15005         test_ast_node->line = 1;
   15006 
   15007         int rc = cil_gen_fsuse(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   15008         CuAssertIntEquals(tc, SEPOL_OK, rc);
   15009 }
   15010 
   15011 void test_cil_gen_fsuse_invalidtype_neg(CuTest *tc) {
   15012 	char *line[] = {"(", "fsuse", "foo", "ext3", "con", ")", NULL};
   15013 
   15014         struct cil_tree *test_tree;
   15015         gen_test_tree(&test_tree, line);
   15016 
   15017         struct cil_tree_node *test_ast_node;
   15018         cil_tree_node_init(&test_ast_node);
   15019 
   15020         struct cil_db *test_db;
   15021         cil_db_init(&test_db);
   15022 
   15023         test_ast_node->parent = test_db->ast->root;
   15024         test_ast_node->line = 1;
   15025 
   15026         int rc = cil_gen_fsuse(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   15027         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   15028 }
   15029 
   15030 void test_cil_gen_fsuse_notype_neg(CuTest *tc) {
   15031 	char *line[] = {"(", "fsuse", ")", NULL};
   15032 
   15033         struct cil_tree *test_tree;
   15034         gen_test_tree(&test_tree, line);
   15035 
   15036         struct cil_tree_node *test_ast_node;
   15037         cil_tree_node_init(&test_ast_node);
   15038 
   15039         struct cil_db *test_db;
   15040         cil_db_init(&test_db);
   15041 
   15042         test_ast_node->parent = test_db->ast->root;
   15043         test_ast_node->line = 1;
   15044 
   15045         int rc = cil_gen_fsuse(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   15046         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   15047 }
   15048 
   15049 void test_cil_gen_fsuse_typeinparens_neg(CuTest *tc) {
   15050 	char *line[] = {"(", "fsuse", "(", "xattr", ")", "ext3", "con", ")", NULL};
   15051 
   15052         struct cil_tree *test_tree;
   15053         gen_test_tree(&test_tree, line);
   15054 
   15055         struct cil_tree_node *test_ast_node;
   15056         cil_tree_node_init(&test_ast_node);
   15057 
   15058         struct cil_db *test_db;
   15059         cil_db_init(&test_db);
   15060 
   15061         test_ast_node->parent = test_db->ast->root;
   15062         test_ast_node->line = 1;
   15063 
   15064         int rc = cil_gen_fsuse(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   15065         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   15066 }
   15067 
   15068 void test_cil_gen_fsuse_nofilesystem_neg(CuTest *tc) {
   15069 	char *line[] = {"(", "fsuse", "xattr", ")", NULL};
   15070 
   15071         struct cil_tree *test_tree;
   15072         gen_test_tree(&test_tree, line);
   15073 
   15074         struct cil_tree_node *test_ast_node;
   15075         cil_tree_node_init(&test_ast_node);
   15076 
   15077         struct cil_db *test_db;
   15078         cil_db_init(&test_db);
   15079 
   15080         test_ast_node->parent = test_db->ast->root;
   15081         test_ast_node->line = 1;
   15082 
   15083         int rc = cil_gen_fsuse(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   15084         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   15085 }
   15086 
   15087 void test_cil_gen_fsuse_filesysteminparens_neg(CuTest *tc) {
   15088 	char *line[] = {"(", "fsuse", "xattr", "(", "ext3", ")", "con", ")", NULL};
   15089 
   15090         struct cil_tree *test_tree;
   15091         gen_test_tree(&test_tree, line);
   15092 
   15093         struct cil_tree_node *test_ast_node;
   15094         cil_tree_node_init(&test_ast_node);
   15095 
   15096         struct cil_db *test_db;
   15097         cil_db_init(&test_db);
   15098 
   15099         test_ast_node->parent = test_db->ast->root;
   15100         test_ast_node->line = 1;
   15101 
   15102         int rc = cil_gen_fsuse(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   15103         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   15104 }
   15105 
   15106 void test_cil_gen_fsuse_nocontext_neg(CuTest *tc) {
   15107 	char *line[] = {"(", "fsuse", "xattr", "ext3", ")", NULL};
   15108 
   15109         struct cil_tree *test_tree;
   15110         gen_test_tree(&test_tree, line);
   15111 
   15112         struct cil_tree_node *test_ast_node;
   15113         cil_tree_node_init(&test_ast_node);
   15114 
   15115         struct cil_db *test_db;
   15116         cil_db_init(&test_db);
   15117 
   15118         test_ast_node->parent = test_db->ast->root;
   15119         test_ast_node->line = 1;
   15120 
   15121         int rc = cil_gen_fsuse(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   15122         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   15123 }
   15124 
   15125 void test_cil_gen_fsuse_emptyconparens_neg(CuTest *tc) {
   15126 	char *line[] = {"(", "fsuse", "xattr", "ext3", "(", ")", ")", NULL};
   15127 
   15128         struct cil_tree *test_tree;
   15129         gen_test_tree(&test_tree, line);
   15130 
   15131         struct cil_tree_node *test_ast_node;
   15132         cil_tree_node_init(&test_ast_node);
   15133 
   15134         struct cil_db *test_db;
   15135         cil_db_init(&test_db);
   15136 
   15137         test_ast_node->parent = test_db->ast->root;
   15138         test_ast_node->line = 1;
   15139 
   15140         int rc = cil_gen_fsuse(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   15141         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   15142 }
   15143 
   15144 void test_cil_gen_fsuse_extra_neg(CuTest *tc) {
   15145 	char *line[] = {"(", "fsuse", "xattr", "ext3", "con", "extra", ")", NULL};
   15146 
   15147         struct cil_tree *test_tree;
   15148         gen_test_tree(&test_tree, line);
   15149 
   15150         struct cil_tree_node *test_ast_node;
   15151         cil_tree_node_init(&test_ast_node);
   15152 
   15153         struct cil_db *test_db;
   15154         cil_db_init(&test_db);
   15155 
   15156         test_ast_node->parent = test_db->ast->root;
   15157         test_ast_node->line = 1;
   15158 
   15159         int rc = cil_gen_fsuse(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   15160         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   15161 }
   15162 
   15163 void test_cil_gen_fsuse_dbnull_neg(CuTest *tc) {
   15164 	char *line[] = {"(", "fsuse", "xattr", "ext3", "con", ")", NULL};
   15165 
   15166         struct cil_tree *test_tree;
   15167         gen_test_tree(&test_tree, line);
   15168 
   15169         struct cil_tree_node *test_ast_node;
   15170         cil_tree_node_init(&test_ast_node);
   15171 
   15172         struct cil_db *test_db = NULL;
   15173 
   15174         int rc = cil_gen_fsuse(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   15175         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   15176 }
   15177 
   15178 void test_cil_gen_fsuse_currnull_neg(CuTest *tc) {
   15179 	char *line[] = {"(", ")", NULL};
   15180 
   15181         struct cil_tree *test_tree;
   15182         gen_test_tree(&test_tree, line);
   15183 
   15184         struct cil_tree_node *test_ast_node;
   15185         cil_tree_node_init(&test_ast_node);
   15186 
   15187         struct cil_db *test_db;
   15188         cil_db_init(&test_db);
   15189 
   15190         test_ast_node->parent = test_db->ast->root;
   15191         test_ast_node->line = 1;
   15192 
   15193         int rc = cil_gen_fsuse(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   15194         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   15195 }
   15196 
   15197 void test_cil_gen_fsuse_astnull_neg(CuTest *tc) {
   15198 	char *line[] = {"(", "fsuse", "xattr", "ext3", "con", ")", NULL};
   15199 
   15200         struct cil_tree *test_tree;
   15201         gen_test_tree(&test_tree, line);
   15202 
   15203         struct cil_tree_node *test_ast_node = NULL;
   15204 
   15205         struct cil_db *test_db;
   15206         cil_db_init(&test_db);
   15207 
   15208         int rc = cil_gen_fsuse(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   15209         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   15210 }
   15211 
   15212 void test_cil_gen_macro_noparams(CuTest *tc) {
   15213 	char *line[] = {"(", "macro", "mm", "(", ")", "(", "type", "b", ")", ")", NULL};
   15214 
   15215         struct cil_tree *test_tree;
   15216         gen_test_tree(&test_tree, line);
   15217 
   15218         struct cil_tree_node *test_ast_node;
   15219         cil_tree_node_init(&test_ast_node);
   15220 
   15221         struct cil_db *test_db;
   15222         cil_db_init(&test_db);
   15223 
   15224         test_ast_node->parent = test_db->ast->root;
   15225         test_ast_node->line = 1;
   15226 
   15227         int rc = cil_gen_macro(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   15228         CuAssertIntEquals(tc, SEPOL_OK, rc);
   15229 }
   15230 
   15231 void test_cil_gen_macro_type(CuTest *tc) {
   15232 	char *line[] = {"(", "macro", "mm", "(", "(", "type", "a", ")", ")", "(", "type", "b", ")", ")", NULL};
   15233 
   15234         struct cil_tree *test_tree;
   15235         gen_test_tree(&test_tree, line);
   15236 
   15237         struct cil_tree_node *test_ast_node;
   15238         cil_tree_node_init(&test_ast_node);
   15239 
   15240         struct cil_db *test_db;
   15241         cil_db_init(&test_db);
   15242 
   15243         test_ast_node->parent = test_db->ast->root;
   15244         test_ast_node->line = 1;
   15245 
   15246         int rc = cil_gen_macro(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   15247         CuAssertIntEquals(tc, SEPOL_OK, rc);
   15248 }
   15249 
   15250 void test_cil_gen_macro_role(CuTest *tc) {
   15251 	char *line[] = {"(", "macro", "mm", "(", "(", "role", "a", ")", ")", "(", "role", "b", ")", ")", NULL};
   15252 
   15253         struct cil_tree *test_tree;
   15254         gen_test_tree(&test_tree, line);
   15255 
   15256         struct cil_tree_node *test_ast_node;
   15257         cil_tree_node_init(&test_ast_node);
   15258 
   15259         struct cil_db *test_db;
   15260         cil_db_init(&test_db);
   15261 
   15262         test_ast_node->parent = test_db->ast->root;
   15263         test_ast_node->line = 1;
   15264 
   15265         int rc = cil_gen_macro(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   15266         CuAssertIntEquals(tc, SEPOL_OK, rc);
   15267 }
   15268 
   15269 void test_cil_gen_macro_user(CuTest *tc) {
   15270 	char *line[] = {"(", "macro", "mm", "(", "(", "user", "a", ")", ")", "(", "user", "b", ")", ")", NULL};
   15271 
   15272         struct cil_tree *test_tree;
   15273         gen_test_tree(&test_tree, line);
   15274 
   15275         struct cil_tree_node *test_ast_node;
   15276         cil_tree_node_init(&test_ast_node);
   15277 
   15278         struct cil_db *test_db;
   15279         cil_db_init(&test_db);
   15280 
   15281         test_ast_node->parent = test_db->ast->root;
   15282         test_ast_node->line = 1;
   15283 
   15284         int rc = cil_gen_macro(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   15285         CuAssertIntEquals(tc, SEPOL_OK, rc);
   15286 }
   15287 
   15288 void test_cil_gen_macro_sensitivity(CuTest *tc) {
   15289 	char *line[] = {"(", "macro", "mm", "(", "(", "sensitivity", "a", ")", ")", "(", "sensitivity", "b", ")", ")", NULL};
   15290 
   15291         struct cil_tree *test_tree;
   15292         gen_test_tree(&test_tree, line);
   15293 
   15294         struct cil_tree_node *test_ast_node;
   15295         cil_tree_node_init(&test_ast_node);
   15296 
   15297         struct cil_db *test_db;
   15298         cil_db_init(&test_db);
   15299 
   15300         test_ast_node->parent = test_db->ast->root;
   15301         test_ast_node->line = 1;
   15302 
   15303         int rc = cil_gen_macro(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   15304         CuAssertIntEquals(tc, SEPOL_OK, rc);
   15305 }
   15306 
   15307 void test_cil_gen_macro_category(CuTest *tc) {
   15308 	char *line[] = {"(", "macro", "mm", "(", "(", "category", "a", ")", ")", "(", "category", "b", ")", ")", ")", NULL};
   15309 
   15310         struct cil_tree *test_tree;
   15311         gen_test_tree(&test_tree, line);
   15312 
   15313         struct cil_tree_node *test_ast_node;
   15314         cil_tree_node_init(&test_ast_node);
   15315 
   15316         struct cil_db *test_db;
   15317         cil_db_init(&test_db);
   15318 
   15319         test_ast_node->parent = test_db->ast->root;
   15320         test_ast_node->line = 1;
   15321 
   15322         int rc = cil_gen_macro(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   15323         CuAssertIntEquals(tc, SEPOL_OK, rc);
   15324 }
   15325 
   15326 void test_cil_gen_macro_catset(CuTest *tc) {
   15327 	char *line[] = {"(", "macro", "mm", "(", "(", "categoryset", "a", ")", ")", "(", "categoryset", "b", ")", ")", ")", NULL};
   15328 
   15329         struct cil_tree *test_tree;
   15330         gen_test_tree(&test_tree, line);
   15331 
   15332         struct cil_tree_node *test_ast_node;
   15333         cil_tree_node_init(&test_ast_node);
   15334 
   15335         struct cil_db *test_db;
   15336         cil_db_init(&test_db);
   15337 
   15338         test_ast_node->parent = test_db->ast->root;
   15339         test_ast_node->line = 1;
   15340 
   15341         int rc = cil_gen_macro(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   15342         CuAssertIntEquals(tc, SEPOL_OK, rc);
   15343 }
   15344 
   15345 void test_cil_gen_macro_level(CuTest *tc) {
   15346 	char *line[] = {"(", "macro", "mm", "(", "(", "level", "a", ")", ")", "(", "level", "b", ")", ")", ")", NULL};
   15347 
   15348         struct cil_tree *test_tree;
   15349         gen_test_tree(&test_tree, line);
   15350 
   15351         struct cil_tree_node *test_ast_node;
   15352         cil_tree_node_init(&test_ast_node);
   15353 
   15354         struct cil_db *test_db;
   15355         cil_db_init(&test_db);
   15356 
   15357         test_ast_node->parent = test_db->ast->root;
   15358         test_ast_node->line = 1;
   15359 
   15360         int rc = cil_gen_macro(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   15361         CuAssertIntEquals(tc, SEPOL_OK, rc);
   15362 }
   15363 
   15364 void test_cil_gen_macro_class(CuTest *tc) {
   15365 	char *line[] = {"(", "macro", "mm", "(", "(", "class", "a", ")", ")", "(", "class", "b", ")", ")", ")", NULL};
   15366 
   15367         struct cil_tree *test_tree;
   15368         gen_test_tree(&test_tree, line);
   15369 
   15370         struct cil_tree_node *test_ast_node;
   15371         cil_tree_node_init(&test_ast_node);
   15372 
   15373         struct cil_db *test_db;
   15374         cil_db_init(&test_db);
   15375 
   15376         test_ast_node->parent = test_db->ast->root;
   15377         test_ast_node->line = 1;
   15378 
   15379         int rc = cil_gen_macro(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   15380         CuAssertIntEquals(tc, SEPOL_OK, rc);
   15381 }
   15382 
   15383 void test_cil_gen_macro_classmap(CuTest *tc) {
   15384 	char *line[] = {"(", "macro", "mm", "(", "(", "classmap", "a", ")", ")", "(", "classmap", "b", ")", ")", ")", NULL};
   15385 
   15386         struct cil_tree *test_tree;
   15387         gen_test_tree(&test_tree, line);
   15388 
   15389         struct cil_tree_node *test_ast_node;
   15390         cil_tree_node_init(&test_ast_node);
   15391 
   15392         struct cil_db *test_db;
   15393         cil_db_init(&test_db);
   15394 
   15395         test_ast_node->parent = test_db->ast->root;
   15396         test_ast_node->line = 1;
   15397 
   15398         int rc = cil_gen_macro(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   15399         CuAssertIntEquals(tc, SEPOL_OK, rc);
   15400 }
   15401 
   15402 void test_cil_gen_macro_permset(CuTest *tc) {
   15403 	char *line[] = {"(", "macro", "mm", "(", "(", "permissionset", "a", ")", ")",
   15404 				"(", "allow", "foo", "bar", "baz", "a", ")", ")", NULL};
   15405 
   15406         struct cil_tree *test_tree;
   15407         gen_test_tree(&test_tree, line);
   15408 
   15409         struct cil_tree_node *test_ast_node;
   15410         cil_tree_node_init(&test_ast_node);
   15411 
   15412         struct cil_db *test_db;
   15413         cil_db_init(&test_db);
   15414 
   15415         test_ast_node->parent = test_db->ast->root;
   15416         test_ast_node->line = 1;
   15417 
   15418         int rc = cil_gen_macro(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   15419         CuAssertIntEquals(tc, SEPOL_OK, rc);
   15420 }
   15421 
   15422 void test_cil_gen_macro_duplicate(CuTest *tc) {
   15423 	char *line[] = {"(", "macro", "mm", "(", "(", "class", "a",")", "(", "class", "x", ")", ")", "(", "class", "b", ")", ")", ")", NULL};
   15424 
   15425         struct cil_tree *test_tree;
   15426         gen_test_tree(&test_tree, line);
   15427 
   15428         struct cil_tree_node *test_ast_node;
   15429         cil_tree_node_init(&test_ast_node);
   15430 
   15431         struct cil_db *test_db;
   15432         cil_db_init(&test_db);
   15433 
   15434         test_ast_node->parent = test_db->ast->root;
   15435         test_ast_node->line = 1;
   15436 
   15437         int rc = cil_gen_macro(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   15438         CuAssertIntEquals(tc, SEPOL_OK, rc);
   15439 }
   15440 
   15441 void test_cil_gen_macro_duplicate_neg(CuTest *tc) {
   15442 	char *line[] = {"(", "macro", "mm", "(", "(", "class", "a",")", "(", "class", "a", ")", ")", "(", "class", "b", "(", "read," ")", ")", ")", ")", NULL};
   15443 
   15444         struct cil_tree *test_tree;
   15445         gen_test_tree(&test_tree, line);
   15446 
   15447         struct cil_tree_node *test_ast_node;
   15448         cil_tree_node_init(&test_ast_node);
   15449 
   15450         struct cil_db *test_db;
   15451         cil_db_init(&test_db);
   15452 
   15453         test_ast_node->parent = test_db->ast->root;
   15454         test_ast_node->line = 1;
   15455 
   15456         int rc = cil_gen_macro(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   15457         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   15458 }
   15459 
   15460 void test_cil_gen_macro_unknown_neg(CuTest *tc) {
   15461 	char *line[] = {"(", "macro", "mm", "(", "(", "foo", "a", ")", ")", "(", "foo", "b", ")", ")", ")", NULL};
   15462 
   15463         struct cil_tree *test_tree;
   15464         gen_test_tree(&test_tree, line);
   15465 
   15466         struct cil_tree_node *test_ast_node;
   15467         cil_tree_node_init(&test_ast_node);
   15468 
   15469         struct cil_db *test_db;
   15470         cil_db_init(&test_db);
   15471 
   15472         test_ast_node->parent = test_db->ast->root;
   15473         test_ast_node->line = 1;
   15474 
   15475         int rc = cil_gen_macro(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   15476         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   15477 }
   15478 
   15479 void test_cil_gen_macro_dbnull_neg(CuTest *tc) {
   15480 	char *line[] = {"(", "macro", "mm", "(", "(", "foo", "a", ")", ")", "(", "foo", "b", ")", ")", NULL};
   15481 
   15482         struct cil_tree *test_tree;
   15483         gen_test_tree(&test_tree, line);
   15484 
   15485         struct cil_tree_node *test_ast_node;
   15486         cil_tree_node_init(&test_ast_node);
   15487 
   15488         struct cil_db *test_db = NULL;
   15489 
   15490         int rc = cil_gen_macro(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   15491         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   15492 }
   15493 
   15494 void test_cil_gen_macro_currnull_neg(CuTest *tc) {
   15495 	char *line[] = {"(", ")", NULL};
   15496 
   15497         struct cil_tree *test_tree;
   15498         gen_test_tree(&test_tree, line);
   15499 
   15500         struct cil_tree_node *test_ast_node;
   15501         cil_tree_node_init(&test_ast_node);
   15502 
   15503         struct cil_db *test_db;
   15504         cil_db_init(&test_db);
   15505 
   15506         test_ast_node->parent = test_db->ast->root;
   15507         test_ast_node->line = 1;
   15508 
   15509         int rc = cil_gen_macro(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   15510         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   15511 }
   15512 
   15513 void test_cil_gen_macro_astnull_neg(CuTest *tc) {
   15514 	char *line[] = {"(", "macro", "mm", "(", "(", "foo", "a", ")", ")", "(", "foo", "b", ")", ")", NULL};
   15515 
   15516         struct cil_tree *test_tree;
   15517         gen_test_tree(&test_tree, line);
   15518 
   15519         struct cil_tree_node *test_ast_node;
   15520         cil_tree_node_init(&test_ast_node);
   15521 
   15522         struct cil_db *test_db;
   15523         cil_db_init(&test_db);
   15524 
   15525         test_ast_node = NULL;
   15526 
   15527         int rc = cil_gen_macro(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   15528         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   15529 }
   15530 
   15531 void test_cil_gen_macro_unnamed_neg(CuTest *tc) {
   15532 	char *line[] = {"(", "macro", NULL};
   15533 
   15534         struct cil_tree *test_tree;
   15535         gen_test_tree(&test_tree, line);
   15536 
   15537         struct cil_tree_node *test_ast_node;
   15538         cil_tree_node_init(&test_ast_node);
   15539 
   15540         struct cil_db *test_db;
   15541         cil_db_init(&test_db);
   15542 
   15543         test_ast_node->parent = test_db->ast->root;
   15544         test_ast_node->line = 1;
   15545 
   15546         int rc = cil_gen_macro(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   15547         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   15548 }
   15549 
   15550 void test_cil_gen_macro_noparam_neg(CuTest *tc) {
   15551 	char *line[] = {"(", "macro", "mm", NULL};
   15552 
   15553         struct cil_tree *test_tree;
   15554         gen_test_tree(&test_tree, line);
   15555 
   15556         struct cil_tree_node *test_ast_node;
   15557         cil_tree_node_init(&test_ast_node);
   15558 
   15559         struct cil_db *test_db;
   15560         cil_db_init(&test_db);
   15561 
   15562         test_ast_node->parent = test_db->ast->root;
   15563         test_ast_node->line = 1;
   15564 
   15565         int rc = cil_gen_macro(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   15566         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   15567 }
   15568 
   15569 void test_cil_gen_macro_nosecondparam_neg(CuTest *tc) {
   15570 	char *line[] = {"(", "macro", "mm", "(", "(", "foo", "a", ")", ")", NULL};
   15571 
   15572         struct cil_tree *test_tree;
   15573         gen_test_tree(&test_tree, line);
   15574 
   15575         struct cil_tree_node *test_ast_node;
   15576         cil_tree_node_init(&test_ast_node);
   15577 
   15578         struct cil_db *test_db;
   15579         cil_db_init(&test_db);
   15580 
   15581         test_ast_node->parent = test_db->ast->root;
   15582         test_ast_node->line = 1;
   15583 
   15584         int rc = cil_gen_macro(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   15585         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   15586 }
   15587 
   15588 void test_cil_gen_macro_noparam_name_neg(CuTest *tc) {
   15589 	char *line[] = {"(", "macro", "mm", "(", "(", "type", ")", ")", ")", NULL};
   15590 
   15591         struct cil_tree *test_tree;
   15592         gen_test_tree(&test_tree, line);
   15593 
   15594         struct cil_tree_node *test_ast_node;
   15595         cil_tree_node_init(&test_ast_node);
   15596 
   15597         struct cil_db *test_db;
   15598         cil_db_init(&test_db);
   15599 
   15600         test_ast_node->parent = test_db->ast->root;
   15601         test_ast_node->line = 1;
   15602 
   15603         int rc = cil_gen_macro(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   15604         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   15605 }
   15606 
   15607 void test_cil_gen_macro_emptyparam_neg(CuTest *tc) {
   15608 	char *line[] = {"(", "macro", "mm", "(", "(", ")", ")", "(", "foo", "b", ")", ")", NULL};
   15609 
   15610         struct cil_tree *test_tree;
   15611         gen_test_tree(&test_tree, line);
   15612 
   15613         struct cil_tree_node *test_ast_node;
   15614         cil_tree_node_init(&test_ast_node);
   15615 
   15616         struct cil_db *test_db;
   15617         cil_db_init(&test_db);
   15618 
   15619         test_ast_node->parent = test_db->ast->root;
   15620         test_ast_node->line = 1;
   15621 
   15622         int rc = cil_gen_macro(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   15623         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   15624 }
   15625 
   15626 void test_cil_gen_macro_paramcontainsperiod_neg(CuTest *tc) {
   15627 	char *line[] = {"(", "macro", "mm", "(", "(", "type", "a.", ")", ")", "(", "type", "b", ")", ")", NULL};
   15628 
   15629         struct cil_tree *test_tree;
   15630         gen_test_tree(&test_tree, line);
   15631 
   15632         struct cil_tree_node *test_ast_node;
   15633         cil_tree_node_init(&test_ast_node);
   15634 
   15635         struct cil_db *test_db;
   15636         cil_db_init(&test_db);
   15637 
   15638         test_ast_node->parent = test_db->ast->root;
   15639         test_ast_node->line = 1;
   15640 
   15641         int rc = cil_gen_macro(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   15642         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   15643 }
   15644 
   15645 void test_cil_gen_call(CuTest *tc) {
   15646 	char *line[] = {"(", "call", "mm", "(", "foo", ")", ")", NULL};
   15647 
   15648         struct cil_tree *test_tree;
   15649         gen_test_tree(&test_tree, line);
   15650 
   15651         struct cil_tree_node *test_ast_node;
   15652         cil_tree_node_init(&test_ast_node);
   15653 
   15654         struct cil_db *test_db;
   15655         cil_db_init(&test_db);
   15656 
   15657         test_ast_node->parent = test_db->ast->root;
   15658         test_ast_node->line = 1;
   15659 
   15660         int rc = cil_gen_call(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   15661         CuAssertIntEquals(tc, SEPOL_OK, rc);
   15662 }
   15663 
   15664 void test_cil_gen_call_noargs(CuTest *tc) {
   15665 	char *line[] = {"(", "call", "mm", ")", NULL};
   15666 
   15667         struct cil_tree *test_tree;
   15668         gen_test_tree(&test_tree, line);
   15669 
   15670         struct cil_tree_node *test_ast_node;
   15671         cil_tree_node_init(&test_ast_node);
   15672 
   15673         struct cil_db *test_db;
   15674         cil_db_init(&test_db);
   15675 
   15676         test_ast_node->parent = test_db->ast->root;
   15677         test_ast_node->line = 1;
   15678 
   15679         int rc = cil_gen_call(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   15680         CuAssertIntEquals(tc, SEPOL_OK, rc);
   15681 }
   15682 
   15683 void test_cil_gen_call_anon(CuTest *tc) {
   15684 	char *line[] = {"(", "call", "mm", "(", "(", "s0", "(", "c0", ")", ")", ")", ")", NULL};
   15685 
   15686         struct cil_tree *test_tree;
   15687         gen_test_tree(&test_tree, line);
   15688 
   15689         struct cil_tree_node *test_ast_node;
   15690         cil_tree_node_init(&test_ast_node);
   15691 
   15692         struct cil_db *test_db;
   15693         cil_db_init(&test_db);
   15694 
   15695         test_ast_node->parent = test_db->ast->root;
   15696         test_ast_node->line = 1;
   15697 
   15698         int rc = cil_gen_call(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   15699         CuAssertIntEquals(tc, SEPOL_OK, rc);
   15700 }
   15701 
   15702 void test_cil_gen_call_empty_call_neg(CuTest *tc) {
   15703 	char *line[] = {"(", "call", "mm", "(", ")", ")", NULL};
   15704 
   15705         struct cil_tree *test_tree;
   15706         gen_test_tree(&test_tree, line);
   15707 
   15708         struct cil_tree_node *test_ast_node;
   15709         cil_tree_node_init(&test_ast_node);
   15710 
   15711         struct cil_db *test_db;
   15712         cil_db_init(&test_db);
   15713 
   15714         test_ast_node->parent = test_db->ast->root;
   15715         test_ast_node->line = 1;
   15716 
   15717         int rc = cil_gen_call(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   15718         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   15719 }
   15720 
   15721 void test_cil_gen_call_dbnull_neg(CuTest *tc) {
   15722 	char *line[] = {"(", "call", "mm", "(", ")", ")", NULL};
   15723 
   15724         struct cil_tree *test_tree;
   15725         gen_test_tree(&test_tree, line);
   15726 
   15727         struct cil_tree_node *test_ast_node;
   15728         cil_tree_node_init(&test_ast_node);
   15729 
   15730         struct cil_db *test_db = NULL;
   15731 
   15732         int rc = cil_gen_call(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   15733         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   15734 }
   15735 
   15736 void test_cil_gen_call_currnull_neg(CuTest *tc) {
   15737 	char *line[] = {"(", ")", NULL};
   15738 
   15739         struct cil_tree *test_tree;
   15740         gen_test_tree(&test_tree, line);
   15741 
   15742         struct cil_tree_node *test_ast_node;
   15743         cil_tree_node_init(&test_ast_node);
   15744 
   15745         struct cil_db *test_db;
   15746         cil_db_init(&test_db);
   15747 
   15748         test_ast_node->parent = test_db->ast->root;
   15749         test_ast_node->line = 1;
   15750 
   15751         int rc = cil_gen_call(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   15752         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   15753 }
   15754 
   15755 void test_cil_gen_call_astnull_neg(CuTest *tc) {
   15756 	char *line[] = {"(", "call", "mm", "(", ")", ")", NULL};
   15757 
   15758         struct cil_tree *test_tree;
   15759         gen_test_tree(&test_tree, line);
   15760 
   15761         struct cil_tree_node *test_ast_node = NULL;
   15762 
   15763         struct cil_db *test_db;
   15764         cil_db_init(&test_db);
   15765 
   15766         int rc = cil_gen_call(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   15767         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   15768 }
   15769 
   15770 void test_cil_gen_call_name_inparens_neg(CuTest *tc) {
   15771 	char *line[] = {"(", "call", "(", "mm", ")", "(", "foo", ")", ")", NULL};
   15772 
   15773         struct cil_tree *test_tree;
   15774         gen_test_tree(&test_tree, line);
   15775 
   15776         struct cil_tree_node *test_ast_node;
   15777         cil_tree_node_init(&test_ast_node);
   15778 
   15779         struct cil_db *test_db;
   15780         cil_db_init(&test_db);
   15781 
   15782         test_ast_node->parent = test_db->ast->root;
   15783         test_ast_node->line = 1;
   15784 
   15785         int rc = cil_gen_call(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   15786         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   15787 }
   15788 
   15789 void test_cil_gen_call_noname_neg(CuTest *tc) {
   15790 	char *line[] = {"(", "call", ")", NULL};
   15791 
   15792         struct cil_tree *test_tree;
   15793         gen_test_tree(&test_tree, line);
   15794 
   15795         struct cil_tree_node *test_ast_node;
   15796         cil_tree_node_init(&test_ast_node);
   15797 
   15798         struct cil_db *test_db;
   15799         cil_db_init(&test_db);
   15800 
   15801         test_ast_node->parent = test_db->ast->root;
   15802         test_ast_node->line = 1;
   15803 
   15804         int rc = cil_gen_call(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   15805         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   15806 }
   15807 
   15808 void test_cil_gen_optional(CuTest *tc) {
   15809 	char *line[] = {"(", "optional", "opt", "(", "allow", "foo", "bar", "(", "file", "(", "read", ")", ")", ")", ")", NULL};
   15810 
   15811         struct cil_tree *test_tree;
   15812         gen_test_tree(&test_tree, line);
   15813 
   15814         struct cil_tree_node *test_ast_node;
   15815         cil_tree_node_init(&test_ast_node);
   15816 
   15817         struct cil_db *test_db;
   15818         cil_db_init(&test_db);
   15819 
   15820         test_ast_node->parent = test_db->ast->root;
   15821         test_ast_node->line = 1;
   15822 
   15823         int rc = cil_gen_optional(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   15824         CuAssertIntEquals(tc, SEPOL_OK, rc);
   15825 }
   15826 
   15827 void test_cil_gen_optional_dbnull_neg(CuTest *tc) {
   15828 	char *line[] = {"(", "optional", "opt", "(", "allow", "foo", "bar", "(", "file", "(", "read", ")", ")", ")", ")", NULL};
   15829 
   15830         struct cil_tree *test_tree;
   15831         gen_test_tree(&test_tree, line);
   15832 
   15833         struct cil_tree_node *test_ast_node;
   15834         cil_tree_node_init(&test_ast_node);
   15835 
   15836         struct cil_db *test_db = NULL;
   15837 
   15838         int rc = cil_gen_optional(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   15839         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   15840 }
   15841 
   15842 void test_cil_gen_optional_currnull_neg(CuTest *tc) {
   15843 	char *line[] = {"(", ")", NULL};
   15844 
   15845         struct cil_tree *test_tree;
   15846         gen_test_tree(&test_tree, line);
   15847 
   15848         struct cil_tree_node *test_ast_node;
   15849         cil_tree_node_init(&test_ast_node);
   15850 
   15851         struct cil_db *test_db;
   15852         cil_db_init(&test_db);
   15853 
   15854         test_ast_node->parent = test_db->ast->root;
   15855         test_ast_node->line = 1;
   15856 
   15857         int rc = cil_gen_optional(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   15858         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   15859 }
   15860 
   15861 void test_cil_gen_optional_astnull_neg(CuTest *tc) {
   15862 	char *line[] = {"(", "optional", "opt", "(", "allow", "foo", "bar", "(", "file", "(", "read", ")", ")", ")", ")", NULL};
   15863 
   15864         struct cil_tree *test_tree;
   15865         gen_test_tree(&test_tree, line);
   15866 
   15867         struct cil_tree_node *test_ast_node = NULL;
   15868 
   15869         struct cil_db *test_db;
   15870         cil_db_init(&test_db);
   15871 
   15872         int rc = cil_gen_optional(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   15873         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   15874 }
   15875 
   15876 void test_cil_gen_optional_unnamed_neg(CuTest *tc) {
   15877 	char *line[] = {"(", "optional", ")", NULL};
   15878 
   15879         struct cil_tree *test_tree;
   15880         gen_test_tree(&test_tree, line);
   15881 
   15882         struct cil_tree_node *test_ast_node;
   15883         cil_tree_node_init(&test_ast_node);
   15884 
   15885         struct cil_db *test_db;
   15886         cil_db_init(&test_db);
   15887 
   15888         test_ast_node->parent = test_db->ast->root;
   15889         test_ast_node->line = 1;
   15890 
   15891         int rc = cil_gen_optional(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   15892         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   15893 }
   15894 
   15895 void test_cil_gen_optional_extra_neg(CuTest *tc) {
   15896 	char *line[] = {"(", "optional", "opt", "(", "allow", "foo", "bar", "(", "file", "(", "read", ")", ")", ")", "extra", ")", NULL};
   15897 
   15898         struct cil_tree *test_tree;
   15899         gen_test_tree(&test_tree, line);
   15900 
   15901         struct cil_tree_node *test_ast_node;
   15902         cil_tree_node_init(&test_ast_node);
   15903 
   15904         struct cil_db *test_db;
   15905         cil_db_init(&test_db);
   15906 
   15907         test_ast_node->parent = test_db->ast->root;
   15908         test_ast_node->line = 1;
   15909 
   15910         int rc = cil_gen_optional(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   15911         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   15912 }
   15913 
   15914 void test_cil_gen_optional_nameinparens_neg(CuTest *tc) {
   15915 	char *line[] = {"(", "optional", "(", "opt", ")", ")", NULL};
   15916 
   15917         struct cil_tree *test_tree;
   15918         gen_test_tree(&test_tree, line);
   15919 
   15920         struct cil_tree_node *test_ast_node;
   15921         cil_tree_node_init(&test_ast_node);
   15922 
   15923         struct cil_db *test_db;
   15924         cil_db_init(&test_db);
   15925 
   15926         test_ast_node->parent = test_db->ast->root;
   15927         test_ast_node->line = 1;
   15928 
   15929         int rc = cil_gen_optional(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   15930         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   15931 }
   15932 
   15933 void test_cil_gen_optional_emptyoptional(CuTest *tc) {
   15934 	char *line[] = {"(", "optional", "opt", ")", NULL};
   15935 
   15936         struct cil_tree *test_tree;
   15937         gen_test_tree(&test_tree, line);
   15938 
   15939         struct cil_tree_node *test_ast_node;
   15940         cil_tree_node_init(&test_ast_node);
   15941 
   15942         struct cil_db *test_db;
   15943         cil_db_init(&test_db);
   15944 
   15945         test_ast_node->parent = test_db->ast->root;
   15946         test_ast_node->line = 1;
   15947 
   15948         int rc = cil_gen_optional(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   15949         CuAssertIntEquals(tc, SEPOL_OK, rc);
   15950 }
   15951 
   15952 void test_cil_gen_optional_norule_neg(CuTest *tc) {
   15953 	char *line[] = {"(", "optional", "opt", "(", ")", ")", NULL};
   15954 
   15955         struct cil_tree *test_tree;
   15956         gen_test_tree(&test_tree, line);
   15957 
   15958         struct cil_tree_node *test_ast_node;
   15959         cil_tree_node_init(&test_ast_node);
   15960 
   15961         struct cil_db *test_db;
   15962         cil_db_init(&test_db);
   15963 
   15964         test_ast_node->parent = test_db->ast->root;
   15965         test_ast_node->line = 1;
   15966 
   15967         int rc = cil_gen_optional(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   15968         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   15969 }
   15970 
   15971 void test_cil_gen_policycap(CuTest *tc) {
   15972 	char *line[] = {"(", "policycap", "open_perms", ")", NULL};
   15973 
   15974         struct cil_tree *test_tree;
   15975         gen_test_tree(&test_tree, line);
   15976 
   15977         struct cil_tree_node *test_ast_node;
   15978         cil_tree_node_init(&test_ast_node);
   15979 
   15980         struct cil_db *test_db;
   15981         cil_db_init(&test_db);
   15982 
   15983         test_ast_node->parent = test_db->ast->root;
   15984         test_ast_node->line = 1;
   15985 
   15986         int rc = cil_gen_policycap(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   15987         CuAssertIntEquals(tc, SEPOL_OK, rc);
   15988 }
   15989 
   15990 void test_cil_gen_policycap_noname_neg(CuTest *tc) {
   15991 	char *line[] = {"(", "policycap", ")", NULL};
   15992 
   15993         struct cil_tree *test_tree;
   15994         gen_test_tree(&test_tree, line);
   15995 
   15996         struct cil_tree_node *test_ast_node;
   15997         cil_tree_node_init(&test_ast_node);
   15998 
   15999         struct cil_db *test_db;
   16000         cil_db_init(&test_db);
   16001 
   16002         test_ast_node->parent = test_db->ast->root;
   16003         test_ast_node->line = 1;
   16004 
   16005         int rc = cil_gen_policycap(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   16006         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   16007 }
   16008 
   16009 void test_cil_gen_policycap_nameinparens_neg(CuTest *tc) {
   16010 	char *line[] = {"(", "policycap", "(", "pol", ")", ")", NULL};
   16011 
   16012         struct cil_tree *test_tree;
   16013         gen_test_tree(&test_tree, line);
   16014 
   16015         struct cil_tree_node *test_ast_node;
   16016         cil_tree_node_init(&test_ast_node);
   16017 
   16018         struct cil_db *test_db;
   16019         cil_db_init(&test_db);
   16020 
   16021         test_ast_node->parent = test_db->ast->root;
   16022         test_ast_node->line = 1;
   16023 
   16024         int rc = cil_gen_policycap(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   16025         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   16026 }
   16027 
   16028 void test_cil_gen_policycap_extra_neg(CuTest *tc) {
   16029 	char *line[] = {"(", "policycap", "pol", "extra", ")", NULL};
   16030 
   16031         struct cil_tree *test_tree;
   16032         gen_test_tree(&test_tree, line);
   16033 
   16034         struct cil_tree_node *test_ast_node;
   16035         cil_tree_node_init(&test_ast_node);
   16036 
   16037         struct cil_db *test_db;
   16038         cil_db_init(&test_db);
   16039 
   16040         test_ast_node->parent = test_db->ast->root;
   16041         test_ast_node->line = 1;
   16042 
   16043         int rc = cil_gen_policycap(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   16044         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   16045 }
   16046 
   16047 void test_cil_gen_policycap_dbnull_neg(CuTest *tc) {
   16048 	char *line[] = {"(", "policycap", "pol", ")", NULL};
   16049 
   16050         struct cil_tree *test_tree;
   16051         gen_test_tree(&test_tree, line);
   16052 
   16053         struct cil_tree_node *test_ast_node;
   16054         cil_tree_node_init(&test_ast_node);
   16055 
   16056         struct cil_db *test_db = NULL;
   16057 
   16058         int rc = cil_gen_policycap(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   16059         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   16060 }
   16061 
   16062 void test_cil_gen_policycap_currnull_neg(CuTest *tc) {
   16063 	char *line[] = {"(", ")", NULL};
   16064 
   16065         struct cil_tree *test_tree;
   16066         gen_test_tree(&test_tree, line);
   16067 
   16068         struct cil_tree_node *test_ast_node;
   16069         cil_tree_node_init(&test_ast_node);
   16070 
   16071         struct cil_db *test_db;
   16072         cil_db_init(&test_db);
   16073 
   16074         test_ast_node->parent = test_db->ast->root;
   16075         test_ast_node->line = 1;
   16076 
   16077         int rc = cil_gen_policycap(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   16078         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   16079 }
   16080 
   16081 void test_cil_gen_policycap_astnull_neg(CuTest *tc) {
   16082 	char *line[] = {"(", "policycap", "pol", ")", NULL};
   16083 
   16084         struct cil_tree *test_tree;
   16085         gen_test_tree(&test_tree, line);
   16086 
   16087         struct cil_tree_node *test_ast_node = NULL;
   16088 
   16089         struct cil_db *test_db;
   16090         cil_db_init(&test_db);
   16091 
   16092         int rc = cil_gen_policycap(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   16093         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   16094 }
   16095 
   16096 void test_cil_gen_policycap_neg(CuTest *tc) {
   16097 	char *line[] = {"(", "policycap", "pol", ")", NULL};
   16098 
   16099         struct cil_tree *test_tree;
   16100         gen_test_tree(&test_tree, line);
   16101 
   16102         struct cil_tree_node *test_ast_node;
   16103         cil_tree_node_init(&test_ast_node);
   16104 
   16105         struct cil_db *test_db;
   16106         cil_db_init(&test_db);
   16107 
   16108         test_ast_node->parent = test_db->ast->root;
   16109         test_ast_node->line = 1;
   16110 
   16111         int rc = cil_gen_policycap(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   16112         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   16113 }
   16114 
   16115 void test_cil_gen_ipaddr_ipv4(CuTest *tc) {
   16116 	char *line[] = {"(", "ipaddr", "ip", "192.168.1.1", ")", NULL};
   16117 
   16118         struct cil_tree *test_tree;
   16119         gen_test_tree(&test_tree, line);
   16120 
   16121         struct cil_tree_node *test_ast_node;
   16122         cil_tree_node_init(&test_ast_node);
   16123 
   16124         struct cil_db *test_db;
   16125         cil_db_init(&test_db);
   16126 
   16127         test_ast_node->parent = test_db->ast->root;
   16128         test_ast_node->line = 1;
   16129 
   16130         int rc = cil_gen_ipaddr(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   16131         CuAssertIntEquals(tc, SEPOL_OK, rc);
   16132 }
   16133 
   16134 void test_cil_gen_ipaddr_ipv4_neg(CuTest *tc) {
   16135 	char *line[] = {"(", "ipaddr", "ip", ".168.1.1", ")", NULL};
   16136 
   16137         struct cil_tree *test_tree;
   16138         gen_test_tree(&test_tree, line);
   16139 
   16140         struct cil_tree_node *test_ast_node;
   16141         cil_tree_node_init(&test_ast_node);
   16142 
   16143         struct cil_db *test_db;
   16144         cil_db_init(&test_db);
   16145 
   16146         test_ast_node->parent = test_db->ast->root;
   16147         test_ast_node->line = 1;
   16148 
   16149         int rc = cil_gen_ipaddr(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   16150         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   16151 }
   16152 
   16153 void test_cil_gen_ipaddr_ipv6(CuTest *tc) {
   16154 	char *line[] = {"(", "ipaddr", "ip", "2001:0db8:85a3:0000:0000:8a2e:0370:7334", ")", NULL};
   16155 
   16156         struct cil_tree *test_tree;
   16157         gen_test_tree(&test_tree, line);
   16158 
   16159         struct cil_tree_node *test_ast_node;
   16160         cil_tree_node_init(&test_ast_node);
   16161 
   16162         struct cil_db *test_db;
   16163         cil_db_init(&test_db);
   16164 
   16165         test_ast_node->parent = test_db->ast->root;
   16166         test_ast_node->line = 1;
   16167 
   16168         int rc = cil_gen_ipaddr(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   16169         CuAssertIntEquals(tc, SEPOL_OK, rc);
   16170 }
   16171 
   16172 void test_cil_gen_ipaddr_ipv6_neg(CuTest *tc) {
   16173 	char *line[] = {"(", "ipaddr", "ip", "2001:0db8:85a3:0000:0000:8a2e:0370:::7334", ")", NULL};
   16174 
   16175         struct cil_tree *test_tree;
   16176         gen_test_tree(&test_tree, line);
   16177 
   16178         struct cil_tree_node *test_ast_node;
   16179         cil_tree_node_init(&test_ast_node);
   16180 
   16181         struct cil_db *test_db;
   16182         cil_db_init(&test_db);
   16183 
   16184         test_ast_node->parent = test_db->ast->root;
   16185         test_ast_node->line = 1;
   16186 
   16187         int rc = cil_gen_ipaddr(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   16188         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   16189 }
   16190 
   16191 void test_cil_gen_ipaddr_noname_neg(CuTest *tc) {
   16192 	char *line[] = {"(", "ipaddr", ")", NULL};
   16193 
   16194         struct cil_tree *test_tree;
   16195         gen_test_tree(&test_tree, line);
   16196 
   16197         struct cil_tree_node *test_ast_node;
   16198         cil_tree_node_init(&test_ast_node);
   16199 
   16200         struct cil_db *test_db;
   16201         cil_db_init(&test_db);
   16202 
   16203         test_ast_node->parent = test_db->ast->root;
   16204         test_ast_node->line = 1;
   16205 
   16206         int rc = cil_gen_ipaddr(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   16207         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   16208 }
   16209 
   16210 void test_cil_gen_ipaddr_nameinparens_neg(CuTest *tc) {
   16211 	char *line[] = {"(", "ipaddr", "(", "ip", ")", "192.168.1.1", ")", NULL};
   16212 
   16213         struct cil_tree *test_tree;
   16214         gen_test_tree(&test_tree, line);
   16215 
   16216         struct cil_tree_node *test_ast_node;
   16217         cil_tree_node_init(&test_ast_node);
   16218 
   16219         struct cil_db *test_db;
   16220         cil_db_init(&test_db);
   16221 
   16222         test_ast_node->parent = test_db->ast->root;
   16223         test_ast_node->line = 1;
   16224 
   16225         int rc = cil_gen_ipaddr(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   16226         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   16227 }
   16228 
   16229 void test_cil_gen_ipaddr_noip_neg(CuTest *tc) {
   16230 	char *line[] = {"(", "ipaddr", "ip", ")", NULL};
   16231 
   16232         struct cil_tree *test_tree;
   16233         gen_test_tree(&test_tree, line);
   16234 
   16235         struct cil_tree_node *test_ast_node;
   16236         cil_tree_node_init(&test_ast_node);
   16237 
   16238         struct cil_db *test_db;
   16239         cil_db_init(&test_db);
   16240 
   16241         test_ast_node->parent = test_db->ast->root;
   16242         test_ast_node->line = 1;
   16243 
   16244         int rc = cil_gen_ipaddr(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   16245         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   16246 }
   16247 
   16248 void test_cil_gen_ipaddr_ipinparens_neg(CuTest *tc) {
   16249 	char *line[] = {"(", "ipaddr", "ip", "(", "192.168.1.1", ")", ")", NULL};
   16250 
   16251         struct cil_tree *test_tree;
   16252         gen_test_tree(&test_tree, line);
   16253 
   16254         struct cil_tree_node *test_ast_node;
   16255         cil_tree_node_init(&test_ast_node);
   16256 
   16257         struct cil_db *test_db;
   16258         cil_db_init(&test_db);
   16259 
   16260         test_ast_node->parent = test_db->ast->root;
   16261         test_ast_node->line = 1;
   16262 
   16263         int rc = cil_gen_ipaddr(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   16264         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   16265 }
   16266 
   16267 void test_cil_gen_ipaddr_extra_neg(CuTest *tc) {
   16268 	char *line[] = {"(", "ipaddr", "ip", "192.168.1.1", "extra", ")", NULL};
   16269 
   16270         struct cil_tree *test_tree;
   16271         gen_test_tree(&test_tree, line);
   16272 
   16273         struct cil_tree_node *test_ast_node;
   16274         cil_tree_node_init(&test_ast_node);
   16275 
   16276         struct cil_db *test_db;
   16277         cil_db_init(&test_db);
   16278 
   16279         test_ast_node->parent = test_db->ast->root;
   16280         test_ast_node->line = 1;
   16281 
   16282         int rc = cil_gen_ipaddr(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   16283         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   16284 }
   16285 
   16286 void test_cil_gen_ipaddr_dbnull_neg(CuTest *tc) {
   16287 	char *line[] = {"(", "ipaddr", "ip", "192.168.1.1", ")", NULL};
   16288 
   16289         struct cil_tree *test_tree;
   16290         gen_test_tree(&test_tree, line);
   16291 
   16292         struct cil_tree_node *test_ast_node;
   16293         cil_tree_node_init(&test_ast_node);
   16294 
   16295         struct cil_db *test_db = NULL;
   16296 
   16297         int rc = cil_gen_ipaddr(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   16298         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   16299 }
   16300 
   16301 void test_cil_gen_ipaddr_currnull_neg(CuTest *tc) {
   16302 	char *line[] = {"(", ")", NULL};
   16303 
   16304         struct cil_tree *test_tree;
   16305         gen_test_tree(&test_tree, line);
   16306 
   16307         struct cil_tree_node *test_ast_node;
   16308         cil_tree_node_init(&test_ast_node);
   16309 
   16310         struct cil_db *test_db;
   16311         cil_db_init(&test_db);
   16312 
   16313         test_ast_node->parent = test_db->ast->root;
   16314         test_ast_node->line = 1;
   16315 
   16316         int rc = cil_gen_ipaddr(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   16317         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   16318 }
   16319 
   16320 void test_cil_gen_ipaddr_astnull_neg(CuTest *tc) {
   16321 	char *line[] = {"(", "ipaddr", "ip", "192.168.1.1", ")", NULL};
   16322 
   16323         struct cil_tree *test_tree;
   16324         gen_test_tree(&test_tree, line);
   16325 
   16326         struct cil_tree_node *test_ast_node = NULL;
   16327 
   16328         struct cil_db *test_db;
   16329         cil_db_init(&test_db);
   16330 
   16331         int rc = cil_gen_ipaddr(test_db, test_tree->root->cl_head->cl_head, test_ast_node);
   16332         CuAssertIntEquals(tc, SEPOL_ERR, rc);
   16333 }
   16334 
   16335 /*
   16336 	cil_build_ast test cases
   16337 */
   16338 
   16339 void test_cil_build_ast(CuTest *tc) {
   16340 	char *line[] = {"(", "type", "foo", ")", NULL};
   16341 
   16342 	struct cil_tree *test_tree;
   16343 	gen_test_tree(&test_tree, line);
   16344 
   16345 	struct cil_db *test_db;
   16346 	cil_db_init(&test_db);
   16347 
   16348 	int rc = cil_build_ast(test_db, test_tree->root, test_db->ast->root);
   16349 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   16350 }
   16351 
   16352 void test_cil_build_ast_dbnull_neg(CuTest *tc) {
   16353 	char *line[] = {"(", "test", "\"qstring\"", ")", ";comment", NULL};
   16354 
   16355 	struct cil_tree *test_tree;
   16356 	gen_test_tree(&test_tree, line);
   16357 
   16358 	struct cil_db *null_db = NULL;
   16359 
   16360 	struct cil_db *test_db;
   16361 	cil_db_init(&test_db);
   16362 
   16363 	int rc = cil_build_ast(null_db, test_tree->root, test_db->ast->root);
   16364 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   16365 }
   16366 
   16367 void test_cil_build_ast_astnull_neg(CuTest *tc) {
   16368 	char *line[] = {"(", "test", "\"qstring\"", ")", ";comment", NULL};
   16369 
   16370 	struct cil_tree *test_tree;
   16371 	gen_test_tree(&test_tree, line);
   16372 
   16373 	struct cil_db *test_db;
   16374 	cil_db_init(&test_db);
   16375 
   16376 	test_db->ast->root = NULL;
   16377 
   16378 	int rc = cil_build_ast(test_db, test_tree->root, test_db->ast->root);
   16379 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   16380 }
   16381 
   16382 void test_cil_build_ast_suberr_neg(CuTest *tc) {
   16383 	char *line[] = {"(", "block", "test", "(", "block", "(", "type", "log", ")", ")", ")", NULL};
   16384 
   16385 	struct cil_tree *test_tree;
   16386 	gen_test_tree(&test_tree, line);
   16387 
   16388 	struct cil_db *test_db;
   16389 	cil_db_init(&test_db);
   16390 
   16391 	int rc = cil_build_ast(test_db, test_tree->root, test_db->ast->root);
   16392 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   16393 }
   16394 
   16395 void test_cil_build_ast_treenull_neg(CuTest *tc) {
   16396 	char *line[] = {"(", "allow", "test", "foo", "bar", "(", "read", "write", ")", ")", NULL};
   16397 
   16398 	struct cil_tree *test_tree;
   16399 	gen_test_tree(&test_tree, line);
   16400 
   16401 	test_tree->root = NULL;
   16402 
   16403 	struct cil_db *test_db;
   16404 	cil_db_init(&test_db);
   16405 
   16406 	test_db->ast->root = NULL;
   16407 
   16408 	int rc = cil_build_ast(test_db, test_tree->root, test_db->ast->root);
   16409 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   16410 }
   16411 
   16412 void test_cil_build_ast_node_helper_block(CuTest *tc) {
   16413 	char *line[] = {"(", "block", "test", "(", "type", "log", ")", ")", NULL};
   16414 
   16415 	struct cil_tree *test_tree;
   16416 	gen_test_tree(&test_tree, line);
   16417 
   16418 	struct cil_db *test_db;
   16419 	cil_db_init(&test_db);
   16420 
   16421 	uint32_t finished = 0;
   16422 
   16423 	struct cil_args_build *extra_args = gen_build_args(test_db->ast->root, test_db, NULL, NULL);
   16424 
   16425 	int rc = __cil_build_ast_node_helper(test_tree->root->cl_head->cl_head, &finished, extra_args);
   16426 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   16427 	CuAssertIntEquals(tc, 0, finished);
   16428 }
   16429 
   16430 void test_cil_build_ast_node_helper_block_neg(CuTest *tc) {
   16431 	char *line[] = {"(", "block", "(", "type", "log", ")", ")", NULL};
   16432 
   16433 	struct cil_tree *test_tree;
   16434 	gen_test_tree(&test_tree, line);
   16435 
   16436 	struct cil_db *test_db;
   16437 	cil_db_init(&test_db);
   16438 
   16439 	uint32_t finished = 0;
   16440 
   16441 	struct cil_args_build *extra_args = gen_build_args(test_db->ast->root, test_db, NULL, NULL);
   16442 
   16443 	int rc = __cil_build_ast_node_helper(test_tree->root->cl_head->cl_head, &finished, extra_args);
   16444 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   16445 	CuAssertIntEquals(tc, 0, finished);
   16446 
   16447 }
   16448 
   16449 void test_cil_build_ast_node_helper_blockinherit(CuTest *tc) {
   16450 	char *line[] = {"(", "blockinherit", "test", ")", NULL};
   16451 
   16452 	struct cil_tree *test_tree;
   16453 	gen_test_tree(&test_tree, line);
   16454 
   16455 	struct cil_db *test_db;
   16456 	cil_db_init(&test_db);
   16457 
   16458 	uint32_t finished = 0;
   16459 
   16460 	struct cil_args_build *extra_args = gen_build_args(test_db->ast->root, test_db, NULL, NULL);
   16461 
   16462 	int rc = __cil_build_ast_node_helper(test_tree->root->cl_head->cl_head, &finished, extra_args);
   16463 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   16464 	CuAssertIntEquals(tc, 0, finished);
   16465 }
   16466 
   16467 void test_cil_build_ast_node_helper_blockinherit_neg(CuTest *tc) {
   16468 	char *line[] = {"(", "blockinherit", ")", NULL};
   16469 
   16470 	struct cil_tree *test_tree;
   16471 	gen_test_tree(&test_tree, line);
   16472 
   16473 	struct cil_db *test_db;
   16474 	cil_db_init(&test_db);
   16475 
   16476 	uint32_t finished = 0;
   16477 
   16478 	struct cil_args_build *extra_args = gen_build_args(test_db->ast->root, test_db, NULL, NULL);
   16479 
   16480 	int rc = __cil_build_ast_node_helper(test_tree->root->cl_head->cl_head, &finished, extra_args);
   16481 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   16482 	CuAssertIntEquals(tc, 0, finished);
   16483 
   16484 }
   16485 
   16486 void test_cil_build_ast_node_helper_permset(CuTest *tc) {
   16487 	char *line[] = {"(", "permissionset", "foo", "(", "read", "write", ")", ")", NULL};
   16488 
   16489 	struct cil_tree *test_tree;
   16490 	gen_test_tree(&test_tree, line);
   16491 
   16492 	struct cil_db *test_db;
   16493 	cil_db_init(&test_db);
   16494 
   16495 	uint32_t finished = 0;
   16496 
   16497 	struct cil_args_build *extra_args = gen_build_args(test_db->ast->root, test_db, NULL, NULL);
   16498 
   16499 	int rc = __cil_build_ast_node_helper(test_tree->root->cl_head->cl_head, &finished, extra_args);
   16500 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   16501 	CuAssertIntEquals(tc, CIL_TREE_SKIP_NEXT, finished);
   16502 }
   16503 
   16504 void test_cil_build_ast_node_helper_permset_neg(CuTest *tc) {
   16505 	char *line[] = {"(", "permissionset", "foo", ")", NULL};
   16506 
   16507 	struct cil_tree *test_tree;
   16508 	gen_test_tree(&test_tree, line);
   16509 
   16510 	struct cil_db *test_db;
   16511 	cil_db_init(&test_db);
   16512 
   16513 	uint32_t finished = 0;
   16514 
   16515 	struct cil_args_build *extra_args = gen_build_args(test_db->ast->root, test_db, NULL, NULL);
   16516 
   16517 	int rc = __cil_build_ast_node_helper(test_tree->root->cl_head->cl_head, &finished, extra_args);
   16518 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   16519 	CuAssertIntEquals(tc, 0, finished);
   16520 
   16521 }
   16522 
   16523 void test_cil_build_ast_node_helper_in(CuTest *tc) {
   16524 	char *line[] = {"(", "in", "foo", "(", "allow", "test", "baz", "(", "char", "(", "read", ")", ")", ")", ")", NULL};
   16525 
   16526 	struct cil_tree *test_tree;
   16527 	gen_test_tree(&test_tree, line);
   16528 
   16529 	struct cil_db *test_db;
   16530 	cil_db_init(&test_db);
   16531 
   16532 	uint32_t finished = 0;
   16533 
   16534 	struct cil_args_build *extra_args = gen_build_args(test_db->ast->root, test_db, NULL, NULL);
   16535 
   16536 	int rc = __cil_build_ast_node_helper(test_tree->root->cl_head->cl_head, &finished, extra_args);
   16537 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   16538 	CuAssertIntEquals(tc, 0, finished);
   16539 }
   16540 
   16541 void test_cil_build_ast_node_helper_in_neg(CuTest *tc) {
   16542 	char *line[] = {"(", "in", "foo", ")", NULL};
   16543 
   16544 	struct cil_tree *test_tree;
   16545 	gen_test_tree(&test_tree, line);
   16546 
   16547 	struct cil_db *test_db;
   16548 	cil_db_init(&test_db);
   16549 
   16550 	uint32_t finished = 0;
   16551 
   16552 	struct cil_args_build *extra_args = gen_build_args(test_db->ast->root, test_db, NULL, NULL);
   16553 
   16554 	int rc = __cil_build_ast_node_helper(test_tree->root->cl_head->cl_head, &finished, extra_args);
   16555 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   16556 	CuAssertIntEquals(tc, 0, finished);
   16557 }
   16558 
   16559 void test_cil_build_ast_node_helper_class(CuTest *tc) {
   16560 	char *line[] = {"(", "class", "file", "(", "read", "write", "open", ")", ")", NULL};
   16561 
   16562 	struct cil_tree *test_tree;
   16563 	gen_test_tree(&test_tree, line);
   16564 
   16565 	struct cil_db *test_db;
   16566 	cil_db_init(&test_db);
   16567 
   16568 	uint32_t finished = 0;
   16569 
   16570 	struct cil_args_build *extra_args = gen_build_args(test_db->ast->root, test_db, NULL, NULL);
   16571 
   16572 	int rc = __cil_build_ast_node_helper(test_tree->root->cl_head->cl_head, &finished, extra_args);
   16573 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   16574 	CuAssertIntEquals(tc, 1, finished);
   16575 }
   16576 
   16577 void test_cil_build_ast_node_helper_class_neg(CuTest *tc) {
   16578 	char *line[] = {"(", "class", "(", "read", "write", "open", ")", ")", NULL};
   16579 
   16580 	struct cil_tree *test_tree;
   16581 	gen_test_tree(&test_tree, line);
   16582 
   16583 	struct cil_db *test_db;
   16584 	cil_db_init(&test_db);
   16585 
   16586 	uint32_t finished = 0;
   16587 
   16588 	struct cil_args_build *extra_args = gen_build_args(test_db->ast->root, test_db, NULL, NULL);
   16589 
   16590 	int rc = __cil_build_ast_node_helper(test_tree->root->cl_head->cl_head, &finished, extra_args);
   16591 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   16592 	CuAssertIntEquals(tc, 0, finished);
   16593 }
   16594 
   16595 void test_cil_build_ast_node_helper_classpermset(CuTest *tc) {
   16596 	char *line[] = {"(", "classpermissionset", "foo", "(", "read", "(", "write", ")", ")", ")", NULL};
   16597 
   16598 	struct cil_tree *test_tree;
   16599 	gen_test_tree(&test_tree, line);
   16600 
   16601 	struct cil_db *test_db;
   16602 	cil_db_init(&test_db);
   16603 
   16604 	uint32_t finished = 0;
   16605 
   16606 	struct cil_args_build *extra_args = gen_build_args(test_db->ast->root, test_db, NULL, NULL);
   16607 
   16608 	int rc = __cil_build_ast_node_helper(test_tree->root->cl_head->cl_head, &finished, extra_args);
   16609 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   16610 	CuAssertIntEquals(tc, CIL_TREE_SKIP_NEXT, finished);
   16611 }
   16612 
   16613 void test_cil_build_ast_node_helper_classpermset_neg(CuTest *tc) {
   16614 	char *line[] = {"(", "classpermissionset", "foo", ")", NULL};
   16615 
   16616 	struct cil_tree *test_tree;
   16617 	gen_test_tree(&test_tree, line);
   16618 
   16619 	struct cil_db *test_db;
   16620 	cil_db_init(&test_db);
   16621 
   16622 	uint32_t finished = 0;
   16623 
   16624 	struct cil_args_build *extra_args = gen_build_args(test_db->ast->root, test_db, NULL, NULL);
   16625 
   16626 	int rc = __cil_build_ast_node_helper(test_tree->root->cl_head->cl_head, &finished, extra_args);
   16627 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   16628 	CuAssertIntEquals(tc, 0, finished);
   16629 
   16630 }
   16631 
   16632 void test_cil_build_ast_node_helper_classmap(CuTest *tc) {
   16633 	char *line[] = {"(", "classmap", "files", "(", "read", "write", ")", ")", NULL};
   16634 
   16635 	struct cil_tree *test_tree;
   16636 	gen_test_tree(&test_tree, line);
   16637 
   16638 	struct cil_db *test_db;
   16639 	cil_db_init(&test_db);
   16640 
   16641 	uint32_t finished = 0;
   16642 
   16643 	struct cil_args_build *extra_args = gen_build_args(test_db->ast->root, test_db, NULL, NULL);
   16644 
   16645 	int rc = __cil_build_ast_node_helper(test_tree->root->cl_head->cl_head, &finished, extra_args);
   16646 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   16647 	CuAssertIntEquals(tc, 1, finished);
   16648 }
   16649 
   16650 void test_cil_build_ast_node_helper_classmap_neg(CuTest *tc) {
   16651 	char *line[] = {"(", "classmap", "(", "read", "write", ")", ")", NULL};
   16652 
   16653 	struct cil_tree *test_tree;
   16654 	gen_test_tree(&test_tree, line);
   16655 
   16656 	struct cil_db *test_db;
   16657 	cil_db_init(&test_db);
   16658 
   16659 	uint32_t finished = 0;
   16660 
   16661 	struct cil_args_build *extra_args = gen_build_args(test_db->ast->root, test_db, NULL, NULL);
   16662 
   16663 	int rc = __cil_build_ast_node_helper(test_tree->root->cl_head->cl_head, &finished, extra_args);
   16664 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   16665 	CuAssertIntEquals(tc, 0, finished);
   16666 }
   16667 
   16668 void test_cil_build_ast_node_helper_classmapping(CuTest *tc) {
   16669 	char *line[] = {"(", "classmapping", "files", "read", "char_w", ")", NULL};
   16670 
   16671 	struct cil_tree *test_tree;
   16672 	gen_test_tree(&test_tree, line);
   16673 
   16674 	struct cil_db *test_db;
   16675 	cil_db_init(&test_db);
   16676 
   16677 	uint32_t finished = 0;
   16678 
   16679 	struct cil_args_build *extra_args = gen_build_args(test_db->ast->root, test_db, NULL, NULL);
   16680 
   16681 	int rc = __cil_build_ast_node_helper(test_tree->root->cl_head->cl_head, &finished, extra_args);
   16682 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   16683 	CuAssertIntEquals(tc, 1, finished);
   16684 }
   16685 
   16686 void test_cil_build_ast_node_helper_classmapping_neg(CuTest *tc) {
   16687 	char *line[] = {"(", "classmapping", "files", "read", ")", NULL};
   16688 
   16689 	struct cil_tree *test_tree;
   16690 	gen_test_tree(&test_tree, line);
   16691 
   16692 	struct cil_db *test_db;
   16693 	cil_db_init(&test_db);
   16694 
   16695 	uint32_t finished = 0;
   16696 
   16697 	struct cil_args_build *extra_args = gen_build_args(test_db->ast->root, test_db, NULL, NULL);
   16698 
   16699 	int rc = __cil_build_ast_node_helper(test_tree->root->cl_head->cl_head, &finished, extra_args);
   16700 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   16701 	CuAssertIntEquals(tc, 0, finished);
   16702 }
   16703 
   16704 void test_cil_build_ast_node_helper_common(CuTest *tc) {
   16705 	char *line[] = {"(", "common", "test", "(", "read", "write", ")", ")", NULL};
   16706 
   16707 	struct cil_tree *test_tree;
   16708 	gen_test_tree(&test_tree, line);
   16709 
   16710 	struct cil_db *test_db;
   16711 	cil_db_init(&test_db);
   16712 
   16713 	uint32_t finished = 0;
   16714 
   16715 	struct cil_args_build *extra_args = gen_build_args(test_db->ast->root, test_db, NULL, NULL);
   16716 
   16717 	int rc = __cil_build_ast_node_helper(test_tree->root->cl_head->cl_head, &finished, extra_args);
   16718 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   16719 	CuAssertIntEquals(tc, 1, finished);
   16720 }
   16721 
   16722 void test_cil_build_ast_node_helper_common_neg(CuTest *tc) {
   16723 	char *line[] = {"(", "common", "(", "read", "write", ")", ")", NULL};
   16724 
   16725 	struct cil_tree *test_tree;
   16726 	gen_test_tree(&test_tree, line);
   16727 
   16728 	struct cil_db *test_db;
   16729 	cil_db_init(&test_db);
   16730 
   16731 	uint32_t finished = 0;
   16732 
   16733 	struct cil_args_build *extra_args = gen_build_args(test_db->ast->root, test_db, NULL, NULL);
   16734 
   16735 	int rc = __cil_build_ast_node_helper(test_tree->root->cl_head->cl_head, &finished, extra_args);
   16736 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   16737 	CuAssertIntEquals(tc, 0, finished);
   16738 }
   16739 
   16740 void test_cil_build_ast_node_helper_sid(CuTest *tc) {
   16741 	char *line[] = {"(", "sid", "test", ")", NULL};
   16742 
   16743 	struct cil_tree *test_tree;
   16744 	gen_test_tree(&test_tree, line);
   16745 
   16746 	struct cil_db *test_db;
   16747 	cil_db_init(&test_db);
   16748 
   16749 	uint32_t finished = 0;
   16750 
   16751 	struct cil_args_build *extra_args = gen_build_args(test_db->ast->root, test_db, NULL, NULL);
   16752 
   16753 	int rc = __cil_build_ast_node_helper(test_tree->root->cl_head->cl_head, &finished, extra_args);
   16754 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   16755 	CuAssertIntEquals(tc, 1, finished);
   16756 }
   16757 
   16758 void test_cil_build_ast_node_helper_sid_neg(CuTest *tc) {
   16759 	char *line[] = {"(", "sid", "(", "blah", ")", ")", NULL};
   16760 
   16761 	struct cil_tree *test_tree;
   16762 	gen_test_tree(&test_tree, line);
   16763 
   16764 	struct cil_db *test_db;
   16765 	cil_db_init(&test_db);
   16766 
   16767 	uint32_t finished = 0;
   16768 
   16769 	struct cil_args_build *extra_args = gen_build_args(test_db->ast->root, test_db, NULL, NULL);
   16770 
   16771 	int rc = __cil_build_ast_node_helper(test_tree->root->cl_head->cl_head, &finished, extra_args);
   16772 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   16773 	CuAssertIntEquals(tc, 0, finished);
   16774 }
   16775 
   16776 void test_cil_build_ast_node_helper_sidcontext(CuTest *tc) {
   16777 	char *line[] = {"(", "sidcontext", "test", "(", "blah", "blah", "blah", "(", "(", "s0", "(", "c0", ")", ")", "(", "s0", "(", "c0", ")", ")", ")", ")", ")", NULL};
   16778 
   16779 	struct cil_tree *test_tree;
   16780 	gen_test_tree(&test_tree, line);
   16781 
   16782 	struct cil_db *test_db;
   16783 	cil_db_init(&test_db);
   16784 
   16785 	uint32_t finished = 0;
   16786 
   16787 	struct cil_args_build *extra_args = gen_build_args(test_db->ast->root, test_db, NULL, NULL);
   16788 
   16789 	int rc = __cil_build_ast_node_helper(test_tree->root->cl_head->cl_head, &finished, extra_args);
   16790 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   16791 	CuAssertIntEquals(tc, 1, finished);
   16792 }
   16793 
   16794 void test_cil_build_ast_node_helper_sidcontext_neg(CuTest *tc) {
   16795 	char *line[] = {"(", "sidcontext", "(", "blah", "blah", ")", ")", NULL};
   16796 
   16797 	struct cil_tree *test_tree;
   16798 	gen_test_tree(&test_tree, line);
   16799 
   16800 	struct cil_db *test_db;
   16801 	cil_db_init(&test_db);
   16802 
   16803 	uint32_t finished = 0;
   16804 
   16805 	struct cil_args_build *extra_args = gen_build_args(test_db->ast->root, test_db, NULL, NULL);
   16806 
   16807 	int rc = __cil_build_ast_node_helper(test_tree->root->cl_head->cl_head, &finished, extra_args);
   16808 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   16809 	CuAssertIntEquals(tc, 0, finished);
   16810 }
   16811 
   16812 void test_cil_build_ast_node_helper_user(CuTest *tc) {
   16813 	char *line[] = {"(", "user", "jimmypage", NULL};
   16814 
   16815 	struct cil_tree *test_tree;
   16816 	gen_test_tree(&test_tree, line);
   16817 
   16818 	struct cil_db *test_db;
   16819 	cil_db_init(&test_db);
   16820 
   16821 	uint32_t finished = 0;
   16822 
   16823 	struct cil_args_build *extra_args = gen_build_args(test_db->ast->root, test_db, NULL, NULL);
   16824 
   16825 	int rc = __cil_build_ast_node_helper(test_tree->root->cl_head->cl_head, &finished, extra_args);
   16826 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   16827 	CuAssertIntEquals(tc, 0, finished);
   16828 }
   16829 
   16830 void test_cil_build_ast_node_helper_user_neg(CuTest *tc) {
   16831 	char *line[] = {"(", "user", "foo", "bar", NULL};
   16832 
   16833 	struct cil_tree *test_tree;
   16834 	gen_test_tree(&test_tree, line);
   16835 
   16836 	struct cil_db *test_db;
   16837 	cil_db_init(&test_db);
   16838 
   16839 	uint32_t finished = 0;
   16840 
   16841 	struct cil_args_build *extra_args = gen_build_args(test_db->ast->root, test_db, NULL, NULL);
   16842 
   16843 	int rc = __cil_build_ast_node_helper(test_tree->root->cl_head->cl_head, &finished, extra_args);
   16844 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   16845 	CuAssertIntEquals(tc, 0, finished);
   16846 }
   16847 
   16848 void test_cil_build_ast_node_helper_userlevel(CuTest *tc) {
   16849 	char *line[] = {"(", "userlevel", "johnpauljones", "level", NULL};
   16850 
   16851 	struct cil_tree *test_tree;
   16852 	gen_test_tree(&test_tree, line);
   16853 
   16854 	struct cil_db *test_db;
   16855 	cil_db_init(&test_db);
   16856 
   16857 	uint32_t finished = 0;
   16858 
   16859 	struct cil_args_build *extra_args = gen_build_args(test_db->ast->root, test_db, NULL, NULL);
   16860 
   16861 	int rc = __cil_build_ast_node_helper(test_tree->root->cl_head->cl_head, &finished, extra_args);
   16862 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   16863 	CuAssertIntEquals(tc, 1, finished);
   16864 }
   16865 
   16866 void test_cil_build_ast_node_helper_userlevel_neg(CuTest *tc) {
   16867 	char *line[] = {"(", "userlevel", "johnpauljones", NULL};
   16868 
   16869 	struct cil_tree *test_tree;
   16870 	gen_test_tree(&test_tree, line);
   16871 
   16872 	struct cil_db *test_db;
   16873 	cil_db_init(&test_db);
   16874 
   16875 	uint32_t finished = 0;
   16876 
   16877 	struct cil_args_build *extra_args = gen_build_args(test_db->ast->root, test_db, NULL, NULL);
   16878 
   16879 	int rc = __cil_build_ast_node_helper(test_tree->root->cl_head->cl_head, &finished, extra_args);
   16880 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   16881 	CuAssertIntEquals(tc, 0, finished);
   16882 }
   16883 
   16884 void test_cil_build_ast_node_helper_userrange(CuTest *tc) {
   16885 	char *line[] = {"(", "userrange", "johnpauljones", "range", NULL};
   16886 
   16887 	struct cil_tree *test_tree;
   16888 	gen_test_tree(&test_tree, line);
   16889 
   16890 	struct cil_db *test_db;
   16891 	cil_db_init(&test_db);
   16892 
   16893 	uint32_t finished = 0;
   16894 
   16895 	struct cil_args_build *extra_args = gen_build_args(test_db->ast->root, test_db, NULL, NULL);
   16896 
   16897 	int rc = __cil_build_ast_node_helper(test_tree->root->cl_head->cl_head, &finished, extra_args);
   16898 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   16899 	CuAssertIntEquals(tc, 1, finished);
   16900 }
   16901 
   16902 void test_cil_build_ast_node_helper_userrange_neg(CuTest *tc) {
   16903 	char *line[] = {"(", "userrange", "johnpauljones", NULL};
   16904 
   16905 	struct cil_tree *test_tree;
   16906 	gen_test_tree(&test_tree, line);
   16907 
   16908 	struct cil_db *test_db;
   16909 	cil_db_init(&test_db);
   16910 
   16911 	uint32_t finished = 0;
   16912 
   16913 	struct cil_args_build *extra_args = gen_build_args(test_db->ast->root, test_db, NULL, NULL);
   16914 
   16915 	int rc = __cil_build_ast_node_helper(test_tree->root->cl_head->cl_head, &finished, extra_args);
   16916 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   16917 	CuAssertIntEquals(tc, 0, finished);
   16918 }
   16919 
   16920 void test_cil_build_ast_node_helper_type(CuTest *tc) {
   16921 	char *line[] = {"(", "type", "test", ")", NULL};
   16922 
   16923 	struct cil_tree *test_tree;
   16924 	gen_test_tree(&test_tree, line);
   16925 
   16926 	struct cil_db *test_db;
   16927 	cil_db_init(&test_db);
   16928 
   16929 	uint32_t finished = 0;
   16930 
   16931 	struct cil_args_build *extra_args = gen_build_args(test_db->ast->root, test_db, NULL, NULL);
   16932 
   16933 	int rc = __cil_build_ast_node_helper(test_tree->root->cl_head->cl_head, &finished, extra_args);
   16934 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   16935 	CuAssertIntEquals(tc, 0, finished);
   16936 }
   16937 
   16938 void test_cil_build_ast_node_helper_type_neg(CuTest *tc) {
   16939 	char *line[] = {"(", "type", ")", NULL};
   16940 
   16941 	struct cil_tree *test_tree;
   16942 	gen_test_tree(&test_tree, line);
   16943 
   16944 	struct cil_db *test_db;
   16945 	cil_db_init(&test_db);
   16946 
   16947 	uint32_t finished = 0;
   16948 
   16949 	struct cil_args_build *extra_args = gen_build_args(test_db->ast->root, test_db, NULL, NULL);
   16950 
   16951 	int rc = __cil_build_ast_node_helper(test_tree->root->cl_head->cl_head, &finished, extra_args);
   16952 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   16953 	CuAssertIntEquals(tc, 0, finished);
   16954 }
   16955 
   16956 void test_cil_build_ast_node_helper_attribute(CuTest *tc) {
   16957 	char *line[] = {"(", "typeattribute", "test", ")", NULL};
   16958 
   16959 	struct cil_tree *test_tree;
   16960 	gen_test_tree(&test_tree, line);
   16961 
   16962 	struct cil_db *test_db;
   16963 	cil_db_init(&test_db);
   16964 
   16965 	uint32_t finished = 0;
   16966 
   16967 	struct cil_args_build *extra_args = gen_build_args(test_db->ast->root, test_db, NULL, NULL);
   16968 
   16969 	int rc = __cil_build_ast_node_helper(test_tree->root->cl_head->cl_head, &finished, extra_args);
   16970 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   16971 	CuAssertIntEquals(tc, 0, finished);
   16972 }
   16973 
   16974 void test_cil_build_ast_node_helper_attribute_neg(CuTest *tc) {
   16975 	char *line[] = {"(", "typeattribute", ")", NULL};
   16976 
   16977 	struct cil_tree *test_tree;
   16978 	gen_test_tree(&test_tree, line);
   16979 
   16980 	struct cil_db *test_db;
   16981 	cil_db_init(&test_db);
   16982 
   16983 	uint32_t finished = 0;
   16984 
   16985 	struct cil_args_build *extra_args = gen_build_args(test_db->ast->root, test_db, NULL, NULL);
   16986 
   16987 	int rc = __cil_build_ast_node_helper(test_tree->root->cl_head->cl_head, &finished, extra_args);
   16988 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   16989 	CuAssertIntEquals(tc, 0, finished);
   16990 }
   16991 
   16992 void test_cil_build_ast_node_helper_typebounds(CuTest *tc) {
   16993 	char *line[] = {"(", "typebounds", "foo", "bar", ")", NULL};
   16994 	struct cil_tree *test_tree;
   16995 	gen_test_tree(&test_tree, line);
   16996 
   16997 	struct cil_db *test_db;
   16998 	cil_db_init(&test_db);
   16999 
   17000 	uint32_t finished = 0;
   17001 
   17002 	struct cil_args_build *extra_args = gen_build_args(test_db->ast->root, test_db, NULL, NULL);
   17003 
   17004 	int rc = __cil_build_ast_node_helper(test_tree->root->cl_head->cl_head, &finished, extra_args);
   17005 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   17006 	CuAssertIntEquals(tc, 0, finished);
   17007 }
   17008 
   17009 void test_cil_build_ast_node_helper_typebounds_neg(CuTest *tc) {
   17010 	char *line[] = {"(", "typebounds", "bar", ")", NULL};
   17011 
   17012 	struct cil_tree *test_tree;
   17013 	gen_test_tree(&test_tree, line);
   17014 
   17015 	struct cil_db *test_db;
   17016 	cil_db_init(&test_db);
   17017 
   17018 	uint32_t finished = 0;
   17019 
   17020 	struct cil_args_build *extra_args = gen_build_args(test_db->ast->root, test_db, NULL, NULL);
   17021 
   17022 	int rc = __cil_build_ast_node_helper(test_tree->root->cl_head->cl_head, &finished, extra_args);
   17023 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   17024 	CuAssertIntEquals(tc, 0, finished);
   17025 }
   17026 
   17027 void test_cil_build_ast_node_helper_typepermissive(CuTest *tc) {
   17028 	char *line[] = {"(", "typepermissive", "foo", ")", NULL};
   17029 	struct cil_tree *test_tree;
   17030 	gen_test_tree(&test_tree, line);
   17031 
   17032 	struct cil_db *test_db;
   17033 	cil_db_init(&test_db);
   17034 
   17035 	uint32_t finished = 0;
   17036 
   17037 	struct cil_args_build *extra_args = gen_build_args(test_db->ast->root, test_db, NULL, NULL);
   17038 
   17039 	int rc = __cil_build_ast_node_helper(test_tree->root->cl_head->cl_head, &finished, extra_args);
   17040 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   17041 	CuAssertIntEquals(tc, 0, finished);
   17042 }
   17043 
   17044 void test_cil_build_ast_node_helper_typepermissive_neg(CuTest *tc) {
   17045 	char *line[] = {"(", "typepermissive", ")", NULL};
   17046 
   17047 	struct cil_tree *test_tree;
   17048 	gen_test_tree(&test_tree, line);
   17049 
   17050 	struct cil_db *test_db;
   17051 	cil_db_init(&test_db);
   17052 
   17053 	uint32_t finished = 0;
   17054 
   17055 	struct cil_args_build *extra_args = gen_build_args(test_db->ast->root, test_db, NULL, NULL);
   17056 
   17057 	int rc = __cil_build_ast_node_helper(test_tree->root->cl_head->cl_head, &finished, extra_args);
   17058 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   17059 	CuAssertIntEquals(tc, 0, finished);
   17060 }
   17061 
   17062 void test_cil_build_ast_node_helper_nametypetransition(CuTest *tc) {
   17063 	char *line[] = {"(", "nametypetransition", "str", "foo", "bar", "file", "foobar", ")", NULL};
   17064 
   17065 	struct cil_tree *test_tree;
   17066 	gen_test_tree(&test_tree, line);
   17067 
   17068 	struct cil_db *test_db;
   17069 	cil_db_init(&test_db);
   17070 
   17071 	uint32_t finished = 0;
   17072 
   17073 	struct cil_args_build *extra_args = gen_build_args(test_db->ast->root, test_db, NULL, NULL);
   17074 
   17075 	int rc = __cil_build_ast_node_helper(test_tree->root->cl_head->cl_head, &finished, extra_args);
   17076 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   17077 	CuAssertIntEquals(tc, 0, finished);
   17078 }
   17079 
   17080 void test_cil_build_ast_node_helper_nametypetransition_neg(CuTest *tc) {
   17081 	char *line[] = {"(", "nametypetransition", "str", "foo", "bar", "foobar", ")", NULL};
   17082 
   17083 	struct cil_tree *test_tree;
   17084 	gen_test_tree(&test_tree, line);
   17085 
   17086 	struct cil_db *test_db;
   17087 	cil_db_init(&test_db);
   17088 
   17089 	uint32_t finished = 0;
   17090 
   17091 	struct cil_args_build *extra_args = gen_build_args(test_db->ast->root, test_db, NULL, NULL);
   17092 
   17093 	int rc = __cil_build_ast_node_helper(test_tree->root->cl_head->cl_head, &finished, extra_args);
   17094 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   17095 	CuAssertIntEquals(tc, 0, finished);
   17096 }
   17097 
   17098 void test_cil_build_ast_node_helper_rangetransition(CuTest *tc) {
   17099 	char *line[] = {"(", "rangetransition", "type_a", "type_b", "class", "(", "low_l", "high_l", ")", ")", NULL};
   17100 
   17101 	struct cil_tree *test_tree;
   17102 	gen_test_tree(&test_tree, line);
   17103 
   17104 	struct cil_db *test_db;
   17105 	cil_db_init(&test_db);
   17106 
   17107 	uint32_t finished = 0;
   17108 
   17109 	struct cil_args_build *extra_args = gen_build_args(test_db->ast->root, test_db, NULL, NULL);
   17110 
   17111 	int rc = __cil_build_ast_node_helper(test_tree->root->cl_head->cl_head, &finished, extra_args);
   17112 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   17113 	CuAssertIntEquals(tc, 1, finished);
   17114 }
   17115 
   17116 void test_cil_build_ast_node_helper_rangetransition_neg(CuTest *tc) {
   17117 	char *line[] = {"(", "rangetransition", ")", NULL};
   17118 
   17119 	struct cil_tree *test_tree;
   17120 	gen_test_tree(&test_tree, line);
   17121 
   17122 	struct cil_db *test_db;
   17123 	cil_db_init(&test_db);
   17124 
   17125 	uint32_t finished = 0;
   17126 
   17127 	struct cil_args_build *extra_args = gen_build_args(test_db->ast->root, test_db, NULL, NULL);
   17128 
   17129 	int rc = __cil_build_ast_node_helper(test_tree->root->cl_head->cl_head, &finished, extra_args);
   17130 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   17131 	CuAssertIntEquals(tc, 0, finished);
   17132 }
   17133 
   17134 void test_cil_build_ast_node_helper_boolif(CuTest *tc) {
   17135 	char *line[] = {"(", "booleanif", "(", "and", "foo", "bar", ")",
   17136 			"(", "true",
   17137 			"(", "allow", "foo", "bar", "read", ")", ")", ")", NULL};
   17138 
   17139 	struct cil_tree *test_tree;
   17140 	gen_test_tree(&test_tree, line);
   17141 
   17142 	struct cil_db *test_db;
   17143 	cil_db_init(&test_db);
   17144 
   17145 	uint32_t finished = 0;
   17146 
   17147 	struct cil_args_build *extra_args = gen_build_args(test_db->ast->root, test_db, NULL, NULL);
   17148 
   17149 	int rc = __cil_build_ast_node_helper(test_tree->root->cl_head->cl_head, &finished, extra_args);
   17150 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   17151 	CuAssertIntEquals(tc, 0, finished);
   17152 }
   17153 
   17154 void test_cil_build_ast_node_helper_boolif_neg(CuTest *tc) {
   17155 	char *line[] = {"(", "booleanif", "(", "*&", "foo", "bar", ")",
   17156 			"(", "true",
   17157 			"(", "allow", "foo", "bar", "read", ")", ")", ")", NULL};
   17158 
   17159 	struct cil_tree *test_tree;
   17160 	gen_test_tree(&test_tree, line);
   17161 
   17162 	struct cil_db *test_db;
   17163 	cil_db_init(&test_db);
   17164 
   17165 	uint32_t finished = 0;
   17166 
   17167 	struct cil_args_build *extra_args = gen_build_args(test_db->ast->root, test_db, NULL, NULL);
   17168 
   17169 	int rc = __cil_build_ast_node_helper(test_tree->root->cl_head->cl_head, &finished, extra_args);
   17170 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   17171 	CuAssertIntEquals(tc, 0, finished);
   17172 }
   17173 
   17174 void test_cil_build_ast_node_helper_condblock_true(CuTest *tc) {
   17175 	char *line[] = {"(", "true", "(", "allow", "foo", "bar", "baz", "(", "write", ")", ")", ")", NULL};
   17176 
   17177 	struct cil_tree *test_tree;
   17178 	gen_test_tree(&test_tree, line);
   17179 
   17180 	struct cil_db *test_db;
   17181 	cil_db_init(&test_db);
   17182 
   17183 	uint32_t finished = 0;
   17184 
   17185 	struct cil_args_build *extra_args = gen_build_args(test_db->ast->root, test_db, NULL, NULL);
   17186 
   17187 	int rc = __cil_build_ast_node_helper(test_tree->root->cl_head->cl_head, &finished, extra_args);
   17188 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   17189 	CuAssertIntEquals(tc, 0, finished);
   17190 }
   17191 
   17192 void test_cil_build_ast_node_helper_condblock_true_neg(CuTest *tc) {
   17193 	char *line[] = {"(", "true", "(", ")", ")", NULL};
   17194 
   17195 	struct cil_tree *test_tree;
   17196 	gen_test_tree(&test_tree, line);
   17197 
   17198 	struct cil_db *test_db;
   17199 	cil_db_init(&test_db);
   17200 
   17201 	uint32_t finished = 0;
   17202 
   17203 	struct cil_args_build *extra_args = gen_build_args(test_db->ast->root, test_db, NULL, NULL);
   17204 
   17205 	int rc = __cil_build_ast_node_helper(test_tree->root->cl_head->cl_head, &finished, extra_args);
   17206 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   17207 	CuAssertIntEquals(tc, 0, finished);
   17208 }
   17209 
   17210 void test_cil_build_ast_node_helper_condblock_false(CuTest *tc) {
   17211 	char *line[] = {"(", "false", "(", "allow", "foo", "bar", "baz", "(", "write", ")", ")", ")", NULL};
   17212 
   17213 	struct cil_tree *test_tree;
   17214 	gen_test_tree(&test_tree, line);
   17215 
   17216 	struct cil_db *test_db;
   17217 	cil_db_init(&test_db);
   17218 
   17219 	uint32_t finished = 0;
   17220 
   17221 	struct cil_args_build *extra_args = gen_build_args(test_db->ast->root, test_db, NULL, NULL);
   17222 
   17223 	int rc = __cil_build_ast_node_helper(test_tree->root->cl_head->cl_head, &finished, extra_args);
   17224 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   17225 	CuAssertIntEquals(tc, 0, finished);
   17226 }
   17227 
   17228 void test_cil_build_ast_node_helper_condblock_false_neg(CuTest *tc) {
   17229 	char *line[] = {"(", "false", "(", ")", ")", NULL};
   17230 
   17231 	struct cil_tree *test_tree;
   17232 	gen_test_tree(&test_tree, line);
   17233 
   17234 	struct cil_db *test_db;
   17235 	cil_db_init(&test_db);
   17236 
   17237 	uint32_t finished = 0;
   17238 
   17239 	struct cil_args_build *extra_args = gen_build_args(test_db->ast->root, test_db, NULL, NULL);
   17240 
   17241 	int rc = __cil_build_ast_node_helper(test_tree->root->cl_head->cl_head, &finished, extra_args);
   17242 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   17243 	CuAssertIntEquals(tc, 0, finished);
   17244 }
   17245 
   17246 void test_cil_build_ast_node_helper_tunif(CuTest *tc) {
   17247 	char *line[] = {"(", "tunableif", "(", "and", "foo", "bar", ")",
   17248 			"(", "true",
   17249 			"(", "allow", "foo", "bar", "read", ")", ")", ")", NULL};
   17250 
   17251 	struct cil_tree *test_tree;
   17252 	gen_test_tree(&test_tree, line);
   17253 
   17254 	struct cil_db *test_db;
   17255 	cil_db_init(&test_db);
   17256 
   17257 	uint32_t finished = 0;
   17258 
   17259 	struct cil_args_build *extra_args = gen_build_args(test_db->ast->root, test_db, NULL, NULL);
   17260 
   17261 	int rc = __cil_build_ast_node_helper(test_tree->root->cl_head->cl_head, &finished, extra_args);
   17262 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   17263 	CuAssertIntEquals(tc, 0, finished);
   17264 }
   17265 
   17266 void test_cil_build_ast_node_helper_tunif_neg(CuTest *tc) {
   17267 	char *line[] = {"(", "tunableif", "(", "*&", "foo", "bar", ")",
   17268 			"(", "allow", "foo", "bar", "read", ")", ")", NULL};
   17269 
   17270 	struct cil_tree *test_tree;
   17271 	gen_test_tree(&test_tree, line);
   17272 
   17273 	struct cil_db *test_db;
   17274 	cil_db_init(&test_db);
   17275 
   17276 	uint32_t finished = 0;
   17277 
   17278 	struct cil_args_build *extra_args = gen_build_args(test_db->ast->root, test_db, NULL, NULL);
   17279 
   17280 	int rc = __cil_build_ast_node_helper(test_tree->root->cl_head->cl_head, &finished, extra_args);
   17281 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   17282 	CuAssertIntEquals(tc, 0, finished);
   17283 }
   17284 
   17285 void test_cil_build_ast_node_helper_typealias(CuTest *tc) {
   17286 	char *line[] = {"(", "typealias", ".test.type", "type_t", ")", "(", "type", "test", ")", NULL};
   17287 
   17288 	struct cil_tree *test_tree;
   17289 	gen_test_tree(&test_tree, line);
   17290 
   17291 	struct cil_db *test_db;
   17292 	cil_db_init(&test_db);
   17293 
   17294 	uint32_t finished = 0;
   17295 
   17296 	struct cil_args_build *extra_args = gen_build_args(test_db->ast->root, test_db, NULL, NULL);
   17297 
   17298 	int rc = __cil_build_ast_node_helper(test_tree->root->cl_head->cl_head, &finished, extra_args);
   17299 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   17300 	CuAssertIntEquals(tc, 0, finished);
   17301 }
   17302 
   17303 void test_cil_build_ast_node_helper_typealias_notype_neg(CuTest *tc) {
   17304 	char *line[] = {"(", "typealias", ".test.type", ")", NULL};
   17305 
   17306 	struct cil_tree *test_tree;
   17307 	gen_test_tree(&test_tree, line);
   17308 
   17309 	struct cil_db *test_db;
   17310 	cil_db_init(&test_db);
   17311 
   17312 	uint32_t finished = 0;
   17313 
   17314 	struct cil_args_build *extra_args = gen_build_args(test_db->ast->root, test_db, NULL, NULL);
   17315 
   17316 	int rc = __cil_build_ast_node_helper(test_tree->root->cl_head->cl_head, &finished, extra_args);
   17317 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   17318 	CuAssertIntEquals(tc, 0, finished);
   17319 }
   17320 
   17321 void test_cil_build_ast_node_helper_typeattribute(CuTest *tc)
   17322 {
   17323 	char *line[] = {"(", "typeattribute", "type", ")", NULL};
   17324 
   17325 	struct cil_tree *test_tree;
   17326 	gen_test_tree(&test_tree, line);
   17327 
   17328 	struct cil_db *test_db;
   17329 	cil_db_init(&test_db);
   17330 
   17331 	uint32_t finished = 0;
   17332 
   17333 	struct cil_args_build *extra_args = gen_build_args(test_db->ast->root, test_db, NULL, NULL);
   17334 
   17335 	int rc = __cil_build_ast_node_helper(test_tree->root->cl_head->cl_head, &finished, extra_args);
   17336 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   17337 	CuAssertIntEquals(tc, 0, finished);
   17338 }
   17339 
   17340 void test_cil_build_ast_node_helper_typeattribute_neg(CuTest *tc)
   17341 {
   17342 	char *line[] = {"(", "typeattribute", ".fail.type", ")", NULL};
   17343 
   17344 	struct cil_tree *test_tree;
   17345 	gen_test_tree(&test_tree, line);
   17346 
   17347 	struct cil_db *test_db;
   17348 	cil_db_init(&test_db);
   17349 
   17350 	uint32_t finished = 0;
   17351 
   17352 	struct cil_args_build *extra_args = gen_build_args(test_db->ast->root, test_db, NULL, NULL);
   17353 
   17354 	int rc = __cil_build_ast_node_helper(test_tree->root->cl_head->cl_head, &finished, extra_args);
   17355 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   17356 	CuAssertIntEquals(tc, 0, finished);
   17357 }
   17358 
   17359 void test_cil_build_ast_node_helper_typeattributeset(CuTest *tc) {
   17360 	char *line[] = {"(", "typeattributeset", "filetypes", "(", "and", "test_t", "test2_t", ")", ")", NULL};
   17361 
   17362 	struct cil_tree *test_tree;
   17363 	gen_test_tree(&test_tree, line);
   17364 
   17365 	struct cil_db *test_db;
   17366 	cil_db_init(&test_db);
   17367 
   17368 	uint32_t finished = 0;
   17369 
   17370 	struct cil_args_build *extra_args = gen_build_args(test_db->ast->root, test_db, NULL, NULL);
   17371 
   17372 	int rc = __cil_build_ast_node_helper(test_tree->root->cl_head->cl_head, &finished, extra_args);
   17373 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   17374 	CuAssertIntEquals(tc, 1, finished);
   17375 }
   17376 
   17377 void test_cil_build_ast_node_helper_typeattributeset_neg(CuTest *tc) {
   17378 	char *line[] = {"(", "typeattributeset", "files", "(", ")", ")", NULL};
   17379 
   17380 	struct cil_tree *test_tree;
   17381 	gen_test_tree(&test_tree, line);
   17382 
   17383 	struct cil_db *test_db;
   17384 	cil_db_init(&test_db);
   17385 
   17386 	uint32_t finished = 0;
   17387 
   17388 	struct cil_args_build *extra_args = gen_build_args(test_db->ast->root, test_db, NULL, NULL);
   17389 
   17390 	int rc = __cil_build_ast_node_helper(test_tree->root->cl_head->cl_head, &finished, extra_args);
   17391 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   17392 	CuAssertIntEquals(tc, 0, finished);
   17393 }
   17394 
   17395 void test_cil_build_ast_node_helper_userbounds(CuTest *tc) {
   17396 	char *line[] = {"(", "userbounds", "user1", "user2", ")", NULL};
   17397 
   17398 	struct cil_tree *test_tree;
   17399 	gen_test_tree(&test_tree, line);
   17400 
   17401 	struct cil_db *test_db;
   17402 	cil_db_init(&test_db);
   17403 
   17404 	uint32_t finished = 0;
   17405 
   17406 	struct cil_args_build *extra_args = gen_build_args(test_db->ast->root, test_db, NULL, NULL);
   17407 
   17408 	int rc = __cil_build_ast_node_helper(test_tree->root->cl_head->cl_head, &finished, extra_args);
   17409 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   17410 	CuAssertIntEquals(tc, 0, finished);
   17411 }
   17412 
   17413 void test_cil_build_ast_node_helper_userbounds_neg(CuTest *tc) {
   17414 	char *line[] = {"(", "userbounds", "user1", ")", NULL};
   17415 
   17416 	struct cil_tree *test_tree;
   17417 	gen_test_tree(&test_tree, line);
   17418 
   17419 	struct cil_db *test_db;
   17420 	cil_db_init(&test_db);
   17421 
   17422 	uint32_t finished = 0;
   17423 
   17424 	struct cil_args_build *extra_args = gen_build_args(test_db->ast->root, test_db, NULL, NULL);
   17425 
   17426 	int rc = __cil_build_ast_node_helper(test_tree->root->cl_head->cl_head, &finished, extra_args);
   17427 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   17428 	CuAssertIntEquals(tc, 0, finished);
   17429 }
   17430 
   17431 void test_cil_build_ast_node_helper_role(CuTest *tc) {
   17432 	char *line[] = {"(", "role", "test_r", ")", NULL};
   17433 
   17434 	struct cil_tree *test_tree;
   17435 	gen_test_tree(&test_tree, line);
   17436 
   17437 	struct cil_db *test_db;
   17438 	cil_db_init(&test_db);
   17439 
   17440 	uint32_t finished = 0;
   17441 
   17442 	struct cil_args_build *extra_args = gen_build_args(test_db->ast->root, test_db, NULL, NULL);
   17443 
   17444 	int rc = __cil_build_ast_node_helper(test_tree->root->cl_head->cl_head, &finished, extra_args);
   17445 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   17446 	CuAssertIntEquals(tc, 0, finished);
   17447 }
   17448 
   17449 void test_cil_build_ast_node_helper_role_neg(CuTest *tc) {
   17450 	char *line[] = {"(", "role", ")", NULL};
   17451 
   17452 	struct cil_tree *test_tree;
   17453 	gen_test_tree(&test_tree, line);
   17454 
   17455 	struct cil_db *test_db;
   17456 	cil_db_init(&test_db);
   17457 
   17458 	uint32_t finished = 0;
   17459 
   17460 	struct cil_args_build *extra_args = gen_build_args(test_db->ast->root, test_db, NULL, NULL);
   17461 
   17462 	int rc = __cil_build_ast_node_helper(test_tree->root->cl_head->cl_head, &finished, extra_args);
   17463 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   17464 	CuAssertIntEquals(tc, 0, finished);
   17465 }
   17466 
   17467 void test_cil_build_ast_node_helper_roletransition(CuTest *tc) {
   17468 	char *line[] = {"(", "roletransition", "foo_r", "bar_t", "process", "foobar_r", ")", NULL};
   17469 
   17470 	struct cil_tree *test_tree;
   17471 	gen_test_tree(&test_tree, line);
   17472 
   17473 	struct cil_db *test_db;
   17474 	cil_db_init(&test_db);
   17475 
   17476 	uint32_t finished = 0;
   17477 
   17478 	struct cil_args_build *extra_args = gen_build_args(test_db->ast->root, test_db, NULL, NULL);
   17479 
   17480 	int rc = __cil_build_ast_node_helper(test_tree->root->cl_head->cl_head, &finished, extra_args);
   17481 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   17482 	CuAssertIntEquals(tc, 0, finished);
   17483 }
   17484 
   17485 void test_cil_build_ast_node_helper_roletransition_neg(CuTest *tc) {
   17486 	char *line[] = {"(", "roletransition", "foo_r", "bar_t", ")", NULL};
   17487 
   17488 	struct cil_tree *test_tree;
   17489 	gen_test_tree(&test_tree, line);
   17490 
   17491 	struct cil_db *test_db;
   17492 	cil_db_init(&test_db);
   17493 
   17494 	uint32_t finished = 0;
   17495 
   17496 	struct cil_args_build *extra_args = gen_build_args(test_db->ast->root, test_db, NULL, NULL);
   17497 
   17498 	int rc = __cil_build_ast_node_helper(test_tree->root->cl_head->cl_head, &finished, extra_args);
   17499 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   17500 	CuAssertIntEquals(tc, 0, finished);
   17501 }
   17502 
   17503 void test_cil_build_ast_node_helper_roleallow(CuTest *tc) {
   17504         char *line[] = {"(", "roleallow", "staff_r", "sysadm_r", NULL};
   17505 
   17506 	struct cil_tree *test_tree;
   17507 	gen_test_tree(&test_tree, line);
   17508 
   17509 	struct cil_db *test_db;
   17510 	cil_db_init(&test_db);
   17511 
   17512 	uint32_t finished = 0;
   17513 
   17514 	struct cil_args_build *extra_args = gen_build_args(test_db->ast->root, test_db, NULL, NULL);
   17515 
   17516 	int rc = __cil_build_ast_node_helper(test_tree->root->cl_head->cl_head, &finished, extra_args);
   17517 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   17518 	CuAssertIntEquals(tc, 0, finished);
   17519 }
   17520 
   17521 void test_cil_build_ast_node_helper_roleallow_neg(CuTest *tc) {
   17522         char *line[] = {"(", "roleallow", "staff_r", NULL};
   17523 
   17524 	struct cil_tree *test_tree;
   17525 	gen_test_tree(&test_tree, line);
   17526 
   17527 	struct cil_db *test_db;
   17528 	cil_db_init(&test_db);
   17529 
   17530 	uint32_t finished = 0;
   17531 
   17532 	struct cil_args_build *extra_args = gen_build_args(test_db->ast->root, test_db, NULL, NULL);
   17533 
   17534 	int rc = __cil_build_ast_node_helper(test_tree->root->cl_head->cl_head, &finished, extra_args);
   17535 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   17536 	CuAssertIntEquals(tc, 0, finished);
   17537 }
   17538 
   17539 void test_cil_build_ast_node_helper_rolebounds(CuTest *tc) {
   17540 	char *line[] = {"(", "rolebounds", "role1", "role2", ")", NULL};
   17541 
   17542 	struct cil_tree *test_tree;
   17543 	gen_test_tree(&test_tree, line);
   17544 
   17545 	struct cil_db *test_db;
   17546 	cil_db_init(&test_db);
   17547 
   17548 	uint32_t finished = 0;
   17549 
   17550 	struct cil_args_build *extra_args = gen_build_args(test_db->ast->root, test_db, NULL, NULL);
   17551 
   17552 	int rc = __cil_build_ast_node_helper(test_tree->root->cl_head->cl_head, &finished, extra_args);
   17553 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   17554 	CuAssertIntEquals(tc, 0, finished);
   17555 }
   17556 
   17557 void test_cil_build_ast_node_helper_rolebounds_neg(CuTest *tc) {
   17558 	char *line[] = {"(", "rolebounds", "role1", ")", NULL};
   17559 
   17560 	struct cil_tree *test_tree;
   17561 	gen_test_tree(&test_tree, line);
   17562 
   17563 	struct cil_db *test_db;
   17564 	cil_db_init(&test_db);
   17565 
   17566 	uint32_t finished = 0;
   17567 
   17568 	struct cil_args_build *extra_args = gen_build_args(test_db->ast->root, test_db, NULL, NULL);
   17569 
   17570 	int rc = __cil_build_ast_node_helper(test_tree->root->cl_head->cl_head, &finished, extra_args);
   17571 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   17572 	CuAssertIntEquals(tc, 0, finished);
   17573 }
   17574 
   17575 void test_cil_build_ast_node_helper_avrule_allow(CuTest *tc) {
   17576 	char *line[] = {"(", "allow", "test", "foo", "(", "bar", "(", "read", "write", ")", ")", ")", NULL};
   17577 
   17578 	struct cil_tree *test_tree;
   17579 	gen_test_tree(&test_tree, line);
   17580 
   17581 	struct cil_db *test_db;
   17582 	cil_db_init(&test_db);
   17583 
   17584 	uint32_t finished = 0;
   17585 
   17586 	struct cil_args_build *extra_args = gen_build_args(test_db->ast->root, test_db, NULL, NULL);
   17587 
   17588 	int rc = __cil_build_ast_node_helper(test_tree->root->cl_head->cl_head, &finished, extra_args);
   17589 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   17590 	CuAssertIntEquals(tc, 1, finished);
   17591 }
   17592 
   17593 void test_cil_build_ast_node_helper_avrule_allow_neg(CuTest *tc) {
   17594 	char *line[] = {"(", "allow", "foo", "bar", "(", "read", "write", ")", "blah", ")", NULL};
   17595 
   17596 	struct cil_tree *test_tree;
   17597 	gen_test_tree(&test_tree, line);
   17598 
   17599 	struct cil_db *test_db;
   17600 	cil_db_init(&test_db);
   17601 
   17602 	uint32_t finished = 0;
   17603 
   17604 	struct cil_args_build *extra_args = gen_build_args(test_db->ast->root, test_db, NULL, NULL);
   17605 
   17606 	int rc = __cil_build_ast_node_helper(test_tree->root->cl_head->cl_head, &finished, extra_args);
   17607 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   17608 	CuAssertIntEquals(tc, 0, finished);
   17609 }
   17610 
   17611 void test_cil_build_ast_node_helper_avrule_auditallow(CuTest *tc) {
   17612 	char *line[] = {"(", "auditallow", "test", "foo", "(", "bar", "(", "read", "write", ")", ")", ")", NULL};
   17613 
   17614 	struct cil_tree *test_tree;
   17615 	gen_test_tree(&test_tree, line);
   17616 
   17617 	struct cil_db *test_db;
   17618 	cil_db_init(&test_db);
   17619 
   17620 	uint32_t finished = 0;
   17621 
   17622 	struct cil_args_build *extra_args = gen_build_args(test_db->ast->root, test_db, NULL, NULL);
   17623 
   17624 	int rc = __cil_build_ast_node_helper(test_tree->root->cl_head->cl_head, &finished, extra_args);
   17625 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   17626 	CuAssertIntEquals(tc, 1, finished);
   17627 }
   17628 
   17629 void test_cil_build_ast_node_helper_avrule_auditallow_neg(CuTest *tc) {
   17630 	char *line[] = {"(", "auditallow", "foo", "bar", "(", "read", "write", ")", "blah", ")", NULL};
   17631 
   17632 	struct cil_tree *test_tree;
   17633 	gen_test_tree(&test_tree, line);
   17634 
   17635 	struct cil_db *test_db;
   17636 	cil_db_init(&test_db);
   17637 
   17638 	uint32_t finished = 0;
   17639 
   17640 	struct cil_args_build *extra_args = gen_build_args(test_db->ast->root, test_db, NULL, NULL);
   17641 
   17642 	int rc = __cil_build_ast_node_helper(test_tree->root->cl_head->cl_head, &finished, extra_args);
   17643 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   17644 	CuAssertIntEquals(tc, 0, finished);
   17645 }
   17646 
   17647 void test_cil_build_ast_node_helper_avrule_dontaudit(CuTest *tc) {
   17648 	char *line[] = {"(", "dontaudit", "test", "foo", "(", "bar", "(", "read", "write", ")", ")", ")", NULL};
   17649 
   17650 	struct cil_tree *test_tree;
   17651 	gen_test_tree(&test_tree, line);
   17652 
   17653 	struct cil_db *test_db;
   17654 	cil_db_init(&test_db);
   17655 
   17656 	uint32_t finished = 0;
   17657 
   17658 	struct cil_args_build *extra_args = gen_build_args(test_db->ast->root, test_db, NULL, NULL);
   17659 
   17660 	int rc = __cil_build_ast_node_helper(test_tree->root->cl_head->cl_head, &finished, extra_args);
   17661 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   17662 	CuAssertIntEquals(tc, 1, finished);
   17663 }
   17664 
   17665 void test_cil_build_ast_node_helper_avrule_dontaudit_neg(CuTest *tc) {
   17666 	char *line[] = {"(", "dontaudit", "foo", "bar", "(", "read", "write", ")", "blah", ")", NULL};
   17667 
   17668 	struct cil_tree *test_tree;
   17669 	gen_test_tree(&test_tree, line);
   17670 
   17671 	struct cil_db *test_db;
   17672 	cil_db_init(&test_db);
   17673 
   17674 	uint32_t finished = 0;
   17675 
   17676 	struct cil_args_build *extra_args = gen_build_args(test_db->ast->root, test_db, NULL, NULL);
   17677 
   17678 	int rc = __cil_build_ast_node_helper(test_tree->root->cl_head->cl_head, &finished, extra_args);
   17679 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   17680 	CuAssertIntEquals(tc, 0, finished);
   17681 }
   17682 
   17683 void test_cil_build_ast_node_helper_avrule_neverallow(CuTest *tc) {
   17684 	char *line[] = {"(", "neverallow", "test", "foo", "(", "bar", "(", "read", "write", ")", ")", ")", NULL};
   17685 
   17686 	struct cil_tree *test_tree;
   17687 	gen_test_tree(&test_tree, line);
   17688 
   17689 	struct cil_db *test_db;
   17690 	cil_db_init(&test_db);
   17691 
   17692 	uint32_t finished = 0;
   17693 
   17694 	struct cil_args_build *extra_args = gen_build_args(test_db->ast->root, test_db, NULL, NULL);
   17695 
   17696 	int rc = __cil_build_ast_node_helper(test_tree->root->cl_head->cl_head, &finished, extra_args);
   17697 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   17698 	CuAssertIntEquals(tc, 1, finished);
   17699 }
   17700 
   17701 void test_cil_build_ast_node_helper_avrule_neverallow_neg(CuTest *tc) {
   17702 	char *line[] = {"(", "neverallow", "foo", "bar", "(", "read", "write", ")", "blah", ")", NULL};
   17703 
   17704 	struct cil_tree *test_tree;
   17705 	gen_test_tree(&test_tree, line);
   17706 
   17707 	struct cil_db *test_db;
   17708 	cil_db_init(&test_db);
   17709 
   17710 	uint32_t finished = 0;
   17711 
   17712 	struct cil_args_build *extra_args = gen_build_args(test_db->ast->root, test_db, NULL, NULL);
   17713 
   17714 	int rc = __cil_build_ast_node_helper(test_tree->root->cl_head->cl_head, &finished, extra_args);
   17715 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   17716 	CuAssertIntEquals(tc, 0, finished);
   17717 }
   17718 
   17719 void test_cil_build_ast_node_helper_type_rule_transition(CuTest *tc) {
   17720 	char *line[] = {"(", "typetransition", "foo", "bar", "file", "foobar", ")", NULL};
   17721 
   17722 	struct cil_tree *test_tree;
   17723 	gen_test_tree(&test_tree, line);
   17724 
   17725 	struct cil_db *test_db;
   17726 	cil_db_init(&test_db);
   17727 
   17728 	uint32_t finished = 0;
   17729 
   17730 	struct cil_args_build *extra_args = gen_build_args(test_db->ast->root, test_db, NULL, NULL);
   17731 
   17732 	int rc = __cil_build_ast_node_helper(test_tree->root->cl_head->cl_head, &finished, extra_args);
   17733 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   17734 	CuAssertIntEquals(tc, 0, finished);
   17735 }
   17736 
   17737 void test_cil_build_ast_node_helper_type_rule_transition_neg(CuTest *tc) {
   17738 	char *line[] = {"(", "typetransition", "foo", "bar", "file", "foobar", "extra",  ")", NULL};
   17739 
   17740 	struct cil_tree *test_tree;
   17741 	gen_test_tree(&test_tree, line);
   17742 
   17743 	struct cil_db *test_db;
   17744 	cil_db_init(&test_db);
   17745 
   17746 	uint32_t finished = 0;
   17747 
   17748 	struct cil_args_build *extra_args = gen_build_args(test_db->ast->root, test_db, NULL, NULL);
   17749 
   17750 	int rc = __cil_build_ast_node_helper(test_tree->root->cl_head->cl_head, &finished, extra_args);
   17751 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   17752 	CuAssertIntEquals(tc, 0, finished);
   17753 }
   17754 
   17755 void test_cil_build_ast_node_helper_type_rule_change(CuTest *tc) {
   17756 	char *line[] = {"(", "typechange", "foo", "bar", "file", "foobar", ")", NULL};
   17757 
   17758 	struct cil_tree *test_tree;
   17759 	gen_test_tree(&test_tree, line);
   17760 
   17761 	struct cil_db *test_db;
   17762 	cil_db_init(&test_db);
   17763 
   17764 	uint32_t finished = 0;
   17765 
   17766 	struct cil_args_build *extra_args = gen_build_args(test_db->ast->root, test_db, NULL, NULL);
   17767 
   17768 	int rc = __cil_build_ast_node_helper(test_tree->root->cl_head->cl_head, &finished, extra_args);
   17769 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   17770 	CuAssertIntEquals(tc, 0, finished);
   17771 }
   17772 
   17773 void test_cil_build_ast_node_helper_type_rule_change_neg(CuTest *tc) {
   17774 	char *line[] = {"(", "typechange", "foo", "bar", "file", "foobar", "extra",  ")", NULL};
   17775 
   17776 	struct cil_tree *test_tree;
   17777 	gen_test_tree(&test_tree, line);
   17778 
   17779 	struct cil_db *test_db;
   17780 	cil_db_init(&test_db);
   17781 
   17782 	uint32_t finished = 0;
   17783 
   17784 	struct cil_args_build *extra_args = gen_build_args(test_db->ast->root, test_db, NULL, NULL);
   17785 
   17786 	int rc = __cil_build_ast_node_helper(test_tree->root->cl_head->cl_head, &finished, extra_args);
   17787 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   17788 	CuAssertIntEquals(tc, 0, finished);
   17789 }
   17790 
   17791 void test_cil_build_ast_node_helper_type_rule_member(CuTest *tc) {
   17792 	char *line[] = {"(", "typemember", "foo", "bar", "file", "foobar", ")", NULL};
   17793 
   17794 	struct cil_tree *test_tree;
   17795 	gen_test_tree(&test_tree, line);
   17796 
   17797 	struct cil_db *test_db;
   17798 	cil_db_init(&test_db);
   17799 
   17800 	uint32_t finished = 0;
   17801 
   17802 	struct cil_args_build *extra_args = gen_build_args(test_db->ast->root, test_db, NULL, NULL);
   17803 
   17804 	int rc = __cil_build_ast_node_helper(test_tree->root->cl_head->cl_head, &finished, extra_args);
   17805 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   17806 	CuAssertIntEquals(tc, 0, finished);
   17807 }
   17808 
   17809 void test_cil_build_ast_node_helper_type_rule_member_neg(CuTest *tc) {
   17810 	char *line[] = {"(", "typemember", "foo", "bar", "file", "foobar", "extra",  ")", NULL};
   17811 
   17812 	struct cil_tree *test_tree;
   17813 	gen_test_tree(&test_tree, line);
   17814 
   17815 	struct cil_db *test_db;
   17816 	cil_db_init(&test_db);
   17817 
   17818 	uint32_t finished = 0;
   17819 
   17820 	struct cil_args_build *extra_args = gen_build_args(test_db->ast->root, test_db, NULL, NULL);
   17821 
   17822 	int rc = __cil_build_ast_node_helper(test_tree->root->cl_head->cl_head, &finished, extra_args);
   17823 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   17824 	CuAssertIntEquals(tc, 0, finished);
   17825 }
   17826 
   17827 void test_cil_build_ast_node_helper_bool(CuTest *tc) {
   17828 	char *line[] = {"(", "boolean", "foo", "true", ")", NULL};
   17829 
   17830 	struct cil_tree *test_tree;
   17831 	gen_test_tree(&test_tree, line);
   17832 
   17833 	struct cil_db *test_db;
   17834 	cil_db_init(&test_db);
   17835 
   17836 	uint32_t finished = 0;
   17837 
   17838 	struct cil_args_build *extra_args = gen_build_args(test_db->ast->root, test_db, NULL, NULL);
   17839 
   17840 	int rc = __cil_build_ast_node_helper(test_tree->root->cl_head->cl_head, &finished, extra_args);
   17841 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   17842 	CuAssertIntEquals(tc, 0, finished);
   17843 }
   17844 
   17845 void test_cil_build_ast_node_helper_bool_neg(CuTest *tc) {
   17846 	char *line[] = {"(", "boolean", "foo", ")", NULL};
   17847 
   17848 	struct cil_tree *test_tree;
   17849 	gen_test_tree(&test_tree, line);
   17850 
   17851 	struct cil_db *test_db;
   17852 	cil_db_init(&test_db);
   17853 
   17854 	uint32_t finished = 0;
   17855 
   17856 	struct cil_args_build *extra_args = gen_build_args(test_db->ast->root, test_db, NULL, NULL);
   17857 
   17858 	int rc = __cil_build_ast_node_helper(test_tree->root->cl_head->cl_head, &finished, extra_args);
   17859 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   17860 	CuAssertIntEquals(tc, 0, finished);
   17861 }
   17862 
   17863 void test_cil_build_ast_node_helper_bool_tunable(CuTest *tc) {
   17864 	char *line[] = {"(", "tunable", "foo", "true", ")", NULL};
   17865 
   17866 	struct cil_tree *test_tree;
   17867 	gen_test_tree(&test_tree, line);
   17868 
   17869 	struct cil_db *test_db;
   17870 	cil_db_init(&test_db);
   17871 
   17872 	uint32_t finished = 0;
   17873 
   17874 	struct cil_args_build *extra_args = gen_build_args(test_db->ast->root, test_db, NULL, NULL);
   17875 
   17876 	int rc = __cil_build_ast_node_helper(test_tree->root->cl_head->cl_head, &finished, extra_args);
   17877 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   17878 	CuAssertIntEquals(tc, 0, finished);
   17879 }
   17880 
   17881 void test_cil_build_ast_node_helper_bool_tunable_neg(CuTest *tc) {
   17882 	char *line[] = {"(", "tunable", "foo", ")", NULL};
   17883 
   17884 	struct cil_tree *test_tree;
   17885 	gen_test_tree(&test_tree, line);
   17886 
   17887 	struct cil_db *test_db;
   17888 	cil_db_init(&test_db);
   17889 
   17890 	uint32_t finished = 0;
   17891 
   17892 	struct cil_args_build *extra_args = gen_build_args(test_db->ast->root, test_db, NULL, NULL);
   17893 
   17894 	int rc = __cil_build_ast_node_helper(test_tree->root->cl_head->cl_head, &finished, extra_args);
   17895 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   17896 	CuAssertIntEquals(tc, 0, finished);
   17897 }
   17898 
   17899 void test_cil_build_ast_node_helper_sensitivity(CuTest *tc) {
   17900 	char *line[] = {"(", "sensitivity", "s0", ")", NULL};
   17901 
   17902 	struct cil_tree *test_tree;
   17903 	gen_test_tree(&test_tree, line);
   17904 
   17905 	struct cil_db *test_db;
   17906 	cil_db_init(&test_db);
   17907 
   17908 	uint32_t finished = 0;
   17909 
   17910 	struct cil_args_build *extra_args = gen_build_args(test_db->ast->root, test_db, NULL, NULL);
   17911 
   17912 	int rc = __cil_build_ast_node_helper(test_tree->root->cl_head->cl_head, &finished, extra_args);
   17913 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   17914 	CuAssertIntEquals(tc, 0, finished);
   17915 }
   17916 
   17917 void test_cil_build_ast_node_helper_sensitivity_neg(CuTest *tc) {
   17918 	char *line[] = {"(", "sensitivity", "s0", "extra", ")", NULL};
   17919 
   17920 	struct cil_tree *test_tree;
   17921 	gen_test_tree(&test_tree, line);
   17922 
   17923 	struct cil_db *test_db;
   17924 	cil_db_init(&test_db);
   17925 
   17926 	uint32_t finished = 0;
   17927 
   17928 	struct cil_args_build *extra_args = gen_build_args(test_db->ast->root, test_db, NULL, NULL);
   17929 
   17930 	int rc = __cil_build_ast_node_helper(test_tree->root->cl_head->cl_head, &finished, extra_args);
   17931 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   17932 	CuAssertIntEquals(tc, 0, finished);
   17933 }
   17934 
   17935 void test_cil_build_ast_node_helper_sensalias(CuTest *tc) {
   17936 	char *line[] = {"(", "sensitivityalias", "s0", "alias", ")", NULL};
   17937 
   17938 	struct cil_tree *test_tree;
   17939 	gen_test_tree(&test_tree, line);
   17940 
   17941 	struct cil_db *test_db;
   17942 	cil_db_init(&test_db);
   17943 
   17944 	uint32_t finished = 0;
   17945 
   17946 	struct cil_args_build *extra_args = gen_build_args(test_db->ast->root, test_db, NULL, NULL);
   17947 
   17948 	int rc = __cil_build_ast_node_helper(test_tree->root->cl_head->cl_head, &finished, extra_args);
   17949 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   17950 	CuAssertIntEquals(tc, 0, finished);
   17951 }
   17952 
   17953 void test_cil_build_ast_node_helper_sensalias_neg(CuTest *tc) {
   17954 	char *line[] = {"(", "sensitivityalias", "s0", "alias", "extra", ")", NULL};
   17955 
   17956 	struct cil_tree *test_tree;
   17957 	gen_test_tree(&test_tree, line);
   17958 
   17959 	struct cil_db *test_db;
   17960 	cil_db_init(&test_db);
   17961 
   17962 	uint32_t finished = 0;
   17963 
   17964 	struct cil_args_build *extra_args = gen_build_args(test_db->ast->root, test_db, NULL, NULL);
   17965 
   17966 	int rc = __cil_build_ast_node_helper(test_tree->root->cl_head->cl_head, &finished, extra_args);
   17967 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   17968 	CuAssertIntEquals(tc, 0, finished);
   17969 }
   17970 
   17971 void test_cil_build_ast_node_helper_category(CuTest *tc) {
   17972 	char *line[] = {"(", "category", "c0", ")", NULL};
   17973 
   17974 	struct cil_tree *test_tree;
   17975 	gen_test_tree(&test_tree, line);
   17976 
   17977 	struct cil_db *test_db;
   17978 	cil_db_init(&test_db);
   17979 
   17980 	uint32_t finished = 0;
   17981 
   17982 	struct cil_args_build *extra_args = gen_build_args(test_db->ast->root, test_db, NULL, NULL);
   17983 
   17984 	int rc = __cil_build_ast_node_helper(test_tree->root->cl_head->cl_head, &finished, extra_args);
   17985 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   17986 	CuAssertIntEquals(tc, 0, finished);
   17987 }
   17988 
   17989 void test_cil_build_ast_node_helper_category_neg(CuTest *tc) {
   17990 	char *line[] = {"(", "category", ")", NULL};
   17991 
   17992 	struct cil_tree *test_tree;
   17993 	gen_test_tree(&test_tree, line);
   17994 
   17995 	struct cil_db *test_db;
   17996 	cil_db_init(&test_db);
   17997 
   17998 	uint32_t finished = 0;
   17999 
   18000 	struct cil_args_build *extra_args = gen_build_args(test_db->ast->root, test_db, NULL, NULL);
   18001 
   18002 	int rc = __cil_build_ast_node_helper(test_tree->root->cl_head->cl_head, &finished, extra_args);
   18003 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   18004 	CuAssertIntEquals(tc, 0, finished);
   18005 }
   18006 
   18007 void test_cil_build_ast_node_helper_catset(CuTest *tc) {
   18008 	char *line[] = {"(", "categoryset", "somecats", "(", "c0", "c1", "c2", ")", ")", NULL};
   18009 
   18010 	struct cil_tree *test_tree;
   18011 	gen_test_tree(&test_tree, line);
   18012 
   18013 	struct cil_db *test_db;
   18014 	cil_db_init(&test_db);
   18015 
   18016 	uint32_t finished = 0;
   18017 
   18018 	struct cil_args_build *extra_args = gen_build_args(test_db->ast->root, test_db, NULL, NULL);
   18019 
   18020 	int rc = __cil_build_ast_node_helper(test_tree->root->cl_head->cl_head, &finished, extra_args);
   18021 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   18022 	CuAssertIntEquals(tc, 1, finished);
   18023 }
   18024 
   18025 void test_cil_build_ast_node_helper_catset_neg(CuTest *tc) {
   18026 	char *line[] = {"(", "categoryset", "somecats", "(", "c0", "c1", "c2", ")", "extra", ")", NULL};
   18027 
   18028 	struct cil_tree *test_tree;
   18029 	gen_test_tree(&test_tree, line);
   18030 
   18031 	struct cil_db *test_db;
   18032 	cil_db_init(&test_db);
   18033 
   18034 	uint32_t finished = 0;
   18035 
   18036 	struct cil_args_build *extra_args = gen_build_args(test_db->ast->root, test_db, NULL, NULL);
   18037 
   18038 	int rc = __cil_build_ast_node_helper(test_tree->root->cl_head->cl_head, &finished, extra_args);
   18039 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   18040 	CuAssertIntEquals(tc, 0, finished);
   18041 }
   18042 
   18043 void test_cil_build_ast_node_helper_catorder(CuTest *tc) {
   18044 	char *line[] = {"(", "categoryorder", "(", "c0", "c1", "c2", ")", ")", NULL};
   18045 
   18046 	struct cil_tree *test_tree;
   18047 	gen_test_tree(&test_tree, line);
   18048 
   18049 	struct cil_db *test_db;
   18050 	cil_db_init(&test_db);
   18051 
   18052 	uint32_t finished = 0;
   18053 
   18054 	struct cil_args_build *extra_args = gen_build_args(test_db->ast->root, test_db, NULL, NULL);
   18055 
   18056 	int rc = __cil_build_ast_node_helper(test_tree->root->cl_head->cl_head, &finished, extra_args);
   18057 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   18058 	CuAssertIntEquals(tc, 1, finished);
   18059 }
   18060 
   18061 void test_cil_build_ast_node_helper_catorder_neg(CuTest *tc) {
   18062 	char *line[] = {"(", "categoryorder", "c0", "c1", "c2", "extra", ")", NULL};
   18063 
   18064 	struct cil_tree *test_tree;
   18065 	gen_test_tree(&test_tree, line);
   18066 
   18067 	struct cil_db *test_db;
   18068 	cil_db_init(&test_db);
   18069 
   18070 	uint32_t finished = 0;
   18071 
   18072 	struct cil_args_build *extra_args = gen_build_args(test_db->ast->root, test_db, NULL, NULL);
   18073 
   18074 	int rc = __cil_build_ast_node_helper(test_tree->root->cl_head->cl_head, &finished, extra_args);
   18075 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   18076 	CuAssertIntEquals(tc, 0, finished);
   18077 }
   18078 
   18079 void test_cil_build_ast_node_helper_catalias(CuTest *tc) {
   18080 	char *line[] = {"(", "categoryalias", "c0", "red", ")", NULL};
   18081 
   18082 	struct cil_tree *test_tree;
   18083 	gen_test_tree(&test_tree, line);
   18084 
   18085 	struct cil_db *test_db;
   18086 	cil_db_init(&test_db);
   18087 
   18088 	uint32_t finished = 0;
   18089 
   18090 	struct cil_args_build *extra_args = gen_build_args(test_db->ast->root, test_db, NULL, NULL);
   18091 
   18092 	int rc = __cil_build_ast_node_helper(test_tree->root->cl_head->cl_head, &finished, extra_args);
   18093 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   18094 	CuAssertIntEquals(tc, 0, finished);
   18095 }
   18096 
   18097 void test_cil_build_ast_node_helper_catalias_neg(CuTest *tc) {
   18098 	char *line[] = {"(", "categoryalias", "range", "(", "c0", "c1", ")", ")", NULL};
   18099 
   18100 	struct cil_tree *test_tree;
   18101 	gen_test_tree(&test_tree, line);
   18102 
   18103 	struct cil_db *test_db;
   18104 	cil_db_init(&test_db);
   18105 
   18106 	uint32_t finished = 0;
   18107 
   18108 	struct cil_args_build *extra_args = gen_build_args(test_db->ast->root, test_db, NULL, NULL);
   18109 
   18110 	int rc = __cil_build_ast_node_helper(test_tree->root->cl_head->cl_head, &finished, extra_args);
   18111 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   18112 	CuAssertIntEquals(tc, 0, finished);
   18113 }
   18114 
   18115 void test_cil_build_ast_node_helper_catrange(CuTest *tc) {
   18116 	char *line[] = {"(", "categoryrange", "range", "(", "c0", "c1", ")", ")", NULL};
   18117 
   18118 	struct cil_tree *test_tree;
   18119 	gen_test_tree(&test_tree, line);
   18120 
   18121 	struct cil_db *test_db;
   18122 	cil_db_init(&test_db);
   18123 
   18124 	uint32_t finished = 0;
   18125 
   18126 	struct cil_args_build *extra_args = gen_build_args(test_db->ast->root, test_db, NULL, NULL);
   18127 
   18128 	int rc = __cil_build_ast_node_helper(test_tree->root->cl_head->cl_head, &finished, extra_args);
   18129 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   18130 	CuAssertIntEquals(tc, 1, finished);
   18131 }
   18132 
   18133 void test_cil_build_ast_node_helper_catrange_neg(CuTest *tc) {
   18134 	char *line[] = {"(", "categoryrange", ")", NULL};
   18135 
   18136 	struct cil_tree *test_tree;
   18137 	gen_test_tree(&test_tree, line);
   18138 
   18139 	struct cil_db *test_db;
   18140 	cil_db_init(&test_db);
   18141 
   18142 	uint32_t finished = 0;
   18143 
   18144 	struct cil_args_build *extra_args = gen_build_args(test_db->ast->root, test_db, NULL, NULL);
   18145 
   18146 	int rc = __cil_build_ast_node_helper(test_tree->root->cl_head->cl_head, &finished, extra_args);
   18147 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   18148 	CuAssertIntEquals(tc, 0, finished);
   18149 }
   18150 
   18151 void test_cil_build_ast_node_helper_roletype(CuTest *tc) {
   18152 	char *line[] = {"(", "roletype", "admin_r", "admin_t", ")", NULL};
   18153 
   18154 	struct cil_tree *test_tree;
   18155 	gen_test_tree(&test_tree, line);
   18156 
   18157 	struct cil_db *test_db;
   18158 	cil_db_init(&test_db);
   18159 
   18160 
   18161 	uint32_t finished = 0;
   18162 
   18163 	struct cil_args_build *extra_args = gen_build_args(test_db->ast->root, test_db, NULL, NULL);
   18164 
   18165 	int rc = __cil_build_ast_node_helper(test_tree->root->cl_head->cl_head, &finished, extra_args);
   18166 	CuAssertIntEquals(tc, finished, 0);
   18167 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   18168 }
   18169 
   18170 void test_cil_build_ast_node_helper_roletype_neg(CuTest *tc) {
   18171 	char *line[] = {"(", "roletype", "(", "admin_r", ")", "admin_t", ")", NULL};
   18172 
   18173 	struct cil_tree *test_tree;
   18174 	gen_test_tree(&test_tree, line);
   18175 
   18176 	struct cil_db *test_db;
   18177 	cil_db_init(&test_db);
   18178 
   18179 	uint32_t finished = 0;
   18180 
   18181 	struct cil_args_build *extra_args = gen_build_args(test_db->ast->root, test_db, NULL, NULL);
   18182 
   18183 	int rc = __cil_build_ast_node_helper(test_tree->root->cl_head->cl_head, &finished, extra_args);
   18184 	CuAssertIntEquals(tc, finished, 0);
   18185 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   18186 }
   18187 
   18188 void test_cil_build_ast_node_helper_userrole(CuTest *tc) {
   18189 	char *line[] = {"(", "userrole", "staff_u", "staff_r", ")", NULL};
   18190 
   18191 	struct cil_tree *test_tree;
   18192 	gen_test_tree(&test_tree, line);
   18193 
   18194 	struct cil_db *test_db;
   18195 	cil_db_init(&test_db);
   18196 
   18197 	uint32_t finished = 0;
   18198 
   18199 	struct cil_args_build *extra_args = gen_build_args(test_db->ast->root, test_db, NULL, NULL);
   18200 
   18201 	int rc = __cil_build_ast_node_helper(test_tree->root->cl_head->cl_head, &finished, extra_args);
   18202 	CuAssertIntEquals(tc, 0, finished);
   18203 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   18204 }
   18205 
   18206 void test_cil_build_ast_node_helper_userrole_neg(CuTest *tc) {
   18207 	char *line[] = {"(", "userrole", "staff_u", "(", "staff_r", ")", ")", NULL};
   18208 
   18209 	struct cil_tree *test_tree;
   18210 	gen_test_tree(&test_tree, line);
   18211 
   18212 	struct cil_db *test_db;
   18213 	cil_db_init(&test_db);
   18214 
   18215 	uint32_t finished = 0;
   18216 
   18217 	struct cil_args_build *extra_args = gen_build_args(test_db->ast->root, test_db, NULL, NULL);
   18218 
   18219 	int rc = __cil_build_ast_node_helper(test_tree->root->cl_head->cl_head, &finished, extra_args);
   18220 	CuAssertIntEquals(tc, finished, 0);
   18221 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   18222 }
   18223 
   18224 void test_cil_build_ast_node_helper_gen_classcommon(CuTest *tc) {
   18225 	char *line[] = {"(", "classcommon", "foo", "foo", NULL};
   18226 
   18227 	struct cil_tree *test_tree;
   18228 	gen_test_tree(&test_tree, line);
   18229 
   18230 	struct cil_db *test_db;
   18231 	cil_db_init(&test_db);
   18232 
   18233 	uint32_t finished = 0;
   18234 
   18235 	struct cil_args_build *extra_args = gen_build_args(test_db->ast->root, test_db, NULL, NULL);
   18236 
   18237 	int rc = __cil_build_ast_node_helper(test_tree->root->cl_head->cl_head, &finished, extra_args);
   18238 	CuAssertIntEquals(tc, finished, 0);
   18239 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   18240 }
   18241 
   18242 void test_cil_build_ast_node_helper_gen_classcommon_neg(CuTest *tc) {
   18243 	char *line[] = {"(", "classcommon", "staff_u", ")", NULL};
   18244 
   18245 	struct cil_tree *test_tree;
   18246 	gen_test_tree(&test_tree, line);
   18247 
   18248 	struct cil_db *test_db;
   18249 	cil_db_init(&test_db);
   18250 
   18251 	uint32_t finished = 0;
   18252 
   18253 	struct cil_args_build *extra_args = gen_build_args(test_db->ast->root, test_db, NULL, NULL);
   18254 
   18255 	int rc = __cil_build_ast_node_helper(test_tree->root->cl_head->cl_head, &finished, extra_args);
   18256 	CuAssertIntEquals(tc, finished, 0);
   18257 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   18258 }
   18259 
   18260 void test_cil_build_ast_node_helper_gen_dominance(CuTest *tc) {
   18261 	char *line[] = {"(", "sensitivity", "s0", ")",
   18262                         "(", "sensitivity", "s1", ")",
   18263                         "(", "sensitivity", "s2", ")",
   18264                         "(", "dominance", "(", "s0", "s1", ")", ")", NULL};
   18265 
   18266 	struct cil_tree *test_tree;
   18267 	gen_test_tree(&test_tree, line);
   18268 
   18269 	struct cil_db *test_db;
   18270 	cil_db_init(&test_db);
   18271 
   18272 	uint32_t finished = 0;
   18273 
   18274 	struct cil_args_build *extra_args = gen_build_args(test_db->ast->root, test_db, NULL, NULL);
   18275 
   18276 	int rc = __cil_build_ast_node_helper(test_tree->root->cl_head->next->next->next->cl_head, &finished, extra_args);
   18277 	CuAssertIntEquals(tc, finished, 1);
   18278 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   18279 }
   18280 
   18281 void test_cil_build_ast_node_helper_gen_dominance_neg(CuTest *tc) {
   18282 	char *line[] = {"(", "sensitivity", "s0", ")",
   18283                         "(", "sensitivity", "s1", ")",
   18284                         "(", "sensitivity", "s2", ")",
   18285                         "(", "dominance", "(", ")", ")", NULL};
   18286 
   18287 	struct cil_tree *test_tree;
   18288 	gen_test_tree(&test_tree, line);
   18289 
   18290 	struct cil_db *test_db;
   18291 	cil_db_init(&test_db);
   18292 
   18293 	uint32_t finished = 0;
   18294 
   18295 	struct cil_args_build *extra_args = gen_build_args(test_db->ast->root, test_db, NULL, NULL);
   18296 
   18297 	int rc = __cil_build_ast_node_helper(test_tree->root->cl_head->next->next->next->cl_head, &finished, extra_args);
   18298 	CuAssertIntEquals(tc, finished, 0);
   18299 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   18300 }
   18301 
   18302 void test_cil_build_ast_node_helper_gen_senscat(CuTest *tc) {
   18303 	char *line[] = {"(", "sensitivity", "s0", ")",
   18304                         "(", "sensitivity", "s1", ")",
   18305                         "(", "dominance", "(", "s0", "s1", ")", ")",
   18306 			"(", "category", "c0", ")",
   18307 			"(", "category", "c255", ")",
   18308 			"(", "categoryorder", "(", "c0", "c255", ")", ")",
   18309 			"(", "sensitivitycategory", "s1", "(", "c0", "c255", ")", ")", NULL};
   18310 
   18311 	struct cil_tree *test_tree;
   18312 	gen_test_tree(&test_tree, line);
   18313 
   18314 	struct cil_db *test_db;
   18315 	cil_db_init(&test_db);
   18316 
   18317 	uint32_t finished = 0;
   18318 
   18319 	struct cil_args_build *extra_args = gen_build_args(test_db->ast->root, test_db, NULL, NULL);
   18320 
   18321 	int rc = __cil_build_ast_node_helper(test_tree->root->cl_head->next->next->next->next->next->next->cl_head, &finished, extra_args);
   18322 	CuAssertIntEquals(tc, finished, 1);
   18323 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   18324 }
   18325 
   18326 void test_cil_build_ast_node_helper_gen_senscat_neg(CuTest *tc) {
   18327 	char *line[] = {"(", "sensitivity", "s0", ")",
   18328                         "(", "sensitivity", "s1", ")",
   18329                         "(", "dominance", "(", "s0", "s1", ")", ")",
   18330 			"(", "category", "c0", ")",
   18331 			"(", "category", "c255", ")",
   18332 			"(", "categoryorder", "(", "c0", "c255", ")", ")",
   18333 			"(", "sensitivitycategory", "s1", ")", NULL};
   18334 
   18335 	struct cil_tree *test_tree;
   18336 	gen_test_tree(&test_tree, line);
   18337 
   18338 	struct cil_db *test_db;
   18339 	cil_db_init(&test_db);
   18340 
   18341 	uint32_t finished = 0;
   18342 
   18343 	struct cil_args_build *extra_args = gen_build_args(test_db->ast->root, test_db, NULL, NULL);
   18344 
   18345 	int rc = __cil_build_ast_node_helper(test_tree->root->cl_head->next->next->next->next->next->next->cl_head, &finished, extra_args);
   18346 	CuAssertIntEquals(tc, finished, 0);
   18347 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   18348 }
   18349 
   18350 void test_cil_build_ast_node_helper_gen_level(CuTest *tc) {
   18351 	char *line[] = {"(", "sensitivity", "s0", ")",
   18352 			"(", "category", "c1", ")",
   18353 			"(", "level", "low", "(", "s0", "(", "c1", ")", ")", ")", NULL};
   18354 
   18355 	struct cil_tree *test_tree;
   18356 	gen_test_tree(&test_tree, line);
   18357 
   18358 	struct cil_db *test_db;
   18359 	cil_db_init(&test_db);
   18360 
   18361 	uint32_t finished = 0;
   18362 
   18363 	struct cil_args_build *extra_args = gen_build_args(test_db->ast->root, test_db, NULL, NULL);
   18364 
   18365 	int rc = __cil_build_ast_node_helper(test_tree->root->cl_head->next->next->cl_head, &finished, extra_args);
   18366 	CuAssertIntEquals(tc, finished, 1);
   18367 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   18368 }
   18369 
   18370 void test_cil_build_ast_node_helper_gen_level_neg(CuTest *tc) {
   18371 	char *line[] = {"(", "sensitivity", "s0", ")",
   18372 			"(", "category", "c1", ")",
   18373 			"(", "level", "low", "(", "s0", "(", ")", ")", ")", NULL};
   18374 
   18375 	struct cil_tree *test_tree;
   18376 	gen_test_tree(&test_tree, line);
   18377 
   18378 	struct cil_db *test_db;
   18379 	cil_db_init(&test_db);
   18380 
   18381 	uint32_t finished = 0;
   18382 
   18383 	struct cil_args_build *extra_args = gen_build_args(test_db->ast->root, test_db, NULL, NULL);
   18384 
   18385 	int rc = __cil_build_ast_node_helper(test_tree->root->cl_head->next->next->cl_head, &finished, extra_args);
   18386 	CuAssertIntEquals(tc, finished, 0);
   18387 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   18388 }
   18389 
   18390 void test_cil_build_ast_node_helper_gen_levelrange(CuTest *tc) {
   18391 	char *line[] = {"(", "levelrange", "range", "(", "low", "high", ")", ")", NULL};
   18392 
   18393 	struct cil_tree *test_tree;
   18394 	gen_test_tree(&test_tree, line);
   18395 
   18396 	struct cil_db *test_db;
   18397 	cil_db_init(&test_db);
   18398 
   18399 	uint32_t finished = 0;
   18400 
   18401 	struct cil_args_build *extra_args = gen_build_args(test_db->ast->root, test_db, NULL, NULL);
   18402 
   18403 	int rc = __cil_build_ast_node_helper(test_tree->root->cl_head->cl_head, &finished, extra_args);
   18404 	CuAssertIntEquals(tc, finished, 1);
   18405 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   18406 }
   18407 
   18408 void test_cil_build_ast_node_helper_gen_levelrange_neg(CuTest *tc) {
   18409 	char *line[] = {"(", "levelrange", "range", ")", NULL};
   18410 
   18411 	struct cil_tree *test_tree;
   18412 	gen_test_tree(&test_tree, line);
   18413 
   18414 	struct cil_db *test_db;
   18415 	cil_db_init(&test_db);
   18416 
   18417 	uint32_t finished = 0;
   18418 
   18419 	struct cil_args_build *extra_args = gen_build_args(test_db->ast->root, test_db, NULL, NULL);
   18420 
   18421 	int rc = __cil_build_ast_node_helper(test_tree->root->cl_head->cl_head, &finished, extra_args);
   18422 	CuAssertIntEquals(tc, finished, 0);
   18423 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   18424 }
   18425 
   18426 void test_cil_build_ast_node_helper_gen_constrain(CuTest *tc) {
   18427 	char *line[] = {"(", "constrain", "(", "file", "(", "create", "relabelto", ")", ")", "(", "eq", "r1", "r2", ")", ")", NULL};
   18428 
   18429 	struct cil_tree *test_tree;
   18430 	gen_test_tree(&test_tree, line);
   18431 
   18432 	struct cil_db *test_db;
   18433 	cil_db_init(&test_db);
   18434 
   18435 	uint32_t finished = 0;
   18436 
   18437 	struct cil_args_build *extra_args = gen_build_args(test_db->ast->root, test_db, NULL, NULL);
   18438 
   18439 	int rc = __cil_build_ast_node_helper(test_tree->root->cl_head->cl_head, &finished, extra_args);
   18440 	CuAssertIntEquals(tc, finished, 1);
   18441 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   18442 }
   18443 
   18444 void test_cil_build_ast_node_helper_gen_constrain_neg(CuTest *tc) {
   18445 	char *line[] = {"(", "constrain", ")", NULL};
   18446 
   18447 	struct cil_tree *test_tree;
   18448 	gen_test_tree(&test_tree, line);
   18449 
   18450 	struct cil_db *test_db;
   18451 	cil_db_init(&test_db);
   18452 
   18453 	uint32_t finished = 0;
   18454 
   18455 	struct cil_args_build *extra_args = gen_build_args(test_db->ast->root, test_db, NULL, NULL);
   18456 
   18457 	int rc = __cil_build_ast_node_helper(test_tree->root->cl_head->cl_head, &finished, extra_args);
   18458 	CuAssertIntEquals(tc, finished, 0);
   18459 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   18460 }
   18461 
   18462 void test_cil_build_ast_node_helper_gen_mlsconstrain(CuTest *tc) {
   18463 	char *line[] = {"(", "mlsconstrain", "(", "file", "(", "create", "relabelto", ")", ")", "(", "eq", "l2", "h2", ")", ")", NULL};
   18464 
   18465 	struct cil_tree *test_tree;
   18466 	gen_test_tree(&test_tree, line);
   18467 
   18468 	struct cil_db *test_db;
   18469 	cil_db_init(&test_db);
   18470 
   18471 	uint32_t finished = 0;
   18472 
   18473 	struct cil_args_build *extra_args = gen_build_args(test_db->ast->root, test_db, NULL, NULL);
   18474 
   18475 	int rc = __cil_build_ast_node_helper(test_tree->root->cl_head->cl_head, &finished, extra_args);
   18476 	CuAssertIntEquals(tc, finished, 1);
   18477 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   18478 }
   18479 
   18480 void test_cil_build_ast_node_helper_gen_mlsconstrain_neg(CuTest *tc) {
   18481 	char *line[] = {"(", "mlsconstrain", ")", NULL};
   18482 
   18483 	struct cil_tree *test_tree;
   18484 	gen_test_tree(&test_tree, line);
   18485 
   18486 	struct cil_db *test_db;
   18487 	cil_db_init(&test_db);
   18488 
   18489 	uint32_t finished = 0;
   18490 
   18491 	struct cil_args_build *extra_args = gen_build_args(test_db->ast->root, test_db, NULL, NULL);
   18492 
   18493 	int rc = __cil_build_ast_node_helper(test_tree->root->cl_head->cl_head, &finished, extra_args);
   18494 	CuAssertIntEquals(tc, finished, 0);
   18495 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   18496 }
   18497 
   18498 void test_cil_build_ast_node_helper_gen_context(CuTest *tc) {
   18499 	char *line[] = {"(", "context", "localhost_node_label", "(", "system_u", "object_r", "node_lo_t", "(", "low", "high", ")", ")", ")", NULL};
   18500 
   18501 	struct cil_tree *test_tree;
   18502 	gen_test_tree(&test_tree, line);
   18503 
   18504 	struct cil_db *test_db;
   18505 	cil_db_init(&test_db);
   18506 
   18507 	uint32_t finished = 0;
   18508 
   18509 	struct cil_args_build *extra_args = gen_build_args(test_db->ast->root, test_db, NULL, NULL);
   18510 
   18511 	int rc = __cil_build_ast_node_helper(test_tree->root->cl_head->cl_head, &finished, extra_args);
   18512 	CuAssertIntEquals(tc, finished, 1);
   18513 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   18514 }
   18515 
   18516 void test_cil_build_ast_node_helper_gen_context_neg(CuTest *tc) {
   18517 	char *line[] = {"(", "context", "localhost_node_label", "(", "system_u", "object_r", ")", ")", NULL};
   18518 
   18519 	struct cil_tree *test_tree;
   18520 	gen_test_tree(&test_tree, line);
   18521 
   18522 	struct cil_db *test_db;
   18523 	cil_db_init(&test_db);
   18524 
   18525 	uint32_t finished = 0;
   18526 
   18527 	struct cil_args_build *extra_args = gen_build_args(test_db->ast->root, test_db, NULL, NULL);
   18528 
   18529 	int rc = __cil_build_ast_node_helper(test_tree->root->cl_head->cl_head, &finished, extra_args);
   18530 	CuAssertIntEquals(tc, finished, 0);
   18531 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   18532 }
   18533 
   18534 void test_cil_build_ast_node_helper_gen_filecon(CuTest *tc) {
   18535 	char *line[] = {"(", "filecon", "root", "path", "file", "context", NULL};
   18536 
   18537 	struct cil_tree *test_tree;
   18538 	gen_test_tree(&test_tree, line);
   18539 
   18540 	struct cil_db *test_db;
   18541 	cil_db_init(&test_db);
   18542 
   18543 	uint32_t finished = 0;
   18544 
   18545 	struct cil_args_build *extra_args = gen_build_args(test_db->ast->root, test_db, NULL, NULL);
   18546 
   18547 	int rc = __cil_build_ast_node_helper(test_tree->root->cl_head->cl_head, &finished, extra_args);
   18548 	CuAssertIntEquals(tc, finished, 1);
   18549 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   18550 }
   18551 
   18552 void test_cil_build_ast_node_helper_gen_filecon_neg(CuTest *tc) {
   18553 	char *line[] = {"(", "filecon", ")", NULL};
   18554 
   18555 	struct cil_tree *test_tree;
   18556 	gen_test_tree(&test_tree, line);
   18557 
   18558 	struct cil_db *test_db;
   18559 	cil_db_init(&test_db);
   18560 
   18561 	uint32_t finished = 0;
   18562 
   18563 	struct cil_args_build *extra_args = gen_build_args(test_db->ast->root, test_db, NULL, NULL);
   18564 
   18565 	int rc = __cil_build_ast_node_helper(test_tree->root->cl_head->cl_head, &finished, extra_args);
   18566 	CuAssertIntEquals(tc, finished, 0);
   18567 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   18568 }
   18569 
   18570 void test_cil_build_ast_node_helper_gen_portcon(CuTest *tc) {
   18571 	char *line[] = {"(", "portcon", "udp", "25", "con", ")", NULL};
   18572 
   18573 	struct cil_tree *test_tree;
   18574 	gen_test_tree(&test_tree, line);
   18575 
   18576 	struct cil_db *test_db;
   18577 	cil_db_init(&test_db);
   18578 
   18579 	uint32_t finished = 0;
   18580 
   18581 	struct cil_args_build *extra_args = gen_build_args(test_db->ast->root, test_db, NULL, NULL);
   18582 
   18583 	int rc = __cil_build_ast_node_helper(test_tree->root->cl_head->cl_head, &finished, extra_args);
   18584 	CuAssertIntEquals(tc, finished, 1);
   18585 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   18586 }
   18587 
   18588 void test_cil_build_ast_node_helper_gen_portcon_neg(CuTest *tc) {
   18589 	char *line[] = {"(", "portcon", ")", NULL};
   18590 
   18591 	struct cil_tree *test_tree;
   18592 	gen_test_tree(&test_tree, line);
   18593 
   18594 	struct cil_db *test_db;
   18595 	cil_db_init(&test_db);
   18596 
   18597 	uint32_t finished = 0;
   18598 
   18599 	struct cil_args_build *extra_args = gen_build_args(test_db->ast->root, test_db, NULL, NULL);
   18600 
   18601 	int rc = __cil_build_ast_node_helper(test_tree->root->cl_head->cl_head, &finished, extra_args);
   18602 	CuAssertIntEquals(tc, finished, 0);
   18603 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   18604 }
   18605 
   18606 void test_cil_build_ast_node_helper_gen_nodecon(CuTest *tc) {
   18607 	char *line[] = {"(", "nodecon", "ipaddr", "ipaddr", "con", ")", NULL};
   18608 
   18609 	struct cil_tree *test_tree;
   18610 	gen_test_tree(&test_tree, line);
   18611 
   18612 	struct cil_db *test_db;
   18613 	cil_db_init(&test_db);
   18614 
   18615 	uint32_t finished = 0;
   18616 
   18617 	struct cil_args_build *extra_args = gen_build_args(test_db->ast->root, test_db, NULL, NULL);
   18618 
   18619 	int rc = __cil_build_ast_node_helper(test_tree->root->cl_head->cl_head, &finished, extra_args);
   18620 	CuAssertIntEquals(tc, finished, 1);
   18621 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   18622 }
   18623 
   18624 void test_cil_build_ast_node_helper_gen_nodecon_neg(CuTest *tc) {
   18625 	char *line[] = {"(", "nodecon", ")", NULL};
   18626 
   18627 	struct cil_tree *test_tree;
   18628 	gen_test_tree(&test_tree, line);
   18629 
   18630 	struct cil_db *test_db;
   18631 	cil_db_init(&test_db);
   18632 
   18633 	uint32_t finished = 0;
   18634 
   18635 	struct cil_args_build *extra_args = gen_build_args(test_db->ast->root, test_db, NULL, NULL);
   18636 
   18637 	int rc = __cil_build_ast_node_helper(test_tree->root->cl_head->cl_head, &finished, extra_args);
   18638 	CuAssertIntEquals(tc, finished, 0);
   18639 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   18640 }
   18641 
   18642 void test_cil_build_ast_node_helper_gen_genfscon(CuTest *tc) {
   18643 	char *line[] = {"(", "genfscon", "type", "path", "con", ")", NULL};
   18644 
   18645 	struct cil_tree *test_tree;
   18646 	gen_test_tree(&test_tree, line);
   18647 
   18648 	struct cil_db *test_db;
   18649 	cil_db_init(&test_db);
   18650 
   18651 	uint32_t finished = 0;
   18652 
   18653 	struct cil_args_build *extra_args = gen_build_args(test_db->ast->root, test_db, NULL, NULL);
   18654 
   18655 	int rc = __cil_build_ast_node_helper(test_tree->root->cl_head->cl_head, &finished, extra_args);
   18656 	CuAssertIntEquals(tc, finished, 1);
   18657 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   18658 }
   18659 
   18660 void test_cil_build_ast_node_helper_gen_genfscon_neg(CuTest *tc) {
   18661 	char *line[] = {"(", "genfscon", ")", NULL};
   18662 
   18663 	struct cil_tree *test_tree;
   18664 	gen_test_tree(&test_tree, line);
   18665 
   18666 	struct cil_db *test_db;
   18667 	cil_db_init(&test_db);
   18668 
   18669 	uint32_t finished = 0;
   18670 
   18671 	struct cil_args_build *extra_args = gen_build_args(test_db->ast->root, test_db, NULL, NULL);
   18672 
   18673 	int rc = __cil_build_ast_node_helper(test_tree->root->cl_head->cl_head, &finished, extra_args);
   18674 	CuAssertIntEquals(tc, finished, 0);
   18675 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   18676 }
   18677 
   18678 void test_cil_build_ast_node_helper_gen_netifcon(CuTest *tc) {
   18679 	char *line[] = {"(", "netifcon", "eth1",
   18680 			"(", "system_u", "object_r", "netif_t", "(", "low", "high", ")", ")",
   18681 			"(", "system_u", "object_r", "netif_t", "(", "low", "high", ")", ")", ")", NULL};
   18682 
   18683 	struct cil_tree *test_tree;
   18684 	gen_test_tree(&test_tree, line);
   18685 
   18686 	struct cil_db *test_db;
   18687 	cil_db_init(&test_db);
   18688 
   18689 	uint32_t finished = 0;
   18690 
   18691 	struct cil_args_build *extra_args = gen_build_args(test_db->ast->root, test_db, NULL, NULL);
   18692 
   18693 	int rc = __cil_build_ast_node_helper(test_tree->root->cl_head->cl_head, &finished, extra_args);
   18694 	CuAssertIntEquals(tc, finished, 1);
   18695 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   18696 }
   18697 
   18698 void test_cil_build_ast_node_helper_gen_netifcon_neg(CuTest *tc) {
   18699 	char *line[] = {"(", "netifcon", ")", NULL};
   18700 
   18701 	struct cil_tree *test_tree;
   18702 	gen_test_tree(&test_tree, line);
   18703 
   18704 	struct cil_db *test_db;
   18705 	cil_db_init(&test_db);
   18706 
   18707 	uint32_t finished = 0;
   18708 
   18709 	struct cil_args_build *extra_args = gen_build_args(test_db->ast->root, test_db, NULL, NULL);
   18710 
   18711 	int rc = __cil_build_ast_node_helper(test_tree->root->cl_head->cl_head, &finished, extra_args);
   18712 	CuAssertIntEquals(tc, finished, 0);
   18713 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   18714 }
   18715 
   18716 void test_cil_build_ast_node_helper_gen_pirqcon(CuTest *tc) {
   18717 	char *line[] = {"(", "pirqcon", "1", "con", ")", NULL};
   18718 
   18719 	struct cil_tree *test_tree;
   18720 	gen_test_tree(&test_tree, line);
   18721 
   18722 	struct cil_db *test_db;
   18723 	cil_db_init(&test_db);
   18724 
   18725 	uint32_t finished = 0;
   18726 
   18727 	struct cil_args_build *extra_args = gen_build_args(test_db->ast->root, test_db, NULL, NULL);
   18728 
   18729 	int rc = __cil_build_ast_node_helper(test_tree->root->cl_head->cl_head, &finished, extra_args);
   18730 	CuAssertIntEquals(tc, finished, 1);
   18731 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   18732 }
   18733 
   18734 void test_cil_build_ast_node_helper_gen_pirqcon_neg(CuTest *tc) {
   18735 	char *line[] = {"(", "pirqcon", ")", NULL};
   18736 
   18737 	struct cil_tree *test_tree;
   18738 	gen_test_tree(&test_tree, line);
   18739 
   18740 	struct cil_db *test_db;
   18741 	cil_db_init(&test_db);
   18742 
   18743 	uint32_t finished = 0;
   18744 
   18745 	struct cil_args_build *extra_args = gen_build_args(test_db->ast->root, test_db, NULL, NULL);
   18746 
   18747 	int rc = __cil_build_ast_node_helper(test_tree->root->cl_head->cl_head, &finished, extra_args);
   18748 	CuAssertIntEquals(tc, finished, 0);
   18749 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   18750 }
   18751 
   18752 void test_cil_build_ast_node_helper_gen_iomemcon(CuTest *tc) {
   18753 	char *line[] = {"(", "iomemcon", "1", "con", ")", NULL};
   18754 
   18755 	struct cil_tree *test_tree;
   18756 	gen_test_tree(&test_tree, line);
   18757 
   18758 	struct cil_db *test_db;
   18759 	cil_db_init(&test_db);
   18760 
   18761 	uint32_t finished = 0;
   18762 
   18763 	struct cil_args_build *extra_args = gen_build_args(test_db->ast->root, test_db, NULL, NULL);
   18764 
   18765 	int rc = __cil_build_ast_node_helper(test_tree->root->cl_head->cl_head, &finished, extra_args);
   18766 	CuAssertIntEquals(tc, finished, 1);
   18767 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   18768 }
   18769 
   18770 void test_cil_build_ast_node_helper_gen_iomemcon_neg(CuTest *tc) {
   18771 	char *line[] = {"(", "iomemcon", ")", NULL};
   18772 
   18773 	struct cil_tree *test_tree;
   18774 	gen_test_tree(&test_tree, line);
   18775 
   18776 	struct cil_db *test_db;
   18777 	cil_db_init(&test_db);
   18778 
   18779 	uint32_t finished = 0;
   18780 
   18781 	struct cil_args_build *extra_args = gen_build_args(test_db->ast->root, test_db, NULL, NULL);
   18782 
   18783 	int rc = __cil_build_ast_node_helper(test_tree->root->cl_head->cl_head, &finished, extra_args);
   18784 	CuAssertIntEquals(tc, finished, 0);
   18785 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   18786 }
   18787 
   18788 void test_cil_build_ast_node_helper_gen_ioportcon(CuTest *tc) {
   18789 	char *line[] = {"(", "ioportcon", "1", "con", ")", NULL};
   18790 
   18791 	struct cil_tree *test_tree;
   18792 	gen_test_tree(&test_tree, line);
   18793 
   18794 	struct cil_db *test_db;
   18795 	cil_db_init(&test_db);
   18796 
   18797 	uint32_t finished = 0;
   18798 
   18799 	struct cil_args_build *extra_args = gen_build_args(test_db->ast->root, test_db, NULL, NULL);
   18800 
   18801 	int rc = __cil_build_ast_node_helper(test_tree->root->cl_head->cl_head, &finished, extra_args);
   18802 	CuAssertIntEquals(tc, finished, 1);
   18803 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   18804 }
   18805 
   18806 void test_cil_build_ast_node_helper_gen_ioportcon_neg(CuTest *tc) {
   18807 	char *line[] = {"(", "ioportcon", ")", NULL};
   18808 
   18809 	struct cil_tree *test_tree;
   18810 	gen_test_tree(&test_tree, line);
   18811 
   18812 	struct cil_db *test_db;
   18813 	cil_db_init(&test_db);
   18814 
   18815 	uint32_t finished = 0;
   18816 
   18817 	struct cil_args_build *extra_args = gen_build_args(test_db->ast->root, test_db, NULL, NULL);
   18818 
   18819 	int rc = __cil_build_ast_node_helper(test_tree->root->cl_head->cl_head, &finished, extra_args);
   18820 	CuAssertIntEquals(tc, finished, 0);
   18821 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   18822 }
   18823 
   18824 void test_cil_build_ast_node_helper_gen_pcidevicecon(CuTest *tc) {
   18825 	char *line[] = {"(", "pcidevicecon", "1", "con", ")", NULL};
   18826 
   18827 	struct cil_tree *test_tree;
   18828 	gen_test_tree(&test_tree, line);
   18829 
   18830 	struct cil_db *test_db;
   18831 	cil_db_init(&test_db);
   18832 
   18833 	uint32_t finished = 0;
   18834 
   18835 	struct cil_args_build *extra_args = gen_build_args(test_db->ast->root, test_db, NULL, NULL);
   18836 
   18837 	int rc = __cil_build_ast_node_helper(test_tree->root->cl_head->cl_head, &finished, extra_args);
   18838 	CuAssertIntEquals(tc, finished, 1);
   18839 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   18840 }
   18841 
   18842 void test_cil_build_ast_node_helper_gen_pcidevicecon_neg(CuTest *tc) {
   18843 	char *line[] = {"(", "pcidevicecon", ")", NULL};
   18844 
   18845 	struct cil_tree *test_tree;
   18846 	gen_test_tree(&test_tree, line);
   18847 
   18848 	struct cil_db *test_db;
   18849 	cil_db_init(&test_db);
   18850 
   18851 	uint32_t finished = 0;
   18852 
   18853 	struct cil_args_build *extra_args = gen_build_args(test_db->ast->root, test_db, NULL, NULL);
   18854 
   18855 	int rc = __cil_build_ast_node_helper(test_tree->root->cl_head->cl_head, &finished, extra_args);
   18856 	CuAssertIntEquals(tc, finished, 0);
   18857 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   18858 }
   18859 
   18860 void test_cil_build_ast_node_helper_gen_fsuse(CuTest *tc) {
   18861 	char *line[] = {"(", "fsuse", "xattr", "ext3", "con", ")", NULL};
   18862 
   18863 	struct cil_tree *test_tree;
   18864 	gen_test_tree(&test_tree, line);
   18865 
   18866 	struct cil_db *test_db;
   18867 	cil_db_init(&test_db);
   18868 
   18869 	uint32_t finished = 0;
   18870 
   18871 	struct cil_args_build *extra_args = gen_build_args(test_db->ast->root, test_db, NULL, NULL);
   18872 
   18873 	int rc = __cil_build_ast_node_helper(test_tree->root->cl_head->cl_head, &finished, extra_args);
   18874 	CuAssertIntEquals(tc, finished, 1);
   18875 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   18876 }
   18877 
   18878 void test_cil_build_ast_node_helper_gen_fsuse_neg(CuTest *tc) {
   18879 	char *line[] = {"(", "fsuse", ")", NULL};
   18880 
   18881 	struct cil_tree *test_tree;
   18882 	gen_test_tree(&test_tree, line);
   18883 
   18884 	struct cil_db *test_db;
   18885 	cil_db_init(&test_db);
   18886 
   18887 	uint32_t finished = 0;
   18888 
   18889 	struct cil_args_build *extra_args = gen_build_args(test_db->ast->root, test_db, NULL, NULL);
   18890 
   18891 	int rc = __cil_build_ast_node_helper(test_tree->root->cl_head->cl_head, &finished, extra_args);
   18892 	CuAssertIntEquals(tc, finished, 0);
   18893 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   18894 }
   18895 
   18896 void test_cil_build_ast_node_helper_gen_macro(CuTest *tc) {
   18897 	char *line[] = {"(", "macro", "mm", "(", "(", "type", "a", ")", ")", "(", "type", "b", ")", ")", NULL};
   18898 
   18899 	struct cil_tree *test_tree;
   18900 	gen_test_tree(&test_tree, line);
   18901 
   18902 	struct cil_db *test_db;
   18903 	cil_db_init(&test_db);
   18904 
   18905 	uint32_t finished = 0;
   18906 
   18907 	struct cil_args_build *extra_args = gen_build_args(test_db->ast->root, test_db, NULL, NULL);
   18908 
   18909 	int rc = __cil_build_ast_node_helper(test_tree->root->cl_head->cl_head, &finished, extra_args);
   18910 	CuAssertIntEquals(tc, finished, 0);
   18911 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   18912 }
   18913 
   18914 void test_cil_build_ast_node_helper_gen_macro_neg(CuTest *tc) {
   18915 	char *line[] = {"(", "macro", "mm", "(", "(", ")", ")", ")", NULL};
   18916 
   18917 	struct cil_tree *test_tree;
   18918 	gen_test_tree(&test_tree, line);
   18919 
   18920 	struct cil_db *test_db;
   18921 	cil_db_init(&test_db);
   18922 
   18923 	uint32_t finished = 0;
   18924 
   18925 	struct cil_args_build *extra_args = gen_build_args(test_db->ast->root, test_db, NULL, NULL);
   18926 
   18927 	int rc = __cil_build_ast_node_helper(test_tree->root->cl_head->cl_head, &finished, extra_args);
   18928 	CuAssertIntEquals(tc, finished, 0);
   18929 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   18930 }
   18931 
   18932 void test_cil_build_ast_node_helper_gen_macro_nested_macro_neg(CuTest *tc) {
   18933 	char *line[] = {"(", "macro", "mm", "(", "(", "type", "a", ")", ")", "(", "type", "b", ")", ")", NULL};
   18934 
   18935 	struct cil_tree *test_tree;
   18936 	gen_test_tree(&test_tree, line);
   18937 
   18938 	struct cil_db *test_db;
   18939 	cil_db_init(&test_db);
   18940 
   18941 	struct cil_macro *macro;
   18942 	cil_macro_init(&macro);
   18943 
   18944 	struct cil_tree_node *macronode;
   18945 	cil_tree_node_init(&macronode);
   18946 	macronode->data = macro;
   18947 	macronode->flavor = CIL_MACRO;
   18948 
   18949 	uint32_t finished = 0;
   18950 
   18951 	struct cil_args_build *extra_args = gen_build_args(test_db->ast->root, test_db, macronode, NULL);
   18952 
   18953 	int rc = __cil_build_ast_node_helper(test_tree->root->cl_head->cl_head, &finished, extra_args);
   18954 	CuAssertIntEquals(tc, finished, 0);
   18955 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   18956 
   18957 	cil_db_destroy(&test_db);
   18958 	cil_destroy_macro(macro);
   18959 }
   18960 
   18961 void test_cil_build_ast_node_helper_gen_macro_nested_tunif_neg(CuTest *tc) {
   18962 	char *line[] = {"(", "tunableif", "(", "and", "foo", "bar", ")",
   18963 			"(", "allow", "foo", "bar", "(", "read", ")", ")", ")", NULL};
   18964 
   18965 	struct cil_tree *test_tree;
   18966 	gen_test_tree(&test_tree, line);
   18967 
   18968 	struct cil_db *test_db;
   18969 	cil_db_init(&test_db);
   18970 
   18971 	struct cil_macro *macro;
   18972 	cil_macro_init(&macro);
   18973 
   18974 	struct cil_tree_node *macronode;
   18975 	cil_tree_node_init(&macronode);
   18976 	macronode->data = macro;
   18977 	macronode->flavor = CIL_MACRO;
   18978 
   18979 	uint32_t finished = 0;
   18980 
   18981 	struct cil_args_build *extra_args = gen_build_args(test_db->ast->root, test_db, macronode, NULL);
   18982 
   18983 	int rc = __cil_build_ast_node_helper(test_tree->root->cl_head->cl_head, &finished, extra_args);
   18984 	CuAssertIntEquals(tc, finished, 0);
   18985 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   18986 
   18987 	cil_db_destroy(&test_db);
   18988 	cil_destroy_macro(macro);
   18989 }
   18990 
   18991 void test_cil_build_ast_node_helper_gen_call(CuTest *tc) {
   18992 	char *line[] = {"(", "call", "mm", "(", "foo", ")", ")", NULL};
   18993 
   18994 	struct cil_tree *test_tree;
   18995 	gen_test_tree(&test_tree, line);
   18996 
   18997 	struct cil_db *test_db;
   18998 	cil_db_init(&test_db);
   18999 
   19000 	uint32_t finished = 0;
   19001 
   19002 	struct cil_args_build *extra_args = gen_build_args(test_db->ast->root, test_db, NULL, NULL);
   19003 
   19004 	int rc = __cil_build_ast_node_helper(test_tree->root->cl_head->cl_head, &finished, extra_args);
   19005 	CuAssertIntEquals(tc, finished, 1);
   19006 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   19007 }
   19008 
   19009 void test_cil_build_ast_node_helper_gen_call_neg(CuTest *tc) {
   19010 	char *line[] = {"(", "call", ")", NULL};
   19011 
   19012 	struct cil_tree *test_tree;
   19013 	gen_test_tree(&test_tree, line);
   19014 
   19015 	struct cil_db *test_db;
   19016 	cil_db_init(&test_db);
   19017 
   19018 	uint32_t finished = 0;
   19019 
   19020 	struct cil_args_build *extra_args = gen_build_args(test_db->ast->root, test_db, NULL, NULL);
   19021 
   19022 	int rc = __cil_build_ast_node_helper(test_tree->root->cl_head->cl_head, &finished, extra_args);
   19023 	CuAssertIntEquals(tc, finished, 0);
   19024 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   19025 }
   19026 
   19027 void test_cil_build_ast_node_helper_gen_optional(CuTest *tc) {
   19028 	char *line[] = {"(", "optional", "opt", "(", "allow", "foo", "bar", "(", "file", "(", "read", ")", ")", ")", ")", NULL};
   19029 
   19030 	struct cil_tree *test_tree;
   19031 	gen_test_tree(&test_tree, line);
   19032 
   19033 	struct cil_db *test_db;
   19034 	cil_db_init(&test_db);
   19035 
   19036 	uint32_t finished = 0;
   19037 
   19038 	struct cil_args_build *extra_args = gen_build_args(test_db->ast->root, test_db, NULL, NULL);
   19039 
   19040 	int rc = __cil_build_ast_node_helper(test_tree->root->cl_head->cl_head, &finished, extra_args);
   19041 	CuAssertIntEquals(tc, finished, 0);
   19042 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   19043 }
   19044 
   19045 void test_cil_build_ast_node_helper_gen_optional_neg(CuTest *tc) {
   19046 	char *line[] = {"(", "optional", ")", NULL};
   19047 
   19048 	struct cil_tree *test_tree;
   19049 	gen_test_tree(&test_tree, line);
   19050 
   19051 	struct cil_db *test_db;
   19052 	cil_db_init(&test_db);
   19053 
   19054 	uint32_t finished = 0;
   19055 
   19056 	struct cil_args_build *extra_args = gen_build_args(test_db->ast->root, test_db, NULL, NULL);
   19057 
   19058 	int rc = __cil_build_ast_node_helper(test_tree->root->cl_head->cl_head, &finished, extra_args);
   19059 	CuAssertIntEquals(tc, finished, 0);
   19060 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   19061 }
   19062 
   19063 void test_cil_build_ast_node_helper_gen_policycap(CuTest *tc) {
   19064 	char *line[] = {"(", "policycap", "open_perms", ")", NULL};
   19065 
   19066 	struct cil_tree *test_tree;
   19067 	gen_test_tree(&test_tree, line);
   19068 
   19069 	struct cil_db *test_db;
   19070 	cil_db_init(&test_db);
   19071 
   19072 	uint32_t finished = 0;
   19073 
   19074 	struct cil_args_build *extra_args = gen_build_args(test_db->ast->root, test_db, NULL, NULL);
   19075 
   19076 	int rc = __cil_build_ast_node_helper(test_tree->root->cl_head->cl_head, &finished, extra_args);
   19077 	CuAssertIntEquals(tc, finished, 1);
   19078 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   19079 }
   19080 
   19081 void test_cil_build_ast_node_helper_gen_policycap_neg(CuTest *tc) {
   19082 	char *line[] = {"(", "policycap", ")", NULL};
   19083 
   19084 	struct cil_tree *test_tree;
   19085 	gen_test_tree(&test_tree, line);
   19086 
   19087 	struct cil_db *test_db;
   19088 	cil_db_init(&test_db);
   19089 
   19090 	uint32_t finished = 0;
   19091 
   19092 	struct cil_args_build *extra_args = gen_build_args(test_db->ast->root, test_db, NULL, NULL);
   19093 
   19094 	int rc = __cil_build_ast_node_helper(test_tree->root->cl_head->cl_head, &finished, extra_args);
   19095 	CuAssertIntEquals(tc, finished, 0);
   19096 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   19097 }
   19098 
   19099 void test_cil_build_ast_node_helper_gen_ipaddr(CuTest *tc) {
   19100 	char *line[] = {"(", "ipaddr", "ip", "192.168.1.1", ")", NULL};
   19101 
   19102 	struct cil_tree *test_tree;
   19103 	gen_test_tree(&test_tree, line);
   19104 
   19105 	struct cil_db *test_db;
   19106 	cil_db_init(&test_db);
   19107 
   19108 	uint32_t finished = 0;
   19109 
   19110 	struct cil_args_build *extra_args = gen_build_args(test_db->ast->root, test_db, NULL, NULL);
   19111 
   19112 	int rc = __cil_build_ast_node_helper(test_tree->root->cl_head->cl_head, &finished, extra_args);
   19113 	CuAssertIntEquals(tc, finished, 0);
   19114 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   19115 }
   19116 
   19117 void test_cil_build_ast_node_helper_gen_ipaddr_neg(CuTest *tc) {
   19118 	char *line[] = {"(", "ipaddr", ")", NULL};
   19119 
   19120 	struct cil_tree *test_tree;
   19121 	gen_test_tree(&test_tree, line);
   19122 
   19123 	struct cil_db *test_db;
   19124 	cil_db_init(&test_db);
   19125 
   19126 	uint32_t finished = 0;
   19127 
   19128 	struct cil_args_build *extra_args = gen_build_args(test_db->ast->root, test_db, NULL, NULL);
   19129 
   19130 	int rc = __cil_build_ast_node_helper(test_tree->root->cl_head->cl_head, &finished, extra_args);
   19131 	CuAssertIntEquals(tc, finished, 0);
   19132 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   19133 }
   19134 
   19135 void test_cil_build_ast_node_helper_extraargsnull_neg(CuTest *tc) {
   19136 	char *line[] = {"(", "ipaddr", "ip", "192.168.1.1", ")", NULL};
   19137 
   19138 	struct cil_tree *test_tree;
   19139 	gen_test_tree(&test_tree, line);
   19140 
   19141 	struct cil_db *test_db;
   19142 	cil_db_init(&test_db);
   19143 
   19144 	struct cil_args_build *extra_args = NULL;
   19145 
   19146 	uint32_t finished = 0;
   19147 
   19148 	int rc = __cil_build_ast_node_helper(test_tree->root->cl_head->cl_head, &finished, extra_args);
   19149 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   19150 }
   19151 
   19152 void test_cil_build_ast_last_child_helper(CuTest *tc) {
   19153 	char *line[] = {"(", "ipaddr", "ip", "192.168.1.1", ")", NULL};
   19154 
   19155 	struct cil_tree *test_tree;
   19156 	gen_test_tree(&test_tree, line);
   19157 
   19158 	struct cil_db *test_db;
   19159 	cil_db_init(&test_db);
   19160 
   19161 	struct cil_args_build *extra_args = gen_build_args(test_db->ast->root, test_db, NULL, NULL);
   19162 
   19163 	int rc = __cil_build_ast_last_child_helper(test_tree->root->cl_head->cl_head, extra_args);
   19164 	CuAssertIntEquals(tc, SEPOL_OK, rc);
   19165 }
   19166 
   19167 void test_cil_build_ast_last_child_helper_extraargsnull_neg(CuTest *tc) {
   19168 	char *line[] = {"(", "ipaddr", "ip", "192.168.1.1", ")", NULL};
   19169 
   19170 	struct cil_tree *test_tree;
   19171 	gen_test_tree(&test_tree, line);
   19172 
   19173 	struct cil_db *test_db;
   19174 	cil_db_init(&test_db);
   19175 
   19176 	int rc = __cil_build_ast_last_child_helper(test_tree->root->cl_head->cl_head, NULL);
   19177 	CuAssertIntEquals(tc, SEPOL_ERR, rc);
   19178 }
   19179 
   19180