mirror of
https://github.com/alliedmodders/metamod-source.git
synced 2025-12-08 10:58:31 +00:00
Added TestBail
--HG-- extra : convert_revision : svn%3Ac2935e3e-5518-0410-8daf-afa5dab7d4e3/trunk%4076
This commit is contained in:
parent
a3fe9b64de
commit
1c1b3953a3
@ -63,6 +63,7 @@ DO_TEST(Basic);
|
|||||||
DO_TEST(VafmtAndOverload);
|
DO_TEST(VafmtAndOverload);
|
||||||
DO_TEST(ThisPtrOffs);
|
DO_TEST(ThisPtrOffs);
|
||||||
DO_TEST(PlugSys);
|
DO_TEST(PlugSys);
|
||||||
|
DO_TEST(Bail);
|
||||||
|
|
||||||
int main(int argc, char *argv[])
|
int main(int argc, char *argv[])
|
||||||
{
|
{
|
||||||
|
|||||||
37
sourcehook/test/testbail.cpp
Normal file
37
sourcehook/test/testbail.cpp
Normal file
@ -0,0 +1,37 @@
|
|||||||
|
// TESTBAIL
|
||||||
|
// Test for a bug Bail has found
|
||||||
|
|
||||||
|
#include "testbail.h"
|
||||||
|
|
||||||
|
void *___testbail_gabgab;
|
||||||
|
|
||||||
|
bool TestBail(std::string &error)
|
||||||
|
{
|
||||||
|
SourceHook::CSourceHookImpl g_SHImpl;
|
||||||
|
g_SHPtr = &g_SHImpl;
|
||||||
|
g_PLID = 1;
|
||||||
|
|
||||||
|
g_Gabgab = new IGaben;
|
||||||
|
___testbail_gabgab = (void*)g_Gabgab;
|
||||||
|
|
||||||
|
g_Gabgab->EatYams();
|
||||||
|
|
||||||
|
SH_ADD_HOOK_STATICFUNC(IGaben, EatYams, g_Gabgab, EatYams0_Handler, false);
|
||||||
|
|
||||||
|
g_Gabgab->EatYams();
|
||||||
|
|
||||||
|
___TestBail2();
|
||||||
|
|
||||||
|
g_Gabgab->EatYams();
|
||||||
|
|
||||||
|
SH_REMOVE_HOOK_STATICFUNC(IGaben, EatYams, g_Gabgab, EatYams0_Handler, false);
|
||||||
|
|
||||||
|
g_Gabgab->EatYams();
|
||||||
|
|
||||||
|
delete g_Gabgab;
|
||||||
|
|
||||||
|
// If it didn't crash, it's ok
|
||||||
|
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
40
sourcehook/test/testbail.h
Normal file
40
sourcehook/test/testbail.h
Normal file
@ -0,0 +1,40 @@
|
|||||||
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
// Shared data for testbail
|
||||||
|
|
||||||
|
#include <string>
|
||||||
|
#include "sourcehook_impl.h"
|
||||||
|
#include "testevents.h"
|
||||||
|
#include <stdarg.h>
|
||||||
|
|
||||||
|
void ___TestBail2();
|
||||||
|
|
||||||
|
namespace
|
||||||
|
{
|
||||||
|
StateList g_States;
|
||||||
|
SourceHook::ISourceHook *g_SHPtr;
|
||||||
|
SourceHook::Plugin g_PLID;
|
||||||
|
|
||||||
|
MAKE_STATE(State_EatYams_Called);
|
||||||
|
MAKE_STATE(State_EatYams_Handler_Called);
|
||||||
|
|
||||||
|
|
||||||
|
class IGaben
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
virtual void EatYams()
|
||||||
|
{
|
||||||
|
ADD_STATE(State_EatYams_Called);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
SH_DECL_HOOK0_void(IGaben, EatYams, SH_NOATTRIB, 0);
|
||||||
|
|
||||||
|
void EatYams0_Handler()
|
||||||
|
{
|
||||||
|
ADD_STATE(State_EatYams_Handler_Called);
|
||||||
|
}
|
||||||
|
|
||||||
|
IGaben *g_Gabgab;
|
||||||
|
}
|
||||||
|
|
||||||
|
extern void *___testbail_gabgab;
|
||||||
23
sourcehook/test/testbail2.cpp
Normal file
23
sourcehook/test/testbail2.cpp
Normal file
@ -0,0 +1,23 @@
|
|||||||
|
// TESTBAIL
|
||||||
|
// Different compilation unit
|
||||||
|
|
||||||
|
#include "testbail.h"
|
||||||
|
|
||||||
|
void ___TestBail2()
|
||||||
|
{
|
||||||
|
SourceHook::CSourceHookImpl g_SHImpl;
|
||||||
|
g_SHPtr = &g_SHImpl;
|
||||||
|
g_PLID = 2;
|
||||||
|
|
||||||
|
g_Gabgab = (IGaben*)___testbail_gabgab;
|
||||||
|
|
||||||
|
g_Gabgab->EatYams();
|
||||||
|
|
||||||
|
SH_ADD_HOOK_STATICFUNC(IGaben, EatYams, g_Gabgab, EatYams0_Handler, false);
|
||||||
|
|
||||||
|
g_Gabgab->EatYams();
|
||||||
|
|
||||||
|
SH_REMOVE_HOOK_STATICFUNC(IGaben, EatYams, g_Gabgab, EatYams0_Handler, false);
|
||||||
|
|
||||||
|
g_Gabgab->EatYams();
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue
Block a user