diff --git a/reactos/lib/kernel32/include/kernel32.h b/reactos/lib/kernel32/include/kernel32.h
index d52b3498c0c..84b4a007685 100755
--- a/reactos/lib/kernel32/include/kernel32.h
+++ b/reactos/lib/kernel32/include/kernel32.h
@@ -66,9 +66,8 @@ PWCHAR FilenameA2W(LPCSTR NameA, BOOL alloc);
DWORD FilenameW2A_FitOrFail(LPSTR DestA, INT destLen, LPCWSTR SourceW, INT sourceLen);
DWORD FilenameU2A_FitOrFail(LPSTR DestA, INT destLen, PUNICODE_STRING SourceU);
-
-
-
+#define HeapAlloc RtlAllocateHeap
+#define HeapFree RtlFreeHeap
#endif /* ndef _KERNEL32_INCLUDE_KERNEL32_H */
diff --git a/reactos/lib/kernel32/kernel32.xml b/reactos/lib/kernel32/kernel32.xml
index d62f7119a69..12a17f1ffb3 100644
--- a/reactos/lib/kernel32/kernel32.xml
+++ b/reactos/lib/kernel32/kernel32.xml
@@ -1,19 +1,3 @@
-
-
- .
- include
-
-
- 0x0500
- kernel32_base
- pseh
- rosrtl
- ntdll
- -lgcc
- -nostartfiles
- -nostdlib
- kernel32.rc
-
.
include
@@ -120,8 +104,22 @@
tls.c
-
\ No newline at end of file
diff --git a/reactos/lib/kernel32/mem/heap.c b/reactos/lib/kernel32/mem/heap.c
index b239e4d79f7..9fb0afd9321 100644
--- a/reactos/lib/kernel32/mem/heap.c
+++ b/reactos/lib/kernel32/mem/heap.c
@@ -32,17 +32,6 @@
#define NDEBUG
#include "../include/debug.h"
-PVOID WINAPI HeapAlloc(HANDLE hHeap, DWORD dwFlags, DWORD dwBytes)
-{
- return RtlAllocateHeap(hHeap, dwFlags, dwBytes);
-}
-
-BOOL WINAPI HeapFree(HANDLE hHeap, DWORD dwFlags, LPVOID lpMem)
-{
- return RtlFreeHeap(hHeap, dwFlags, lpMem);
-}
-
-
/*********************************************************************
* HeapCreate -- KERNEL32 *
*********************************************************************/
diff --git a/reactos/lib/kernel32/tests/Makefile b/reactos/lib/kernel32/tests/Makefile
index eb71025309c..9813c96fe30 100644
--- a/reactos/lib/kernel32/tests/Makefile
+++ b/reactos/lib/kernel32/tests/Makefile
@@ -1,23 +1,5 @@
-# $Id$
+# This file is automatically generated.
-PATH_TO_TOP = ../../..
-
-TARGET_TYPE = test
-
-TARGET_NAME = regtests
-
-TARGET_LIBPATH = .
-
-TARGET_CFLAGS = -I$(REGTESTS_PATH_INC)
-
-TARGET_LIBS = ../kernel32.a
-
--include Makefile.tests
-
-TARGET_OBJECTS = \
- setup.o \
- $(addprefix tests/, $(TESTS))
-
-include $(PATH_TO_TOP)/rules.mak
-
-include $(TOOLS_PATH)/helper.mk
+TOP = ..\..\..
+DEFAULT = kernel32_test
+include $(TOP)/proxy.mak
diff --git a/reactos/lib/kernel32/tests/kernel32.xml b/reactos/lib/kernel32/tests/kernel32.xml
index de5e5e61d45..0478b0fef8b 100644
--- a/reactos/lib/kernel32/tests/kernel32.xml
+++ b/reactos/lib/kernel32/tests/kernel32.xml
@@ -3,11 +3,13 @@
0x0500
+ rtshared
+ regtests
kernel32_base
pseh
rosrtl
ntdll
- rtshared
+ msvcrt
-lgcc
-nostartfiles
-nostdlib
diff --git a/reactos/lib/kernel32/tests/stubs.xml b/reactos/lib/kernel32/tests/stubs.xml
index 80b5566eb51..03088d46b6c 100644
--- a/reactos/lib/kernel32/tests/stubs.xml
+++ b/reactos/lib/kernel32/tests/stubs.xml
@@ -8,7 +8,6 @@
HeapFree@12
LdrAccessResource@16
LdrDisableThreadCalloutsForDll@4
- LdrDisableThreadCalloutsForDll@4
LdrFindResource_U@16
LdrLoadDll@16
LdrShutdownProcess@0
diff --git a/reactos/regtests/regtests/regtests.def b/reactos/regtests/regtests/regtests.def
index 652c3d3423b..79fbd224312 100644
--- a/reactos/regtests/regtests/regtests.def
+++ b/reactos/regtests/regtests/regtests.def
@@ -7,4 +7,3 @@ _LoadLibraryA@4
_CreateThread@24
_TerminateThread@8
_WaitForSingleObject@8
-
diff --git a/reactos/regtests/shared/regtests.c b/reactos/regtests/shared/regtests.c
index 24528575db2..1729cae064c 100755
--- a/reactos/regtests/shared/regtests.c
+++ b/reactos/regtests/shared/regtests.c
@@ -60,11 +60,11 @@ PerformTest(PVOID _arg)
if (_Result != TS_OK)
{
- sprintf(OutputBuffer, "ROSREGTEST: |%s| Status: Failed (%s)\n", TestName, Buffer);
+ sprintf(OutputBuffer, "[%s] Failed (%s)\n", TestName, Buffer);
}
else
{
- sprintf(OutputBuffer, "ROSREGTEST: |%s| Status: Success\n", TestName);
+ sprintf(OutputBuffer, "[%s] Success\n", TestName);
}
if (OutputRoutine != NULL)
{
@@ -137,7 +137,7 @@ PerformTests(TestOutputRoutine OutputRoutine, LPSTR TestName)
if (hThread == NULL)
{
sprintf(OutputBuffer,
- "ROSREGTEST: |%s| Status: Failed (CreateThread failed: 0x%x)\n",
+ "[%s] Failed (CreateThread failed: 0x%x)\n",
Name, (unsigned int)GetLastError());
}
else if (_WaitForSingleObject(hThread, TimeOut) == WAIT_TIMEOUT)
@@ -145,12 +145,12 @@ PerformTests(TestOutputRoutine OutputRoutine, LPSTR TestName)
if (!_TerminateThread(hThread, 0))
{
sprintf(OutputBuffer,
- "ROSREGTEST: |%s| Status: Failed (Test timed out - %d ms, TerminateThread failed: 0x%x)\n",
+ "[%s] Failed (Test timed out - %d ms, TerminateThread failed: 0x%x)\n",
Name, (int)TimeOut, (unsigned int)GetLastError());
}
else
{
- sprintf(OutputBuffer, "ROSREGTEST: |%s| Status: Failed (Test timed out - %d ms)\n", Name, (int)TimeOut);
+ sprintf(OutputBuffer, "[%s] Failed (Test timed out - %d ms)\n", Name, (int)TimeOut);
}
}
else
diff --git a/reactos/tools/rbuild/backend/mingw/mingw.cpp b/reactos/tools/rbuild/backend/mingw/mingw.cpp
index 63cbcdf3ec9..11e022f56ec 100644
--- a/reactos/tools/rbuild/backend/mingw/mingw.cpp
+++ b/reactos/tools/rbuild/backend/mingw/mingw.cpp
@@ -280,6 +280,7 @@ MingwBackend::ProcessModules ()
GenerateAllTarget ( v );
GenerateInitTarget ();
+ GenerateRegTestsRunTarget ();
for ( i = 0; i < iend; i++ )
v[i]->GenerateOtherMacros();
@@ -558,6 +559,18 @@ MingwBackend::GenerateInitTarget () const
fprintf ( fMakefile, "\n" );
}
+void
+MingwBackend::GenerateRegTestsRunTarget () const
+{
+ fprintf ( fMakefile,
+ "REGTESTS_RUN_TARGET = regtests.dll\n" );
+ fprintf ( fMakefile,
+ "$(REGTESTS_RUN_TARGET):\n" );
+ fprintf ( fMakefile,
+ "\t$(cp) $(REGTESTS_TARGET) $(REGTESTS_RUN_TARGET)\n" );
+ fprintf ( fMakefile, "\n" );
+}
+
void
MingwBackend::GenerateXmlBuildFilesMacro() const
{
diff --git a/reactos/tools/rbuild/backend/mingw/mingw.h b/reactos/tools/rbuild/backend/mingw/mingw.h
index bcc5f5f8fd7..88380d76d5d 100644
--- a/reactos/tools/rbuild/backend/mingw/mingw.h
+++ b/reactos/tools/rbuild/backend/mingw/mingw.h
@@ -77,6 +77,7 @@ private:
void GenerateAllTarget ( const std::vector& handlers ) const;
std::string GetBuildToolDependencies () const;
void GenerateInitTarget () const;
+ void GenerateRegTestsRunTarget () const;
void GenerateXmlBuildFilesMacro() const;
std::string GetBin2ResExecutable ();
void UnpackWineResources ();
diff --git a/reactos/tools/rbuild/backend/mingw/modulehandler.cpp b/reactos/tools/rbuild/backend/mingw/modulehandler.cpp
index 36923a97546..d175c28082e 100644
--- a/reactos/tools/rbuild/backend/mingw/modulehandler.cpp
+++ b/reactos/tools/rbuild/backend/mingw/modulehandler.cpp
@@ -349,16 +349,15 @@ MingwModuleHandler::GetModuleDependencies (
}
void
-MingwModuleHandler::GetSourceFilenames (
- string_list& list,
- bool includeGeneratedFiles ) const
+MingwModuleHandler::GetSourceFilenames ( string_list& list,
+ bool includeGeneratedFiles ) const
{
size_t i;
const vector& files = module.non_if_data.files;
for ( i = 0; i < files.size (); i++ )
{
- if ( includeGeneratedFiles || !IsGeneratedFile ( *files[i] ) )
+ if ( includeGeneratedFiles || !files[i]->IsGeneratedFile () )
{
list.push_back (
GetActualSourceFilename ( files[i]->name ) );
@@ -379,7 +378,7 @@ MingwModuleHandler::GetSourceFilenames (
for ( j = 0; j < files.size (); j++ )
{
File& file = *files[j];
- if ( includeGeneratedFiles || !IsGeneratedFile ( file ) )
+ if ( includeGeneratedFiles || !file.IsGeneratedFile () )
{
list.push_back (
GetActualSourceFilename ( file.name ) );
@@ -736,6 +735,18 @@ MingwModuleHandler::GenerateMacros (
}
}
+void
+MingwModuleHandler::CleanupFileVector ( vector& sourceFiles )
+{
+ for (size_t i = 0; i < sourceFiles.size (); i++)
+ delete sourceFiles[i];
+}
+
+void
+MingwModuleHandler::GetModuleSpecificSourceFiles ( vector& sourceFiles )
+{
+}
+
void
MingwModuleHandler::GenerateObjectMacros (
const char* assignmentOperation,
@@ -806,6 +817,19 @@ MingwModuleHandler::GenerateObjectMacros (
"endif\n\n" );
}
}
+
+ vector sourceFiles;
+ GetModuleSpecificSourceFiles ( sourceFiles );
+ for ( i = 0; i < sourceFiles.size (); i++ )
+ {
+ fprintf (
+ fMakefile,
+ "%s += %s\n",
+ objectsMacro.c_str(),
+ GetObjectFilename (
+ sourceFiles[i]->name, NULL ).c_str () );
+ }
+ CleanupFileVector ( sourceFiles );
}
void
@@ -1362,12 +1386,13 @@ MingwModuleHandler::GenerateLinkerCommand (
void
MingwModuleHandler::GeneratePhonyTarget() const
{
- string targetMacro ( GetTargetMacro(module) );
- fprintf ( fMakefile, ".PHONY: %s\n\n",
+ string targetMacro ( GetTargetMacro ( module ) );
+ fprintf ( fMakefile,
+ ".PHONY: %s\n\n",
targetMacro.c_str ());
fprintf ( fMakefile, "%s: | %s\n",
targetMacro.c_str (),
- GetDirectory(GetTargetFilename(module,NULL)).c_str () );
+ GetDirectory ( GetTargetFilename ( module, NULL ) ).c_str () );
}
void
@@ -1407,6 +1432,20 @@ MingwModuleHandler::GenerateObjectFileTargets (
windresflagsMacro,
widlflagsMacro );
}
+
+ vector sourceFiles;
+ GetModuleSpecificSourceFiles ( sourceFiles );
+ for ( i = 0; i < sourceFiles.size (); i++ )
+ {
+ GenerateCommands ( *sourceFiles[i],
+ cc,
+ cppc,
+ cflagsMacro,
+ nasmflagsMacro,
+ windresflagsMacro,
+ widlflagsMacro );
+ }
+ CleanupFileVector ( sourceFiles );
}
void
@@ -1665,25 +1704,32 @@ MingwModuleHandler::GenerateRules ()
// generate phony target for module name
fprintf ( fMakefile, ".PHONY: %s\n",
module.name.c_str () );
+ string dependencies = GetTargetMacro ( module );
+ if ( module.type == Test )
+ dependencies += " $(REGTESTS_RUN_TARGET)";
fprintf ( fMakefile, "%s: %s\n\n",
module.name.c_str (),
- GetTargetMacro ( module ).c_str () );
+ dependencies.c_str () );
+ if ( module.type == Test )
+ {
+ fprintf ( fMakefile,
+ "\t%s\n",
+ targetMacro.c_str ());
+ }
if ( !ReferenceObjects ( module ) )
{
string ar_target ( GenerateArchiveTarget ( ar, objectsMacro ) );
if ( targetMacro != ar_target )
- {
CLEAN_FILE ( ar_target );
- }
}
GenerateObjectFileTargets ( cc,
- cppc,
- cflagsMacro,
- nasmflagsMacro,
- windresflagsMacro,
- widlflagsMacro );
+ cppc,
+ cflagsMacro,
+ nasmflagsMacro,
+ windresflagsMacro,
+ widlflagsMacro );
}
void
@@ -2829,6 +2875,15 @@ MingwTestModuleHandler::Process ()
GenerateTestModuleTarget ();
}
+void
+MingwTestModuleHandler::GetModuleSpecificSourceFiles ( vector& sourceFiles )
+{
+ string basePath = "$(INTERMEDIATE)" SSEP + module.GetBasePath ();
+ sourceFiles.push_back ( new File ( basePath + SSEP "_hooks.c", false, "" ) );
+ sourceFiles.push_back ( new File ( basePath + SSEP "_stubs.S", false, "" ) );
+ sourceFiles.push_back ( new File ( basePath + SSEP "_startup.c", false, "" ) );
+}
+
void
MingwTestModuleHandler::GenerateTestModuleTarget ()
{
diff --git a/reactos/tools/rbuild/backend/mingw/modulehandler.h b/reactos/tools/rbuild/backend/mingw/modulehandler.h
index 02739d11026..1cdcb0e9212 100644
--- a/reactos/tools/rbuild/backend/mingw/modulehandler.h
+++ b/reactos/tools/rbuild/backend/mingw/modulehandler.h
@@ -63,6 +63,7 @@ public:
void GenerateInstallTarget () const;
static bool ReferenceObjects ( const Module& module );
protected:
+ virtual void GetModuleSpecificSourceFiles ( std::vector& sourceFiles );
std::string GetWorkingDirectory () const;
std::string GetBasename ( const std::string& filename ) const;
std::string GetActualSourceFilename ( const std::string& filename ) const;
@@ -73,7 +74,8 @@ protected:
string_list& targets );
void GetModuleDependencies ( string_list& dependencies );
std::string GetAllDependencies () const;
- void GetSourceFilenames ( string_list& list, bool includeGeneratedFiles = true ) const;
+ void GetSourceFilenames ( string_list& list,
+ bool includeGeneratedFiles ) const;
void GetSourceFilenamesWithoutGeneratedFiles ( string_list& list ) const;
std::string GetObjectFilename ( const std::string& sourceFilename,
string_list* pclean_files ) const;
@@ -174,6 +176,7 @@ private:
static std::string RemoveVariables ( std::string path);
void GenerateBuildMapCode ();
void GenerateBuildNonSymbolStrippedCode ();
+ void CleanupFileVector ( std::vector& sourceFiles );
public:
const Module& module;
string_list clean_files;
@@ -389,6 +392,8 @@ public:
MingwTestModuleHandler ( const Module& module );
virtual HostType DefaultHost() { return HostFalse; }
virtual void Process ();
+protected:
+ virtual void GetModuleSpecificSourceFiles ( std::vector& sourceFiles );
private:
void GenerateTestModuleTarget ();
};
diff --git a/reactos/tools/rbuild/module.cpp b/reactos/tools/rbuild/module.cpp
index 3168e657507..94c5dc069fd 100644
--- a/reactos/tools/rbuild/module.cpp
+++ b/reactos/tools/rbuild/module.cpp
@@ -78,6 +78,16 @@ GetDirectory ( const string& filename )
return filename.substr ( 0, index );
}
+string
+GetFilename ( const string& filename )
+{
+ size_t index = filename.find_last_of ( CSEP );
+ if ( index == string::npos )
+ return filename;
+ else
+ return filename.substr ( index + 1, filename.length () - index );
+}
+
string
NormalizeFilename ( const string& filename )
{
@@ -731,6 +741,13 @@ File::ProcessXML()
{
}
+bool
+File::IsGeneratedFile () const
+{
+ string extension = GetExtension ( name );
+ return ( extension == ".spec" || extension == ".SPEC" );
+}
+
Library::Library ( const XMLElement& _node,
const Module& _module,
diff --git a/reactos/tools/rbuild/rbuild.h b/reactos/tools/rbuild/rbuild.h
index 8192e8fe1cb..c8330ee4372 100644
--- a/reactos/tools/rbuild/rbuild.h
+++ b/reactos/tools/rbuild/rbuild.h
@@ -218,6 +218,8 @@ public:
bool HasFileWithExtension ( const IfableData&, const std::string& extension ) const;
void InvokeModule () const;
void ProcessXML ();
+ void GetSourceFilenames ( string_list& list,
+ bool includeGeneratedFiles ) const;
private:
std::string GetDefaultModuleExtension () const;
std::string GetDefaultModuleEntrypoint () const;
@@ -282,6 +284,7 @@ public:
std::string _switches );
void ProcessXML();
+ bool IsGeneratedFile () const;
};
@@ -468,6 +471,16 @@ private:
const StubbedComponent& component,
int* stubIndex );
void WriteStubsFile ( Module& module );
+ std::string GetStartupFilename ( Module& module );
+ std::string GetTestDispatcherName ( std::string filename );
+ bool IsTestFile ( std::string& filename ) const;
+ void GetSourceFilenames ( string_list& list,
+ Module& module ) const;
+ char* WriteTestDispatcherPrototypesToStartupFile ( char* buffer,
+ Module& module );
+ char* WriteRegisterTestsFunctionToStartupFile ( char* buffer,
+ Module& module );
+ void WriteStartupFile ( Module& module );
};
@@ -688,6 +701,9 @@ GetExtension ( const std::string& filename );
extern std::string
GetDirectory ( const std::string& filename );
+extern std::string
+GetFilename ( const std::string& filename );
+
extern std::string
NormalizeFilename ( const std::string& filename );
diff --git a/reactos/tools/rbuild/tests/functiontest.cpp b/reactos/tools/rbuild/tests/functiontest.cpp
index 571d4c7c805..411e559338c 100644
--- a/reactos/tools/rbuild/tests/functiontest.cpp
+++ b/reactos/tools/rbuild/tests/functiontest.cpp
@@ -6,4 +6,6 @@ void FunctionTest::Run ()
{
string fixedupFilename = NormalizeFilename ( "." SSEP "dir1" SSEP "dir2" SSEP ".." SSEP "filename.txt" );
ARE_EQUAL ( "dir1" SSEP "filename.txt", fixedupFilename );
+ ARE_EQUAL ( "file.txt", GetFilename ( "file.txt" ) );
+ ARE_EQUAL ( "file.txt", GetFilename ( "dir" SSEP "file.txt" ) );
}
diff --git a/reactos/tools/rbuild/testsupportcode.cpp b/reactos/tools/rbuild/testsupportcode.cpp
index 4c1860a4d94..8569ebfc1ba 100644
--- a/reactos/tools/rbuild/testsupportcode.cpp
+++ b/reactos/tools/rbuild/testsupportcode.cpp
@@ -46,6 +46,7 @@ TestSupportCode::GenerateTestSupportCodeForModule ( Module& module,
WriteHooksFile ( module );
WriteStubsFile ( module );
+ WriteStartupFile ( module );
}
string
@@ -188,3 +189,160 @@ TestSupportCode::WriteStubsFile ( Module& module )
free ( buf );
}
+
+string
+TestSupportCode::GetStartupFilename ( Module& module )
+{
+ return NormalizeFilename ( Environment::GetIntermediatePath () + SSEP + module.GetBasePath () + SSEP + "_startup.c" );
+}
+
+string
+TestSupportCode::GetTestDispatcherName ( string filename )
+{
+ string filenamePart = ReplaceExtension ( GetFilename ( filename ), "" );
+ if ( filenamePart.length () > 0 )
+ filenamePart[0] = toupper ( filenamePart[0] );
+ for ( size_t i = 1; i < filenamePart.length (); i++ )
+ {
+ filenamePart[i] = tolower ( filenamePart[i] );
+ }
+ return filenamePart + "Test";
+}
+
+bool
+TestSupportCode::IsTestFile ( string& filename ) const
+{
+ if ( stricmp ( GetFilename ( filename ).c_str (), "setup.c" ) == 0 )
+ return false;
+ return true;
+}
+
+void
+TestSupportCode::GetSourceFilenames ( string_list& list,
+ Module& module ) const
+{
+ size_t i;
+
+ const vector& files = module.non_if_data.files;
+ for ( i = 0; i < files.size (); i++ )
+ {
+ if ( !files[i]->IsGeneratedFile () && IsTestFile ( files[i]->name ) )
+ list.push_back ( files[i]->name );
+ }
+ // intentionally make a copy so that we can append more work in
+ // the middle of processing without having to go recursive
+ vector v = module.non_if_data.ifs;
+ for ( i = 0; i < v.size (); i++ )
+ {
+ size_t j;
+ If& rIf = *v[i];
+ // check for sub-ifs to add to list
+ const vector& ifs = rIf.data.ifs;
+ for ( j = 0; j < ifs.size (); j++ )
+ v.push_back ( ifs[j] );
+ const vector& files = rIf.data.files;
+ for ( j = 0; j < files.size (); j++ )
+ {
+ File& file = *files[j];
+ if ( !file.IsGeneratedFile () && IsTestFile ( file.name ) )
+ {
+ list.push_back ( file.name );
+ }
+ }
+ }
+}
+
+char*
+TestSupportCode::WriteTestDispatcherPrototypesToStartupFile ( char* buffer,
+ Module& module )
+{
+ string_list files;
+ GetSourceFilenames ( files,
+ module );
+ for ( size_t i = 0; i < files.size (); i++ )
+ {
+ buffer = buffer + sprintf ( buffer,
+ "extern void %s(int Command, char *Buffer);\n",
+ GetTestDispatcherName ( files[i] ).c_str () );
+ }
+ buffer = buffer + sprintf ( buffer, "\n" );
+ return buffer;
+}
+
+char*
+TestSupportCode::WriteRegisterTestsFunctionToStartupFile ( char* buffer,
+ Module& module )
+{
+ buffer = buffer + sprintf ( buffer,
+ "extern void AddTest(TestRoutine Routine);\n" );
+ buffer = buffer + sprintf ( buffer,
+ "\n" );
+
+ buffer = buffer + sprintf ( buffer,
+ "void\n" );
+ buffer = buffer + sprintf ( buffer,
+ "RegisterTests()\n" );
+ buffer = buffer + sprintf ( buffer,
+ "{\n" );
+
+ string_list files;
+ GetSourceFilenames ( files,
+ module );
+ for ( size_t i = 0; i < files.size (); i++ )
+ {
+ buffer = buffer + sprintf ( buffer,
+ "AddTest((TestRoutine)%s);\n",
+ GetTestDispatcherName ( files[i]).c_str () );
+ }
+ buffer = buffer + sprintf ( buffer,
+ "}\n" );
+ buffer = buffer + sprintf ( buffer, "\n" );
+ return buffer;
+}
+
+void
+TestSupportCode::WriteStartupFile ( Module& module )
+{
+ char* buf;
+ char* s;
+
+ buf = (char*) malloc ( 50*1024 );
+ if ( buf == NULL )
+ throw OutOfMemoryException ();
+
+ s = buf;
+ s = s + sprintf ( s, "/* This file is automatically generated. */\n" );
+ s = s + sprintf ( s, "\n" );
+ s = s + sprintf ( s, "#include \n" );
+ s = s + sprintf ( s, "#include \"regtests.h\"\n" );
+ s = s + sprintf ( s, "\n" );
+ s = WriteTestDispatcherPrototypesToStartupFile ( s,
+ module );
+ s = WriteRegisterTestsFunctionToStartupFile ( s,
+ module );
+ s = s + sprintf ( s, "\n" );
+ s = s + sprintf ( s, "void\n" );
+ s = s + sprintf ( s, "ConsoleWrite(char *Buffer)\n" );
+ s = s + sprintf ( s, "{\n" );
+ s = s + sprintf ( s, " printf(Buffer);\n" );
+ s = s + sprintf ( s, "}\n" );
+ s = s + sprintf ( s, "\n" );
+ s = s + sprintf ( s, "int\n" );
+ s = s + sprintf ( s, "mainCRTStartup(HANDLE hInstance,\n" );
+ s = s + sprintf ( s, " HANDLE hPrevInstance,\n" );
+ s = s + sprintf ( s, " LPSTR lpszCmdParam,\n" );
+ s = s + sprintf ( s, " int nCmdShow)\n" );
+ s = s + sprintf ( s, "{\n" );
+ s = s + sprintf ( s, " InitializeTests();\n" );
+ s = s + sprintf ( s, " RegisterTests();\n" );
+ s = s + sprintf ( s, " SetupOnce();\n" );
+ s = s + sprintf ( s, " PerformTests(ConsoleWrite, NULL);\n" );
+ s = s + sprintf ( s, " _ExitProcess(0);\n" );
+ s = s + sprintf ( s, " return 0;\n" );
+ s = s + sprintf ( s, "}\n" );
+ s = s + sprintf ( s, "\n" );
+
+ FileSupportCode::WriteIfChanged ( buf, GetStartupFilename ( module ) );
+
+ free ( buf );
+}