From e6645949821d88c79355c68fc868762b731107a3 Mon Sep 17 00:00:00 2001 From: "(no author)" <(no author)@92f0537e-14c0-1d44-b2ba-3b60a4d6dcee> Date: Sat, 17 Apr 2010 14:12:11 +0000 Subject: [PATCH] EventDll sample --- cdiag/cdiag/cdiag.rc | 6 +- cfix/cfix/cfix.rc | 6 +- cfix/cfix/cfixmsg.mc | 8 + cfix/cfixcmd/runtest.rc | 6 +- cfix/cfixcons/cfixcons.def | 2 +- cfix/cfixemb/cfixemb.rc | 6 +- cfixkern/cfixkl/cfixkl.rc | 6 +- cfixkern/cfixkr/cfixkr.rc | 6 +- doc/__buildnum.inc | 2 +- doc/docbook/book.xml | 2 +- include/cfixmsg.h | 9 + include/cfixutil.h | 4 +- installer/cfix.wxs | 18 + installer/cfix_samples_eventdll.wxs | 8 + installer/makefile | 2 +- makefile.cfix | 2 +- samples/DIRS | 2 +- samples/EventDll/Logfile/Logfile.cpp | 488 ++++++++++++++++++++++++ samples/EventDll/Logfile/Logfile.def | 21 + samples/EventDll/Logfile/Logfile.sln | 26 ++ samples/EventDll/Logfile/Logfile.vcproj | 351 +++++++++++++++++ samples/EventDll/Logfile/SOURCES | 50 +++ 22 files changed, 1011 insertions(+), 20 deletions(-) create mode 100644 installer/cfix_samples_eventdll.wxs create mode 100644 samples/EventDll/Logfile/Logfile.cpp create mode 100644 samples/EventDll/Logfile/Logfile.def create mode 100644 samples/EventDll/Logfile/Logfile.sln create mode 100644 samples/EventDll/Logfile/Logfile.vcproj create mode 100644 samples/EventDll/Logfile/SOURCES diff --git a/cdiag/cdiag/cdiag.rc b/cdiag/cdiag/cdiag.rc index 5799cc8..cb160c0 100644 --- a/cdiag/cdiag/cdiag.rc +++ b/cdiag/cdiag/cdiag.rc @@ -97,7 +97,7 @@ END // VS_VERSION_INFO VERSIONINFO - FILEVERSION 1, 6, 0, 3752 + FILEVERSION 1, 7, 0, 3759 PRODUCTVERSION 1,0,0,1 FILEFLAGSMASK 0x17L #ifdef _DEBUG @@ -116,7 +116,7 @@ BEGIN VALUE "Comments", "Cfix Diagnostics Library" VALUE "CompanyName", "Johannes Passing" VALUE "FileDescription", "Cfix Diagnostics Library" - VALUE "FileVersion", "1, 6, 0, 3752\0" + VALUE "FileVersion", "1, 7, 0, 3759\0" VALUE "InternalName", "cdiag" VALUE "LegalCopyright", "Copyright (C) 2007" VALUE "OriginalFilename", "cdiag.dll" @@ -363,6 +363,8 @@ END + + diff --git a/cfix/cfix/cfix.rc b/cfix/cfix/cfix.rc index 9c95cce..269a330 100644 --- a/cfix/cfix/cfix.rc +++ b/cfix/cfix/cfix.rc @@ -53,7 +53,7 @@ END // VS_VERSION_INFO VERSIONINFO - FILEVERSION 1, 6, 0, 3752 + FILEVERSION 1, 7, 0, 3759 PRODUCTVERSION 1,1,0,1 FILEFLAGSMASK 0x17L #ifdef _DEBUG @@ -71,7 +71,7 @@ BEGIN BEGIN VALUE "CompanyName", "Johannes Passing" VALUE "FileDescription", "Cfix" - VALUE "FileVersion", "1, 6, 0, 3752\0" + VALUE "FileVersion", "1, 7, 0, 3759\0" VALUE "InternalName", "Cfix" VALUE "LegalCopyright", "Copyright (C) 2008 Johannes Passing" VALUE "OriginalFilename", "Cfix" @@ -330,6 +330,8 @@ END + + diff --git a/cfix/cfix/cfixmsg.mc b/cfix/cfix/cfixmsg.mc index a5eab8e..b54d75c 100644 --- a/cfix/cfix/cfixmsg.mc +++ b/cfix/cfix/cfixmsg.mc @@ -260,3 +260,11 @@ SymbolicName = CFIX_E_LOADING_EVENTDLL_FAILED Language = English Loading Event DLL failed. Make sure that path and CPU architecture are correct. . + +MessageId = 0x801d +Severity = Warning +Facility = Interface +SymbolicName = CFIX_E_EVENTDLL_INVALID_OPTIONS +Language = English +Options passed to Event DLL are invalid. +. diff --git a/cfix/cfixcmd/runtest.rc b/cfix/cfixcmd/runtest.rc index 3ac678d..213790e 100644 --- a/cfix/cfixcmd/runtest.rc +++ b/cfix/cfixcmd/runtest.rc @@ -53,7 +53,7 @@ END // VS_VERSION_INFO VERSIONINFO - FILEVERSION 1, 6, 0, 3752 + FILEVERSION 1, 7, 0, 3759 PRODUCTVERSION 1,1,0,1 FILEFLAGSMASK 0x17L #ifdef _DEBUG @@ -71,7 +71,7 @@ BEGIN BEGIN VALUE "CompanyName", "Johannes Passing" VALUE "FileDescription", "Cfix" - VALUE "FileVersion", "1, 6, 0, 3752\0" + VALUE "FileVersion", "1, 7, 0, 3759\0" VALUE "InternalName", "Cfix" VALUE "LegalCopyright", "Copyright (C) 2008 Johannes Passing" VALUE "OriginalFilename", "Cfix" @@ -339,6 +339,8 @@ IDI_ICON1 ICON "icon.ico" + + diff --git a/cfix/cfixcons/cfixcons.def b/cfix/cfixcons/cfixcons.def index 1cfcb89..83808f7 100644 --- a/cfix/cfixcons/cfixcons.def +++ b/cfix/cfixcons/cfixcons.def @@ -1,5 +1,5 @@ ; Copyright: -; 2008-2009, Johannes Passing (passing at users.sourceforge.net) +; 2008-2010, Johannes Passing (passing at users.sourceforge.net) ; ; This file is part of cfix. ; diff --git a/cfix/cfixemb/cfixemb.rc b/cfix/cfixemb/cfixemb.rc index e268b27..6b97355 100644 --- a/cfix/cfixemb/cfixemb.rc +++ b/cfix/cfixemb/cfixemb.rc @@ -53,7 +53,7 @@ END // VS_VERSION_INFO VERSIONINFO - FILEVERSION 1, 6, 0, 3752 + FILEVERSION 1, 7, 0, 3759 PRODUCTVERSION 1,1,0,1 FILEFLAGSMASK 0x17L #ifdef _DEBUG @@ -71,7 +71,7 @@ BEGIN BEGIN VALUE "CompanyName", "Johannes Passing" VALUE "FileDescription", "cfix Embedding Helper Library" - VALUE "FileVersion", "1, 6, 0, 3752\0" + VALUE "FileVersion", "1, 7, 0, 3759\0" VALUE "InternalName", "cfix" VALUE "LegalCopyright", "Copyright (C) 2008 Johannes Passing" VALUE "OriginalFilename", "cfix" @@ -329,6 +329,8 @@ END + + diff --git a/cfixkern/cfixkl/cfixkl.rc b/cfixkern/cfixkl/cfixkl.rc index 4b8e14a..9b8eeb9 100644 --- a/cfixkern/cfixkl/cfixkl.rc +++ b/cfixkern/cfixkl/cfixkl.rc @@ -53,7 +53,7 @@ END // VS_VERSION_INFO VERSIONINFO - FILEVERSION 1, 6, 0, 3752 + FILEVERSION 1, 7, 0, 3759 PRODUCTVERSION 1,1,0,1 FILEFLAGSMASK 0x17L #ifdef _DEBUG @@ -71,7 +71,7 @@ BEGIN BEGIN VALUE "CompanyName", "Johannes Passing" VALUE "FileDescription", "Cfix Kernel Layer DLL" - VALUE "FileVersion", "1, 6, 0, 3752\0" + VALUE "FileVersion", "1, 7, 0, 3759\0" VALUE "InternalName", "Cfixkl" VALUE "LegalCopyright", "Copyright (C) 2008 Johannes Passing" VALUE "OriginalFilename", "Cfixkl" @@ -325,6 +325,8 @@ END + + diff --git a/cfixkern/cfixkr/cfixkr.rc b/cfixkern/cfixkr/cfixkr.rc index 93961c4..654b26e 100644 --- a/cfixkern/cfixkr/cfixkr.rc +++ b/cfixkern/cfixkr/cfixkr.rc @@ -53,7 +53,7 @@ END // VS_VERSION_INFO VERSIONINFO - FILEVERSION 1, 6, 0, 3752 + FILEVERSION 1, 7, 0, 3759 PRODUCTVERSION 1,1,0,1 FILEFLAGSMASK 0x17L #ifdef _DEBUG @@ -71,7 +71,7 @@ BEGIN BEGIN VALUE "CompanyName", "Johannes Passing" VALUE "FileDescription", "Cfix Kernel Reflector" - VALUE "FileVersion", "1, 6, 0, 3752\0" + VALUE "FileVersion", "1, 7, 0, 3759\0" VALUE "InternalName", "Cfixkr" VALUE "LegalCopyright", "Copyright (C) 2008 Johannes Passing" VALUE "OriginalFilename", "Cfixkr" @@ -324,6 +324,8 @@ END + + diff --git a/doc/__buildnum.inc b/doc/__buildnum.inc index 2442114..9f9e96f 100644 --- a/doc/__buildnum.inc +++ b/doc/__buildnum.inc @@ -1,3 +1,3 @@ -BUILDNUMBER = 3752 +BUILDNUMBER = 3759 diff --git a/doc/docbook/book.xml b/doc/docbook/book.xml index d8db1a5..657ae8e 100644 --- a/doc/docbook/book.xml +++ b/doc/docbook/book.xml @@ -39,7 +39,7 @@ cfix - Release 1.6 + Release 1.7 Johannes Passing diff --git a/include/cfixmsg.h b/include/cfixmsg.h index d428b5a..b3e3a02 100644 --- a/include/cfixmsg.h +++ b/include/cfixmsg.h @@ -301,3 +301,12 @@ // #define CFIX_E_LOADING_EVENTDLL_FAILED ((HRESULT)0x8004801CL) +// +// MessageId: CFIX_E_EVENTDLL_INVALID_OPTIONS +// +// MessageText: +// +// Options passed to Event DLL are invalid. +// +#define CFIX_E_EVENTDLL_INVALID_OPTIONS ((HRESULT)0x8004801DL) + diff --git a/include/cfixutil.h b/include/cfixutil.h index fb413d7..1679b20 100644 --- a/include/cfixutil.h +++ b/include/cfixutil.h @@ -88,11 +88,11 @@ EXTERN_C HRESULT CFIXCALLTYPE CfixutilSearch( Parameters: DllPath - Name/path of DLL. - Flags - CFIX_EVENT_SINK_FLAG_*. + Flags - CFIX_EVENT_SINK_FLAG_*. Options - Options to pass to event DLL. Sink - Result. --*/ -HRESULT CfixutilLoadEventSinkFromDll( +EXTERN_C HRESULT CfixutilLoadEventSinkFromDll( __in PCWSTR DllPath, __in ULONG Flags, __in_opt PCWSTR Options, diff --git a/installer/cfix.wxs b/installer/cfix.wxs index 077775a..02f3cc7 100644 --- a/installer/cfix.wxs +++ b/installer/cfix.wxs @@ -360,6 +360,23 @@ + + + + + + + + + + @@ -456,6 +473,7 @@ + diff --git a/installer/cfix_samples_eventdll.wxs b/installer/cfix_samples_eventdll.wxs new file mode 100644 index 0000000..3032579 --- /dev/null +++ b/installer/cfix_samples_eventdll.wxs @@ -0,0 +1,8 @@ + + + + + + + + \ No newline at end of file diff --git a/installer/makefile b/installer/makefile index 5cf6968..ebf7272 100644 --- a/installer/makefile +++ b/installer/makefile @@ -4,7 +4,7 @@ WIXBINPATH=D:\prog\wix\wix-2.0.5805.0-binaries !ENDIF !INCLUDE __buildnum.inc -VERSION = 1.6.0.$(BUILDNUMBER) +VERSION = 1.7.0.$(BUILDNUMBER) #---------------------------------------------------------------------- # diff --git a/makefile.cfix b/makefile.cfix index 6d077f3..c0ff05a 100644 --- a/makefile.cfix +++ b/makefile.cfix @@ -28,7 +28,7 @@ !ENDIF !INCLUDE __buildnum.inc -VERSION=1.6.0.$(BUILDNUMBER) +VERSION=1.7.0.$(BUILDNUMBER) CUSTOMSYMSTORE=D:\XSYMBOLS\Custom CFIX_CLAGS=-f -z -kern diff --git a/samples/DIRS b/samples/DIRS index ca6b8d2..5998149 100644 --- a/samples/DIRS +++ b/samples/DIRS @@ -1 +1 @@ -DIRS=UserCc UserC Kernel \ No newline at end of file +DIRS=UserCc UserC Kernel EventDll \ No newline at end of file diff --git a/samples/EventDll/Logfile/Logfile.cpp b/samples/EventDll/Logfile/Logfile.cpp new file mode 100644 index 0000000..c655320 --- /dev/null +++ b/samples/EventDll/Logfile/Logfile.cpp @@ -0,0 +1,488 @@ +/*---------------------------------------------------------------------- + * Purpose: + * Event Sink. + * + * Copyright: + * 2008-2009, Johannes Passing (passing at users.sourceforge.net) + * + * This file is part of cfix. + * + * cfix is free software: you can redistribute it and/or modify + * it under the terms of the GNU Lesser General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * cfix is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public License + * along with cfix. If not, see . + */ + +#define CFIXAPI + +#include +#include +#include +#include +#include + +#pragma warning( push ) +#pragma warning( disable: 6011; disable: 6387 ) +#include +#pragma warning( pop ) + +#define ASSERT _ASSERTE + +typedef struct _LOGFILE_EVENT_SINK +{ + CFIX_EVENT_SINK Base; + + volatile LONG ReferenceCount; + + FILE* File; + + struct + { + ULONG FailureCount; + ULONG InconclusiveCount; + } CurrentTestCase; +} LOGFILE_EVENT_SINK, *PLOGFILE_EVENT_SINK; + + +/*---------------------------------------------------------------------- + * + * Helpers. + * + */ + +static HRESULT LogfileOpen( + __in PCWSTR Path, + __out FILE** File + ) +{ + HANDLE FileHandle = CreateFile( + Path, + FILE_APPEND_DATA, + FILE_SHARE_READ, + NULL, + OPEN_ALWAYS, + 0, + NULL ); + if ( File == INVALID_HANDLE_VALUE ) + { + return HRESULT_FROM_WIN32( GetLastError() ); + } + + int Fdes = _open_osfhandle( ( intptr_t ) FileHandle, _O_APPEND ); + if ( Fdes == -1 ) + { + CloseHandle( FileHandle ); + return E_UNEXPECTED; + } + + *File = _wfdopen( Fdes, L"a" ); + if ( ! *File ) + { + _close( Fdes ); + return E_UNEXPECTED; + } + + return S_OK; +} + +static VOID LogfileFormatStackTrace( + __in PCFIX_STACKTRACE StackTrace, + __in BOOL ShowSourceInformation, + __out PWSTR Buffer, + __in SIZE_T BufferSizeInChars + ) +{ + UINT FrameIndex; + + ASSERT( StackTrace->FrameCount > 0 ); + ASSERT( StackTrace->GetInformationStackFrame ); + + for ( FrameIndex = 0; FrameIndex < StackTrace->FrameCount; FrameIndex++ ) + { + HRESULT Hr; + + WCHAR ModuleName[ 64 ]; + WCHAR FunctionName[ 100 ]; + WCHAR SourceFile[ 100 ]; + ULONG SourceLine; + ULONG Displacement; + + WCHAR FrameBuffer[ 200 ]; + + // + // Resolve symbolic information. + // + if ( FAILED( ( StackTrace->GetInformationStackFrame ) ( + StackTrace->Frames[ FrameIndex ], + _countof( ModuleName ), + ModuleName, + _countof( FunctionName ), + FunctionName, + ( PDWORD ) &Displacement, + _countof( SourceFile ), + SourceFile, + ( PDWORD ) &SourceLine ) ) ) + { + continue; + } + + // + // Add to buffer. + // + + if ( SourceLine != 0 && ShowSourceInformation ) + { + Hr = StringCchPrintf( + FrameBuffer, + _countof( FrameBuffer ), + L" %s!%s +0x%x (%s:%d)\r\n", + ModuleName, + FunctionName, + Displacement, + SourceFile, + SourceLine ); + } + else + { + Hr = StringCchPrintf( + FrameBuffer, + _countof( FrameBuffer ), + L" %s!%s +0x%x\r\n", + ModuleName, + FunctionName, + Displacement ); + } + + if ( FAILED( Hr ) ) + { + break; + } + + if ( FAILED( StringCchCat( + Buffer, + BufferSizeInChars, + FrameBuffer ) ) ) + { + break; + } + } +} + +/*---------------------------------------------------------------------- + * + * Methods. + * + */ + +static VOID CFIXCALLTYPE LogfileReference( + __in PCFIX_EVENT_SINK This + ) +{ + PLOGFILE_EVENT_SINK Sink = ( PLOGFILE_EVENT_SINK ) This; + ASSERT( Sink ); + + InterlockedIncrement( &Sink->ReferenceCount ); +} + +static VOID CFIXCALLTYPE LogfileDereference( + __in PCFIX_EVENT_SINK This + ) +{ + PLOGFILE_EVENT_SINK Sink = ( PLOGFILE_EVENT_SINK ) This; + ASSERT( Sink ); + + if ( 0 == InterlockedDecrement( &Sink->ReferenceCount ) ) + { + fclose( Sink->File ); + free( Sink ); + } +} + +static VOID CFIXCALLTYPE LogfileReportEvent( + __in PCFIX_EVENT_SINK This, + __in PCFIX_THREAD_ID Thread, + __in PCWSTR ModuleBaseName, + __in PCWSTR FixtureName, + __in PCWSTR TestCaseName, + __in PCFIX_TESTCASE_EXECUTION_EVENT Event + ) +{ + PLOGFILE_EVENT_SINK Sink = ( PLOGFILE_EVENT_SINK ) This; + WCHAR StackTraceBuffer[ 2048 ] = { 0 }; + WCHAR LastErrorMessage[ 260 ] = { 0 }; + WCHAR ExceptionMessage[ 260 ] = { 0 }; + + UNREFERENCED_PARAMETER( Thread ); + + if ( Event->StackTrace.FrameCount > 0 ) + { + LogfileFormatStackTrace( + &Event->StackTrace, + TRUE, + StackTraceBuffer, + _countof( StackTraceBuffer ) ); + } + + + switch ( Event->Type ) + { + case CfixEventFailedAssertion: + if ( Event->Info.FailedAssertion.Line ) + { + fwprintf( + Sink->File, + L"[Failure] %s.%s.%s \r\n" + L" %s(%d): %s\r\n\r\n" + L" Expression: %s\r\n" + L" Last Error: %d\r\n\r\n" + L"%s\r\n\r\n", + ModuleBaseName, + FixtureName, + TestCaseName, + Event->Info.FailedAssertion.File, + Event->Info.FailedAssertion.Line, + Event->Info.FailedAssertion.Routine, + Event->Info.FailedAssertion.Expression, + Event->Info.FailedAssertion.LastError, + StackTraceBuffer ); + } + else + { + fwprintf( + Sink->File, + L"[Failure] %s.%s.%s \r\n" + L" Expression: %s\r\n" + L" Last Error: %d (%s)\r\n\r\n" + L"%s\r\n\r\n", + ModuleBaseName, + FixtureName, + TestCaseName, + Event->Info.FailedAssertion.Expression, + Event->Info.FailedAssertion.LastError, + LastErrorMessage, + StackTraceBuffer ); + } + + break; + + case CfixEventUncaughtException: + ( VOID ) StringCchPrintf( + ExceptionMessage, + _countof( ExceptionMessage ), + L"Unhandled Exception 0x%08X at %p", + Event->Info.UncaughtException.ExceptionRecord.ExceptionCode, + Event->Info.UncaughtException.ExceptionRecord.ExceptionAddress ); + + fwprintf( + Sink->File, + L"[Failure] %s.%s.%s \r\n" + L" %s\r\n\r\n" + L"%s\r\n\r\n", + ModuleBaseName, + FixtureName, + TestCaseName, + ExceptionMessage, + StackTraceBuffer ); + + break; + + case CfixEventInconclusiveness: + fwprintf( + Sink->File, + L"[Inconclusive] %s.%s.%s \r\n" + L" %s\r\n\r\n" + L"%s\r\n\r\n", + ModuleBaseName, + FixtureName, + TestCaseName, + Event->Info.Inconclusiveness.Message, + StackTraceBuffer ); + + break; + + case CfixEventLog: + fwprintf( + Sink->File, + L"[Log] %s.%s.%s \r\n" + L" %s\r\n\r\n", + ModuleBaseName, + FixtureName, + TestCaseName, + Event->Info.Log.Message ); + } +} + +static VOID CFIXCALLTYPE LogfileBeforeFixtureStart( + __in PCFIX_EVENT_SINK This, + __in PCFIX_THREAD_ID Thread, + __in PCWSTR ModuleBaseName, + __in PCWSTR FixtureName + ) +{ + UNREFERENCED_PARAMETER( This ); + UNREFERENCED_PARAMETER( Thread ); + UNREFERENCED_PARAMETER( ModuleBaseName ); + UNREFERENCED_PARAMETER( FixtureName ); + + // + // Nop. + // +} + +static VOID CFIXCALLTYPE LogfileAfterFixtureFinish( + __in PCFIX_EVENT_SINK This, + __in PCFIX_THREAD_ID Thread, + __in PCWSTR ModuleBaseName, + __in PCWSTR FixtureName, + __in BOOL RanToCompletion + ) +{ + UNREFERENCED_PARAMETER( This ); + UNREFERENCED_PARAMETER( Thread ); + UNREFERENCED_PARAMETER( ModuleBaseName ); + UNREFERENCED_PARAMETER( FixtureName ); + UNREFERENCED_PARAMETER( RanToCompletion ); + + // + // Nop. + // +} + +static VOID CFIXCALLTYPE LogfileBeforeTestCaseStart( + __in PCFIX_EVENT_SINK This, + __in PCFIX_THREAD_ID Thread, + __in PCWSTR ModuleBaseName, + __in PCWSTR FixtureName, + __in PCWSTR TestCaseName + ) +{ + PLOGFILE_EVENT_SINK Sink = ( PLOGFILE_EVENT_SINK ) This; + + UNREFERENCED_PARAMETER( Thread ); + UNREFERENCED_PARAMETER( ModuleBaseName ); + UNREFERENCED_PARAMETER( FixtureName ); + UNREFERENCED_PARAMETER( TestCaseName ); + + // + // Reset counters. + // + Sink->CurrentTestCase.FailureCount = 0; + Sink->CurrentTestCase.InconclusiveCount = 0; +} + +static VOID CFIXCALLTYPE LogfileAfterTestCaseFinish( + __in PCFIX_EVENT_SINK This, + __in PCFIX_THREAD_ID Thread, + __in PCWSTR ModuleBaseName, + __in PCWSTR FixtureName, + __in PCWSTR TestCaseName, + __in BOOL RanToCompletion + ) +{ + PLOGFILE_EVENT_SINK Sink = ( PLOGFILE_EVENT_SINK ) This; + + UNREFERENCED_PARAMETER( Thread ); + UNREFERENCED_PARAMETER( ModuleBaseName ); + UNREFERENCED_PARAMETER( FixtureName ); + UNREFERENCED_PARAMETER( TestCaseName ); + UNREFERENCED_PARAMETER( RanToCompletion ); + + // + // Was is a success or failure? + // + if ( Sink->CurrentTestCase.FailureCount == 0 && + Sink->CurrentTestCase.InconclusiveCount == 0 ) + { + // + // Success -> report. + // + + fwprintf( + Sink->File, + L"[Success] %s.%s.%s\r\n", + ModuleBaseName, + FixtureName, + TestCaseName ); + } + else + { + // + // Failure/Inconclusive, errors have already been reported. + // + } +} + + +/*---------------------------------------------------------------------- + * + * Exports. + * + */ + +CFIXAPI HRESULT CFIXCALLTYPE CreateEventSink( + __in ULONG Version, + __in ULONG Flags, + __in_opt PCWSTR FilePath, + __reserved ULONG Reserved, + __out PCFIX_EVENT_SINK *Sink + ) +{ + HRESULT Hr; + PLOGFILE_EVENT_SINK NewSink; + + UNREFERENCED_PARAMETER( Reserved ); + UNREFERENCED_PARAMETER( Flags ); + + if ( Version != CFIX_EVENT_SINK_VERSION ) + { + return CFIX_E_UNSUPPORTED_EVENT_SINK_VERSION; + } + + if ( ! Sink || ! FilePath ) + { + return CFIX_E_EVENTDLL_INVALID_OPTIONS; + } + + NewSink = ( PLOGFILE_EVENT_SINK ) malloc( sizeof( LOGFILE_EVENT_SINK ) ); + if ( ! NewSink ) + { + return E_OUTOFMEMORY; + } + + + ZeroMemory( NewSink, sizeof( LOGFILE_EVENT_SINK ) ); + + NewSink->ReferenceCount = 1; + NewSink->CurrentTestCase.FailureCount = 0; + NewSink->CurrentTestCase.InconclusiveCount = 0; + + Hr = LogfileOpen( FilePath, &NewSink->File ); + if ( FAILED( Hr ) ) + { + free( NewSink ); + return Hr; + } + + NewSink->Base.Version = CFIX_EVENT_SINK_VERSION; + NewSink->Base.ReportEvent = LogfileReportEvent; + NewSink->Base.BeforeFixtureStart = LogfileBeforeFixtureStart; + NewSink->Base.AfterFixtureFinish = LogfileAfterFixtureFinish; + NewSink->Base.BeforeTestCaseStart = LogfileBeforeTestCaseStart; + NewSink->Base.AfterTestCaseFinish = LogfileAfterTestCaseFinish; + NewSink->Base.Reference = LogfileReference; + NewSink->Base.Dereference = LogfileDereference; + + *Sink = &NewSink->Base; + + return S_OK; +} + + diff --git a/samples/EventDll/Logfile/Logfile.def b/samples/EventDll/Logfile/Logfile.def new file mode 100644 index 0000000..83808f7 --- /dev/null +++ b/samples/EventDll/Logfile/Logfile.def @@ -0,0 +1,21 @@ +; Copyright: +; 2008-2010, Johannes Passing (passing at users.sourceforge.net) +; +; This file is part of cfix. +; +; cfix is free software: you can redistribute it and/or modify +; it under the terms of the GNU Lesser General Public License as published by +; the Free Software Foundation, either version 3 of the License, or +; (at your option) any later version. +; +; cfix is distributed in the hope that it will be useful, +; but WITHOUT ANY WARRANTY; without even the implied warranty of +; MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +; GNU Lesser General Public License for more details. +; +; You should have received a copy of the GNU Lesser General Public License +; along with cfix. If not, see . + +EXPORTS + CreateEventSink + \ No newline at end of file diff --git a/samples/EventDll/Logfile/Logfile.sln b/samples/EventDll/Logfile/Logfile.sln new file mode 100644 index 0000000..a555767 --- /dev/null +++ b/samples/EventDll/Logfile/Logfile.sln @@ -0,0 +1,26 @@ + +Microsoft Visual Studio Solution File, Format Version 10.00 +# Visual Studio 2008 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "Logfile", "Logfile.vcproj", "{3A08456A-A938-439F-A6FD-9DA66997572B}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Debug|x64 = Debug|x64 + Release|Win32 = Release|Win32 + Release|x64 = Release|x64 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {3A08456A-A938-439F-A6FD-9DA66997572B}.Debug|Win32.ActiveCfg = Debug|Win32 + {3A08456A-A938-439F-A6FD-9DA66997572B}.Debug|Win32.Build.0 = Debug|Win32 + {3A08456A-A938-439F-A6FD-9DA66997572B}.Debug|x64.ActiveCfg = Debug|x64 + {3A08456A-A938-439F-A6FD-9DA66997572B}.Debug|x64.Build.0 = Debug|x64 + {3A08456A-A938-439F-A6FD-9DA66997572B}.Release|Win32.ActiveCfg = Release|Win32 + {3A08456A-A938-439F-A6FD-9DA66997572B}.Release|Win32.Build.0 = Release|Win32 + {3A08456A-A938-439F-A6FD-9DA66997572B}.Release|x64.ActiveCfg = Release|x64 + {3A08456A-A938-439F-A6FD-9DA66997572B}.Release|x64.Build.0 = Release|x64 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/samples/EventDll/Logfile/Logfile.vcproj b/samples/EventDll/Logfile/Logfile.vcproj new file mode 100644 index 0000000..e670168 --- /dev/null +++ b/samples/EventDll/Logfile/Logfile.vcproj @@ -0,0 +1,351 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/samples/EventDll/Logfile/SOURCES b/samples/EventDll/Logfile/SOURCES new file mode 100644 index 0000000..ff62baf --- /dev/null +++ b/samples/EventDll/Logfile/SOURCES @@ -0,0 +1,50 @@ +# +# Copyright: +# 2008, Johannes Passing (passing at users.sourceforge.net) +# +# This file is part of cfix. +# +# cfix is free software: you can redistribute it and/or modify +# it under the terms of the GNU Lesser General Public License as published by +# the Free Software Foundation, either version 3 of the License, or +# (at your option) any later version. +# +# cfix is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU Lesser General Public License +# along with cfix. If not, see . +# + +!if ( "$(CFIX_HOME)" == "" ) +# Only applies when entire source tree is build and cfix has not been installed yet. +CFIX_INC_PATH=..\..\..\include +CFIX_LIB_PATH=$(MAKEDIR)\..\..\..\bin\$(DDKBUILDENV)\$(TARGET_DIRECTORY) + +!else +# cfix installed. +CFIX_INC_PATH=$(CFIX_HOME)\include +CFIX_LIB_PATH=$(CFIX_HOME)\lib\$(TARGET_DIRECTORY) +!endif + +# +# The cfix include directory is required. +# +INCLUDES=$(CFIX_INC_PATH);$(DDK_INC_PATH) + +MSC_WARNING_LEVEL=/W4 /WX /Wp64 + +USER_C_FLAGS=/D_UNICODE /DUNICODE /EHa +USE_LIBCMT=1 +USE_STL=1 + +TARGETLIBS=$(SDK_LIB_PATH)\kernel32.lib \ + $(CFIX_LIB_PATH)\cfix.lib + +TARGETNAME=logfile +TARGETPATH=..\..\bin\$(DDKBUILDENV) +TARGETTYPE=DYNLINK +SOURCES=\ + logfile.cpp