testing system function override
This commit is contained in:
parent
1fbdb703eb
commit
5d833e2928
4 changed files with 28 additions and 2 deletions
25
tests/test_system_function.cpp
Normal file
25
tests/test_system_function.cpp
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
// Copyright (c) Lysann Tranvouez. All rights reserved.
|
||||
|
||||
#include <catch2/catch_test_macros.hpp>
|
||||
|
||||
#include <mach_detours.h>
|
||||
|
||||
char* (*realStrerror)(int) = strerror;
|
||||
char* strerrorDetour(int errno)
|
||||
{
|
||||
return (char *)"strerrorOverride";
|
||||
}
|
||||
|
||||
TEST_CASE( "Overriding system function", "[attach][system]" )
|
||||
{
|
||||
REQUIRE( std::string_view(strerror( 0 )) == "Undefined error: 0" );
|
||||
|
||||
REQUIRE( detour_transaction_begin() == err_none );
|
||||
REQUIRE( detour_attach_and_commit(reinterpret_cast<detour_func_t*>(&realStrerror), reinterpret_cast<detour_func_t>(strerrorDetour)) == err_none );
|
||||
|
||||
CHECK( std::string_view(strerror( 0 )) == "strerrorOverride" );
|
||||
|
||||
// clean up
|
||||
CHECK( detour_transaction_begin() == err_none );
|
||||
CHECK( detour_detach_and_commit(reinterpret_cast<detour_func_t*>(&realStrerror), reinterpret_cast<detour_func_t>(strerrorDetour)) == err_none );
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue