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;
|
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;
|
libFunctionCounter = 0;
|
||||||
libFunctionDetourCounter = 0;
|
libFunctionDetourCounter = 0;
|
||||||
|
|
||||||
SECTION( "attaching installs a detour" )
|
|
||||||
{
|
|
||||||
REQUIRE( realLibFunction == libFunction );
|
REQUIRE( realLibFunction == libFunction );
|
||||||
REQUIRE( libFunction() == 42 );
|
REQUIRE( libFunction() == 42 );
|
||||||
REQUIRE( libFunctionCounter == 1 );
|
REQUIRE( libFunctionCounter == 1 );
|
||||||
|
|
@ -50,12 +48,16 @@ TEST_CASE( "Overriding custom function in dylib", "[attach][detach][dylib]" )
|
||||||
CHECK( detour_detach_and_commit(reinterpret_cast<detour_func_t*>(&realLibFunction), reinterpret_cast<detour_func_t>(libFunctionDetour)) == err_none );
|
CHECK( detour_detach_and_commit(reinterpret_cast<detour_func_t*>(&realLibFunction), reinterpret_cast<detour_func_t>(libFunctionDetour)) == err_none );
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION( "detaching in separate transaction removes detour" )
|
TEST_CASE( "Detaching custom function in dylib removes detour", "[detach][dylib]" )
|
||||||
{
|
{
|
||||||
|
libFunctionCounter = 0;
|
||||||
|
libFunctionDetourCounter = 0;
|
||||||
|
|
||||||
REQUIRE( detour_transaction_begin() == err_none );
|
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( detour_attach_and_commit(reinterpret_cast<detour_func_t*>(&realLibFunction), reinterpret_cast<detour_func_t>(libFunctionDetour)) == err_none );
|
||||||
REQUIRE( realLibFunction != libFunction );
|
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 );
|
REQUIRE( detour_transaction_begin() == err_none );
|
||||||
|
|
||||||
SECTION( "detach + transaction_commit" )
|
SECTION( "detach + transaction_commit" )
|
||||||
|
|
@ -75,4 +77,3 @@ TEST_CASE( "Overriding custom function in dylib", "[attach][detach][dylib]" )
|
||||||
CHECK( libFunctionCounter == 1 );
|
CHECK( libFunctionCounter == 1 );
|
||||||
CHECK( libFunctionDetourCounter == 0 );
|
CHECK( libFunctionDetourCounter == 0 );
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue