aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
Diffstat (limited to 'tests')
-rw-r--r--tests/Makemodule.am40
-rw-r--r--tests/fstree1.txt9
-rw-r--r--tests/fstree_from_file.c32
-rw-r--r--tests/str_table.c1
4 files changed, 48 insertions, 34 deletions
diff --git a/tests/Makemodule.am b/tests/Makemodule.am
index 34b0238..93f286d 100644
--- a/tests/Makemodule.am
+++ b/tests/Makemodule.am
@@ -2,7 +2,7 @@ test_canonicalize_name_SOURCES = tests/canonicalize_name.c
test_canonicalize_name_LDADD = libutil.la
test_str_table_SOURCES = tests/str_table.c
-test_str_table_LDADD = libutil.la
+test_str_table_LDADD = libutil.la libcompat.a
test_str_table_CPPFLAGS = $(AM_CPPFLAGS) -DTESTPATH=$(top_srcdir)/tests
test_abi_SOURCES = tests/abi.c
@@ -13,67 +13,68 @@ TESTS += test_canonicalize_name test_str_table test_abi
if BUILD_TOOLS
test_mknode_simple_SOURCES = tests/mknode_simple.c
-test_mknode_simple_LDADD = libfstree.a
+test_mknode_simple_LDADD = libfstree.a libcompat.a
test_mknode_slink_SOURCES = tests/mknode_slink.c
-test_mknode_slink_LDADD = libfstree.a
+test_mknode_slink_LDADD = libfstree.a libcompat.a
test_mknode_reg_SOURCES = tests/mknode_reg.c
-test_mknode_reg_LDADD = libfstree.a
+test_mknode_reg_LDADD = libfstree.a libcompat.a
test_mknode_dir_SOURCES = tests/mknode_dir.c
-test_mknode_dir_LDADD = libfstree.a
+test_mknode_dir_LDADD = libfstree.a libcompat.a
test_gen_inode_table_SOURCES = tests/gen_inode_table.c
-test_gen_inode_table_LDADD = libfstree.a libutil.la
+test_gen_inode_table_LDADD = libfstree.a libutil.la libcompat.a
test_add_by_path_SOURCES = tests/add_by_path.c
-test_add_by_path_LDADD = libfstree.a libutil.la
+test_add_by_path_LDADD = libfstree.a libutil.la libcompat.a
test_get_path_SOURCES = tests/get_path.c
-test_get_path_LDADD = libfstree.a libutil.la
+test_get_path_LDADD = libfstree.a libutil.la libcompat.a
test_fstree_sort_SOURCES = tests/fstree_sort.c
-test_fstree_sort_LDADD = libfstree.a libutil.la
+test_fstree_sort_LDADD = libfstree.a libutil.la libcompat.a
test_fstree_from_file_SOURCES = tests/fstree_from_file.c
-test_fstree_from_file_LDADD = libfstree.a libutil.la
+test_fstree_from_file_CPPFLAGS = $(AM_CPPFLAGS) -DTESTPATH=$(top_srcdir)/tests/fstree1.txt
+test_fstree_from_file_LDADD = libfstree.a libutil.la libcompat.a
test_fstree_init_SOURCES = tests/fstree_init.c
-test_fstree_init_LDADD = libfstree.a libutil.la
+test_fstree_init_LDADD = libfstree.a libutil.la libcompat.a
test_tar_gnu_SOURCES = tests/tar_gnu.c
-test_tar_gnu_LDADD = libtar.a libutil.la
+test_tar_gnu_LDADD = libtar.a libcompat.a libutil.la
test_tar_gnu_CPPFLAGS = $(AM_CPPFLAGS) -DTESTPATH=$(top_srcdir)/tests/tar
test_tar_pax_SOURCES = tests/tar_pax.c
-test_tar_pax_LDADD = libtar.a libutil.la
+test_tar_pax_LDADD = libtar.a libcompat.a libutil.la
test_tar_pax_CPPFLAGS = $(AM_CPPFLAGS) -DTESTPATH=$(top_srcdir)/tests/tar
test_tar_ustar_SOURCES = tests/tar_ustar.c
-test_tar_ustar_LDADD = libtar.a libutil.la
+test_tar_ustar_LDADD = libtar.a libcompat.a libutil.la
test_tar_ustar_CPPFLAGS = $(AM_CPPFLAGS) -DTESTPATH=$(top_srcdir)/tests/tar
test_tar_sparse_gnu_SOURCES = tests/tar_sparse_gnu.c
-test_tar_sparse_gnu_LDADD = libtar.a libutil.la
+test_tar_sparse_gnu_LDADD = libtar.a libcompat.a libutil.la
test_tar_sparse_gnu_CPPFLAGS = $(AM_CPPFLAGS) -DTESTPATH=$(top_srcdir)/tests/tar
test_tar_sparse_gnu1_SOURCES = tests/tar_sparse_gnu1.c
-test_tar_sparse_gnu1_LDADD = libtar.a libutil.la
+test_tar_sparse_gnu1_LDADD = libtar.a libcompat.a libutil.la
test_tar_sparse_gnu1_CPPFLAGS = $(AM_CPPFLAGS)
test_tar_sparse_gnu1_CPPFLAGS += -DTESTPATH=$(top_srcdir)/tests/tar
test_tar_sparse_gnu2_SOURCES = tests/tar_sparse_gnu1.c
-test_tar_sparse_gnu2_LDADD = libtar.a libutil.la
+test_tar_sparse_gnu2_LDADD = libtar.a libcompat.a libutil.la
test_tar_sparse_gnu2_CPPFLAGS = $(AM_CPPFLAGS)
test_tar_sparse_gnu2_CPPFLAGS += -DTESTPATH=$(top_srcdir)/tests/tar
test_tar_xattr_bsd_SOURCES = tests/tar_xattr_bsd.c
-test_tar_xattr_bsd_LDADD = libtar.a libutil.la
+test_tar_xattr_bsd_LDADD = libtar.a libcompat.a libutil.la
test_tar_xattr_bsd_CPPFLAGS = $(AM_CPPFLAGS) -DTESTPATH=$(top_srcdir)/tests/tar
test_tar_xattr_schily_SOURCES = tests/tar_xattr_schily.c
-test_tar_xattr_schily_LDADD = libtar.a libutil.la
+test_tar_xattr_schily_LDADD = libtar.a libcompat.a libutil.la
test_tar_xattr_schily_CPPFLAGS = $(AM_CPPFLAGS)
test_tar_xattr_schily_CPPFLAGS += -DTESTPATH=$(top_srcdir)/tests/tar
@@ -101,3 +102,4 @@ TESTS += test_tar_sparse_gnu2 test_tar_xattr_bsd test_tar_xattr_schily
endif
EXTRA_DIST += $(top_srcdir)/tests/tar $(top_srcdir)/tests/words.txt
+EXTRA_DIST += $(top_srcdir)/tests/fstree1.txt
diff --git a/tests/fstree1.txt b/tests/fstree1.txt
new file mode 100644
index 0000000..090aff9
--- /dev/null
+++ b/tests/fstree1.txt
@@ -0,0 +1,9 @@
+# comment line
+slink /slink 0644 2 3 slinktarget
+dir /dir 0755 4 5
+nod /chardev 0600 6 7 c 13 37
+nod /blkdev 0600 8 9 b 42 21
+pipe /pipe 0644 10 11
+dir "/foo bar" 0755 0 0
+dir "/foo bar/ test \"/" 0755 0 0
+ sock /sock 0555 12 13 \ No newline at end of file
diff --git a/tests/fstree_from_file.c b/tests/fstree_from_file.c
index b5ac2a3..4df0a4e 100644
--- a/tests/fstree_from_file.c
+++ b/tests/fstree_from_file.c
@@ -13,28 +13,30 @@
#include <assert.h>
#include <stdio.h>
-static const char *testdesc =
-"# comment line\n"
-"slink /slink 0644 2 3 slinktarget\n"
-"dir /dir 0755 4 5\n"
-"nod /chardev 0600 6 7 c 13 37\n"
-"nod /blkdev 0600 8 9 b 42 21\n"
-"pipe /pipe 0644 10 11\n"
-"dir \"/foo bar\" 0755 0 0\n"
-"dir \"/foo bar/ test \\\"/\" 0755 0 0\n"
-" sock /sock 0555 12 13 ";
+#define STR(x) #x
+#define STRVALUE(x) STR(x)
+
+#define TEST_PATH STRVALUE(TESTPATH)
+
+static FILE *open_read(const char *path)
+{
+ FILE *fp = fopen(path, "rb");
+
+ if (fp == NULL) {
+ perror(path);
+ exit(EXIT_FAILURE);
+ }
+
+ return fp;
+}
int main(void)
{
tree_node_t *n;
fstree_t fs;
- char *ptr;
FILE *fp;
- ptr = strdup(testdesc);
- assert(ptr != NULL);
-
- fp = fmemopen(ptr, strlen(ptr), "r");
+ fp = open_read(TEST_PATH);
assert(fp != NULL);
assert(fstree_init(&fs, NULL) == 0);
diff --git a/tests/str_table.c b/tests/str_table.c
index df4ca29..ae77a61 100644
--- a/tests/str_table.c
+++ b/tests/str_table.c
@@ -12,6 +12,7 @@
#include <stdio.h>
#include "util/str_table.h"
+#include "compat.h"
#define STR(x) #x
#define STRVALUE(x) STR(x)