From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([2001:4830:134:3::10]:53780) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XTvPj-0006St-SR for qemu-devel@nongnu.org; Tue, 16 Sep 2014 12:15:42 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1XTvPd-0004xR-Hh for qemu-devel@nongnu.org; Tue, 16 Sep 2014 12:15:35 -0400 Received: from mx1.redhat.com ([209.132.183.28]:6628) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1XTvPc-0004xE-Qy for qemu-devel@nongnu.org; Tue, 16 Sep 2014 12:15:29 -0400 Date: Tue, 16 Sep 2014 19:18:43 +0300 From: "Michael S. Tsirkin" Message-ID: <20140916161843.GA2437@redhat.com> References: <1410882204-9836-1-git-send-email-pbonzini@redhat.com> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <1410882204-9836-1-git-send-email-pbonzini@redhat.com> Subject: Re: [Qemu-devel] [RFC PATCH] tests: use g_test_trap_fork for glib between 2.16 and 2.38 List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: Paolo Bonzini Cc: peter.maydell@linaro.org, qemu-devel@nongnu.org, ehabkost@redhat.com On Tue, Sep 16, 2014 at 05:43:24PM +0200, Paolo Bonzini wrote: > Glib recently introduced a robust way to run tests in a subprocess, > which is used in test-qdev-global-props. However, we would like > to have the same tests run with older versions of glib, and the > older fork-based mechanisms works well enough. > > This still requires: > > - bumping the minimum required version from 2.12 to 2.16. I suggest > bumping to the currently required version for Windows, which is 2.20 > (released March 2009). > > - disabling the test on Windows, since it does not have fork Right but it could work on windows if glib is new enough? Why disable there? > Signed-off-by: Paolo Bonzini > --- > tests/Makefile | 2 +- > tests/test-qdev-global-props.c | 63 +++++++++++++++++++++++++++--------------- > 2 files changed, 41 insertions(+), 24 deletions(-) > > diff --git a/tests/Makefile b/tests/Makefile > index d5db97b..7f125e8 100644 > --- a/tests/Makefile > +++ b/tests/Makefile > @@ -58,7 +58,7 @@ check-unit-y += tests/test-int128$(EXESUF) > # all code tested by test-int128 is inside int128.h > gcov-files-test-int128-y = > check-unit-y += tests/test-bitops$(EXESUF) > -check-unit-y += tests/test-qdev-global-props$(EXESUF) > +check-unit-$(CONFIG_POSIX) += tests/test-qdev-global-props$(EXESUF) > check-unit-y += tests/check-qom-interface$(EXESUF) > gcov-files-check-qom-interface-y = qom/object.c > check-unit-$(CONFIG_POSIX) += tests/test-vmstate$(EXESUF) > diff --git a/tests/test-qdev-global-props.c b/tests/test-qdev-global-props.c > index 0be9835..8e4b270 100644 > --- a/tests/test-qdev-global-props.c > +++ b/tests/test-qdev-global-props.c > @@ -29,6 +29,27 @@ > #include "qom/object.h" > #include "qapi/visitor.h" > > +/* Use the older fork() mechanism if the newer, more robust subprocess tests > + * are not available. > + */ > +#if GLIB_CHECK_VERSION(2, 38, 0) > +# define TEST_ADD_FUNC_SUBPROCESS(name, func) do { \ > + g_test_add_func(name "/subprocess", func##_subprocess); \ > + g_test_add_func(name, func); \ > + } while (0) > +# define TEST_TRAP_SUBPROCESS(name, func) \ > + g_test_trap_subprocess(name, 0, 0) > +#else > +# define TEST_ADD_FUNC_SUBPROCESS(name, func) \ > + g_test_add_func(name, func) > +# define TEST_TRAP_SUBPROCESS(name, func) do { \ > + if (g_test_trap_fork (0, G_TEST_TRAP_SILENCE_STDOUT | G_TEST_TRAP_SILENCE_STDERR)) { \ > + func(); \ > + exit(0); \ > + } \ > + } while(0) > +#endif > + > two empty lines. > #define TYPE_STATIC_PROPS "static_prop_type" > #define STATIC_TYPE(obj) \ > @@ -77,7 +98,8 @@ static void test_static_prop_subprocess(void) > > static void test_static_prop(void) > { > - g_test_trap_subprocess("/qdev/properties/static/default/subprocess", 0, 0); > + TEST_TRAP_SUBPROCESS("/qdev/properties/static/default/subprocess", > + test_static_prop_subprocess); > g_test_trap_assert_passed(); > g_test_trap_assert_stderr(""); > g_test_trap_assert_stdout(""); > @@ -103,7 +125,8 @@ static void test_static_globalprop_subprocess(void) > > static void test_static_globalprop(void) > { > - g_test_trap_subprocess("/qdev/properties/static/global/subprocess", 0, 0); > + TEST_TRAP_SUBPROCESS("/qdev/properties/static/global/subprocess", > + test_static_globalprop_subprocess); > g_test_trap_assert_passed(); > g_test_trap_assert_stderr(""); > g_test_trap_assert_stdout(""); > @@ -235,7 +258,8 @@ static void test_dynamic_globalprop_subprocess(void) > > static void test_dynamic_globalprop(void) > { > - g_test_trap_subprocess("/qdev/properties/dynamic/global/subprocess", 0, 0); > + TEST_TRAP_SUBPROCESS("/qdev/properties/dynamic/global/subprocess", > + test_dynamic_globalprop_subprocess); > g_test_trap_assert_passed(); > g_test_trap_assert_stderr_unmatched("*prop1*"); > g_test_trap_assert_stderr_unmatched("*prop2*"); > @@ -280,7 +304,8 @@ static void test_dynamic_globalprop_nouser_subprocess(void) > > static void test_dynamic_globalprop_nouser(void) > { > - g_test_trap_subprocess("/qdev/properties/dynamic/global/nouser/subprocess", 0, 0); > + TEST_TRAP_SUBPROCESS("/qdev/properties/dynamic/global/nouser/subprocess", > + test_dynamic_globalprop_nouser_subprocess); > g_test_trap_assert_passed(); > g_test_trap_assert_stderr(""); > g_test_trap_assert_stdout(""); > @@ -297,25 +322,17 @@ int main(int argc, char **argv) > type_register_static(&nohotplug_type); > type_register_static(&nondevice_type); > > - g_test_add_func("/qdev/properties/static/default/subprocess", > - test_static_prop_subprocess); > - g_test_add_func("/qdev/properties/static/default", > - test_static_prop); > - > - g_test_add_func("/qdev/properties/static/global/subprocess", > - test_static_globalprop_subprocess); > - g_test_add_func("/qdev/properties/static/global", > - test_static_globalprop); > - > - g_test_add_func("/qdev/properties/dynamic/global/subprocess", > - test_dynamic_globalprop_subprocess); > - g_test_add_func("/qdev/properties/dynamic/global", > - test_dynamic_globalprop); > - > - g_test_add_func("/qdev/properties/dynamic/global/nouser/subprocess", > - test_dynamic_globalprop_nouser_subprocess); > - g_test_add_func("/qdev/properties/dynamic/global/nouser", > - test_dynamic_globalprop_nouser); > + TEST_ADD_FUNC_SUBPROCESS("/qdev/properties/static/default", > + test_static_prop); > + > + TEST_ADD_FUNC_SUBPROCESS("/qdev/properties/static/global", > + test_static_globalprop); > + > + TEST_ADD_FUNC_SUBPROCESS("/qdev/properties/dynamic/global", > + test_dynamic_globalprop); > + > + TEST_ADD_FUNC_SUBPROCESS("/qdev/properties/dynamic/global/nouser", > + test_dynamic_globalprop_nouser); > > g_test_run(); > > -- > 2.1.0