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 *