aboutsummaryrefslogtreecommitdiffhomepage
path: root/src/test/cpp/util
diff options
context:
space:
mode:
authorGravatar Laszlo Csomor <laszlocsomor@google.com>2017-03-02 09:09:09 +0000
committerGravatar Yue Gan <yueg@google.com>2017-03-02 13:32:16 +0000
commit508af301b3d7c1465189a0edfe4707a1c261a658 (patch)
treea426a81dd791f3053dd9cb86d5f0860992814a4f /src/test/cpp/util
parent4f2b41d3f5fe936833380a0446adb671b8a50b1f (diff)
Bazel client: do not use `errno`.
Do not use `errno` in platform-independent code, because Windows API functions don't set it. This change abstracts away error handling and the functions whose `errno` result we care about, will set an input error variable. Fixes https://github.com/bazelbuild/bazel/issues/2506 -- PiperOrigin-RevId: 148977873 MOS_MIGRATED_REVID=148977873
Diffstat (limited to 'src/test/cpp/util')
-rw-r--r--src/test/cpp/util/file_test.cc19
1 files changed, 13 insertions, 6 deletions
diff --git a/src/test/cpp/util/file_test.cc b/src/test/cpp/util/file_test.cc
index 0602dcb20c..c941619244 100644
--- a/src/test/cpp/util/file_test.cc
+++ b/src/test/cpp/util/file_test.cc
@@ -32,10 +32,13 @@ TEST(FileTest, TestSingleThreadedPipe) {
std::unique_ptr<IPipe> pipe(CreatePipe());
char buffer[50] = {0};
ASSERT_TRUE(pipe.get()->Send("hello", 5));
- ASSERT_EQ(3, pipe.get()->Receive(buffer, 3));
+ int error = -1;
+ ASSERT_EQ(3, pipe.get()->Receive(buffer, 3, &error));
ASSERT_TRUE(pipe.get()->Send(" world", 6));
- ASSERT_EQ(5, pipe.get()->Receive(buffer + 3, 5));
- ASSERT_EQ(3, pipe.get()->Receive(buffer + 8, 40));
+ ASSERT_EQ(5, pipe.get()->Receive(buffer + 3, 5, &error));
+ ASSERT_EQ(IPipe::SUCCESS, error);
+ ASSERT_EQ(3, pipe.get()->Receive(buffer + 8, 40, &error));
+ ASSERT_EQ(IPipe::SUCCESS, error);
ASSERT_EQ(0, strncmp(buffer, "hello world", 11));
}
@@ -50,9 +53,13 @@ TEST(FileTest, TestMultiThreadedPipe) {
// Wait for all data to be fully written to the pipe.
writer_thread.join();
- ASSERT_EQ(3, pipe.get()->Receive(buffer, 3));
- ASSERT_EQ(5, pipe.get()->Receive(buffer + 3, 5));
- ASSERT_EQ(3, pipe.get()->Receive(buffer + 8, 40));
+ int error = -1;
+ ASSERT_EQ(3, pipe.get()->Receive(buffer, 3, &error));
+ ASSERT_EQ(IPipe::SUCCESS, error);
+ ASSERT_EQ(5, pipe.get()->Receive(buffer + 3, 5, &error));
+ ASSERT_EQ(IPipe::SUCCESS, error);
+ ASSERT_EQ(3, pipe.get()->Receive(buffer + 8, 40, &error));
+ ASSERT_EQ(IPipe::SUCCESS, error);
ASSERT_EQ(0, strncmp(buffer, "hello world", 11));
}