Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 9b68a25f authored by Christopher Ferris's avatar Christopher Ferris Committed by android-build-merger
Browse files

Merge "Update for modified CapturedStderr." am: c16ddeb1 am: f6721f8e

am: 5da0f5bd

Change-Id: I1ea5307e86fabb8c5bf24462114f1718b18600e6
parents 85c8171b 5da0f5bd
Loading
Loading
Loading
Loading
+1 −1
Original line number Diff line number Diff line
@@ -189,7 +189,7 @@ status_t BufferedTextOutput::print(const char* txt, size_t len)
                // them out without going through the buffer.
                
                // Slurp up all of the lines.
                const char* lastLine = txt+1;
                const char* lastLine = txt;
                while (txt < end) {
                    if (*txt++ == '\n') lastLine = txt;
                }
+10 −17
Original line number Diff line number Diff line
@@ -28,15 +28,14 @@
#include <binder/TextOutput.h>
#include <binder/Debug.h>

static void CheckMessage(const CapturedStderr& cap,
static void CheckMessage(CapturedStderr& cap,
                         const char* expected,
                         bool singleline) {
    std::string output;
    ASSERT_EQ(0, lseek(cap.fd(), 0, SEEK_SET));
    android::base::ReadFdToString(cap.fd(), &output);
    cap.Stop();
    std::string output = cap.str();
    if (singleline)
        output.erase(std::remove(output.begin(), output.end(), '\n'));
    ASSERT_STREQ(output.c_str(), expected);
    ASSERT_EQ(output, expected);
}

#define CHECK_LOG_(input, expect, singleline)    \
@@ -60,28 +59,22 @@ static void CheckMessage(const CapturedStderr& cap,
TEST(TextOutput, HandlesStdEndl) {
    CapturedStderr cap;
    android::aerr << "foobar" << std::endl;
    std::string output;
    ASSERT_EQ(0, lseek(cap.fd(), 0, SEEK_SET));
    android::base::ReadFdToString(cap.fd(), &output);
    ASSERT_STREQ(output.c_str(), "foobar\n");
    cap.Stop();
    ASSERT_EQ(cap.str(), "foobar\n");
}

TEST(TextOutput, HandlesCEndl) {
    CapturedStderr cap;
    android::aerr << "foobar" << "\n";
    std::string output;
    ASSERT_EQ(0, lseek(cap.fd(), 0, SEEK_SET));
    android::base::ReadFdToString(cap.fd(), &output);
    ASSERT_STREQ(output.c_str(), "foobar\n");
    cap.Stop();
    ASSERT_EQ(cap.str(), "foobar\n");
}

TEST(TextOutput, HandlesAndroidEndl) {
    CapturedStderr cap;
    android::aerr << "foobar" << android::endl;
    std::string output;
    ASSERT_EQ(0, lseek(cap.fd(), 0, SEEK_SET));
    android::base::ReadFdToString(cap.fd(), &output);
    ASSERT_STREQ(output.c_str(), "foobar\n");
    cap.Stop();
    ASSERT_EQ(cap.str(), "foobar\n");
}

TEST(TextOutput, HandleEmptyString) {