| 1 |
|
| 2 |
|
| 3 |
|
| 4 |
|
| 5 |
|
| 6 |
|
| 7 |
|
| 8 |
|
| 9 |
|
| 10 |
|
| 11 |
|
| 12 |
|
| 13 |
|
| 14 |
|
| 15 |
|
| 16 |
|
| 17 |
|
| 18 |
|
| 19 |
|
| 20 |
|
| 21 |
|
| 22 |
|
| 23 |
|
| 24 |
|
| 25 |
|
| 26 |
|
| 27 |
|
| 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 |
|
| 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 |
|
| 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 |
} |