summaryrefslogtreecommitdiffstats
path: root/third_party/rust/rlbox_lucet_sandbox/test
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 14:29:10 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 14:29:10 +0000
commit2aa4a82499d4becd2284cdb482213d541b8804dd (patch)
treeb80bf8bf13c3766139fbacc530efd0dd9d54394c /third_party/rust/rlbox_lucet_sandbox/test
parentInitial commit. (diff)
downloadfirefox-upstream.tar.xz
firefox-upstream.zip
Adding upstream version 86.0.1.upstream/86.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'third_party/rust/rlbox_lucet_sandbox/test')
-rw-r--r--third_party/rust/rlbox_lucet_sandbox/test/test_lucet_sandbox_glue.cpp17
-rw-r--r--third_party/rust/rlbox_lucet_sandbox/test/test_lucet_sandbox_glue_embedder_vars.cpp19
-rw-r--r--third_party/rust/rlbox_lucet_sandbox/test/test_lucet_sandbox_glue_main.cpp2
-rw-r--r--third_party/rust/rlbox_lucet_sandbox/test/test_lucet_sandbox_glue_preload.cpp27
4 files changed, 65 insertions, 0 deletions
diff --git a/third_party/rust/rlbox_lucet_sandbox/test/test_lucet_sandbox_glue.cpp b/third_party/rust/rlbox_lucet_sandbox/test/test_lucet_sandbox_glue.cpp
new file mode 100644
index 0000000000..2d49067216
--- /dev/null
+++ b/third_party/rust/rlbox_lucet_sandbox/test/test_lucet_sandbox_glue.cpp
@@ -0,0 +1,17 @@
+#define RLBOX_USE_EXCEPTIONS
+#define RLBOX_ENABLE_DEBUG_ASSERTIONS
+#define RLBOX_SINGLE_THREADED_INVOCATIONS
+#include "rlbox_lucet_sandbox.hpp"
+
+// NOLINTNEXTLINE
+#define TestName "rlbox_lucet_sandbox"
+// NOLINTNEXTLINE
+#define TestType rlbox::rlbox_lucet_sandbox
+
+#ifndef GLUE_LIB_LUCET_PATH
+# error "Missing definition for GLUE_LIB_LUCET_PATH"
+#endif
+
+// NOLINTNEXTLINE
+#define CreateSandbox(sandbox) sandbox.create_sandbox(GLUE_LIB_LUCET_PATH)
+#include "test_sandbox_glue.inc.cpp"
diff --git a/third_party/rust/rlbox_lucet_sandbox/test/test_lucet_sandbox_glue_embedder_vars.cpp b/third_party/rust/rlbox_lucet_sandbox/test/test_lucet_sandbox_glue_embedder_vars.cpp
new file mode 100644
index 0000000000..5b6fc79d3b
--- /dev/null
+++ b/third_party/rust/rlbox_lucet_sandbox/test/test_lucet_sandbox_glue_embedder_vars.cpp
@@ -0,0 +1,19 @@
+#define RLBOX_USE_EXCEPTIONS
+#define RLBOX_ENABLE_DEBUG_ASSERTIONS
+#define RLBOX_SINGLE_THREADED_INVOCATIONS
+#define RLBOX_EMBEDDER_PROVIDES_TLS_STATIC_VARIABLES
+#include "rlbox_lucet_sandbox.hpp"
+RLBOX_LUCET_SANDBOX_STATIC_VARIABLES();
+
+// NOLINTNEXTLINE
+#define TestName "rlbox_lucet_sandbox embedder"
+// NOLINTNEXTLINE
+#define TestType rlbox::rlbox_lucet_sandbox
+
+#ifndef GLUE_LIB_LUCET_PATH
+# error "Missing definition for GLUE_LIB_LUCET_PATH"
+#endif
+
+// NOLINTNEXTLINE
+#define CreateSandbox(sandbox) sandbox.create_sandbox(GLUE_LIB_LUCET_PATH)
+#include "test_sandbox_glue.inc.cpp"
diff --git a/third_party/rust/rlbox_lucet_sandbox/test/test_lucet_sandbox_glue_main.cpp b/third_party/rust/rlbox_lucet_sandbox/test/test_lucet_sandbox_glue_main.cpp
new file mode 100644
index 0000000000..62bf7476a1
--- /dev/null
+++ b/third_party/rust/rlbox_lucet_sandbox/test/test_lucet_sandbox_glue_main.cpp
@@ -0,0 +1,2 @@
+#define CATCH_CONFIG_MAIN
+#include "catch2/catch.hpp"
diff --git a/third_party/rust/rlbox_lucet_sandbox/test/test_lucet_sandbox_glue_preload.cpp b/third_party/rust/rlbox_lucet_sandbox/test/test_lucet_sandbox_glue_preload.cpp
new file mode 100644
index 0000000000..de957c8dce
--- /dev/null
+++ b/third_party/rust/rlbox_lucet_sandbox/test/test_lucet_sandbox_glue_preload.cpp
@@ -0,0 +1,27 @@
+#define RLBOX_USE_EXCEPTIONS
+#define RLBOX_ENABLE_DEBUG_ASSERTIONS
+#define RLBOX_SINGLE_THREADED_INVOCATIONS
+#include "rlbox_lucet_sandbox.hpp"
+
+// NOLINTNEXTLINE
+#define TestName "rlbox_lucet_sandbox preload"
+// NOLINTNEXTLINE
+#define TestType rlbox::rlbox_lucet_sandbox
+
+#ifndef GLUE_LIB_LUCET_PATH
+# error "Missing definition for GLUE_LIB_LUCET_PATH"
+#endif
+
+// Test simulating the application preloading the sandboxed library
+// Applications such as Firefox sometimes preload dynamic libraries to ensure it
+// plays well with the content (filepaths) sandbox
+
+#include <dlfcn.h>
+
+#undef CreateSandbox
+// NOLINTNEXTLINE
+#define CreateSandbox(sandbox) \
+ dlopen(GLUE_LIB_LUCET_PATH, RTLD_LAZY); \
+ (sandbox).create_sandbox( \
+ GLUE_LIB_LUCET_PATH, true /* external loads */, false /* allow_stdio */)
+#include "test_sandbox_glue.inc.cpp"