Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/windirstat/llfio.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authorNiall Douglas (s [underscore] sourceforge {at} nedprod [dot] com) <spamtrap@nedprod.com>2019-11-27 14:54:56 +0300
committerNiall Douglas (s [underscore] sourceforge {at} nedprod [dot] com) <spamtrap@nedprod.com>2019-11-27 14:54:56 +0300
commit10be5e636948b51d6ec400091c2befc19b482146 (patch)
treee42bc0e92498ea0fd31c4d0c8915858665834353 /test
parent8186fe5295885974ddc790c74c83f6f78538c0d6 (diff)
Lots more pipe_handle related changes, including an initial unit test. Still doesn't work yet.
Diffstat (limited to 'test')
-rw-r--r--test/tests/pipe_handle.cpp68
1 files changed, 68 insertions, 0 deletions
diff --git a/test/tests/pipe_handle.cpp b/test/tests/pipe_handle.cpp
new file mode 100644
index 00000000..5b1f4d39
--- /dev/null
+++ b/test/tests/pipe_handle.cpp
@@ -0,0 +1,68 @@
+/* Integration test kernel for whether pipe handles work
+(C) 2019 Niall Douglas <http://www.nedproductions.biz/> (2 commits)
+File Created: Nov 2019
+
+
+Licensed under the Apache License, Version 2.0 (the "License");
+you may not use this file except in compliance with the License.
+You may obtain a copy of the License in the accompanying file
+Licence.txt or at
+
+ http://www.apache.org/licenses/LICENSE-2.0
+
+Unless required by applicable law or agreed to in writing, software
+distributed under the License is distributed on an "AS IS" BASIS,
+WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+See the License for the specific language governing permissions and
+limitations under the License.
+
+
+Distributed under the Boost Software License, Version 1.0.
+ (See accompanying file Licence.txt or copy at
+ http://www.boost.org/LICENSE_1_0.txt)
+*/
+
+#include "../test_kernel_decl.hpp"
+
+#include <future>
+
+static inline void TestBlockingPipeHandle()
+{
+ namespace llfio = LLFIO_V2_NAMESPACE;
+ auto reader = std::async([] { // This immediately blocks in blocking mode
+ llfio::pipe_handle reader = llfio::pipe_handle::pipe_create("llfio-pipe-handle-test").value();
+ llfio::byte buffer[64];
+ auto read = reader.read(0, {{buffer, 64}}).value();
+ BOOST_REQUIRE(read == 5);
+ BOOST_CHECK(0 == memcmp(buffer, "hello", 5));
+ reader.close().value();
+ });
+ auto begin = std::chrono::steady_clock::now();
+ while(std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::steady_clock::now() - begin).count() < 100)
+ {
+ std::this_thread::sleep_for(std::chrono::milliseconds(100));
+ }
+ if(std::future_status::ready == reader.wait_for(std::chrono::seconds(0)))
+ {
+ reader.get();
+ }
+ llfio::pipe_handle writer;
+ begin = std::chrono::steady_clock::now();
+ while(std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::steady_clock::now() - begin).count() < 1000)
+ {
+ auto r = llfio::pipe_handle::pipe_open("llfio-pipe-handle-test");
+ if(r)
+ {
+ writer = std::move(r.value());
+ break;
+ }
+ }
+ BOOST_REQUIRE(writer.is_valid());
+ auto written = writer.write(0, {{(const llfio::byte *) "hello", 5}}).value();
+ BOOST_REQUIRE(written == 5);
+ writer.barrier().value();
+ writer.close().value();
+ reader.get();
+}
+
+KERNELTEST_TEST_KERNEL(integration, llfio, path_handle, works, "Tests that blocking llfio::pipe_handle works as expected", TestBlockingPipeHandle())