]> git.ipfire.org Git - thirdparty/libarchive.git/commitdiff
archive_read: group close-twice tests
authordatauwu <209150516+datauwu@users.noreply.github.com>
Tue, 30 Jun 2026 09:12:09 +0000 (17:12 +0800)
committerdatauwu <209150516+datauwu@users.noreply.github.com>
Tue, 30 Jun 2026 09:12:09 +0000 (17:12 +0800)
The close-twice read checks used three tiny source files.

Keep the same DEFINE_TEST cases. Put the fresh-object, fd-backed,
and filename-backed checks in one source file. Remove the two extra
files from the build lists.

Makefile.am
libarchive/test/CMakeLists.txt
libarchive/test/test_archive_read_close_twice.c
libarchive/test/test_archive_read_close_twice_open_fd.c [deleted file]
libarchive/test/test_archive_read_close_twice_open_filename.c [deleted file]

index d43e4f6a7e2d5927bc9f0a58fe886286ea63f96a..04caf08fde7a90efc549a036c5c1ea48da512d69 100644 (file)
@@ -404,8 +404,6 @@ libarchive_test_SOURCES= \
        libarchive/test/test_archive_read.c \
        libarchive/test/test_archive_read_add_passphrase.c \
        libarchive/test/test_archive_read_close_twice.c \
-       libarchive/test/test_archive_read_close_twice_open_fd.c \
-       libarchive/test/test_archive_read_close_twice_open_filename.c \
        libarchive/test/test_archive_read_multiple_data_objects.c \
        libarchive/test/test_archive_read_next_header_empty.c \
        libarchive/test/test_archive_read_next_header_raw.c \
index 2d4223e072e228a5736c7420468ed3faa643de5b..3cd52db5a9070ed4fd0f0cdd4a880dacecd3cd65 100644 (file)
@@ -33,8 +33,6 @@ IF(ENABLE_TEST)
     test_archive_read.c
     test_archive_read_add_passphrase.c
     test_archive_read_close_twice.c
-    test_archive_read_close_twice_open_fd.c
-    test_archive_read_close_twice_open_filename.c
     test_archive_read_multiple_data_objects.c
     test_archive_read_next_header_empty.c
     test_archive_read_next_header_raw.c
index 4320ae6705658439fcfc07c3dba225188c5e9f1c..5f5beb01db9b9fdc04d101f94419ee3555a7570e 100644 (file)
@@ -39,3 +39,45 @@ DEFINE_TEST(test_archive_read_close_twice)
 
        archive_read_free(a);
 }
+
+DEFINE_TEST(test_archive_read_close_twice_open_fd)
+{
+       struct archive* a = archive_read_new();
+
+       assertEqualInt(ARCHIVE_OK, archive_read_support_format_empty(a));
+       assertEqualInt(ARCHIVE_OK, archive_read_open_fd(a, 0, 0));
+       assertEqualInt(0, archive_errno(a));
+       assertEqualString(NULL, archive_error_string(a));
+
+       assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
+       assertEqualInt(0, archive_errno(a));
+       assertEqualString(NULL, archive_error_string(a));
+
+       assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
+       assertEqualInt(0, archive_errno(a));
+       assertEqualString(NULL, archive_error_string(a));
+
+       assertEqualInt(ARCHIVE_OK, archive_read_free(a));
+}
+
+DEFINE_TEST(test_archive_read_close_twice_open_filename)
+{
+       const char *filename = "empty.file";
+       struct archive* a = archive_read_new();
+
+       assertMakeFile(filename, 0644, "");
+       assertEqualInt(ARCHIVE_OK, archive_read_support_format_empty(a));
+       assertEqualInt(ARCHIVE_OK, archive_read_open_filename(a, filename, 0));
+       assertEqualInt(0, archive_errno(a));
+       assertEqualString(NULL, archive_error_string(a));
+
+       assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
+       assertEqualInt(0, archive_errno(a));
+       assertEqualString(NULL, archive_error_string(a));
+
+       assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
+       assertEqualInt(0, archive_errno(a));
+       assertEqualString(NULL, archive_error_string(a));
+
+       assertEqualInt(ARCHIVE_OK, archive_read_free(a));
+}
diff --git a/libarchive/test/test_archive_read_close_twice_open_fd.c b/libarchive/test/test_archive_read_close_twice_open_fd.c
deleted file mode 100644 (file)
index 852038d..0000000
+++ /dev/null
@@ -1,46 +0,0 @@
-/*-
- * Copyright (c) 2011 Tim Kientzle
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "test.h"
-
-DEFINE_TEST(test_archive_read_close_twice_open_fd)
-{
-       struct archive* a = archive_read_new();
-
-       assertEqualInt(ARCHIVE_OK, archive_read_support_format_empty(a));
-       assertEqualInt(ARCHIVE_OK, archive_read_open_fd(a, 0, 0));
-       assertEqualInt(0, archive_errno(a));
-       assertEqualString(NULL, archive_error_string(a));
-
-       assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
-       assertEqualInt(0, archive_errno(a));
-       assertEqualString(NULL, archive_error_string(a));
-
-       assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
-       assertEqualInt(0, archive_errno(a));
-       assertEqualString(NULL, archive_error_string(a));
-
-       assertEqualInt(ARCHIVE_OK, archive_read_free(a));
-}
diff --git a/libarchive/test/test_archive_read_close_twice_open_filename.c b/libarchive/test/test_archive_read_close_twice_open_filename.c
deleted file mode 100644 (file)
index 0be6409..0000000
+++ /dev/null
@@ -1,48 +0,0 @@
-/*-
- * Copyright (c) 2011 Tim Kientzle
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- *    notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- *    notice, this list of conditions and the following disclaimer in the
- *    documentation and/or other materials provided with the distribution.
- *
- * THIS SOFTWARE IS PROVIDED BY THE AUTHOR(S) ``AS IS'' AND ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
- * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
- * IN NO EVENT SHALL THE AUTHOR(S) BE LIABLE FOR ANY DIRECT, INDIRECT,
- * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
- * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
- * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
- * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-#include "test.h"
-
-DEFINE_TEST(test_archive_read_close_twice_open_filename)
-{
-       const char *filename = "empty.file";
-       struct archive* a = archive_read_new();
-
-       assertMakeFile(filename, 0644, "");
-       assertEqualInt(ARCHIVE_OK, archive_read_support_format_empty(a));
-       assertEqualInt(ARCHIVE_OK, archive_read_open_filename(a, filename, 0));
-       assertEqualInt(0, archive_errno(a));
-       assertEqualString(NULL, archive_error_string(a));
-
-       assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
-       assertEqualInt(0, archive_errno(a));
-       assertEqualString(NULL, archive_error_string(a));
-
-       assertEqualIntA(a, ARCHIVE_OK, archive_read_close(a));
-       assertEqualInt(0, archive_errno(a));
-       assertEqualString(NULL, archive_error_string(a));
-
-       assertEqualInt(ARCHIVE_OK, archive_read_free(a));
-}