summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-06-28 11:44:07 +0200
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2019-06-28 11:44:07 +0200
commit62c596a761d9a511bbf908de36e51dc76b5e3340 (patch)
tree674a704f35047b5bdc2646457ec8dd9fe6f766a5
parent3d8415151b67ac1df1ecb370ad0ab9c808d004f0 (diff)
Regroup tar format tests
Instead of having test cases per feature with multiple vendors, pack the tests into test case per vendor with miltiple features. This should make errors easier to find, since the code many vendor extensions is closely related for all features. E.g. breaking pax header parser is will now trigger the pax test case and the others still work, vs all tests breaking because each feature test also tries to read the pax version. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
-rw-r--r--tests/Makemodule.am34
-rw-r--r--tests/tar_big_size.c79
-rw-r--r--tests/tar_gnu.c159
-rw-r--r--tests/tar_large_uid.c89
-rw-r--r--tests/tar_long_paths.c94
-rw-r--r--tests/tar_pax.c (renamed from tests/tar_mtime.c)45
-rw-r--r--tests/tar_ustar.c (renamed from tests/tar_formats.c)53
7 files changed, 239 insertions, 314 deletions
diff --git a/tests/Makemodule.am b/tests/Makemodule.am
index 44c6eda..75e8a14 100644
--- a/tests/Makemodule.am
+++ b/tests/Makemodule.am
@@ -34,36 +34,26 @@ test_fstree_init_LDADD = libfstree.a libutil.a
test_fstree_xattr_SOURCES = tests/fstree_xattr.c
test_fstree_xattr_LDADD = libfstree.a libutil.a
-test_tar_formats_SOURCES = tests/tar_formats.c
-test_tar_formats_LDADD = libtar.a libutil.a
-test_tar_formats_CPPFLAGS = $(AM_CPPFLAGS) -DTESTPATH=$(top_srcdir)/tests/tar
+test_tar_gnu_SOURCES = tests/tar_gnu.c
+test_tar_gnu_LDADD = libtar.a libutil.a
+test_tar_gnu_CPPFLAGS = $(AM_CPPFLAGS) -DTESTPATH=$(top_srcdir)/tests/tar
-test_tar_big_size_SOURCES = tests/tar_big_size.c
-test_tar_big_size_LDADD = libtar.a libutil.a
-test_tar_big_size_CPPFLAGS = $(AM_CPPFLAGS) -DTESTPATH=$(top_srcdir)/tests/tar
+test_tar_pax_SOURCES = tests/tar_pax.c
+test_tar_pax_LDADD = libtar.a libutil.a
+test_tar_pax_CPPFLAGS = $(AM_CPPFLAGS) -DTESTPATH=$(top_srcdir)/tests/tar
-test_tar_long_paths_SOURCES = tests/tar_long_paths.c
-test_tar_long_paths_LDADD = libtar.a libutil.a
-test_tar_long_paths_CPPFLAGS = $(AM_CPPFLAGS) -DTESTPATH=$(top_srcdir)/tests/tar
-
-test_tar_mtime_SOURCES = tests/tar_mtime.c
-test_tar_mtime_LDADD = libtar.a libutil.a
-test_tar_mtime_CPPFLAGS = $(AM_CPPFLAGS) -DTESTPATH=$(top_srcdir)/tests/tar
-
-test_tar_large_uid_SOURCES = tests/tar_large_uid.c
-test_tar_large_uid_LDADD = libtar.a libutil.a
-test_tar_large_uid_CPPFLAGS = $(AM_CPPFLAGS) -DTESTPATH=$(top_srcdir)/tests/tar
+test_tar_ustar_SOURCES = tests/tar_ustar.c
+test_tar_ustar_LDADD = libtar.a libutil.a
+test_tar_ustar_CPPFLAGS = $(AM_CPPFLAGS) -DTESTPATH=$(top_srcdir)/tests/tar
check_PROGRAMS += test_canonicalize_name test_mknode_simple test_mknode_slink
check_PROGRAMS += test_mknode_reg test_mknode_dir test_gen_inode_table
check_PROGRAMS += test_add_by_path test_get_path test_fstree_sort
check_PROGRAMS += test_fstree_from_file test_fstree_init test_fstree_xattr
-check_PROGRAMS += test_tar_formats test_tar_long_paths test_tar_mtime
-check_PROGRAMS += test_tar_large_uid test_tar_big_size
+check_PROGRAMS += test_tar_ustar test_tar_pax test_tar_gnu
TESTS += test_canonicalize_name test_mknode_simple test_mknode_slink
TESTS += test_mknode_reg test_mknode_dir test_gen_inode_table
TESTS += test_add_by_path test_get_path test_fstree_sort test_fstree_from_file
-TESTS += test_fstree_init test_fstree_xattr test_tar_formats
-TESTS += test_tar_long_paths test_tar_mtime test_tar_large_uid
-TESTS += test_tar_big_size
+TESTS += test_fstree_init test_fstree_xattr test_tar_ustar test_tar_pax
+TESTS += test_tar_gnu
diff --git a/tests/tar_big_size.c b/tests/tar_big_size.c
deleted file mode 100644
index 3b5b557..0000000
--- a/tests/tar_big_size.c
+++ /dev/null
@@ -1,79 +0,0 @@
-/* SPDX-License-Identifier: GPL-3.0-or-later */
-#include "util.h"
-#include "tar.h"
-
-#include <unistd.h>
-#include <assert.h>
-#include <stdlib.h>
-#include <string.h>
-#include <fcntl.h>
-#include <stdio.h>
-
-#define STR(x) #x
-#define STRVALUE(x) STR(x)
-
-#define TEST_PATH STRVALUE(TESTPATH)
-
-static int open_read(const char *path)
-{
- int fd = open(path, O_RDONLY);
-
- if (fd < 0) {
- perror(path);
- exit(EXIT_FAILURE);
- }
-
- return fd;
-}
-
-int main(void)
-{
- tar_header_decoded_t hdr;
- int fd;
-
- assert(chdir(TEST_PATH) == 0);
-
- fd = open_read("file-size/pax.tar");
- assert(read_header(fd, &hdr) == 0);
- assert(hdr.sb.st_mode == (S_IFREG | 0644));
- assert(hdr.sb.st_uid == 01750);
- assert(hdr.sb.st_gid == 01750);
- assert(hdr.sb.st_size == 8589934592);
- assert(hdr.sb.st_mtime == 1542959190);
- assert(hdr.sb.st_atime == 1542959522);
- assert(hdr.sb.st_ctime == 1542959190);
- assert(strcmp(hdr.name, "big-file.bin") == 0);
- assert(!hdr.unknown_record);
- clear_header(&hdr);
- close(fd);
-
- fd = open_read("file-size/gnu.tar");
- assert(read_header(fd, &hdr) == 0);
- assert(hdr.sb.st_mode == (S_IFREG | 0644));
- assert(hdr.sb.st_uid == 01750);
- assert(hdr.sb.st_gid == 01750);
- assert(hdr.sb.st_size == 8589934592);
- assert(hdr.sb.st_mtime == 013375730126);
- assert(hdr.sb.st_atime == 013375730126);
- assert(hdr.sb.st_ctime == 013375730126);
- assert(strcmp(hdr.name, "big-file.bin") == 0);
- assert(!hdr.unknown_record);
- clear_header(&hdr);
- close(fd);
-
- fd = open_read("file-size/12-digit.tar");
- assert(read_header(fd, &hdr) == 0);
- assert(hdr.sb.st_mode == (S_IFREG | 0644));
- assert(hdr.sb.st_uid == 01750);
- assert(hdr.sb.st_gid == 01750);
- assert(hdr.sb.st_size == 8589934592);
- assert(hdr.sb.st_mtime == 013375730126);
- assert(hdr.sb.st_atime == 013375730126);
- assert(hdr.sb.st_ctime == 013375730126);
- assert(strcmp(hdr.name, "big-file.bin") == 0);
- assert(!hdr.unknown_record);
- clear_header(&hdr);
- close(fd);
-
- return EXIT_SUCCESS;
-}
diff --git a/tests/tar_gnu.c b/tests/tar_gnu.c
new file mode 100644
index 0000000..5ce150f
--- /dev/null
+++ b/tests/tar_gnu.c
@@ -0,0 +1,159 @@
+/* SPDX-License-Identifier: GPL-3.0-or-later */
+#include "util.h"
+#include "tar.h"
+
+#include <unistd.h>
+#include <assert.h>
+#include <stdlib.h>
+#include <string.h>
+#include <fcntl.h>
+#include <stdio.h>
+
+#define STR(x) #x
+#define STRVALUE(x) STR(x)
+
+#define TEST_PATH STRVALUE(TESTPATH)
+
+static int open_read(const char *path)
+{
+ int fd = open(path, O_RDONLY);
+
+ if (fd < 0) {
+ perror(path);
+ exit(EXIT_FAILURE);
+ }
+
+ return fd;
+}
+
+static const char *filename =
+"012345678901234567890123456789/012345678901234567890123456789/"
+"012345678901234567890123456789/012345678901234567890123456789/"
+"012345678901234567890123456789/input.txt";
+
+int main(void)
+{
+ tar_header_decoded_t hdr;
+ char buffer[6];
+ int fd;
+
+ assert(chdir(TEST_PATH) == 0);
+
+ fd = open_read("format-acceptance/gnu.tar");
+ assert(read_header(fd, &hdr) == 0);
+ assert(hdr.sb.st_mode == (S_IFREG | 0644));
+ assert(hdr.sb.st_uid == 01750);
+ assert(hdr.sb.st_gid == 01750);
+ assert(hdr.sb.st_size == 5);
+ assert(hdr.sb.st_mtime == 1542905892);
+ assert(hdr.sb.st_atime == 1542905892);
+ assert(hdr.sb.st_ctime == 1542905892);
+ assert(strcmp(hdr.name, "input.txt") == 0);
+ assert(!hdr.unknown_record);
+ assert(read_retry(fd, buffer, 5) == 5);
+ buffer[5] = '\0';
+ assert(strcmp(buffer, "test\n") == 0);
+ clear_header(&hdr);
+ close(fd);
+
+ fd = open_read("format-acceptance/gnu-g.tar");
+ assert(read_header(fd, &hdr) == 0);
+ assert(hdr.sb.st_mode == (S_IFREG | 0644));
+ assert(hdr.sb.st_uid == 01750);
+ assert(hdr.sb.st_gid == 01750);
+ assert(hdr.sb.st_size == 5);
+ assert(hdr.sb.st_mtime == 013375560044);
+ assert(hdr.sb.st_atime == 013375561762);
+ assert(hdr.sb.st_ctime == 013375561750);
+ assert(strcmp(hdr.name, "input.txt") == 0);
+ assert(!hdr.unknown_record);
+ assert(read_retry(fd, buffer, 5) == 5);
+ buffer[5] = '\0';
+ assert(strcmp(buffer, "test\n") == 0);
+ clear_header(&hdr);
+ close(fd);
+
+ fd = open_read("file-size/gnu.tar");
+ assert(read_header(fd, &hdr) == 0);
+ assert(hdr.sb.st_mode == (S_IFREG | 0644));
+ assert(hdr.sb.st_uid == 01750);
+ assert(hdr.sb.st_gid == 01750);
+ assert(hdr.sb.st_size == 8589934592);
+ assert(hdr.sb.st_mtime == 013375730126);
+ assert(hdr.sb.st_atime == 013375730126);
+ assert(hdr.sb.st_ctime == 013375730126);
+ assert(strcmp(hdr.name, "big-file.bin") == 0);
+ assert(!hdr.unknown_record);
+ clear_header(&hdr);
+ close(fd);
+
+ fd = open_read("user-group-largenum/gnu.tar");
+ assert(read_header(fd, &hdr) == 0);
+ assert(hdr.sb.st_mode == (S_IFREG | 0644));
+ assert(hdr.sb.st_uid == 0x80000000);
+ assert(hdr.sb.st_gid == 0x80000000);
+ assert(hdr.sb.st_size == 5);
+ assert(hdr.sb.st_mtime == 013376036700);
+ assert(hdr.sb.st_atime == 013376036700);
+ assert(hdr.sb.st_ctime == 013376036700);
+ assert(strcmp(hdr.name, "input.txt") == 0);
+ assert(!hdr.unknown_record);
+ assert(read_retry(fd, buffer, 5) == 5);
+ buffer[5] = '\0';
+ assert(strcmp(buffer, "test\n") == 0);
+ clear_header(&hdr);
+ close(fd);
+
+ fd = open_read("large-mtime/gnu.tar");
+ assert(read_header(fd, &hdr) == 0);
+ assert(hdr.sb.st_mode == (S_IFREG | 0644));
+ assert(hdr.sb.st_uid == 01750);
+ assert(hdr.sb.st_gid == 01750);
+ assert(hdr.sb.st_size == 5);
+ assert(hdr.sb.st_mtime == 8589934592);
+ assert(hdr.sb.st_atime == 8589934592);
+ assert(hdr.sb.st_ctime == 8589934592);
+ assert(strcmp(hdr.name, "input.txt") == 0);
+ assert(!hdr.unknown_record);
+ assert(read_retry(fd, buffer, 5) == 5);
+ buffer[5] = '\0';
+ assert(strcmp(buffer, "test\n") == 0);
+ clear_header(&hdr);
+ close(fd);
+
+ fd = open_read("negative-mtime/gnu.tar");
+ assert(read_header(fd, &hdr) == 0);
+ assert(hdr.sb.st_mode == (S_IFREG | 0644));
+ assert(hdr.sb.st_uid == 01750);
+ assert(hdr.sb.st_gid == 01750);
+ assert(hdr.sb.st_size == 5);
+ assert(hdr.sb.st_mtime == -315622800);
+ assert(hdr.sb.st_atime == -315622800);
+ assert(hdr.sb.st_ctime == -315622800);
+ assert(strcmp(hdr.name, "input.txt") == 0);
+ assert(!hdr.unknown_record);
+ assert(read_retry(fd, buffer, 5) == 5);
+ buffer[5] = '\0';
+ assert(strcmp(buffer, "test\n") == 0);
+ clear_header(&hdr);
+ close(fd);
+
+ fd = open_read("long-paths/gnu.tar");
+ assert(read_header(fd, &hdr) == 0);
+ assert(hdr.sb.st_mode == (S_IFREG | 0644));
+ assert(hdr.sb.st_uid == 01750);
+ assert(hdr.sb.st_gid == 01750);
+ assert(hdr.sb.st_size == 5);
+ assert(hdr.sb.st_mtime == 1542909670);
+ assert(hdr.sb.st_atime == 1542909670);
+ assert(hdr.sb.st_ctime == 1542909670);
+ assert(strcmp(hdr.name, filename) == 0);
+ assert(!hdr.unknown_record);
+ assert(read_retry(fd, buffer, 5) == 5);
+ buffer[5] = '\0';
+ assert(strcmp(buffer, "test\n") == 0);
+ clear_header(&hdr);
+ close(fd);
+
+ return EXIT_SUCCESS;
+}
diff --git a/tests/tar_large_uid.c b/tests/tar_large_uid.c
deleted file mode 100644
index 36ef222..0000000
--- a/tests/tar_large_uid.c
+++ /dev/null
@@ -1,89 +0,0 @@
-/* SPDX-License-Identifier: GPL-3.0-or-later */
-#include "util.h"
-#include "tar.h"
-
-#include <unistd.h>
-#include <assert.h>
-#include <stdlib.h>
-#include <string.h>
-#include <fcntl.h>
-#include <stdio.h>
-
-#define STR(x) #x
-#define STRVALUE(x) STR(x)
-
-#define TEST_PATH STRVALUE(TESTPATH)
-
-static int open_read(const char *path)
-{
- int fd = open(path, O_RDONLY);
-
- if (fd < 0) {
- perror(path);
- exit(EXIT_FAILURE);
- }
-
- return fd;
-}
-
-int main(void)
-{
- tar_header_decoded_t hdr;
- char buffer[6];
- int fd;
-
- assert(chdir(TEST_PATH) == 0);
-
- fd = open_read("user-group-largenum/8-digit.tar");
- assert(read_header(fd, &hdr) == 0);
- assert(hdr.sb.st_mode == (S_IFREG | 0644));
- assert(hdr.sb.st_uid == 8388608);
- assert(hdr.sb.st_gid == 8388608);
- assert(hdr.sb.st_size == 5);
- assert(hdr.sb.st_mtime == 013376036700);
- assert(hdr.sb.st_atime == 013376036700);
- assert(hdr.sb.st_ctime == 013376036700);
- assert(strcmp(hdr.name, "input.txt") == 0);
- assert(!hdr.unknown_record);
- assert(read_retry(fd, buffer, 5) == 5);
- buffer[5] = '\0';
- assert(strcmp(buffer, "test\n") == 0);
- clear_header(&hdr);
- close(fd);
-
- fd = open_read("user-group-largenum/pax.tar");
- assert(read_header(fd, &hdr) == 0);
- assert(hdr.sb.st_mode == (S_IFREG | 0644));
- assert(hdr.sb.st_uid == 2147483648);
- assert(hdr.sb.st_gid == 2147483648);
- assert(hdr.sb.st_size == 5);
- assert(hdr.sb.st_mtime == 013376036700);
- assert(hdr.sb.st_atime == 1542999264);
- assert(hdr.sb.st_ctime == 1542999260);
- assert(strcmp(hdr.name, "input.txt") == 0);
- assert(!hdr.unknown_record);
- assert(read_retry(fd, buffer, 5) == 5);
- buffer[5] = '\0';
- assert(strcmp(buffer, "test\n") == 0);
- clear_header(&hdr);
- close(fd);
-
- fd = open_read("user-group-largenum/gnu.tar");
- assert(read_header(fd, &hdr) == 0);
- assert(hdr.sb.st_mode == (S_IFREG | 0644));
- assert(hdr.sb.st_uid == 0x80000000);
- assert(hdr.sb.st_gid == 0x80000000);
- assert(hdr.sb.st_size == 5);
- assert(hdr.sb.st_mtime == 013376036700);
- assert(hdr.sb.st_atime == 013376036700);
- assert(hdr.sb.st_ctime == 013376036700);
- assert(strcmp(hdr.name, "input.txt") == 0);
- assert(!hdr.unknown_record);
- assert(read_retry(fd, buffer, 5) == 5);
- buffer[5] = '\0';
- assert(strcmp(buffer, "test\n") == 0);
- clear_header(&hdr);
- close(fd);
-
- return EXIT_SUCCESS;
-}
diff --git a/tests/tar_long_paths.c b/tests/tar_long_paths.c
deleted file mode 100644
index a19a235..0000000
--- a/tests/tar_long_paths.c
+++ /dev/null
@@ -1,94 +0,0 @@
-/* SPDX-License-Identifier: GPL-3.0-or-later */
-#include "util.h"
-#include "tar.h"
-
-#include <unistd.h>
-#include <assert.h>
-#include <stdlib.h>
-#include <string.h>
-#include <fcntl.h>
-#include <stdio.h>
-
-#define STR(x) #x
-#define STRVALUE(x) STR(x)
-
-#define TEST_PATH STRVALUE(TESTPATH)
-
-static int open_read(const char *path)
-{
- int fd = open(path, O_RDONLY);
-
- if (fd < 0) {
- perror(path);
- exit(EXIT_FAILURE);
- }
-
- return fd;
-}
-
-static const char *filename =
-"012345678901234567890123456789/012345678901234567890123456789/"
-"012345678901234567890123456789/012345678901234567890123456789/"
-"012345678901234567890123456789/input.txt";
-
-int main(void)
-{
- tar_header_decoded_t hdr;
- char buffer[6];
- int fd;
-
- assert(chdir(TEST_PATH) == 0);
-
- fd = open_read("long-paths/pax.tar");
- assert(read_header(fd, &hdr) == 0);
- assert(hdr.sb.st_mode == (S_IFREG | 0644));
- assert(hdr.sb.st_uid == 01750);
- assert(hdr.sb.st_gid == 01750);
- assert(hdr.sb.st_size == 5);
- assert(hdr.sb.st_mtime == 1542909670);
- assert(hdr.sb.st_atime == 1542909708);
- assert(hdr.sb.st_ctime == 1542909670);
- assert(strcmp(hdr.name, filename) == 0);
- assert(!hdr.unknown_record);
- assert(read_retry(fd, buffer, 5) == 5);
- buffer[5] = '\0';
- assert(strcmp(buffer, "test\n") == 0);
- clear_header(&hdr);
- close(fd);
-
- fd = open_read("long-paths/ustar.tar");
- assert(read_header(fd, &hdr) == 0);
- assert(hdr.sb.st_mode == (S_IFREG | 0644));
- assert(hdr.sb.st_uid == 01750);
- assert(hdr.sb.st_gid == 01750);
- assert(hdr.sb.st_size == 5);
- assert(hdr.sb.st_mtime == 1542909670);
- assert(hdr.sb.st_atime == 1542909670);
- assert(hdr.sb.st_ctime == 1542909670);
- assert(strcmp(hdr.name, filename) == 0);
- assert(!hdr.unknown_record);
- assert(read_retry(fd, buffer, 5) == 5);
- buffer[5] = '\0';
- assert(strcmp(buffer, "test\n") == 0);
- clear_header(&hdr);
- close(fd);
-
- fd = open_read("long-paths/gnu.tar");
- assert(read_header(fd, &hdr) == 0);
- assert(hdr.sb.st_mode == (S_IFREG | 0644));
- assert(hdr.sb.st_uid == 01750);
- assert(hdr.sb.st_gid == 01750);
- assert(hdr.sb.st_size == 5);
- assert(hdr.sb.st_mtime == 1542909670);
- assert(hdr.sb.st_atime == 1542909670);
- assert(hdr.sb.st_ctime == 1542909670);
- assert(strcmp(hdr.name, filename) == 0);
- assert(!hdr.unknown_record);
- assert(read_retry(fd, buffer, 5) == 5);
- buffer[5] = '\0';
- assert(strcmp(buffer, "test\n") == 0);
- clear_header(&hdr);
- close(fd);
-
- return EXIT_SUCCESS;
-}
diff --git a/tests/tar_mtime.c b/tests/tar_pax.c
index b255656..6ecc361 100644
--- a/tests/tar_mtime.c
+++ b/tests/tar_pax.c
@@ -26,6 +26,11 @@ static int open_read(const char *path)
return fd;
}
+static const char *filename =
+"012345678901234567890123456789/012345678901234567890123456789/"
+"012345678901234567890123456789/012345678901234567890123456789/"
+"012345678901234567890123456789/input.txt";
+
int main(void)
{
tar_header_decoded_t hdr;
@@ -34,15 +39,15 @@ int main(void)
assert(chdir(TEST_PATH) == 0);
- fd = open_read("large-mtime/12-digit.tar");
+ fd = open_read("format-acceptance/pax.tar");
assert(read_header(fd, &hdr) == 0);
assert(hdr.sb.st_mode == (S_IFREG | 0644));
assert(hdr.sb.st_uid == 01750);
assert(hdr.sb.st_gid == 01750);
assert(hdr.sb.st_size == 5);
- assert(hdr.sb.st_mtime == 8589934592);
- assert(hdr.sb.st_atime == 8589934592);
- assert(hdr.sb.st_ctime == 8589934592);
+ assert(hdr.sb.st_mtime == 1542905892);
+ assert(hdr.sb.st_atime == 1542905911);
+ assert(hdr.sb.st_ctime == 1542905892);
assert(strcmp(hdr.name, "input.txt") == 0);
assert(!hdr.unknown_record);
assert(read_retry(fd, buffer, 5) == 5);
@@ -51,15 +56,29 @@ int main(void)
clear_header(&hdr);
close(fd);
- fd = open_read("large-mtime/gnu.tar");
+ fd = open_read("file-size/pax.tar");
assert(read_header(fd, &hdr) == 0);
assert(hdr.sb.st_mode == (S_IFREG | 0644));
assert(hdr.sb.st_uid == 01750);
assert(hdr.sb.st_gid == 01750);
+ assert(hdr.sb.st_size == 8589934592);
+ assert(hdr.sb.st_mtime == 1542959190);
+ assert(hdr.sb.st_atime == 1542959522);
+ assert(hdr.sb.st_ctime == 1542959190);
+ assert(strcmp(hdr.name, "big-file.bin") == 0);
+ assert(!hdr.unknown_record);
+ clear_header(&hdr);
+ close(fd);
+
+ fd = open_read("user-group-largenum/pax.tar");
+ assert(read_header(fd, &hdr) == 0);
+ assert(hdr.sb.st_mode == (S_IFREG | 0644));
+ assert(hdr.sb.st_uid == 2147483648);
+ assert(hdr.sb.st_gid == 2147483648);
assert(hdr.sb.st_size == 5);
- assert(hdr.sb.st_mtime == 8589934592);
- assert(hdr.sb.st_atime == 8589934592);
- assert(hdr.sb.st_ctime == 8589934592);
+ assert(hdr.sb.st_mtime == 013376036700);
+ assert(hdr.sb.st_atime == 1542999264);
+ assert(hdr.sb.st_ctime == 1542999260);
assert(strcmp(hdr.name, "input.txt") == 0);
assert(!hdr.unknown_record);
assert(read_retry(fd, buffer, 5) == 5);
@@ -102,16 +121,16 @@ int main(void)
clear_header(&hdr);
close(fd);
- fd = open_read("negative-mtime/gnu.tar");
+ fd = open_read("long-paths/pax.tar");
assert(read_header(fd, &hdr) == 0);
assert(hdr.sb.st_mode == (S_IFREG | 0644));
assert(hdr.sb.st_uid == 01750);
assert(hdr.sb.st_gid == 01750);
assert(hdr.sb.st_size == 5);
- assert(hdr.sb.st_mtime == -315622800);
- assert(hdr.sb.st_atime == -315622800);
- assert(hdr.sb.st_ctime == -315622800);
- assert(strcmp(hdr.name, "input.txt") == 0);
+ assert(hdr.sb.st_mtime == 1542909670);
+ assert(hdr.sb.st_atime == 1542909708);
+ assert(hdr.sb.st_ctime == 1542909670);
+ assert(strcmp(hdr.name, filename) == 0);
assert(!hdr.unknown_record);
assert(read_retry(fd, buffer, 5) == 5);
buffer[5] = '\0';
diff --git a/tests/tar_formats.c b/tests/tar_ustar.c
index a9dcbc3..acd7097 100644
--- a/tests/tar_formats.c
+++ b/tests/tar_ustar.c
@@ -26,6 +26,11 @@ static int open_read(const char *path)
return fd;
}
+static const char *filename =
+"012345678901234567890123456789/012345678901234567890123456789/"
+"012345678901234567890123456789/012345678901234567890123456789/"
+"012345678901234567890123456789/input.txt";
+
int main(void)
{
tar_header_decoded_t hdr;
@@ -34,14 +39,14 @@ int main(void)
assert(chdir(TEST_PATH) == 0);
- fd = open_read("format-acceptance/pax.tar");
+ fd = open_read("format-acceptance/ustar.tar");
assert(read_header(fd, &hdr) == 0);
assert(hdr.sb.st_mode == (S_IFREG | 0644));
assert(hdr.sb.st_uid == 01750);
assert(hdr.sb.st_gid == 01750);
assert(hdr.sb.st_size == 5);
assert(hdr.sb.st_mtime == 1542905892);
- assert(hdr.sb.st_atime == 1542905911);
+ assert(hdr.sb.st_atime == 1542905892);
assert(hdr.sb.st_ctime == 1542905892);
assert(strcmp(hdr.name, "input.txt") == 0);
assert(!hdr.unknown_record);
@@ -51,7 +56,7 @@ int main(void)
clear_header(&hdr);
close(fd);
- fd = open_read("format-acceptance/ustar.tar");
+ fd = open_read("format-acceptance/ustar-pre-posix.tar");
assert(read_header(fd, &hdr) == 0);
assert(hdr.sb.st_mode == (S_IFREG | 0644));
assert(hdr.sb.st_uid == 01750);
@@ -68,7 +73,7 @@ int main(void)
clear_header(&hdr);
close(fd);
- fd = open_read("format-acceptance/ustar-pre-posix.tar");
+ fd = open_read("format-acceptance/v7.tar");
assert(read_header(fd, &hdr) == 0);
assert(hdr.sb.st_mode == (S_IFREG | 0644));
assert(hdr.sb.st_uid == 01750);
@@ -85,15 +90,29 @@ int main(void)
clear_header(&hdr);
close(fd);
- fd = open_read("format-acceptance/v7.tar");
+ fd = open_read("file-size/12-digit.tar");
assert(read_header(fd, &hdr) == 0);
assert(hdr.sb.st_mode == (S_IFREG | 0644));
assert(hdr.sb.st_uid == 01750);
assert(hdr.sb.st_gid == 01750);
+ assert(hdr.sb.st_size == 8589934592);
+ assert(hdr.sb.st_mtime == 013375730126);
+ assert(hdr.sb.st_atime == 013375730126);
+ assert(hdr.sb.st_ctime == 013375730126);
+ assert(strcmp(hdr.name, "big-file.bin") == 0);
+ assert(!hdr.unknown_record);
+ clear_header(&hdr);
+ close(fd);
+
+ fd = open_read("user-group-largenum/8-digit.tar");
+ assert(read_header(fd, &hdr) == 0);
+ assert(hdr.sb.st_mode == (S_IFREG | 0644));
+ assert(hdr.sb.st_uid == 8388608);
+ assert(hdr.sb.st_gid == 8388608);
assert(hdr.sb.st_size == 5);
- assert(hdr.sb.st_mtime == 1542905892);
- assert(hdr.sb.st_atime == 1542905892);
- assert(hdr.sb.st_ctime == 1542905892);
+ assert(hdr.sb.st_mtime == 013376036700);
+ assert(hdr.sb.st_atime == 013376036700);
+ assert(hdr.sb.st_ctime == 013376036700);
assert(strcmp(hdr.name, "input.txt") == 0);
assert(!hdr.unknown_record);
assert(read_retry(fd, buffer, 5) == 5);
@@ -102,15 +121,15 @@ int main(void)
clear_header(&hdr);
close(fd);
- fd = open_read("format-acceptance/gnu.tar");
+ fd = open_read("large-mtime/12-digit.tar");
assert(read_header(fd, &hdr) == 0);
assert(hdr.sb.st_mode == (S_IFREG | 0644));
assert(hdr.sb.st_uid == 01750);
assert(hdr.sb.st_gid == 01750);
assert(hdr.sb.st_size == 5);
- assert(hdr.sb.st_mtime == 1542905892);
- assert(hdr.sb.st_atime == 1542905892);
- assert(hdr.sb.st_ctime == 1542905892);
+ assert(hdr.sb.st_mtime == 8589934592);
+ assert(hdr.sb.st_atime == 8589934592);
+ assert(hdr.sb.st_ctime == 8589934592);
assert(strcmp(hdr.name, "input.txt") == 0);
assert(!hdr.unknown_record);
assert(read_retry(fd, buffer, 5) == 5);
@@ -119,16 +138,16 @@ int main(void)
clear_header(&hdr);
close(fd);
- fd = open_read("format-acceptance/gnu-g.tar");
+ fd = open_read("long-paths/ustar.tar");
assert(read_header(fd, &hdr) == 0);
assert(hdr.sb.st_mode == (S_IFREG | 0644));
assert(hdr.sb.st_uid == 01750);
assert(hdr.sb.st_gid == 01750);
assert(hdr.sb.st_size == 5);
- assert(hdr.sb.st_mtime == 013375560044);
- assert(hdr.sb.st_atime == 013375561762);
- assert(hdr.sb.st_ctime == 013375561750);
- assert(strcmp(hdr.name, "input.txt") == 0);
+ assert(hdr.sb.st_mtime == 1542909670);
+ assert(hdr.sb.st_atime == 1542909670);
+ assert(hdr.sb.st_ctime == 1542909670);
+ assert(strcmp(hdr.name, filename) == 0);
assert(!hdr.unknown_record);
assert(read_retry(fd, buffer, 5) == 5);
buffer[5] = '\0';