aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/functional/common/vars-and-functions.sh.in2
-rw-r--r--tests/functional/extra-sandbox-profile.nix19
-rw-r--r--tests/functional/extra-sandbox-profile.sh23
-rw-r--r--tests/functional/meson.build8
-rw-r--r--tests/functional/plugins.sh4
-rw-r--r--tests/unit/libstore/filetransfer.cc16
6 files changed, 63 insertions, 9 deletions
diff --git a/tests/functional/common/vars-and-functions.sh.in b/tests/functional/common/vars-and-functions.sh.in
index 3d2e44024..3b343b720 100644
--- a/tests/functional/common/vars-and-functions.sh.in
+++ b/tests/functional/common/vars-and-functions.sh.in
@@ -54,8 +54,6 @@ export busybox="@sandbox_shell@"
export version=@PACKAGE_VERSION@
export system=@system@
-export BUILD_SHARED_LIBS=@BUILD_SHARED_LIBS@
-
export IMPURE_VAR1=foo
export IMPURE_VAR2=bar
diff --git a/tests/functional/extra-sandbox-profile.nix b/tests/functional/extra-sandbox-profile.nix
new file mode 100644
index 000000000..aa680b918
--- /dev/null
+++ b/tests/functional/extra-sandbox-profile.nix
@@ -0,0 +1,19 @@
+{ destFile, seed }:
+
+with import ./config.nix;
+
+mkDerivation {
+ name = "simple";
+ __sandboxProfile = ''
+ # Allow writing any file in the filesystem
+ (allow file*)
+ '';
+ inherit seed;
+ buildCommand = ''
+ (
+ set -x
+ touch ${destFile}
+ touch $out
+ )
+ '';
+}
diff --git a/tests/functional/extra-sandbox-profile.sh b/tests/functional/extra-sandbox-profile.sh
new file mode 100644
index 000000000..ac3ca036f
--- /dev/null
+++ b/tests/functional/extra-sandbox-profile.sh
@@ -0,0 +1,23 @@
+source common.sh
+
+if [[ $(uname) != Darwin ]]; then skipTest "Need Darwin"; fi
+
+DEST_FILE="${TEST_ROOT}/foo"
+
+testSandboxProfile () (
+ set -e
+
+ sandboxMode="$1"
+
+ rm -f "${DEST_FILE}"
+ nix-build --no-out-link ./extra-sandbox-profile.nix \
+ --option sandbox "$sandboxMode" \
+ --argstr seed "$RANDOM" \
+ --argstr destFile "${DEST_FILE}"
+
+ ls -l "${DEST_FILE}"
+)
+
+testSandboxProfile "false"
+expectStderr 2 testSandboxProfile "true"
+testSandboxProfile "relaxed"
diff --git a/tests/functional/meson.build b/tests/functional/meson.build
index 3f4a970a7..1e68cfe8c 100644
--- a/tests/functional/meson.build
+++ b/tests/functional/meson.build
@@ -7,7 +7,6 @@ test_confdata = {
'sandbox_shell': busybox.found() ? busybox.full_path() : '',
'PACKAGE_VERSION': meson.project_version(),
'system': host_system,
- 'BUILD_SHARED_LIBS': '1', # XXX(Qyriad): detect this!
}
# Just configures `common/vars-and-functions.sh.in`.
@@ -180,10 +179,15 @@ functional_tests_scripts = [
'read-only-store.sh',
'nested-sandboxing.sh',
'debugger.sh',
- 'plugins.sh',
'test-libstoreconsumer.sh',
+ 'extra-sandbox-profile.sh',
]
+# Plugin tests require shared libraries support.
+if get_option('default_library') != 'static'
+ functional_tests_scripts += ['plugins.sh']
+endif
+
# TODO(Qyriad): this will hopefully be able to be removed when we remove the autoconf+Make
# buildsystem. See the comments at the top of setup-functional-tests.py for why this is here.
meson.add_install_script(
diff --git a/tests/functional/plugins.sh b/tests/functional/plugins.sh
index 5934b9b0c..1b6528f3b 100644
--- a/tests/functional/plugins.sh
+++ b/tests/functional/plugins.sh
@@ -1,9 +1,5 @@
source common.sh
-if [[ $BUILD_SHARED_LIBS != 1 ]]; then
- skipTest "Plugins are not supported"
-fi
-
# FIXME(Qyriad): this is working around Meson putting `libplugintest.so.p` in the same place
# as `libplugintest.so`, so `libplugintest.*` grabs both.
libext=so
diff --git a/tests/unit/libstore/filetransfer.cc b/tests/unit/libstore/filetransfer.cc
index ebd38f19d..684697c69 100644
--- a/tests/unit/libstore/filetransfer.cc
+++ b/tests/unit/libstore/filetransfer.cc
@@ -1,4 +1,5 @@
#include "filetransfer.hh"
+#include "compression.hh"
#include <cstdint>
#include <exception>
@@ -25,7 +26,7 @@ using namespace std::chrono_literals;
namespace nix {
static std::tuple<uint16_t, AutoCloseFD>
-serveHTTP(std::string_view status, std::string_view headers, std::function<std::string_view()> content)
+serveHTTP(std::string_view status, std::string_view headers, std::function<std::string()> content)
{
AutoCloseFD listener(::socket(AF_INET6, SOCK_STREAM, 0));
if (!listener) {
@@ -152,4 +153,17 @@ TEST(FileTransfer, NOT_ON_DARWIN(reportsTransferError))
req.baseRetryTimeMs = 0;
ASSERT_THROW(ft->download(req), FileTransferError);
}
+
+TEST(FileTransfer, NOT_ON_DARWIN(handlesContentEncoding))
+{
+ std::string original = "Test data string";
+ std::string compressed = compress("gzip", original);
+
+ auto [port, srv] = serveHTTP("200 ok", "content-encoding: gzip\r\n", [&] { return compressed; });
+ auto ft = makeFileTransfer();
+
+ StringSink sink;
+ ft->download(FileTransferRequest(fmt("http://[::1]:%d/index", port)), sink);
+ EXPECT_EQ(sink.s, original);
+}
}