• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 "test_integration.h"
34 #include <unistd.h>
35 #include <sys/wait.h>
36 #include <sys/types.h>
37 #include <sys/stat.h>
38 #include <fcntl.h>
39 
test_integration(CuTest * tc)40 void test_integration(CuTest *tc) {
41 	int status = 0, status1 = 0, status2 = 0;
42 
43 	status = system("./secilc -M -c 24 test/integration.cil &> /dev/null");
44 
45 	if (WIFSIGNALED(status) && (WTERMSIG(status) == SIGINT || WTERMSIG(status) == SIGQUIT))
46 		printf("Call to system for secilc failed.\n");
47 
48 	status1 = system("checkpolicy -M -c 24 -o policy.conf.24 test/policy.conf &> /dev/null");
49 
50 	if (WIFSIGNALED(status1) && (WTERMSIG(status1) == SIGINT || WTERMSIG(status1) == SIGQUIT))
51 		printf("Call to checkpolicy failed.\n");
52 
53 	status2 = system("sediff -q policy.24 \\; policy.conf.24 &> /dev/null");
54 
55 	if (WIFSIGNALED(status2) && (WTERMSIG(status2) == SIGINT || WTERMSIG(status2) == SIGQUIT))
56 		printf("Call to sediff for secilc failed.\n");
57 
58 	CuAssertIntEquals(tc, 1, WIFEXITED(status));
59 	CuAssertIntEquals(tc, 0, WEXITSTATUS(status));
60 	CuAssertIntEquals(tc, 1, WIFEXITED(status1));
61 	CuAssertIntEquals(tc, 0, WEXITSTATUS(status1));
62 	CuAssertIntEquals(tc, 1, WIFEXITED(status2));
63 	CuAssertIntEquals(tc, 0, WEXITSTATUS(status2));
64 }
65 
test_min_policy(CuTest * tc)66 void test_min_policy(CuTest *tc) {
67 	int status = 0;
68 
69 	status = system("./secilc -M -c 24 test/policy.cil &> /dev/null");
70 
71 	if (WIFSIGNALED(status) && (WTERMSIG(status) == SIGINT || WTERMSIG(status) == SIGQUIT))
72 		printf("Call to system for secilc failed.\n");
73 
74 	CuAssertIntEquals(tc, 1, WIFEXITED(status));
75 	CuAssertIntEquals(tc, 0, WEXITSTATUS(status));
76 }
77