blob: a7f92db6bfafabc229ab0c567961ae0492811bf8 [file] [log] [blame]
Alex Deymo992e4292015-12-11 19:42:09 -08001// Copyright 2015 The Chromium OS Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style license that can be
3// found in the LICENSE file.
4
5// Internal implementation of brillo::Any class.
6
7#ifndef LIBBRILLO_BRILLO_UNITTEST_UTILS_H_
8#define LIBBRILLO_BRILLO_UNITTEST_UTILS_H_
9
10namespace brillo {
11
12// Helper class to create and close a unidirectional pipe. The file descriptors
13// will be closed on destruction, unless set to -1.
14class ScopedPipe {
15 public:
16 // The internal pipe size.
17 static const int kPipeSize;
18
19 ScopedPipe();
20 ~ScopedPipe();
21
22 // The reader and writer end of the pipe.
23 int reader{-1};
24 int writer{-1};
25};
26
27// Helper class to create and close a bi-directional pair of sockets. The
28// sockets will be closed on destruction, unless set to -1.
29class ScopedSocketPair {
30 public:
31 ScopedSocketPair();
32 ~ScopedSocketPair();
33
34 // The left and right sockets are bi-directional connected and
35 // indistinguishable file descriptor. We named them left/right for easier
36 // reading.
37 int left{-1};
38 int right{-1};
39};
40
41} // namespace brillo
42
43#endif // LIBBRILLO_BRILLO_UNITTEST_UTILS_H_