| OLD | NEW |
| 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2009 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include "chrome/browser/chromeos/pipe_reader.h" | 5 #include "chrome/browser/chromeos/pipe_reader.h" |
| 6 | 6 |
| 7 #include <errno.h> | 7 #include <errno.h> |
| 8 | 8 |
| 9 #include "base/safe_strerror_posix.h" | 9 #include "base/safe_strerror_posix.h" |
| 10 #include "testing/gtest/include/gtest/gtest.h" | 10 #include "testing/gtest/include/gtest/gtest.h" |
| 11 | 11 |
| 12 namespace chromeos { |
| 13 |
| 12 typedef testing::Test PipeReaderTest; | 14 typedef testing::Test PipeReaderTest; |
| 13 | 15 |
| 14 TEST_F(PipeReaderTest, SuccessfulReadTest) { | 16 TEST_F(PipeReaderTest, SuccessfulReadTest) { |
| 15 std::string pipe_name("/tmp/MYFIFO"); | 17 std::string pipe_name("/tmp/MYFIFO"); |
| 16 /* Create the FIFO if it does not exist */ | 18 /* Create the FIFO if it does not exist */ |
| 17 umask(0); | 19 umask(0); |
| 18 mknod(pipe_name.c_str(), S_IFIFO|0666, 0); | 20 mknod(pipe_name.c_str(), S_IFIFO|0666, 0); |
| 19 const char line[] = "foo"; | 21 const char line[] = "foo"; |
| 20 | 22 |
| 21 pid_t pID = fork(); | 23 pid_t pID = fork(); |
| (...skipping 67 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 89 // asking for more should still just return the amount that was written. | 91 // asking for more should still just return the amount that was written. |
| 90 std::string my_foo = reader.Read(5 * line.length()); | 92 std::string my_foo = reader.Read(5 * line.length()); |
| 91 EXPECT_EQ(my_foo[my_foo.length() - 1], '\n'); | 93 EXPECT_EQ(my_foo[my_foo.length() - 1], '\n'); |
| 92 my_foo.resize(my_foo.length() - 1); | 94 my_foo.resize(my_foo.length() - 1); |
| 93 EXPECT_EQ(my_foo, foo); | 95 EXPECT_EQ(my_foo, foo); |
| 94 | 96 |
| 95 std::string my_boo = reader.Read(5 * line.length()); | 97 std::string my_boo = reader.Read(5 * line.length()); |
| 96 EXPECT_EQ(my_boo, boo); | 98 EXPECT_EQ(my_boo, boo); |
| 97 } | 99 } |
| 98 } | 100 } |
| 101 |
| 102 } // namespace chromeos |
| OLD | NEW |