mirror of
https://github.com/reactos/reactos.git
synced 2025-05-18 16:51:18 +00:00
[KMTESTS]
- reference streamout.c and provide a wctomb stub to have an any-IRQL vsnprintf implementation for the test framework svn path=/branches/GSoC_2011/KMTestSuite/; revision=52330
This commit is contained in:
parent
a6b4eba335
commit
dffa722bce
3 changed files with 56 additions and 2 deletions
|
@ -21,12 +21,18 @@ list(APPEND KMTEST_DRV_SOURCE
|
|||
add_library(kmtest_drv SHARED ${KMTEST_DRV_SOURCE})
|
||||
|
||||
set_module_type(kmtest_drv kernelmodedriver)
|
||||
target_link_libraries(kmtest_drv ${PSEH_LIB})
|
||||
target_link_libraries(kmtest_drv kmtest_printf ${PSEH_LIB})
|
||||
add_importlibs(kmtest_drv ntoskrnl hal)
|
||||
set_property(TARGET kmtest_drv PROPERTY COMPILE_DEFINITIONS KMT_KERNEL_MODE)
|
||||
|
||||
add_cd_file(TARGET kmtest_drv DESTINATION reactos/system32/drivers FOR all)
|
||||
|
||||
add_library(kmtest_printf
|
||||
kmtest_drv/printf_stubs.c
|
||||
${REACTOS_SOURCE_DIR}/lib/sdk/crt/printf/streamout.c)
|
||||
set_property(TARGET kmtest_printf PROPERTY COMPILE_DEFINITIONS _LIBCNT_ _USER32_WSPRINTF wctomb=KmtWcToMb)
|
||||
set_property(TARGET kmtest_printf PROPERTY INCLUDE_DIRECTORIES ${REACTOS_SOURCE_DIR}/lib/sdk/crt/include)
|
||||
|
||||
#
|
||||
# kmtest.exe loader application
|
||||
#
|
||||
|
|
|
@ -8,7 +8,9 @@
|
|||
#ifndef _KMTEST_TEST_H_
|
||||
#define _KMTEST_TEST_H_
|
||||
|
||||
typedef void KMT_TESTFUNC(void);
|
||||
#include <stdarg.h>
|
||||
|
||||
typedef VOID KMT_TESTFUNC(VOID);
|
||||
|
||||
typedef struct
|
||||
{
|
||||
|
@ -74,6 +76,12 @@ static VOID KmtAddToLogBuffer(PKMT_RESULTBUFFER Buffer, PCSTR String, SIZE_T Len
|
|||
KmtMemCpy(&Buffer->LogBuffer[OldLength], String, Length);
|
||||
}
|
||||
|
||||
#ifdef KMT_KERNEL_MODE
|
||||
INT __cdecl KmtVSNPrintF(PSTR Buffer, SIZE_T BufferMaxLength, PCSTR Format, va_list Arguments);
|
||||
#elif defined KMT_USER_MODE
|
||||
#define KmtVSNPrintF vsnprintf
|
||||
#endif /* defined KMT_USER_MODE */
|
||||
|
||||
#endif /* defined KMT_DEFINE_TEST_FUNCTIONS */
|
||||
|
||||
#endif /* !defined _KMTEST_TEST_H_ */
|
||||
|
|
40
kmtests/kmtest_drv/printf_stubs.c
Normal file
40
kmtests/kmtest_drv/printf_stubs.c
Normal file
|
@ -0,0 +1,40 @@
|
|||
/*
|
||||
* PROJECT: ReactOS kernel-mode tests
|
||||
* LICENSE: GPLv2+ - See COPYING in the top level directory
|
||||
* PURPOSE: Kernel-Mode Test Suite stub functions for any-IRQL vsnprintf
|
||||
* PROGRAMMER: Thomas Faber <thfabba@gmx.de>
|
||||
*/
|
||||
|
||||
#undef wctomb
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <wchar.h>
|
||||
|
||||
int __cdecl KmtWcToMb(char *mbchar, wchar_t wchar)
|
||||
{
|
||||
*mbchar = wchar;
|
||||
return 1;
|
||||
}
|
||||
|
||||
int __cdecl streamout(FILE *stream, const char *format, va_list argptr);
|
||||
|
||||
int __cdecl KmtVSNPrintF(char *buffer, size_t count, const char *format, va_list argptr)
|
||||
{
|
||||
int result;
|
||||
FILE stream;
|
||||
|
||||
stream._base = (char *)buffer;
|
||||
stream._ptr = stream._base;
|
||||
stream._charbuf = 0;
|
||||
stream._cnt = count;
|
||||
stream._bufsiz = 0;
|
||||
stream._flag = _IOSTRG | _IOWRT;
|
||||
stream._tmpfname = 0;
|
||||
|
||||
result = streamout(&stream, format, argptr);
|
||||
|
||||
/* Only zero terminate if there is enough space left */
|
||||
if (stream._cnt) *(char *)stream._ptr = '\0';
|
||||
|
||||
return result;
|
||||
}
|
Loading…
Reference in a new issue