From e1ae0531bfad0fce8590c26d1e38825df22d812a Mon Sep 17 00:00:00 2001 From: David Kalnischkies Date: Thu, 24 Nov 2016 12:14:39 +0100 Subject: optional write aptwebserver log to client specific files The test test-handle-redirect-as-used-mirror-change serves multiple clients at the same time, so the order of the output is undefined and once in a while the two clients will intermix their lines causing the grep we perform on it later to fail making our tests fail. Solved by introducing client-specific logfiles which we all grep and sort the result to have the results more stable. Git-Dch: Ignore --- test/libapt/teestream_test.cc | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 test/libapt/teestream_test.cc (limited to 'test/libapt') diff --git a/test/libapt/teestream_test.cc b/test/libapt/teestream_test.cc new file mode 100644 index 000000000..18610b24d --- /dev/null +++ b/test/libapt/teestream_test.cc @@ -0,0 +1,39 @@ +#include + +#include +#include +#include +#include "../interactive-helper/teestream.h" + +#include + +TEST(TeeStreamTest,TwoStringSinks) +{ + std::ostringstream one, two; + basic_teeostream tee(one, two); + tee << "This is the " << 1 << '.' << " Test, we expect: " << std::boolalpha << true << "\n"; + std::string okay("This is the 1. Test, we expect: true\n"); + EXPECT_EQ(okay, one.str()); + EXPECT_EQ(okay, two.str()); + EXPECT_EQ(one.str(), two.str()); +} + +TEST(TeeStreamTest,DevNullSink1) +{ + std::ostringstream one; + std::fstream two("/dev/null"); + basic_teeostream tee(one, two); + tee << "This is the " << 2 << '.' << " Test, we expect: " << std::boolalpha << false << "\n"; + std::string okay("This is the 2. Test, we expect: false\n"); + EXPECT_EQ(okay, one.str()); +} + +TEST(TeeStreamTest,DevNullSink2) +{ + std::ostringstream one; + std::fstream two("/dev/null"); + basic_teeostream tee(two, one); + tee << "This is the " << 3 << '.' << " Test, we expect: " << std::boolalpha << false << "\n"; + std::string okay("This is the 3. Test, we expect: false\n"); + EXPECT_EQ(okay, one.str()); +} -- cgit v1.2.3