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



commit 22573b4eede9dab13b6a26d39ebc0f363f567e0e
Author: Mike Fleetwood <mike fleetwood googlemail com>
Date:   Thu May 25 08:11:22 2017 +0100

    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

 tests/test_PipeCapture.cc |   13 +++++++++++++
 1 files changed, 13 insertions(+), 0 deletions(-)
---
diff --git a/tests/test_PipeCapture.cc b/tests/test_PipeCapture.cc
index 3808e28..a45804b 100644
--- a/tests/test_PipeCapture.cc
+++ b/tests/test_PipeCapture.cc
@@ -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


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]