Commit f8352b2a8477e272dcb6a1bae69e184d5f512389

Stefan Sperling 2018-03-12T14:10:23

use pledge(2) in regression tests

diff --git a/regress/delta/delta_test.c b/regress/delta/delta_test.c
index f6edbe0..1567c43 100644
--- a/regress/delta/delta_test.c
+++ b/regress/delta/delta_test.c
@@ -19,6 +19,8 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
+#include <err.h>
+#include <unistd.h>
 
 #include "got_error.h"
 
@@ -108,6 +110,9 @@ main(int argc, const char *argv[])
 		return 1;
 	}
 
+	if (pledge("stdio rpath wpath cpath", NULL) == -1)
+		err(1, "pledge");
+
 	RUN_TEST(delta_apply(), "delta_apply");
 
 	return failure ? 1 : 0;
diff --git a/regress/repository/repository_test.c b/regress/repository/repository_test.c
index 1d2959d..c986d41 100644
--- a/regress/repository/repository_test.c
+++ b/regress/repository/repository_test.c
@@ -22,6 +22,8 @@
 #include <stdlib.h>
 #include <string.h>
 #include <unistd.h>
+#include <err.h>
+#include <unistd.h>
 
 #include "got_error.h"
 #include "got_object.h"
@@ -405,6 +407,9 @@ main(int argc, char *argv[])
 	const char *repo_path;
 	int ch;
 
+	if (pledge("stdio rpath wpath cpath", NULL) == -1)
+		err(1, "pledge");
+
 	while ((ch = getopt(argc, argv, "v")) != -1) {
 		switch (ch) {
 		case 'v':
diff --git a/regress/worktree/worktree_test.c b/regress/worktree/worktree_test.c
index 84ee710..eca73fe 100644
--- a/regress/worktree/worktree_test.c
+++ b/regress/worktree/worktree_test.c
@@ -26,6 +26,8 @@
 #include <unistd.h>
 #include <errno.h>
 #include <util.h>
+#include <err.h>
+#include <unistd.h>
 
 #include "got_error.h"
 #include "got_object.h"
@@ -381,6 +383,9 @@ main(int argc, char *argv[])
 	const char *repo_path;
 	int ch;
 
+	if (pledge("stdio rpath wpath cpath flock", NULL) == -1)
+		err(1, "pledge");
+
 	while ((ch = getopt(argc, argv, "v")) != -1) {
 		switch (ch) {
 		case 'v':