nillerusr
2 years ago
12 changed files with 331 additions and 75 deletions
@ -0,0 +1,37 @@
@@ -0,0 +1,37 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose: Unit test program for testing of tier0 libraries
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#include "unitlib/unitlib.h" |
||||
#include "appframework/IAppSystem.h" |
||||
|
||||
//-----------------------------------------------------------------------------
|
||||
// Used to connect/disconnect the DLL
|
||||
//-----------------------------------------------------------------------------
|
||||
class CTier0TestAppSystem : public CTier0AppSystem< IAppSystem > |
||||
{ |
||||
typedef CTier0AppSystem< IAppSystem > BaseClass; |
||||
|
||||
public: |
||||
virtual bool Connect( CreateInterfaceFn factory ) |
||||
{ |
||||
if ( !BaseClass::Connect( factory ) ) |
||||
return false; |
||||
return true; |
||||
} |
||||
|
||||
virtual InitReturnVal_t Init() |
||||
{ |
||||
return INIT_OK; |
||||
} |
||||
|
||||
virtual void Shutdown() |
||||
{ |
||||
BaseClass::Shutdown(); |
||||
} |
||||
}; |
||||
|
||||
USE_UNITTEST_APPSYSTEM( CTier0TestAppSystem ) |
@ -0,0 +1,39 @@
@@ -0,0 +1,39 @@
|
||||
#! /usr/bin/env python |
||||
# encoding: utf-8 |
||||
|
||||
from waflib import Utils |
||||
import os |
||||
|
||||
top = '.' |
||||
PROJECT_NAME = 'tier0test' |
||||
|
||||
def options(opt): |
||||
return |
||||
|
||||
def configure(conf): |
||||
conf.define('TIER1TEST_EXPORTS', 1) |
||||
|
||||
def build(bld): |
||||
source = ['tier0test.cpp'] |
||||
includes = ['../../public', '../../public/tier0'] |
||||
defines = [] |
||||
libs = ['tier0','tier1','unitlib'] |
||||
|
||||
if bld.env.DEST_OS != 'win32': |
||||
libs += [ 'DL', 'LOG' ] |
||||
else: |
||||
libs += ['USER32', 'SHELL32'] |
||||
|
||||
install_path = bld.env.TESTDIR |
||||
bld.shlib( |
||||
source = source, |
||||
target = PROJECT_NAME, |
||||
name = PROJECT_NAME, |
||||
features = 'c cxx', |
||||
includes = includes, |
||||
defines = defines, |
||||
use = libs, |
||||
install_path = install_path, |
||||
subsystem = bld.env.MSVC_SUBSYSTEM, |
||||
idx = bld.get_taskgen_count() |
||||
) |
@ -1,52 +0,0 @@
@@ -1,52 +0,0 @@
|
||||
//========= Copyright Valve Corporation, All rights reserved. ============//
|
||||
//
|
||||
// Purpose: Unit test program for processes
|
||||
//
|
||||
// $NoKeywords: $
|
||||
//=============================================================================//
|
||||
|
||||
#include "unitlib/unitlib.h" |
||||
#include "vstdlib/iprocessutils.h" |
||||
#include "tier1/strtools.h" |
||||
#include "tier1/tier1.h" |
||||
#include "tier0/dbg.h" |
||||
|
||||
|
||||
DEFINE_TESTSUITE( ProcessTestSuite ) |
||||
|
||||
DEFINE_TESTCASE( ProcessTestSimple, ProcessTestSuite ) |
||||
{ |
||||
Msg( "Simple process test...\n" ); |
||||
|
||||
ProcessHandle_t hProcess = g_pProcessUtils->StartProcess( "unittests\\testprocess.exe -delay 1.0", true ); |
||||
g_pProcessUtils->WaitUntilProcessCompletes( hProcess ); |
||||
int nLen = g_pProcessUtils->GetProcessOutputSize( hProcess ); |
||||
char *pBuf = (char*)_alloca( nLen ); |
||||
g_pProcessUtils->GetProcessOutput( hProcess, pBuf, nLen ); |
||||
g_pProcessUtils->CloseProcess( hProcess ); |
||||
Shipping_Assert( !Q_stricmp( pBuf, "Test Finished!\n" ) ); |
||||
} |
||||
|
||||
|
||||
DEFINE_TESTCASE( ProcessTestBufferOverflow, ProcessTestSuite ) |
||||
{ |
||||
Msg( "Buffer overflow process test...\n" ); |
||||
|
||||
ProcessHandle_t hProcess = g_pProcessUtils->StartProcess( "unittests\\testprocess.exe -delay 1.0 -extrabytes 32768", true ); |
||||
g_pProcessUtils->WaitUntilProcessCompletes( hProcess ); |
||||
int nLen = g_pProcessUtils->GetProcessOutputSize( hProcess ); |
||||
Shipping_Assert( nLen == 32768 + 16 ); |
||||
char *pBuf = (char*)_alloca( nLen ); |
||||
g_pProcessUtils->GetProcessOutput( hProcess, pBuf, nLen ); |
||||
g_pProcessUtils->CloseProcess( hProcess ); |
||||
Shipping_Assert( !Q_strnicmp( pBuf, "Test Finished!\n", 15 ) ); |
||||
|
||||
int nEndExtraBytes = 32768; |
||||
char *pTest = pBuf + 15; |
||||
while( --nEndExtraBytes >= 0 ) |
||||
{ |
||||
Shipping_Assert( *pTest == (( nEndExtraBytes % 10 ) + '0') ); |
||||
++pTest; |
||||
} |
||||
} |
||||
|
@ -0,0 +1,39 @@
@@ -0,0 +1,39 @@
|
||||
#! /usr/bin/env python |
||||
# encoding: utf-8 |
||||
|
||||
from waflib import Utils |
||||
import os |
||||
|
||||
top = '.' |
||||
PROJECT_NAME = 'tier1test' |
||||
|
||||
def options(opt): |
||||
return |
||||
|
||||
def configure(conf): |
||||
conf.define('TIER1TEST_EXPORTS', 1) |
||||
|
||||
def build(bld): |
||||
source = ['commandbuffertest.cpp', 'utlstringtest.cpp', 'tier1test.cpp'] |
||||
includes = ['../../public', '../../public/tier0'] |
||||
defines = [] |
||||
libs = ['tier0', 'tier1', 'mathlib', 'unitlib'] |
||||
|
||||
if bld.env.DEST_OS != 'win32': |
||||
libs += [ 'DL', 'LOG' ] |
||||
else: |
||||
libs += ['USER32', 'SHELL32'] |
||||
|
||||
install_path = bld.env.TESTDIR |
||||
bld.shlib( |
||||
source = source, |
||||
target = PROJECT_NAME, |
||||
name = PROJECT_NAME, |
||||
features = 'c cxx', |
||||
includes = includes, |
||||
defines = defines, |
||||
use = libs, |
||||
install_path = install_path, |
||||
subsystem = bld.env.MSVC_SUBSYSTEM, |
||||
idx = bld.get_taskgen_count() |
||||
) |
@ -0,0 +1,39 @@
@@ -0,0 +1,39 @@
|
||||
#! /usr/bin/env python |
||||
# encoding: utf-8 |
||||
|
||||
from waflib import Utils |
||||
import os |
||||
|
||||
top = '.' |
||||
PROJECT_NAME = 'tier2test' |
||||
|
||||
def options(opt): |
||||
return |
||||
|
||||
def configure(conf): |
||||
conf.define('TIER2TEST_EXPORTS', 1) |
||||
|
||||
def build(bld): |
||||
source = ['tier2test.cpp'] |
||||
includes = ['../../public', '../../public/tier0'] |
||||
defines = [] |
||||
libs = ['tier0', 'tier1','tier2', 'mathlib', 'unitlib'] |
||||
|
||||
if bld.env.DEST_OS != 'win32': |
||||
libs += [ 'DL', 'LOG' ] |
||||
else: |
||||
libs += ['USER32', 'SHELL32'] |
||||
|
||||
install_path = bld.env.TESTDIR |
||||
bld.shlib( |
||||
source = source, |
||||
target = PROJECT_NAME, |
||||
name = PROJECT_NAME, |
||||
features = 'c cxx', |
||||
includes = includes, |
||||
defines = defines, |
||||
use = libs, |
||||
install_path = install_path, |
||||
subsystem = bld.env.MSVC_SUBSYSTEM, |
||||
idx = bld.get_taskgen_count() |
||||
) |
@ -0,0 +1,39 @@
@@ -0,0 +1,39 @@
|
||||
#! /usr/bin/env python |
||||
# encoding: utf-8 |
||||
|
||||
from waflib import Utils |
||||
import os |
||||
|
||||
top = '.' |
||||
PROJECT_NAME = 'tier3test' |
||||
|
||||
def options(opt): |
||||
return |
||||
|
||||
def configure(conf): |
||||
conf.define('TIER3TEST_EXPORTS', 1) |
||||
|
||||
def build(bld): |
||||
source = ['tier3test.cpp'] |
||||
includes = ['../../public', '../../public/tier0'] |
||||
defines = [] |
||||
libs = ['tier0', 'tier1','tier2', 'tier3', 'mathlib', 'unitlib'] |
||||
|
||||
if bld.env.DEST_OS != 'win32': |
||||
libs += [ 'DL', 'LOG' ] |
||||
else: |
||||
libs += ['USER32', 'SHELL32'] |
||||
|
||||
install_path = bld.env.TESTDIR |
||||
bld.shlib( |
||||
source = source, |
||||
target = PROJECT_NAME, |
||||
name = PROJECT_NAME, |
||||
features = 'c cxx', |
||||
includes = includes, |
||||
defines = defines, |
||||
use = libs, |
||||
install_path = install_path, |
||||
subsystem = bld.env.MSVC_SUBSYSTEM, |
||||
idx = bld.get_taskgen_count() |
||||
) |
@ -0,0 +1,40 @@
@@ -0,0 +1,40 @@
|
||||
#! /usr/bin/env python |
||||
# encoding: utf-8 |
||||
|
||||
from waflib import Utils |
||||
import os |
||||
|
||||
top = '.' |
||||
PROJECT_NAME = 'unittest' |
||||
|
||||
def options(opt): |
||||
# stub |
||||
return |
||||
|
||||
def configure(conf): |
||||
conf.define('PROTECTED_THINGS_DISABLE',1) |
||||
|
||||
def build(bld): |
||||
source = ['unittest.cpp'] |
||||
includes = ['../../public'] |
||||
defines = [] |
||||
libs = ['tier0', 'appframework', 'tier1', 'tier2','tier3', 'vstdlib', 'unitlib'] |
||||
|
||||
if bld.env.DEST_OS != 'win32': |
||||
libs += [ 'DL', 'LOG' ] |
||||
else: |
||||
libs += ['USER32', 'SHELL32'] |
||||
|
||||
install_path = bld.env.BINDIR |
||||
bld( |
||||
source = source, |
||||
target = PROJECT_NAME, |
||||
name = PROJECT_NAME, |
||||
features = 'c cxx cxxprogram', |
||||
includes = includes, |
||||
defines = defines, |
||||
use = libs, |
||||
install_path = install_path, |
||||
subsystem = bld.env.MSVC_SUBSYSTEM, |
||||
idx = bld.get_taskgen_count() |
||||
) |
Loading…
Reference in new issue