[dpkg] 82/187: libdpkg: Make test main function a TEST_ENTRY macro
Reiner Herrmann
reiner at reiner-h.de
Sun Nov 6 12:46:27 UTC 2016
This is an automated email from the git hooks/post-receive script.
deki-guest pushed a commit to branch master
in repository dpkg.
commit 0f599ea0ae387771ccfb1aa866c4981ada83932a
Author: Guillem Jover <guillem at debian.org>
Date: Sat Aug 20 03:11:41 2016 +0200
libdpkg: Make test main function a TEST_ENTRY macro
This avoids confusing coverage programs, as the file that actually
contains the main function is the test itself.
---
debian/changelog | 4 ++++
lib/dpkg/t/t-ar.c | 3 +--
lib/dpkg/t/t-arch.c | 3 +--
lib/dpkg/t/t-buffer.c | 3 +--
lib/dpkg/t/t-c-ctype.c | 3 +--
lib/dpkg/t/t-command.c | 3 +--
lib/dpkg/t/t-deb-version.c | 3 +--
lib/dpkg/t/t-error.c | 3 +--
lib/dpkg/t/t-macros.c | 3 +--
lib/dpkg/t/t-mod-db.c | 3 +--
lib/dpkg/t/t-path.c | 3 +--
lib/dpkg/t/t-pkg-list.c | 3 +--
lib/dpkg/t/t-pkg-queue.c | 3 +--
lib/dpkg/t/t-pkginfo.c | 3 +--
lib/dpkg/t/t-progname.c | 3 +--
lib/dpkg/t/t-string.c | 3 +--
lib/dpkg/t/t-subproc.c | 3 +--
lib/dpkg/t/t-test-skip.c | 3 +--
lib/dpkg/t/t-test.c | 3 +--
lib/dpkg/t/t-trigger.c | 3 +--
lib/dpkg/t/t-varbuf.c | 3 +--
lib/dpkg/t/t-version.c | 3 +--
lib/dpkg/test.h | 35 +++++++++++++++++------------------
23 files changed, 42 insertions(+), 60 deletions(-)
diff --git a/debian/changelog b/debian/changelog
index 8b236b3..b4167d1 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -82,6 +82,10 @@ dpkg (1.18.11) UNRELEASED; urgency=medium
verify digests too. Prompted by Johannes Schauer <josch at debian.org>.
- Document the behavior for consecutive calls to Dpkg perl module parse()
methods. Prompted by Johannes Schauer <josch at debian.org>.
+ * Test suite:
+ - Make test main function a TEST_ENTRY macro. This avoids confusing
+ coverage programs, as the file that actually contains the main function
+ is the test itself.
* Build system:
- Add support for profiling perl modules.
- Clean up compiler and linker automatic flag usage in configure.
diff --git a/lib/dpkg/t/t-ar.c b/lib/dpkg/t/t-ar.c
index 82aa7b7..013e62a 100644
--- a/lib/dpkg/t/t-ar.c
+++ b/lib/dpkg/t/t-ar.c
@@ -50,8 +50,7 @@ test_ar_member_is_illegal(void)
test_fail(dpkg_ar_member_is_illegal(&arh));
}
-static void
-test(void)
+TEST_ENTRY(test)
{
test_plan(4);
diff --git a/lib/dpkg/t/t-arch.c b/lib/dpkg/t/t-arch.c
index 6078be4..55c6ea3 100644
--- a/lib/dpkg/t/t-arch.c
+++ b/lib/dpkg/t/t-arch.c
@@ -209,8 +209,7 @@ test_dpkg_arch_describe(void)
test_str(dpkg_arch_describe(arch), ==, ARCHITECTURE);
}
-void
-test(void)
+TEST_ENTRY(test)
{
test_plan(60);
diff --git a/lib/dpkg/t/t-buffer.c b/lib/dpkg/t/t-buffer.c
index 856ca0f..6aef1bb 100644
--- a/lib/dpkg/t/t-buffer.c
+++ b/lib/dpkg/t/t-buffer.c
@@ -71,8 +71,7 @@ test_fdio_hash(void)
test_pass(unlink(test_file) == 0);
}
-static void
-test(void)
+TEST_ENTRY(test)
{
test_plan(10);
diff --git a/lib/dpkg/t/t-c-ctype.c b/lib/dpkg/t/t-c-ctype.c
index 5e4bea1..2da0553 100644
--- a/lib/dpkg/t/t-c-ctype.c
+++ b/lib/dpkg/t/t-c-ctype.c
@@ -97,8 +97,7 @@ test_casing(void)
test_pass(c_tolower(-1) == -1);
}
-static void
-test(void)
+TEST_ENTRY(test)
{
test_plan(2063);
diff --git a/lib/dpkg/t/t-command.c b/lib/dpkg/t/t-command.c
index ebf2ab1..b59abd4 100644
--- a/lib/dpkg/t/t-command.c
+++ b/lib/dpkg/t/t-command.c
@@ -243,8 +243,7 @@ test_command_pager(void)
test_str(pager, ==, CAT);
}
-static void
-test(void)
+TEST_ENTRY(test)
{
test_plan(52);
diff --git a/lib/dpkg/t/t-deb-version.c b/lib/dpkg/t/t-deb-version.c
index 0fcc634..2e06907 100644
--- a/lib/dpkg/t/t-deb-version.c
+++ b/lib/dpkg/t/t-deb-version.c
@@ -62,8 +62,7 @@ test_deb_version_parse(void)
/* FIXME: Complete. */
}
-static void
-test(void)
+TEST_ENTRY(test)
{
test_plan(21);
diff --git a/lib/dpkg/t/t-error.c b/lib/dpkg/t/t-error.c
index e82ea47..5e2f55f 100644
--- a/lib/dpkg/t/t-error.c
+++ b/lib/dpkg/t/t-error.c
@@ -72,8 +72,7 @@ test_dpkg_error_destroy(void)
test_pass(err.str == NULL);
}
-static void
-test(void)
+TEST_ENTRY(test)
{
test_plan(19);
diff --git a/lib/dpkg/t/t-macros.c b/lib/dpkg/t/t-macros.c
index 78ef27c..9f4eaa1 100644
--- a/lib/dpkg/t/t-macros.c
+++ b/lib/dpkg/t/t-macros.c
@@ -24,8 +24,7 @@
#include <dpkg/test.h>
#include <dpkg/macros.h>
-static void
-test(void)
+TEST_ENTRY(test)
{
test_plan(12);
diff --git a/lib/dpkg/t/t-mod-db.c b/lib/dpkg/t/t-mod-db.c
index 92215b9..680dab5 100644
--- a/lib/dpkg/t/t-mod-db.c
+++ b/lib/dpkg/t/t-mod-db.c
@@ -49,8 +49,7 @@ test_db_dir(void)
free(dir);
}
-static void
-test(void)
+TEST_ENTRY(test)
{
test_plan(5);
diff --git a/lib/dpkg/t/t-path.c b/lib/dpkg/t/t-path.c
index 85262cb..deb1b72 100644
--- a/lib/dpkg/t/t-path.c
+++ b/lib/dpkg/t/t-path.c
@@ -169,8 +169,7 @@ test_path_quote(void)
free(dst);
}
-static void
-test(void)
+TEST_ENTRY(test)
{
test_plan(41);
diff --git a/lib/dpkg/t/t-pkg-list.c b/lib/dpkg/t/t-pkg-list.c
index c8c9a5f..722cf2e 100644
--- a/lib/dpkg/t/t-pkg-list.c
+++ b/lib/dpkg/t/t-pkg-list.c
@@ -81,8 +81,7 @@ test_pkg_list_prepend(void)
pkg_list_free(head);
}
-static void
-test(void)
+TEST_ENTRY(test)
{
test_plan(14);
diff --git a/lib/dpkg/t/t-pkg-queue.c b/lib/dpkg/t/t-pkg-queue.c
index da6a7f4..cf1e327 100644
--- a/lib/dpkg/t/t-pkg-queue.c
+++ b/lib/dpkg/t/t-pkg-queue.c
@@ -107,8 +107,7 @@ test_pkg_queue_push_pop(void)
pkg_queue_destroy(&q);
}
-static void
-test(void)
+TEST_ENTRY(test)
{
test_plan(38);
diff --git a/lib/dpkg/t/t-pkginfo.c b/lib/dpkg/t/t-pkginfo.c
index 079dd72..876af51 100644
--- a/lib/dpkg/t/t-pkginfo.c
+++ b/lib/dpkg/t/t-pkginfo.c
@@ -141,8 +141,7 @@ test_pkginfo_instance_tracking(void)
test_pass(pkgset_installed_instances(&set) == 0);
}
-static void
-test(void)
+TEST_ENTRY(test)
{
test_plan(28);
diff --git a/lib/dpkg/t/t-progname.c b/lib/dpkg/t/t-progname.c
index cd30697..af5e3ad 100644
--- a/lib/dpkg/t/t-progname.c
+++ b/lib/dpkg/t/t-progname.c
@@ -45,8 +45,7 @@ test_progname(void)
test_str(dpkg_get_progname(), ==, "newprogname");
}
-static void
-test(void)
+TEST_ENTRY(test)
{
test_plan(3);
diff --git a/lib/dpkg/t/t-string.c b/lib/dpkg/t/t-string.c
index b5e3308..038de84 100644
--- a/lib/dpkg/t/t-string.c
+++ b/lib/dpkg/t/t-string.c
@@ -195,8 +195,7 @@ test_str_strip_quotes(void)
test_str(str, ==, "completely quoted text");
}
-static void
-test(void)
+TEST_ENTRY(test)
{
test_plan(50);
diff --git a/lib/dpkg/t/t-subproc.c b/lib/dpkg/t/t-subproc.c
index 42651c4..7ce610b 100644
--- a/lib/dpkg/t/t-subproc.c
+++ b/lib/dpkg/t/t-subproc.c
@@ -84,8 +84,7 @@ test_subproc_fork(void)
test_pass(ret == -1);
}
-static void
-test(void)
+TEST_ENTRY(test)
{
int fd;
diff --git a/lib/dpkg/t/t-test-skip.c b/lib/dpkg/t/t-test-skip.c
index bcb2cad..972cdf1 100644
--- a/lib/dpkg/t/t-test-skip.c
+++ b/lib/dpkg/t/t-test-skip.c
@@ -23,8 +23,7 @@
#include <dpkg/test.h>
-static void
-test(void)
+TEST_ENTRY(test)
{
test_skip_all("ignore all tests");
diff --git a/lib/dpkg/t/t-test.c b/lib/dpkg/t/t-test.c
index b8a128e..62b35ce 100644
--- a/lib/dpkg/t/t-test.c
+++ b/lib/dpkg/t/t-test.c
@@ -23,8 +23,7 @@
#include <dpkg/test.h>
-static void
-test(void)
+TEST_ENTRY(test)
{
test_plan(20);
diff --git a/lib/dpkg/t/t-trigger.c b/lib/dpkg/t/t-trigger.c
index d99b4d9..af78f23 100644
--- a/lib/dpkg/t/t-trigger.c
+++ b/lib/dpkg/t/t-trigger.c
@@ -41,8 +41,7 @@ test_trig_name_is_illegal(void)
test_pass(trig_name_is_illegal("/file/trigger") == NULL);
}
-void
-test(void)
+TEST_ENTRY(test)
{
test_plan(9);
diff --git a/lib/dpkg/t/t-varbuf.c b/lib/dpkg/t/t-varbuf.c
index 7757eb7..3fb4444 100644
--- a/lib/dpkg/t/t-varbuf.c
+++ b/lib/dpkg/t/t-varbuf.c
@@ -348,8 +348,7 @@ test_varbuf_detach(void)
free(str);
}
-static void
-test(void)
+TEST_ENTRY(test)
{
test_plan(120);
diff --git a/lib/dpkg/t/t-version.c b/lib/dpkg/t/t-version.c
index 9de92f2..0d34527 100644
--- a/lib/dpkg/t/t-version.c
+++ b/lib/dpkg/t/t-version.c
@@ -285,8 +285,7 @@ test_version_parse(void)
/* FIXME: Complete. */
}
-static void
-test(void)
+TEST_ENTRY(test)
{
test_plan(190);
diff --git a/lib/dpkg/test.h b/lib/dpkg/test.h
index 83fca4b..39ecb96 100644
--- a/lib/dpkg/test.h
+++ b/lib/dpkg/test.h
@@ -25,8 +25,10 @@
#include <stdlib.h>
#include <stdio.h>
-#ifndef TEST_MAIN_PROVIDED
+#ifndef TEST_MAIN_CTOR
#include <dpkg/ehandle.h>
+#define TEST_MAIN_CTOR push_error_context()
+#define TEST_MAIN_DTOR pop_error_context(ehflag_normaltidy)
#endif
/**
@@ -121,22 +123,19 @@ static const char *test_skip_reason;
/** @} */
-#ifndef TEST_MAIN_PROVIDED
-static void test(void);
-
-int
-main(int argc, char **argv)
-{
- setvbuf(stdout, NULL, _IOLBF, 0);
-
- push_error_context();
-
- test();
-
- pop_error_context(ehflag_normaltidy);
-
- return 0;
-}
-#endif
+#define TEST_ENTRY(name) \
+static void name(void); \
+int \
+main(int argc, char **argv) \
+{ \
+ setvbuf(stdout, NULL, _IOLBF, 0); \
+ \
+ TEST_MAIN_CTOR; \
+ name(); \
+ TEST_MAIN_DTOR; \
+ return 0; \
+} \
+static void \
+name(void)
#endif
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/reproducible/dpkg.git
More information about the Reproducible-commits
mailing list