From c29b5f7da38c2ca2585e121d2f761fd76fc7af44 Mon Sep 17 00:00:00 2001 From: Christian Prochaska Date: Mon, 27 Feb 2012 15:42:08 +0100 Subject: [PATCH] Fix lx_hybrid_ctors test for Ubuntu 11.10 On Ubuntu 11.10 the host library created for the 'lx_hybrid_ctors' test doesn't get loaded, because the test object in the library is not being used by the application. This commit fixes the problem by having the application call a dummy function in the library. Fixes #120. --- base-linux/src/test/lx_hybrid_ctors/main.cc | 15 +++++++++++++- .../src/test/lx_hybrid_ctors/testlib.cc | 20 +++++++++++-------- base-linux/src/test/lx_hybrid_ctors/testlib.h | 18 +++++++++++++++++ 3 files changed, 44 insertions(+), 9 deletions(-) create mode 100644 base-linux/src/test/lx_hybrid_ctors/testlib.h diff --git a/base-linux/src/test/lx_hybrid_ctors/main.cc b/base-linux/src/test/lx_hybrid_ctors/main.cc index 927e5b2f9..4250df05f 100644 --- a/base-linux/src/test/lx_hybrid_ctors/main.cc +++ b/base-linux/src/test/lx_hybrid_ctors/main.cc @@ -14,6 +14,8 @@ #include +#include "testlib.h" + using namespace Genode; @@ -23,16 +25,27 @@ struct Testapp_testclass { Genode::printf("Global static constructor of Genode application called\n"); } + + void dummy() { } }; -Testapp_testclass testapp_testclass; +extern Testlib_testclass testlib_testobject; + +Testapp_testclass testapp_testobject; int main(int argc, char *argv[]) { printf("--- lx_hybrid global static constructor test ---\n"); + /* + * Call a dummy function on each test object to make sure that the + objects don't get optimized out. + */ + testlib_testobject.dummy(); + testapp_testobject.dummy(); + printf("--- returning from main ---\n"); return 0; diff --git a/base-linux/src/test/lx_hybrid_ctors/testlib.cc b/base-linux/src/test/lx_hybrid_ctors/testlib.cc index 1e579c231..2691fdaa2 100644 --- a/base-linux/src/test/lx_hybrid_ctors/testlib.cc +++ b/base-linux/src/test/lx_hybrid_ctors/testlib.cc @@ -13,12 +13,16 @@ #include -struct Testlib_testclass -{ - Testlib_testclass() - { - printf("[init -> test-lx_hybrid_ctors] Global static constructor of host library called.\n"); - } -}; +#include "testlib.h" -Testlib_testclass testlib_testclass; + +Testlib_testclass::Testlib_testclass() +{ + printf("[init -> test-lx_hybrid_ctors] Global static constructor of host library called.\n"); +} + + +void Testlib_testclass::dummy() { } + + +Testlib_testclass testlib_testobject; diff --git a/base-linux/src/test/lx_hybrid_ctors/testlib.h b/base-linux/src/test/lx_hybrid_ctors/testlib.h new file mode 100644 index 000000000..a0cce9028 --- /dev/null +++ b/base-linux/src/test/lx_hybrid_ctors/testlib.h @@ -0,0 +1,18 @@ +/* + * \brief Test if global static constructors in host shared libs get called + * \author Christian Prochaska + * \date 2011-11-24 + */ + +/* + * Copyright (C) 2011-2012 Genode Labs GmbH + * + * This file is part of the Genode OS framework, which is distributed + * under the terms of the GNU General Public License version 2. + */ + +struct Testlib_testclass +{ + Testlib_testclass(); + void dummy(); +};