aboutsummaryrefslogtreecommitdiff
path: root/tests/libcap_psx_test.c
diff options
context:
space:
mode:
Diffstat (limited to 'tests/libcap_psx_test.c')
-rw-r--r--tests/libcap_psx_test.c19
1 files changed, 17 insertions, 2 deletions
diff --git a/tests/libcap_psx_test.c b/tests/libcap_psx_test.c
index 9f53f06..9ef8cac 100644
--- a/tests/libcap_psx_test.c
+++ b/tests/libcap_psx_test.c
@@ -16,8 +16,15 @@ static void *thread_fork_exit(void *data) {
usleep(1234);
pid_t pid = fork();
cap_t start = cap_get_proc();
+ if (start == NULL) {
+ perror("FAILED: unable to start");
+ exit(1);
+ }
if (pid == 0) {
- cap_set_proc(start);
+ if (cap_set_proc(start)) {
+ perror("setting empty caps failed");
+ exit(1);
+ }
exit(0);
}
int res;
@@ -27,6 +34,7 @@ static void *thread_fork_exit(void *data) {
exit(1);
}
cap_set_proc(start);
+ cap_free(start);
return NULL;
}
@@ -35,6 +43,10 @@ int main(int argc, char **argv) {
printf("hello libcap and libpsx ");
fflush(stdout);
cap_t start = cap_get_proc();
+ if (start == NULL) {
+ perror("FAILED: to actually start");
+ exit(1);
+ }
pthread_t ignored[10];
for (i = 0; i < 10; i++) {
pthread_create(&ignored[i], NULL, thread_fork_exit, NULL);
@@ -42,7 +54,10 @@ int main(int argc, char **argv) {
for (i = 0; i < 10; i++) {
printf("."); /* because of fork, this may print double */
fflush(stdout); /* try to limit the above effect */
- cap_set_proc(start);
+ if (cap_set_proc(start)) {
+ perror("failed to set proc");
+ exit(1);
+ }
usleep(1000);
}
printf(" PASSED\n");