Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / lldb / unittests / Host / PipeTest.cpp
blob35a44ccf03733b3f90729779e92fa294d5402b84
1 //===-- PipeTest.cpp ------------------------------------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
9 #include "lldb/Host/Pipe.h"
10 #include "TestingSupport/SubsystemRAII.h"
11 #include "lldb/Host/FileSystem.h"
12 #include "lldb/Host/HostInfo.h"
13 #include "gtest/gtest.h"
15 using namespace lldb_private;
17 class PipeTest : public testing::Test {
18 public:
19 SubsystemRAII<FileSystem, HostInfo> subsystems;
22 TEST_F(PipeTest, CreateWithUniqueName) {
23 Pipe pipe;
24 llvm::SmallString<0> name;
25 ASSERT_THAT_ERROR(pipe.CreateWithUniqueName("PipeTest-CreateWithUniqueName",
26 /*child_process_inherit=*/false,
27 name)
28 .ToError(),
29 llvm::Succeeded());
32 // Test broken
33 #ifndef _WIN32
34 TEST_F(PipeTest, OpenAsReader) {
35 Pipe pipe;
36 llvm::SmallString<0> name;
37 ASSERT_THAT_ERROR(pipe.CreateWithUniqueName("PipeTest-OpenAsReader",
38 /*child_process_inherit=*/false,
39 name)
40 .ToError(),
41 llvm::Succeeded());
43 // Ensure name is not null-terminated
44 size_t name_len = name.size();
45 name += "foobar";
46 llvm::StringRef name_ref(name.data(), name_len);
47 ASSERT_THAT_ERROR(
48 pipe.OpenAsReader(name_ref, /*child_process_inherit=*/false).ToError(),
49 llvm::Succeeded());
51 #endif