1 : // Copyright 2012 Google Inc.
2 : //
3 : // Licensed under the Apache License, Version 2.0 (the "License");
4 : // you may not use this file except in compliance with the License.
5 : // You may obtain a copy of the License at
6 : //
7 : // http://www.apache.org/licenses/LICENSE-2.0
8 : //
9 : // Unless required by applicable law or agreed to in writing, software
10 : // distributed under the License is distributed on an "AS IS" BASIS,
11 : // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 : // See the License for the specific language governing permissions and
13 : // limitations under the License.
14 : //
15 : // Declares a unittest helper class.
16 :
17 : #ifndef SYZYGY_TRACE_COMMON_UNITTEST_UTIL_H_
18 : #define SYZYGY_TRACE_COMMON_UNITTEST_UTIL_H_
19 :
20 : #include "base/file_path.h"
21 : #include "base/process_util.h"
22 : #include "base/string_piece.h"
23 : #include "gtest/gtest.h"
24 :
25 m : namespace testing {
26 :
27 : // A utility class to manage an instance of the call trace service process
28 : // for tests.
29 m : class CallTraceService {
30 m : public:
31 m : CallTraceService();
32 m : ~CallTraceService();
33 :
34 : // Starts a call trace service instance with an
35 : // instance ID unique to this process.
36 : // @param trace_dir the directory where trace files will be created.
37 : // @note adds failures to the current tests on errors.
38 m : void Start(const FilePath& trace_dir);
39 :
40 : // Stops the service if it's running.
41 m : void Stop();
42 :
43 : // Publishes the instance ID in the process environment.
44 m : void SetEnvironment();
45 :
46 m : private:
47 m : std::string instance_id_;
48 :
49 : // The handle to the call trace service process.
50 m : base::ProcessHandle service_process_;
51 m : };
52 :
53 m : } // namespace testing
54 :
55 : #endif // SYZYGY_TRACE_COMMON_UNITTEST_UTIL_H_
|