libsepol/tests/sepol_check_context/example.c
Serhii Turivny 3a71508af5 Add CI tests using the standard test interface
The following steps are used to execute the tests using the standard test interface:

Docker

    sudo ANSIBLE_INVENTORY=$(test -e inventory && echo inventory || echo /usr/share/ansible/inventory) TEST_SUBJECTS=docker:docker.io/library/fedora:26 TEST_ARTIFACTS=$PWD/artifacts ansible-playbook --tags container tests.yml

Classic

    sudo ANSIBLE_INVENTORY=$(test -e inventory && echo inventory || echo /usr/share/ansible/inventory) TEST_SUBJECTS="" TEST_ARTIFACTS=$PWD/artifacts ansible-playbook --tags classic tests.yml

https://src.fedoraproject.org/rpms/libsepol/pull-request/1
2017-10-12 17:17:39 +02:00

36 lines
681 B
C

#include <stdio.h>
#include <errno.h>
#include <sepol/sepol.h>
int main (int argc, char *argv[]) {
FILE *policyfile;
if (argc < 3) {
fprintf(stderr, "%s <binary-policy-path> <context>\n", argv[0]);
return 1;
}
policyfile = fopen(argv[1], "r");
if (policyfile == NULL) {
perror("fopen");
return 1;
}
if (sepol_set_policydb_from_file(policyfile) < 0) {
perror("sepol_set_policydb_from_file");
return 1;
}
if (sepol_check_context(argv[2]) < 0) {
perror("sepol_check_context");
return 1;
}
if (fclose(policyfile) != 0) {
perror("fclose");
}
return 0;
}