aboutsummaryrefslogtreecommitdiff
path: root/tests/libtar
diff options
context:
space:
mode:
authorDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2021-10-22 17:19:34 +0200
committerDavid Oberhollenzer <david.oberhollenzer@sigma-star.at>2022-03-30 22:31:30 +0200
commit916c8f6e26140cf3c03e58726b57dc4f86e18316 (patch)
tree59603136d62ef2b7ca3626e26929e848db7ab3f1 /tests/libtar
parenta0e9956f931e28eeb430bd2459668fd96a69c676 (diff)
Cleanup: remove struct stat from libtar
The idea was originally to use struct stat in the libfstree code, so we can simply hose data read from a directory into the fstree_t. The struct was then also used with libtar, for simpler interoperation, but it turned out to introduce a lot of platform quirks and causes more trouble than it's worth. Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Diffstat (limited to 'tests/libtar')
-rw-r--r--tests/libtar/tar_big_file.c9
-rw-r--r--tests/libtar/tar_fuzz.c2
-rw-r--r--tests/libtar/tar_simple.c15
-rw-r--r--tests/libtar/tar_sparse.c7
-rw-r--r--tests/libtar/tar_sparse_gnu.c7
-rw-r--r--tests/libtar/tar_target_filled.c24
-rw-r--r--tests/libtar/tar_xattr.c9
-rw-r--r--tests/libtar/tar_xattr_bin.c9
8 files changed, 35 insertions, 47 deletions
diff --git a/tests/libtar/tar_big_file.c b/tests/libtar/tar_big_file.c
index abea1ef..499805f 100644
--- a/tests/libtar/tar_big_file.c
+++ b/tests/libtar/tar_big_file.c
@@ -17,11 +17,10 @@ int main(int argc, char **argv)
fp = istream_open_file(STRVALUE(TESTPATH) "/" STRVALUE(TESTFILE));
TEST_NOT_NULL(fp);
TEST_ASSERT(read_header(fp, &hdr) == 0);
- TEST_EQUAL_UI(hdr.sb.st_mode, S_IFREG | 0644);
- TEST_EQUAL_UI(hdr.sb.st_uid, 01750);
- TEST_EQUAL_UI(hdr.sb.st_gid, 01750);
- TEST_EQUAL_UI(hdr.sb.st_size, 8589934592);
- TEST_EQUAL_UI(hdr.sb.st_mtime, 1542959190);
+ TEST_EQUAL_UI(hdr.mode, S_IFREG | 0644);
+ TEST_EQUAL_UI(hdr.uid, 01750);
+ TEST_EQUAL_UI(hdr.gid, 01750);
+ TEST_EQUAL_UI(hdr.actual_size, 8589934592);
TEST_EQUAL_UI(hdr.mtime, 1542959190);
TEST_STR_EQUAL(hdr.name, "big-file.bin");
TEST_ASSERT(!hdr.unknown_record);
diff --git a/tests/libtar/tar_fuzz.c b/tests/libtar/tar_fuzz.c
index e5f5c0b..d5728b5 100644
--- a/tests/libtar/tar_fuzz.c
+++ b/tests/libtar/tar_fuzz.c
@@ -33,7 +33,7 @@ int main(int argc, char **argv)
if (ret < 0)
goto fail;
- ret = istream_skip(fp, hdr.sb.st_size);
+ ret = istream_skip(fp, hdr.record_size);
clear_header(&hdr);
if (ret < 0)
diff --git a/tests/libtar/tar_simple.c b/tests/libtar/tar_simple.c
index 54b06c8..e5f0137 100644
--- a/tests/libtar/tar_simple.c
+++ b/tests/libtar/tar_simple.c
@@ -44,19 +44,12 @@ int main(int argc, char **argv)
fp = istream_open_file(STRVALUE(TESTPATH) "/" STRVALUE(TESTFILE));
TEST_NOT_NULL(fp);
TEST_ASSERT(read_header(fp, &hdr) == 0);
- TEST_EQUAL_UI(hdr.sb.st_mode, S_IFREG | 0644);
- TEST_EQUAL_UI(hdr.sb.st_uid, TESTUID);
- TEST_EQUAL_UI(hdr.sb.st_gid, TESTGID);
- TEST_EQUAL_UI(hdr.sb.st_size, 5);
+ TEST_EQUAL_UI(hdr.mode, S_IFREG | 0644);
+ TEST_EQUAL_UI(hdr.uid, TESTUID);
+ TEST_EQUAL_UI(hdr.gid, TESTGID);
+ TEST_EQUAL_UI(hdr.actual_size, 5);
ts = TESTTS;
-
- if (sizeof(time_t) < sizeof(ts) && ts > INT32_MAX) {
- TEST_EQUAL_UI(hdr.sb.st_mtime, INT32_MAX);
- } else {
- TEST_EQUAL_UI(hdr.sb.st_mtime, ts);
- }
-
TEST_EQUAL_UI(hdr.mtime, ts);
TEST_STR_EQUAL(hdr.name, fname);
TEST_ASSERT(!hdr.unknown_record);
diff --git a/tests/libtar/tar_sparse.c b/tests/libtar/tar_sparse.c
index c4313f0..24f7a57 100644
--- a/tests/libtar/tar_sparse.c
+++ b/tests/libtar/tar_sparse.c
@@ -17,10 +17,9 @@ static void test_case_sparse(const char *path)
fp = istream_open_file(path);
TEST_NOT_NULL(fp);
TEST_ASSERT(read_header(fp, &hdr) == 0);
- TEST_EQUAL_UI(hdr.sb.st_mode, S_IFREG | 0644);
- TEST_EQUAL_UI(hdr.sb.st_uid, 01750);
- TEST_EQUAL_UI(hdr.sb.st_gid, 01750);
- TEST_EQUAL_UI(hdr.sb.st_size, 2097152);
+ TEST_EQUAL_UI(hdr.mode, S_IFREG | 0644);
+ TEST_EQUAL_UI(hdr.uid, 01750);
+ TEST_EQUAL_UI(hdr.gid, 01750);
TEST_EQUAL_UI(hdr.actual_size, 2097152);
TEST_EQUAL_UI(hdr.record_size, 32768);
TEST_STR_EQUAL(hdr.name, "input.bin");
diff --git a/tests/libtar/tar_sparse_gnu.c b/tests/libtar/tar_sparse_gnu.c
index 06f79f1..5d12478 100644
--- a/tests/libtar/tar_sparse_gnu.c
+++ b/tests/libtar/tar_sparse_gnu.c
@@ -20,10 +20,9 @@ int main(int argc, char **argv)
fp = istream_open_file("sparse-files/gnu-small.tar");
TEST_NOT_NULL(fp);
TEST_ASSERT(read_header(fp, &hdr) == 0);
- TEST_EQUAL_UI(hdr.sb.st_mode, S_IFREG | 0644);
- TEST_EQUAL_UI(hdr.sb.st_uid, 01750);
- TEST_EQUAL_UI(hdr.sb.st_gid, 01750);
- TEST_EQUAL_UI(hdr.sb.st_size, 524288);
+ TEST_EQUAL_UI(hdr.mode, S_IFREG | 0644);
+ TEST_EQUAL_UI(hdr.uid, 01750);
+ TEST_EQUAL_UI(hdr.gid, 01750);
TEST_EQUAL_UI(hdr.actual_size, 524288);
TEST_EQUAL_UI(hdr.record_size, 8192);
TEST_STR_EQUAL(hdr.name, "input.bin");
diff --git a/tests/libtar/tar_target_filled.c b/tests/libtar/tar_target_filled.c
index f0f4026..57c6af9 100644
--- a/tests/libtar/tar_target_filled.c
+++ b/tests/libtar/tar_target_filled.c
@@ -22,33 +22,33 @@ int main(int argc, char **argv)
/* "deep" directory hierarchy containg 2 files */
TEST_ASSERT(read_header(fp, &hdr) == 0);
- TEST_EQUAL_UI(hdr.sb.st_mode, S_IFDIR | 0777);
+ TEST_EQUAL_UI(hdr.mode, S_IFDIR | 0777);
TEST_STR_EQUAL(hdr.name, "20_characters_here01/");
clear_header(&hdr);
TEST_ASSERT(read_header(fp, &hdr) == 0);
- TEST_EQUAL_UI(hdr.sb.st_mode, S_IFDIR | 0777);
+ TEST_EQUAL_UI(hdr.mode, S_IFDIR | 0777);
TEST_STR_EQUAL(hdr.name, "20_characters_here01/20_characters_here02/");
clear_header(&hdr);
TEST_ASSERT(read_header(fp, &hdr) == 0);
- TEST_EQUAL_UI(hdr.sb.st_mode, S_IFDIR | 0777);
+ TEST_EQUAL_UI(hdr.mode, S_IFDIR | 0777);
TEST_STR_EQUAL(hdr.name, "20_characters_here01/20_characters_here02/"
"20_characters_here03/");
clear_header(&hdr);
TEST_ASSERT(read_header(fp, &hdr) == 0);
- TEST_EQUAL_UI(hdr.sb.st_mode, S_IFDIR | 0777);
+ TEST_EQUAL_UI(hdr.mode, S_IFDIR | 0777);
TEST_STR_EQUAL(hdr.name, "20_characters_here01/20_characters_here02/"
"20_characters_here03/20_characters_here04/");
clear_header(&hdr);
TEST_ASSERT(read_header(fp, &hdr) == 0);
- TEST_EQUAL_UI(hdr.sb.st_mode, S_IFREG | 0777);
+ TEST_EQUAL_UI(hdr.mode, S_IFREG | 0777);
TEST_STR_EQUAL(hdr.name, "20_characters_here01/20_characters_here02/"
"20_characters_here03/20_characters_here04/"
"errored_file_tst");
- TEST_EQUAL_UI(hdr.sb.st_size, 5);
+ TEST_EQUAL_UI(hdr.actual_size, 5);
TEST_ASSERT(istream_read(fp, buffer, 5) == 5);
buffer[5] = '\0';
TEST_STR_EQUAL(buffer, "test\n");
@@ -56,11 +56,11 @@ int main(int argc, char **argv)
clear_header(&hdr);
TEST_ASSERT(read_header(fp, &hdr) == 0);
- TEST_EQUAL_UI(hdr.sb.st_mode, S_IFREG | 0777);
+ TEST_EQUAL_UI(hdr.mode, S_IFREG | 0777);
TEST_STR_EQUAL(hdr.name, "20_characters_here01/20_characters_here02/"
"20_characters_here03/20_characters_here04/"
"some_test_file");
- TEST_EQUAL_UI(hdr.sb.st_size, 5);
+ TEST_EQUAL_UI(hdr.actual_size, 5);
TEST_ASSERT(istream_read(fp, buffer, 5) == 5);
buffer[5] = '\0';
TEST_STR_EQUAL(buffer, "test\n");
@@ -69,23 +69,23 @@ int main(int argc, char **argv)
/* "deep" directory hierarchy containg a hard link */
TEST_ASSERT(read_header(fp, &hdr) == 0);
- TEST_EQUAL_UI(hdr.sb.st_mode, S_IFDIR | 0777);
+ TEST_EQUAL_UI(hdr.mode, S_IFDIR | 0777);
TEST_STR_EQUAL(hdr.name, "20CharsForLnkTest001/");
clear_header(&hdr);
TEST_ASSERT(read_header(fp, &hdr) == 0);
- TEST_EQUAL_UI(hdr.sb.st_mode, S_IFDIR | 0777);
+ TEST_EQUAL_UI(hdr.mode, S_IFDIR | 0777);
TEST_STR_EQUAL(hdr.name, "20CharsForLnkTest001/20CharsForLnkTest002/");
clear_header(&hdr);
TEST_ASSERT(read_header(fp, &hdr) == 0);
- TEST_EQUAL_UI(hdr.sb.st_mode, S_IFDIR | 0777);
+ TEST_EQUAL_UI(hdr.mode, S_IFDIR | 0777);
TEST_STR_EQUAL(hdr.name, "20CharsForLnkTest001/20CharsForLnkTest002/"
"20CharsForLnkTest003/");
clear_header(&hdr);
TEST_ASSERT(read_header(fp, &hdr) == 0);
- TEST_EQUAL_UI(hdr.sb.st_mode, S_IFDIR | 0777);
+ TEST_EQUAL_UI(hdr.mode, S_IFDIR | 0777);
TEST_STR_EQUAL(hdr.name, "20CharsForLnkTest001/20CharsForLnkTest002/"
"20CharsForLnkTest003/20CharsForLnkTest004/");
clear_header(&hdr);
diff --git a/tests/libtar/tar_xattr.c b/tests/libtar/tar_xattr.c
index 633c3a2..877bfba 100644
--- a/tests/libtar/tar_xattr.c
+++ b/tests/libtar/tar_xattr.c
@@ -18,11 +18,10 @@ int main(int argc, char **argv)
fp = istream_open_file(STRVALUE(TESTPATH) "/" STRVALUE(TESTFILE));
TEST_NOT_NULL(fp);
TEST_ASSERT(read_header(fp, &hdr) == 0);
- TEST_EQUAL_UI(hdr.sb.st_mode, S_IFREG | 0644);
- TEST_EQUAL_UI(hdr.sb.st_uid, 01750);
- TEST_EQUAL_UI(hdr.sb.st_gid, 01750);
- TEST_EQUAL_UI(hdr.sb.st_size, 5);
- TEST_EQUAL_UI(hdr.sb.st_mtime, 1543094477);
+ TEST_EQUAL_UI(hdr.mode, S_IFREG | 0644);
+ TEST_EQUAL_UI(hdr.uid, 01750);
+ TEST_EQUAL_UI(hdr.gid, 01750);
+ TEST_EQUAL_UI(hdr.actual_size, 5);
TEST_EQUAL_UI(hdr.mtime, 1543094477);
TEST_STR_EQUAL(hdr.name, "input.txt");
TEST_ASSERT(!hdr.unknown_record);
diff --git a/tests/libtar/tar_xattr_bin.c b/tests/libtar/tar_xattr_bin.c
index f44e26f..51ca0b0 100644
--- a/tests/libtar/tar_xattr_bin.c
+++ b/tests/libtar/tar_xattr_bin.c
@@ -26,11 +26,10 @@ int main(int argc, char **argv)
fp = istream_open_file(STRVALUE(TESTPATH) "/" STRVALUE(TESTFILE));
TEST_NOT_NULL(fp);
TEST_ASSERT(read_header(fp, &hdr) == 0);
- TEST_EQUAL_UI(hdr.sb.st_mode, S_IFREG | 0644);
- TEST_EQUAL_UI(hdr.sb.st_uid, 01750);
- TEST_EQUAL_UI(hdr.sb.st_gid, 01750);
- TEST_EQUAL_UI(hdr.sb.st_size, 5);
- TEST_EQUAL_UI(hdr.sb.st_mtime, 1543094477);
+ TEST_EQUAL_UI(hdr.mode, S_IFREG | 0644);
+ TEST_EQUAL_UI(hdr.uid, 01750);
+ TEST_EQUAL_UI(hdr.gid, 01750);
+ TEST_EQUAL_UI(hdr.actual_size, 5);
TEST_EQUAL_UI(hdr.mtime, 1543094477);
TEST_STR_EQUAL(hdr.name, "input.txt");
TEST_ASSERT(!hdr.unknown_record);