diff options
| author | Simon McVittie <smcv@collabora.com> | 2022-01-17 19:21:33 +0000 |
|---|---|---|
| committer | Simon McVittie <smcv@debian.org> | 2022-01-18 16:36:16 +0000 |
| commit | d2128c54188bcccb5e5cea59587532ad3d0295cd (patch) | |
| tree | 27bb76353de71f7068a8d0745afb0cc58b89c55c | |
| parent | 92b8cfe46b3adc43c24404decff0d0c393513731 (diff) | |
| download | flatpak-d2128c54188bcccb5e5cea59587532ad3d0295cd.tar.gz | |
test-exports: Exercise host:reset and related filesystem tokens
Signed-off-by: Simon McVittie <smcv@collabora.com>
Co-authored-by: Alexander Larsson <alexl@redhat.com>
(cherry picked from commit f3d12dc7930334d42cfa96a57fd68de9919f1537)
| -rw-r--r-- | tests/test-exports.c | 38 |
1 files changed, 35 insertions, 3 deletions
diff --git a/tests/test-exports.c b/tests/test-exports.c index 4abaf3c2..2099303d 100644 --- a/tests/test-exports.c +++ b/tests/test-exports.c @@ -580,6 +580,13 @@ static const NotFilesystem not_filesystems[] = { "xdg-run", G_OPTION_ERROR_FAILED }, { "/", G_OPTION_ERROR_BAD_VALUE }, { "/////././././././//////", G_OPTION_ERROR_BAD_VALUE }, + { "host:reset", G_OPTION_ERROR_FAILED }, + { "host-reset", G_OPTION_ERROR_FAILED }, + { "host-reset:rw", G_OPTION_ERROR_FAILED }, + { "host-reset:reset", G_OPTION_ERROR_FAILED }, + { "!host-reset:reset", G_OPTION_ERROR_FAILED }, + { "/foo:reset", G_OPTION_ERROR_FAILED }, + { "!/foo:reset", G_OPTION_ERROR_FAILED }, }; typedef struct @@ -635,6 +642,9 @@ static const Filesystem filesystems[] = { "~///././//", FLATPAK_FILESYSTEM_MODE_READ_WRITE, "home" }, { "home/", FLATPAK_FILESYSTEM_MODE_READ_WRITE, "home" }, { "home/Projects", FLATPAK_FILESYSTEM_MODE_READ_WRITE, "~/Projects" }, + { "!home", FLATPAK_FILESYSTEM_MODE_NONE, "home" }, + { "!host:reset", FLATPAK_FILESYSTEM_MODE_NONE, "host-reset" }, + { "!host-reset", FLATPAK_FILESYSTEM_MODE_NONE, "host-reset" }, }; static void @@ -645,19 +655,32 @@ test_filesystems (void) for (i = 0; i < G_N_ELEMENTS (filesystems); i++) { const Filesystem *fs = &filesystems[i]; + const char *input = fs->input; + gboolean negated = FALSE; g_autoptr(GError) error = NULL; g_autofree char *normalized; FlatpakFilesystemMode mode; gboolean ret; g_test_message ("%s", fs->input); - ret = flatpak_context_parse_filesystem (fs->input, FALSE, + + if (input[0] == '!') + { + g_test_message ("-> input is negated"); + negated = TRUE; + input++; + } + + ret = flatpak_context_parse_filesystem (input, negated, &normalized, &mode, &error); g_assert_no_error (error); g_assert_true (ret); + g_test_message ("-> mode: %u", mode); + g_test_message ("-> normalized filesystem: %s", normalized); + if (fs->fs == NULL) - g_assert_cmpstr (normalized, ==, fs->input); + g_assert_cmpstr (normalized, ==, input); else g_assert_cmpstr (normalized, ==, fs->fs); @@ -667,13 +690,22 @@ test_filesystems (void) for (i = 0; i < G_N_ELEMENTS (not_filesystems); i++) { const NotFilesystem *not = ¬_filesystems[i]; + const char *input = not->input; + gboolean negated = FALSE; g_autoptr(GError) error = NULL; char *normalized = NULL; FlatpakFilesystemMode mode; gboolean ret; g_test_message ("%s", not->input); - ret = flatpak_context_parse_filesystem (not->input, FALSE, + + if (input[0] == '!') + { + negated = TRUE; + input++; + } + + ret = flatpak_context_parse_filesystem (input, negated, &normalized, &mode, &error); g_test_message ("-> %s", error ? error->message : "(no error)"); g_assert_error (error, G_OPTION_ERROR, not->code); |
