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

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

Merge "Update for modified CapturedStderr."

am: c16ddeb1

Change-Id: I3965adac3c7020e3b451c203170e00701e52a991
parents 4848e117 c16ddeb1
Loading
Loading
Loading
Loading
+1 −1
Original line number Original line 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.
                // them out without going through the buffer.
                
                
                // Slurp up all of the lines.
                // Slurp up all of the lines.
                const char* lastLine = txt+1;
                const char* lastLine = txt;
                while (txt < end) {
                while (txt < end) {
                    if (*txt++ == '\n') lastLine = txt;
                    if (*txt++ == '\n') lastLine = txt;
                }
                }
+10 −17
Original line number Original line Diff line number Diff line
@@ -28,15 +28,14 @@
#include <binder/TextOutput.h>
#include <binder/TextOutput.h>
#include <binder/Debug.h>
#include <binder/Debug.h>


static void CheckMessage(const CapturedStderr& cap,
static void CheckMessage(CapturedStderr& cap,
                         const char* expected,
                         const char* expected,
                         bool singleline) {
                         bool singleline) {
    std::string output;
    cap.Stop();
    ASSERT_EQ(0, lseek(cap.fd(), 0, SEEK_SET));
    std::string output = cap.str();
    android::base::ReadFdToString(cap.fd(), &output);
    if (singleline)
    if (singleline)
        output.erase(std::remove(output.begin(), output.end(), '\n'));
        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)    \
#define CHECK_LOG_(input, expect, singleline)    \
@@ -60,28 +59,22 @@ static void CheckMessage(const CapturedStderr& cap,
TEST(TextOutput, HandlesStdEndl) {
TEST(TextOutput, HandlesStdEndl) {
    CapturedStderr cap;
    CapturedStderr cap;
    android::aerr << "foobar" << std::endl;
    android::aerr << "foobar" << std::endl;
    std::string output;
    cap.Stop();
    ASSERT_EQ(0, lseek(cap.fd(), 0, SEEK_SET));
    ASSERT_EQ(cap.str(), "foobar\n");
    android::base::ReadFdToString(cap.fd(), &output);
    ASSERT_STREQ(output.c_str(), "foobar\n");
}
}


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


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


TEST(TextOutput, HandleEmptyString) {
TEST(TextOutput, HandleEmptyString) {