From 8297b3faf8606762b176d57637f2ec5f84601e0d Mon Sep 17 00:00:00 2001
From: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
Date: Sat, 4 Dec 2021 21:12:06 +0100
Subject: Fix: unit test and sample program Windows build

Now that there is a wrapper for main() on Windows, all executable
programs must use a common, cannonical signature for main().

Furthermore, the Windows version of the epoch test needs wrappers
for setenv/unsetenv.

Signed-off-by: David Oberhollenzer <david.oberhollenzer@sigma-star.at>
---
 tests/libfstree/Makemodule.am       | 4 +++-
 tests/libfstree/add_by_path.c       | 3 ++-
 tests/libfstree/canonicalize_name.c | 3 ++-
 tests/libfstree/filename_sane.c     | 3 ++-
 tests/libfstree/fstree_from_dir.c   | 3 ++-
 tests/libfstree/fstree_from_file.c  | 3 ++-
 tests/libfstree/fstree_glob1.c      | 3 ++-
 tests/libfstree/fstree_init.c       | 3 ++-
 tests/libfstree/fstree_sort.c       | 4 +++-
 tests/libfstree/gen_inode_numbers.c | 3 ++-
 tests/libfstree/get_path.c          | 3 ++-
 tests/libfstree/mknode_dir.c        | 3 ++-
 tests/libfstree/mknode_reg.c        | 3 ++-
 tests/libfstree/mknode_simple.c     | 3 ++-
 tests/libfstree/mknode_slink.c      | 3 ++-
 15 files changed, 32 insertions(+), 15 deletions(-)

(limited to 'tests/libfstree')

diff --git a/tests/libfstree/Makemodule.am b/tests/libfstree/Makemodule.am
index 8248f5c..022b8e4 100644
--- a/tests/libfstree/Makemodule.am
+++ b/tests/libfstree/Makemodule.am
@@ -2,7 +2,7 @@ FSTDATADIR=$(top_srcdir)/tests/libfstree
 
 test_canonicalize_name_SOURCES = tests/libfstree/canonicalize_name.c
 test_canonicalize_name_SOURCES += tests/test.h
-test_canonicalize_name_LDADD = libfstree.a
+test_canonicalize_name_LDADD = libfstree.a libcompat.a
 
 test_mknode_simple_SOURCES = tests/libfstree/mknode_simple.c tests/test.h
 test_mknode_simple_LDADD = libfstree.a libcompat.a
@@ -50,10 +50,12 @@ test_fstree_init_LDADD = libfstree.a libfstream.a libcompat.a
 
 test_filename_sane_SOURCES = tests/libfstree/filename_sane.c
 test_filename_sane_SOURCES += lib/fstree/filename_sane.c
+test_filename_sane_LDADD = libcompat.a
 
 test_filename_sane_w32_SOURCES = tests/libfstree/filename_sane.c
 test_filename_sane_w32_SOURCES += lib/fstree/filename_sane.c
 test_filename_sane_w32_CPPFLAGS = $(AM_CPPFLAGS) -DTEST_WIN32=1
+test_filename_sane_w32_LDADD = libcompat.a
 
 fstree_fuzz_SOURCES = tests/libfstree/fstree_fuzz.c
 fstree_fuzz_LDADD = libfstree.a libfstream.a libcompat.a
diff --git a/tests/libfstree/add_by_path.c b/tests/libfstree/add_by_path.c
index 94c0dc9..b21c696 100644
--- a/tests/libfstree/add_by_path.c
+++ b/tests/libfstree/add_by_path.c
@@ -9,12 +9,13 @@
 #include "fstree.h"
 #include "../test.h"
 
