summaryrefslogtreecommitdiff
path: root/tests/integration/project
diff options
context:
space:
mode:
authorThomas Coldrick <thomas.coldrick@codethink.co.uk>2019-11-08 15:24:00 +0000
committerbst-marge-bot <marge-bot@buildstream.build>2019-11-11 14:37:02 +0000
commit068a51b073a48d2b4d0e3dd0a00add77509207e1 (patch)
treeabbb4963b46bdd6c946125bcc54d5e51750470c7 /tests/integration/project
parentb3270030b5a9e520fd6a2d9f7acd923e27e10139 (diff)
downloadbuildstream-068a51b073a48d2b4d0e3dd0a00add77509207e1.tar.gz
_sandboxbwrap.py: Create /dev/shm in the sandbox
Creates /dev/shm as a tmpfs in the sandbox. Before now access to /dev/shm was only available by a plugin using `Sandbox.mark_directory()` or adding to `Sandbox.DEVICES`, either of which would _mount_ /dev/shm into the sandbox, allowing pollution from the host. This adds it as a tmpfs by default, which seems sensible as it is required for POSIX support. Also adds a test which makes sure that we can open a shared memory object inside the build sandbox with some (probably poor) C code.
Diffstat (limited to 'tests/integration/project')
-rw-r--r--tests/integration/project/elements/sandbox-bwrap/test-dev-shm.bst15
-rw-r--r--tests/integration/project/files/test_shm.c29
2 files changed, 44 insertions, 0 deletions
diff --git a/tests/integration/project/elements/sandbox-bwrap/test-dev-shm.bst b/tests/integration/project/elements/sandbox-bwrap/test-dev-shm.bst
new file mode 100644
index 000000000..03dc74a35
--- /dev/null
+++ b/tests/integration/project/elements/sandbox-bwrap/test-dev-shm.bst
@@ -0,0 +1,15 @@
+kind: manual
+
+depends:
+- base.bst
+
+config:
+ build-commands:
+ - cc test_shm.c
+
+ install-commands:
+ - ./a.out
+
+sources:
+- kind: local
+ path: files/test_shm.c
diff --git a/tests/integration/project/files/test_shm.c b/tests/integration/project/files/test_shm.c
new file mode 100644
index 000000000..4ee71cb2b
--- /dev/null
+++ b/tests/integration/project/files/test_shm.c
@@ -0,0 +1,29 @@
+#include <errno.h>
+#include <stdlib.h>
+#include <stdio.h>
+#include <unistd.h>
+#include <string.h>
+#include <sys/mman.h>
+#include <sys/stat.h>
+#include <fcntl.h>
+
+int main ()
+{
+ int fd = shm_open ("/foo", O_RDONLY | O_CREAT, S_IRWXU);
+ if (fd < 0)
+ {
+ fprintf (stderr, "Failed to open shm: %s\n", strerror (errno));
+ exit(1);
+ }
+
+ int success = shm_unlink ("/foo");
+ if (success < 0)
+ {
+ fprintf (stderr, "Failed to close shm: %s\n", strerror (errno));
+ exit(2);
+ }
+
+ close (fd);
+
+ return 0;
+}