1 // Copyright (c) 2012 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 #ifndef LIBBRILLO_BRILLO_MINIJAIL_MOCK_MINIJAIL_H_ 6 #define LIBBRILLO_BRILLO_MINIJAIL_MOCK_MINIJAIL_H_ 7 8 #include <vector> 9 10 #include <base/macros.h> 11 #include <gmock/gmock.h> 12 13 #include "brillo/minijail/minijail.h" 14 15 namespace brillo { 16 17 class MockMinijail : public brillo::Minijail { 18 public: MockMinijail()19 MockMinijail() {} ~MockMinijail()20 virtual ~MockMinijail() {} 21 22 MOCK_METHOD0(New, struct minijail*()); 23 MOCK_METHOD1(Destroy, void(struct minijail*)); 24 25 MOCK_METHOD3(DropRoot, 26 bool(struct minijail* jail, 27 const char* user, 28 const char* group)); 29 MOCK_METHOD2(UseSeccompFilter, void(struct minijail* jail, const char* path)); 30 MOCK_METHOD2(UseCapabilities, void(struct minijail* jail, uint64_t capmask)); 31 MOCK_METHOD1(ResetSignalMask, void(struct minijail* jail)); 32 MOCK_METHOD1(Enter, void(struct minijail* jail)); 33 MOCK_METHOD3(Run, 34 bool(struct minijail* jail, 35 std::vector<char*> args, 36 pid_t* pid)); 37 MOCK_METHOD3(RunSync, 38 bool(struct minijail* jail, 39 std::vector<char*> args, 40 int* status)); 41 MOCK_METHOD3(RunAndDestroy, 42 bool(struct minijail* jail, 43 std::vector<char*> args, 44 pid_t* pid)); 45 MOCK_METHOD3(RunSyncAndDestroy, 46 bool(struct minijail* jail, 47 std::vector<char*> args, 48 int* status)); 49 MOCK_METHOD4(RunPipeAndDestroy, 50 bool(struct minijail* jail, 51 std::vector<char*> args, 52 pid_t* pid, 53 int* stdin)); 54 MOCK_METHOD6(RunPipesAndDestroy, 55 bool(struct minijail* jail, 56 std::vector<char*> args, 57 pid_t* pid, 58 int* stdin, 59 int* stdout, 60 int* stderr)); 61 62 private: 63 DISALLOW_COPY_AND_ASSIGN(MockMinijail); 64 }; 65 66 } // namespace brillo 67 68 #endif // LIBBRILLO_BRILLO_MINIJAIL_MOCK_MINIJAIL_H_ 69