Author: tfaber
Date: Sat Nov 21 12:04:36 2015
New Revision: 69991
URL:
http://svn.reactos.org/svn/reactos?rev=69991&view=rev
Log:
[CRT_APITEST]
- Add tests for static initialization and static constructors
CORE-10562
Added:
trunk/rostests/apitests/crt/static_construct.cpp (with props)
trunk/rostests/apitests/crt/static_init.c (with props)
Modified:
trunk/rostests/apitests/crt/msvcrt_crt_apitest.cmake
trunk/rostests/apitests/crt/testlist.c
Modified: trunk/rostests/apitests/crt/msvcrt_crt_apitest.cmake
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/crt/msvcrt_crt_a…
==============================================================================
--- trunk/rostests/apitests/crt/msvcrt_crt_apitest.cmake [iso-8859-1] (original)
+++ trunk/rostests/apitests/crt/msvcrt_crt_apitest.cmake [iso-8859-1] Sat Nov 21 12:04:36
2015
@@ -1261,6 +1261,8 @@
# wprintf_s.c
# wscanf.c
# wscanf_s.c
+ static_construct.cpp
+ static_init.c
)
if(ARCH STREQUAL "i386")
Added: trunk/rostests/apitests/crt/static_construct.cpp
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/crt/static_const…
==============================================================================
--- trunk/rostests/apitests/crt/static_construct.cpp (added)
+++ trunk/rostests/apitests/crt/static_construct.cpp [iso-8859-1] Sat Nov 21 12:04:36
2015
@@ -0,0 +1,42 @@
+/*
+ * PROJECT: ReactOS api tests
+ * LICENSE: LGPLv2.1+ - See COPYING.LIB in the top level directory
+ * PURPOSE: Test for static C++ object construction
+ * PROGRAMMER: Thomas Faber <thomas.faber(a)reactos.org>
+ */
+
+#include <apitest.h>
+
+extern "C"
+{
+extern int static_init_counter;
+
+static int static_init_counter_at_startup;
+static int static_construct_counter_at_startup;
+
+int static_construct_counter = 789;
+}
+
+struct init_static
+{
+ int m_counter;
+
+ init_static() :
+ m_counter(2)
+ {
+ static_init_counter_at_startup = static_init_counter;
+ static_construct_counter_at_startup = static_construct_counter;
+ static_construct_counter++;
+ }
+} init_static;
+
+START_TEST(static_construct)
+{
+ ok(static_init_counter_at_startup == 123, "static_init_counter at startup:
%d\n", static_init_counter_at_startup);
+ ok(static_construct_counter_at_startup == 789, "static_construct_counter at
startup: %d\n", static_construct_counter_at_startup);
+
+ ok(static_init_counter == 123, "static_init_counter: %d\n",
static_init_counter);
+
+ ok(static_construct_counter == 790, "static_construct_counter: %d\n",
static_construct_counter);
+ ok(init_static.m_counter == 2, "init_static.m_counter: %d\n",
init_static.m_counter);
+}
Propchange: trunk/rostests/apitests/crt/static_construct.cpp
------------------------------------------------------------------------------
svn:eol-style = native
Added: trunk/rostests/apitests/crt/static_init.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/crt/static_init.…
==============================================================================
--- trunk/rostests/apitests/crt/static_init.c (added)
+++ trunk/rostests/apitests/crt/static_init.c [iso-8859-1] Sat Nov 21 12:04:36 2015
@@ -0,0 +1,18 @@
+/*
+ * PROJECT: ReactOS api tests
+ * LICENSE: LGPLv2.1+ - See COPYING.LIB in the top level directory
+ * PURPOSE: Test for static variable initialization
+ * PROGRAMMER: Thomas Faber <thomas.faber(a)reactos.org>
+ */
+
+#include <apitest.h>
+
+extern int static_construct_counter;
+
+int static_init_counter = 123;
+
+START_TEST(static_init)
+{
+ ok(static_init_counter == 123, "static_init_counter: %d\n",
static_init_counter);
+ ok(static_construct_counter == 790, "static_construct_counter: %d\n",
static_construct_counter);
+}
Propchange: trunk/rostests/apitests/crt/static_init.c
------------------------------------------------------------------------------
svn:eol-style = native
Modified: trunk/rostests/apitests/crt/testlist.c
URL:
http://svn.reactos.org/svn/reactos/trunk/rostests/apitests/crt/testlist.c?r…
==============================================================================
--- trunk/rostests/apitests/crt/testlist.c [iso-8859-1] (original)
+++ trunk/rostests/apitests/crt/testlist.c [iso-8859-1] Sat Nov 21 12:04:36 2015
@@ -17,6 +17,9 @@
extern void func_strcpy(void);
extern void func_wcstombs(void);
+extern void func_static_construct(void);
+extern void func_static_init(void);
+
const struct test winetest_testlist[] =
{
{ "_vsnprintf", func__vsnprintf },
@@ -35,6 +38,9 @@
#elif defined(TEST_MSVCRT)
{ "_vscprintf", func__vscprintf },
{ "_vscwprintf", func__vscwprintf },
+
+ { "static_construct", func_static_construct },
+ { "static_init", func_static_init },
#elif defined(TEST_NTDLL)
{ "_vscwprintf", func__vscwprintf },
#elif defined(TEST_CRTDLL)