Add test that PipeCapture can read embedded NUL character (#777973)

Test currently detects failure thus:

    $ ./test_PipeCapture
    ...
    [ RUN      ] PipeCaptureTest.ReadEmbeddedNULCharacter
    unknown file: Failure
    C++ exception with description "std::bad_alloc" thrown in the test body.
    [  FAILED  ] PipeCaptureTest.ReadEmbeddedNULCharacter (31917 ms)
    ...

Bug 777973 - Segmentation fault on bad disk
This commit is contained in:
Mike Fleetwood 2017-05-25 08:11:22 +01:00 committed by Curtis Gedak
parent 0a3e8487a0
commit 22573b4eed
1 changed files with 13 additions and 0 deletions

View File

@ -324,6 +324,19 @@ TEST_F( PipeCaptureTest, MinimalBinaryCrash777973 )
EXPECT_TRUE( eof_signalled );
}
TEST_F( PipeCaptureTest, ReadEmbeddedNULCharacter )
{
// Test embedded NUL character in the middle of the input is read correctly.
const char * buf = "ABC\0EF";
inputstr = std::string( buf, 6 );
PipeCapture pc( pipefds[ReaderFD], capturedstr );
pc.signal_eof.connect( sigc::mem_fun( *this, &PipeCaptureTest::eof_callback ) );
pc.connect_signal();
run_writer_thread();
EXPECT_BINARYSTRINGEQ( inputstr, capturedstr.raw() );
EXPECT_TRUE( eof_signalled );
}
} // namespace GParted
// Custom Google Test main() which also initialises the Glib threading system for