/** print last error of pipe system.
*/ staticvoid printPipeError( ::osl::Pipe const & aPipe )
{
oslPipeError nError = aPipe.getError( );
printf("#printPipeError# " ); switch ( nError ) { case osl_Pipe_E_None:
printf("Success!\n" ); break; case osl_Pipe_E_NotFound:
printf("The returned error is: Not found!\n" ); break; case osl_Pipe_E_AlreadyExists:
printf("The returned error is: Already exist!\n" ); break; case osl_Pipe_E_NoProtocol:
printf("The returned error is: No protocol!\n" ); break; case osl_Pipe_E_NetworkReset:
printf("The returned error is: Network reset!\n" ); break; case osl_Pipe_E_ConnectionAbort:
printf("The returned error is: Connection aborted!\n" ); break; case osl_Pipe_E_ConnectionReset:
printf("The returned error is: Connection reset!\n" ); break; case osl_Pipe_E_NoBufferSpace:
printf("The returned error is: No buffer space!\n" ); break; case osl_Pipe_E_TimedOut:
printf("The returned error is: Timeout!\n" ); break; case osl_Pipe_E_ConnectionRefused:
printf("The returned error is: Connection refused!\n" ); break; case osl_Pipe_E_invalidError:
printf("The returned error is: Invalid error!\n" ); break; default:
printf("The returned error is: Number %d, Unknown Error\n", nError ); break;
}
}
CPPUNIT_ASSERT_MESSAGE( "#test comment#: test constructor with name, option and security, the test of security is not implemented yet.",
bRes );
}
void ctors_copy( )
{ /// create a pipe.
::osl::Pipe aPipe( test::uniquePipeName(aTestPipeName), osl_Pipe_CREATE ); /// create a pipe using copy constructor.
::osl::Pipe aCopyPipe( aPipe );
bRes = aCopyPipe.is( ) && aCopyPipe == aPipe;
CPPUNIT_ASSERT_MESSAGE( "#test comment#: test copy constructor.",
bRes );
}
/* Note: DO NOT DO THIS - I have very deliberately caused send to FAIL, *on purpose* as this is the onlysanewaytotestnoacquire.Thisisaterriblemisuseofno-acquire,butinthiscaseis neededonlysowecantesttomakesureno-acquireisworking!
*/ void ctors_no_acquire( )
{ /// create a pipe.
OUString aPipeName(test::uniquePipeName(aTestPipeName));
oslPipe handle(osl_createPipe(aPipeName.pData, osl_Pipe_CREATE, nullptr)); /// constructs a pipe reference without acquiring the handle.
std::unique_ptr<osl::Pipe> xNoAcquirePipe(new osl::Pipe(handle, SAL_NO_ACQUIRE));
StreamPipe aStreamPipe(handle);
xNoAcquirePipe.reset(); int nRet = aStreamPipe.send("a", 1);
if (nRet >= 0)
bRes = false; else
bRes = true;
CPPUNIT_ASSERT_MESSAGE( "#test comment#: test constructor with no acquire of handle, deleted nonacquired pipe but could still send on original pipe!.",
bRes );
}
void ctors_acquire( )
{ /// create a base pipe.
::osl::Pipe aPipe( test::uniquePipeName(aTestPipeName), osl_Pipe_CREATE ); /// constructs two pipes, the second acquires the first pipe's handle.
::osl::Pipe aAcquirePipe( aPipe.getHandle( ) );
::osl::Pipe aAcquirePipe1( nullptr );
CPPUNIT_ASSERT_MESSAGE( "#test comment#: test constructor with acquire of handle, original pipe does not exist.",
bRes );
CPPUNIT_ASSERT_MESSAGE( "#test comment#: test constructor with acquire of handle, copied pipe does not exist",
!bRes1 );
CPPUNIT_ASSERT_MESSAGE( "#test comment#: test pipes should have same handle", bRes2);
}
CPPUNIT_ASSERT_MESSAGE( "#test comment#: test assign with reference.",
bRes );
CPPUNIT_ASSERT_MESSAGE( "#test comment#: test assign with reference.",
bRes1 );
}
CPPUNIT_ASSERT_MESSAGE( "#test comment#: test assign with handle.",
bRes );
CPPUNIT_ASSERT_MESSAGE( "#test comment#: test assign with handle.",
bRes1 );
}
CPPUNIT_ASSERT_MESSAGE( "#test comment#: test isEqual(),create one copy instance, and compare.",
bRes );
CPPUNIT_ASSERT_MESSAGE( "#test comment#: test isEqual(),create one copy instance, and compare.",
!bRes1 );
}
CPPUNIT_ASSERT_MESSAGE( "#test comment#: difference between close and clear.",
bRes);
CPPUNIT_ASSERT_MESSAGE( "#test comment#: difference between close and clear.",
!bRes1);
}
// assign it and check.
aStreamPipe1 = aStreamPipe;
bRes1 = aStreamPipe1.is( );
aStreamPipe.clear( );
aStreamPipe1.clear( );
CPPUNIT_ASSERT_MESSAGE( "#test comment#: test constructor with no parameter, before and after assign.",
!bRes );
CPPUNIT_ASSERT_MESSAGE( "#test comment#: test constructor with no parameter, before and after assign.",
bRes1 );
}
void ctors_handle( )
{ // create a pipe.
::osl::StreamPipe aStreamPipe( test::uniquePipeName(aTestPipeName), osl_Pipe_CREATE ); // create a pipe with last handle.
::osl::StreamPipe aStreamPipe1( aStreamPipe.getHandle( ) );
bRes = aStreamPipe1.is( ) && aStreamPipe == aStreamPipe1;
aStreamPipe.clear( );
aStreamPipe1.clear( );
CPPUNIT_ASSERT_MESSAGE( "#test comment#: test constructor with other's handle.",
bRes );
}
void ctors_no_acquire( )
{ // create a pipe.
::osl::StreamPipe aPipe( test::uniquePipeName(aTestPipeName), osl_Pipe_CREATE );
osl_acquirePipe(aPipe.getHandle()); // constructs a pipe reference without acquiring the handle.
::osl::StreamPipe aNoAcquirePipe( aPipe.getHandle( ), SAL_NO_ACQUIRE );
bRes = aNoAcquirePipe.is( );
aPipe.clear( );
CPPUNIT_ASSERT_MESSAGE( "#test comment#: test constructor with no acquire of handle, only validation test, do not know how to test no acquire.",
bRes );
}
/** testing the methods: inlineStreamPipe&SAL_CALLoperator=(oslPipePipe); inlineStreamPipe&SAL_CALLoperator=(constPipe&pipe); mindy:notimplementedinosl/pipe.hxx,soremovethecases
*/
/** wait _nSec seconds.
*/ staticvoid thread_sleep( sal_uInt32 _nSec )
{ /// print statement in thread process must use fflush() to force display.
fflush(stdout);
osl::Thread::wait(std::chrono::seconds(_nSec));
} // test read/write & send/recv data to pipe
namespace {
class Pipe_DataSink_Thread : public Thread
{ public: char buf[256];
Pipe_DataSink_Thread( ) { }
Pipe_DataSource_Thread myDataSourceThread;
Pipe_DataSink_Thread myDataSinkThread;
myDataSourceThread.create( );
thread_sleep( 1 );
myDataSourceThread.aListenPipe.close();
myDataSourceThread.join( ); //no condition judgment here, if the case could finish executing within 1 or 2 seconds, it passes.
}
¤ Diese beiden folgenden Angebotsgruppen bietet das Unternehmen0.21Angebot
(Wie Sie bei der Firma Beratungs- und Dienstleistungen beauftragen können 2026-09-29)
¤
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.