-int main(void)
+int main(int argc, char **argv)
 {
 	tree_node_t *a, *b;
 	struct stat sb;
 	fstree_t fs;
 	char *opts;
+	(void)argc; (void)argv;
 
 	opts = strdup("mode=0755,uid=21,gid=42");
 	TEST_ASSERT(fstree_init(&fs, opts) == 0);
diff --git a/tests/libfstree/canonicalize_name.c b/tests/libfstree/canonicalize_name.c
index 37b07e3..f1eb1c1 100644
--- a/tests/libfstree/canonicalize_name.c
+++ b/tests/libfstree/canonicalize_name.c
@@ -40,10 +40,11 @@ static const char *must_not_work[] = {
 	"foo/bar/../",
 };
 
-int main(void)
+int main(int argc, char **argv)
 {
 	char buffer[512];
 	size_t i;
+	(void)argc; (void)argv;
 
 	for (i = 0; i < sizeof(must_work) / sizeof(must_work[0]); ++i) {
 		strcpy(buffer, must_work[i].in);
diff --git a/tests/libfstree/filename_sane.c b/tests/libfstree/filename_sane.c
index 4d25b33..11f27da 100644
--- a/tests/libfstree/filename_sane.c
+++ b/tests/libfstree/filename_sane.c
@@ -40,9 +40,10 @@ static const char *must_not_work_here[] = {
 	NULL,
 };
 
-int main(void)
+int main(int argc, char **argv)
 {
 	size_t i;
+	(void)argc; (void)argv;
 
 	for (i = 0; must_work[i] != NULL; ++i) {
 		if (!is_filename_sane(must_work[i], false)) {
diff --git a/tests/libfstree/fstree_from_dir.c b/tests/libfstree/fstree_from_dir.c
index 7db1b74..845586f 100644
--- a/tests/libfstree/fstree_from_dir.c
+++ b/tests/libfstree/fstree_from_dir.c
@@ -313,11 +313,12 @@ static void check_hierarchy(tree_node_t *root, bool recursive)
 	TEST_NULL(n);
 }
 
-int main(void)
+int main(int argc, char **argv)
 {
 	struct stat sb;
 	tree_node_t *n;
 	fstree_t fs;
+	(void)argc; (void)argv;
 
 	/* recursively scan into root */
 	TEST_ASSERT(fstree_init(&fs, NULL) == 0);
diff --git a/tests/libfstree/fstree_from_file.c b/tests/libfstree/fstree_from_file.c
index 5d37960..08277e6 100644
--- a/tests/libfstree/fstree_from_file.c
+++ b/tests/libfstree/fstree_from_file.c
@@ -9,10 +9,11 @@
 #include "fstree.h"
 #include "../test.h"
 
-int main(void)
+int main(int argc, char **argv)
 {
 	tree_node_t *n;
 	fstree_t fs;
+	(void)argc; (void)argv;
 
 	TEST_ASSERT(fstree_init(&fs, NULL) == 0);
 	TEST_ASSERT(fstree_from_file(&fs, TEST_PATH, NULL) == 0);
diff --git a/tests/libfstree/fstree_glob1.c b/tests/libfstree/fstree_glob1.c
index 708b0e8..08e39bd 100644
--- a/tests/libfstree/fstree_glob1.c
+++ b/tests/libfstree/fstree_glob1.c
@@ -204,10 +204,11 @@ static void check_hierarchy(tree_node_t *root, bool subdir, bool recursive)
 	TEST_NULL(n);
 }
 
-int main(void)
+int main(int argc, char **argv)
 {
 	fstree_t fs;
 	int ret;
+	(void)argc; (void)argv;
 
 	/* first test case, directory tree only */
 	ret = fstree_init(&fs, NULL);
diff --git a/tests/libfstree/fstree_init.c b/tests/libfstree/fstree_init.c
index a101143..5f701cb 100644
--- a/tests/libfstree/fstree_init.c
+++ b/tests/libfstree/fstree_init.c
@@ -10,10 +10,11 @@
 #include "internal.h"
 #include "../test.h"
 
-int main(void)
+int main(int argc, char **argv)
 {
 	fstree_t fs;
 	char *str;
+	(void)argc; (void)argv;
 
 	str = strdup("mtime=1337,uid=1000,gid=100,mode=0321");
 	TEST_NOT_NULL(str);
diff --git a/tests/libfstree/fstree_sort.c b/tests/libfstree/fstree_sort.c
index 6fc7543..618ae9f 100644
--- a/tests/libfstree/fstree_sort.c
+++ b/tests/libfstree/fstree_sort.c
@@ -10,11 +10,13 @@
 #include "internal.h"
 #include "../test.h"
 
-int main(void)
+int main(int argc, char **argv)
 {
 	tree_node_t *a, *b, *c, *d;
 	struct stat sb;
 	fstree_t fs;
+	int ret;
+	(void)argc; (void)argv;
 
 	memset(&fs, 0, sizeof(fs));
 	memset(&sb, 0, sizeof(sb));
diff --git a/tests/libfstree/gen_inode_numbers.c b/tests/libfstree/gen_inode_numbers.c
index 8ee2315..eef5678 100644
--- a/tests/libfstree/gen_inode_numbers.c
+++ b/tests/libfstree/gen_inode_numbers.c
@@ -44,10 +44,11 @@ static void check_children_continuous(tree_node_t *root)
 		check_children_continuous(n);
 }
 
-int main(void)
+int main(int argc, char **argv)
 {
 	tree_node_t *a, *b, *c;
 	fstree_t fs;
+	(void)argc; (void)argv;
 
 	// inode table for the empty tree
 	TEST_ASSERT(fstree_init(&fs, NULL) == 0);
diff --git a/tests/libfstree/get_path.c b/tests/libfstree/get_path.c
index 9bf618b..26dd9ea 100644
--- a/tests/libfstree/get_path.c
+++ b/tests/libfstree/get_path.c
@@ -9,12 +9,13 @@
 #include "fstree.h"
 #include "../test.h"
 
-int main(void)
+int main(int argc, char **argv)
 {
 	tree_node_t *a, *b, *c, *d;
 	struct stat sb;
 	fstree_t fs;
 	char *str;
+	(void)argc; (void)argv;
 
 	TEST_ASSERT(fstree_init(&fs, NULL) == 0);
 
diff --git a/tests/libfstree/mknode_dir.c b/tests/libfstree/mknode_dir.c
index be1156f..900edaa 100644
--- a/tests/libfstree/mknode_dir.c
+++ b/tests/libfstree/mknode_dir.c
@@ -9,11 +9,12 @@
 #include "fstree.h"
 #include "../test.h"
 
-int main(void)
+int main(int argc, char **argv)
 {
 	tree_node_t *root, *a, *b;
 	struct stat sb;
 	fstree_t fs;
+	(void)argc; (void)argv;
 
 	memset(&fs, 0, sizeof(fs));
 	memset(&sb, 0, sizeof(sb));
diff --git a/tests/libfstree/mknode_reg.c b/tests/libfstree/mknode_reg.c
index 1f7ec88..debecd9 100644
--- a/tests/libfstree/mknode_reg.c
+++ b/tests/libfstree/mknode_reg.c
@@ -9,11 +9,12 @@
 #include "fstree.h"
 #include "../test.h"
 
-int main(void)
+int main(int argc, char **argv)
 {
 	tree_node_t *node;
 	struct stat sb;
 	fstree_t fs;
+	(void)argc; (void)argv;
 
 	memset(&fs, 0, sizeof(fs));
 
diff --git a/tests/libfstree/mknode_simple.c b/tests/libfstree/mknode_simple.c
index b8505ed..4e8978c 100644
--- a/tests/libfstree/mknode_simple.c
+++ b/tests/libfstree/mknode_simple.c
@@ -9,11 +9,12 @@
 #include "fstree.h"
 #include "../test.h"
 
-int main(void)
+int main(int argc, char **argv)
 {
 	tree_node_t *node;
 	struct stat sb;
 	fstree_t fs;
+	(void)argc; (void)argv;
 
 	memset(&fs, 0, sizeof(fs));
 	memset(&sb, 0, sizeof(sb));
diff --git a/tests/libfstree/mknode_slink.c b/tests/libfstree/mknode_slink.c
index 29f2679..4b23951 100644
--- a/tests/libfstree/mknode_slink.c
+++ b/tests/libfstree/mknode_slink.c
@@ -9,11 +9,12 @@
 #include "fstree.h"
 #include "../test.h"
 
-int main(void)
+int main(int argc, char **argv)
 {
 	tree_node_t *node;
 	struct stat sb;
 	fstree_t fs;
+	(void)argc; (void)argv;
 
 	memset(&fs, 0, sizeof(fs));
 	memset(&sb, 0, sizeof(sb));
-- 
cgit v1.2.3