From f8846a45878faa9eb51fab3a2b347e9a36ecd250 Mon Sep 17 00:00:00 2001 From: Dmitriy Ivanov Date: Tue, 8 Jul 2014 21:21:34 -0700 Subject: [PATCH] Add test for constructor function. Change-Id: I0ad26d617f00cdd6c2241d613be39a1d16918612 --- tests/dlfcn_test.cpp | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tests/dlfcn_test.cpp b/tests/dlfcn_test.cpp index a79263da5..f056fb692 100644 --- a/tests/dlfcn_test.cpp +++ b/tests/dlfcn_test.cpp @@ -32,6 +32,18 @@ extern "C" void DlSymTestFunction() { g_called = true; } +static int g_ctor_function_called = 0; + +extern "C" void ctor_function() __attribute__ ((constructor)); + +extern "C" void ctor_function() { + g_ctor_function_called = 17; +} + +TEST(dlfcn, ctor_function_call) { + ASSERT_EQ(17, g_ctor_function_called); +} + TEST(dlfcn, dlsym_in_self) { dlerror(); // Clear any pending errors. void* self = dlopen(NULL, RTLD_NOW);