Update PipeCaptureTest.MinimalBinaryCrash777973 expected string (#777973)

PipeCapture::OnReadable() has been almost completely re-written but this
test is still failing thus:

    $ ./test_PipeCapture
    ...
    [ RUN      ] PipeCaptureTest.MinimalBinaryCrash777973
    test_PipeCapture.cc:313: Failure
          Expected: inputstr
         Of length: 27
    To be equal to: capturedstr.raw()
         Of length: 26
    With first binary difference:
    < 0x00000010  "...!......."       A9 C2 A0 21 E2 95 9F E2 88 A9 C2
    --
    > 0x00000010  "...!......"        A9 C2 A0 21 E2 95 9F E2 88 A9
    [  FAILED  ] PipeCaptureTest.MinimalBinaryCrash777973 (0 ms)
    ...

The OnReadable() code specifically skips invalid bytes which aren't part
of valid UTF-8 characters, because they can't be displayed to the user.
The final C2 byte is the start of a multi-byte UTF-8 character, so on
it's own is invalid.  Therefore PipeCapture skips it.  Update expected
string accordingly.  Now the test passes.

Bug 777973 - Segmentation fault on bad disk
This commit is contained in:
Mike Fleetwood 2017-05-25 19:52:24 +01:00 committed by Curtis Gedak
parent b5b3d199f8
commit 0a3e8487a0
1 changed files with 7 additions and 2 deletions

View File

@ -18,7 +18,8 @@
* *
* All the tests work by creating a pipe(3) and using a separate thread to write data into * All the tests work by creating a pipe(3) and using a separate thread to write data into
* the pipe with PipeCapture running in the initial thread. Captured data is then checked * the pipe with PipeCapture running in the initial thread. Captured data is then checked
* that it matches the input. * that it either matches the input or different expected output depending on the features
* being tested.
*/ */
#include "PipeCapture.h" #include "PipeCapture.h"
@ -156,6 +157,7 @@ protected:
static const size_t WriterFD = 1; static const size_t WriterFD = 1;
std::string inputstr; std::string inputstr;
std::string expectedstr;
Glib::ustring capturedstr; Glib::ustring capturedstr;
bool eof_signalled; bool eof_signalled;
unsigned update_signalled; unsigned update_signalled;
@ -315,7 +317,10 @@ TEST_F( PipeCaptureTest, MinimalBinaryCrash777973 )
pc.signal_eof.connect( sigc::mem_fun( *this, &PipeCaptureTest::eof_callback ) ); pc.signal_eof.connect( sigc::mem_fun( *this, &PipeCaptureTest::eof_callback ) );
pc.connect_signal(); pc.connect_signal();
run_writer_thread(); run_writer_thread();
EXPECT_BINARYSTRINGEQ( inputstr, capturedstr.raw() ); // Final \xC2 byte is part of an incomplete UTF-8 character so will be skipped by
// PipeCapture.
expectedstr = "/LOST.DIR/!\xE2\x95\x9F\xE2\x88\xA9\xC2\xA0!\xE2\x95\x9F\xE2\x88\xA9";
EXPECT_BINARYSTRINGEQ( expectedstr, capturedstr.raw() );
EXPECT_TRUE( eof_signalled ); EXPECT_TRUE( eof_signalled );
} }