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