[gnome-autoar/wip/oholy/extractor-readonly-folders: 3/3] tests: Add test for extraction of files from readonly dir
- From: Ondrej Holy <oholy src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-autoar/wip/oholy/extractor-readonly-folders: 3/3] tests: Add test for extraction of files from readonly dir
- Date: Fri, 23 Apr 2021 09:03:44 +0000 (UTC)
commit aec3a1343ae692a514f4b94e14e178b047a5ac3c
Author: Ondrej Holy <oholy redhat com>
Date: Fri Apr 23 10:47:24 2021 +0200
tests: Add test for extraction of files from readonly dir
The extraction of children from a readonly directory should not fail.
Let's add a test to verify this.
.../test-readonly-directory/input/arextract.tar | Bin 0 -> 10240 bytes
.../reference/arextract/arextract.txt | 0
tests/test-extract-unit.c | 47 +++++++++++++++++++++
3 files changed, 47 insertions(+)
---
diff --git a/tests/files/extract/test-readonly-directory/input/arextract.tar
b/tests/files/extract/test-readonly-directory/input/arextract.tar
new file mode 100644
index 0000000..e2dddbb
Binary files /dev/null and b/tests/files/extract/test-readonly-directory/input/arextract.tar differ
diff --git a/tests/files/extract/test-readonly-directory/reference/arextract/arextract.txt
b/tests/files/extract/test-readonly-directory/reference/arextract/arextract.txt
new file mode 100644
index 0000000..e69de29
diff --git a/tests/test-extract-unit.c b/tests/test-extract-unit.c
index 14fb014..4ab2fea 100644
--- a/tests/test-extract-unit.c
+++ b/tests/test-extract-unit.c
@@ -1286,6 +1286,50 @@ test_sanitize_absolute_path (void)
assert_reference_and_output_match (extract_test);
}
+/* Be sure that extraction of children from a readonly directory doesn't fail. */
+static void
+test_readonly_directory (void)
+{
+ /* arextract.tar
+ * └── arextract
+ * └── arextract.txt
+ *
+ * 1 directories, 1 files
+ *
+ *
+ * ref
+ * └── arextract
+ * └── arextract.txt
+ *
+ * 1 directories, 1 files
+ */
+
+ g_autoptr (ExtractTest) extract_test = NULL;
+ g_autoptr (ExtractTestData) data = NULL;
+ g_autoptr (GFile) archive = NULL;
+ g_autoptr (AutoarExtractor) extractor = NULL;
+
+ extract_test = extract_test_new ("test-readonly-directory");
+
+ if (!extract_test) {
+ g_assert_nonnull (extract_test);
+ return;
+ }
+
+ archive = g_file_get_child (extract_test->input, "arextract.tar");
+
+ extractor = autoar_extractor_new (archive, extract_test->output);
+
+ data = extract_test_data_new_for_extract (extractor);
+
+ autoar_extractor_start (extractor, data->cancellable);
+
+ g_assert_cmpuint (data->number_of_files, ==, 2);
+ g_assert_no_error (data->error);
+ g_assert_true (data->completed_signalled);
+ assert_reference_and_output_match (extract_test);
+}
+
static void
setup_test_suite (void)
{
@@ -1324,6 +1368,9 @@ setup_test_suite (void)
test_sanitize_dotdot_parent);
g_test_add_func ("/autoar-extract/test-sanitize-absolute-path",
test_sanitize_absolute_path);
+
+ g_test_add_func ("/autoar-extract/test-readonly-directory",
+ test_readonly_directory);
}
int
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]