small test restructure again
This commit is contained in:
parent
5d833e2928
commit
7257abce71
1 changed files with 50 additions and 49 deletions
|
|
@ -14,13 +14,11 @@ static int libFunctionDetour()
|
|||
return 94;
|
||||
}
|
||||
|
||||
TEST_CASE( "Overriding custom function in dylib", "[attach][detach][dylib]" )
|
||||
TEST_CASE( "Attaching custom function in dylib installs detour", "[attach][dylib]" )
|
||||
{
|
||||
libFunctionCounter = 0;
|
||||
libFunctionDetourCounter = 0;
|
||||
|
||||
SECTION( "attaching installs a detour" )
|
||||
{
|
||||
REQUIRE( realLibFunction == libFunction );
|
||||
REQUIRE( libFunction() == 42 );
|
||||
REQUIRE( libFunctionCounter == 1 );
|
||||
|
|
@ -48,14 +46,18 @@ TEST_CASE( "Overriding custom function in dylib", "[attach][detach][dylib]" )
|
|||
// clean up
|
||||
REQUIRE( detour_transaction_begin() == err_none );
|
||||
CHECK( detour_detach_and_commit(reinterpret_cast<detour_func_t*>(&realLibFunction), reinterpret_cast<detour_func_t>(libFunctionDetour)) == err_none );
|
||||
}
|
||||
}
|
||||
|
||||
TEST_CASE( "Detaching custom function in dylib removes detour", "[detach][dylib]" )
|
||||
{
|
||||
libFunctionCounter = 0;
|
||||
libFunctionDetourCounter = 0;
|
||||
|
||||
SECTION( "detaching in separate transaction removes detour" )
|
||||
{
|
||||
REQUIRE( detour_transaction_begin() == err_none );
|
||||
REQUIRE( detour_attach_and_commit(reinterpret_cast<detour_func_t*>(&realLibFunction), reinterpret_cast<detour_func_t>(libFunctionDetour)) == err_none );
|
||||
REQUIRE( realLibFunction != libFunction );
|
||||
|
||||
// this must be a separate transaction because detach works only if the trampoline is actually in place already (committed)
|
||||
REQUIRE( detour_transaction_begin() == err_none );
|
||||
|
||||
SECTION( "detach + transaction_commit" )
|
||||
|
|
@ -74,5 +76,4 @@ TEST_CASE( "Overriding custom function in dylib", "[attach][detach][dylib]" )
|
|||
CHECK( libFunction() == 42 );
|
||||
CHECK( libFunctionCounter == 1 );
|
||||
CHECK( libFunctionDetourCounter == 0 );
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue