Skip to content

Commit

Permalink
Add "SeparateProcess" test
Browse files Browse the repository at this point in the history
  • Loading branch information
MarcusTomlinson committed Jan 8, 2024
1 parent f43a238 commit 100a325
Showing 1 changed file with 37 additions and 1 deletion.
38 changes: 37 additions & 1 deletion tests/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ Ipc::Message RecvCallback( const Ipc::Message& recvHeader, const Ipc::Message& r
return std::string( "Unix Domain Sockets!" );
}

TEST( Client, Simple )
TEST( Client, SameProcess )
{
Ipc::Server server( c_serverSocket );
auto listenThread = std::thread(
Expand All @@ -72,6 +72,42 @@ TEST( Client, Simple )
listenThread.join();
}

TEST( Simple, SeparateProcess )
{
std::thread(
[]
{
Ipc::Server server( c_serverSocket );
ASSERT_TRUE( server.Listen( RecvCallback ) );
ASSERT_TRUE( server.Listen( RecvCallback ) );
} )
.detach();

EXPECT_EXIT(
{
Ipc::Client client( c_serverSocket );

auto response = client.Send( std::string( "bin" ), std::vector<unsigned char>{ 0 } );
ASSERT_FALSE( response.IsError() );
ASSERT_EQ( response.AsByteVect(), std::vector<unsigned char>{ 1 } );

exit( 0 );
},
testing::ExitedWithCode( 0 ), "" );

EXPECT_EXIT(
{
Ipc::Client client( c_serverSocket );

auto response = client.Send( std::vector<unsigned char>{ 0 }, std::string( "Hello?" ) );
ASSERT_FALSE( response.IsError() );
ASSERT_EQ( response.AsString(), "Unix Domain Sockets!" );

exit( 0 );
},
testing::ExitedWithCode( 0 ), "" );
}

TEST( Server, StopListening )
{
Ipc::Server server( c_serverSocket );
Expand Down

0 comments on commit 100a325

Please sign in to comment.