Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(464)

Side by Side Diff: testing/multiprocess_func_list.cc

Issue 1911483002: Upgrade build and clang. (Closed) Base URL: https://pdfium.googlesource.com/pdfium.git@master
Patch Set: Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « testing/multiprocess_func_list.h ('k') | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
(Empty)
1 // Copyright (c) 2012 The Chromium 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 #include "multiprocess_func_list.h"
6
7 #include <map>
8
9 // Helper functions to maintain mapping of "test name"->test func.
10 // The information is accessed via a global map.
11 namespace multi_process_function_list {
12
13 namespace {
14
15 struct ProcessFunctions {
16 ProcessFunctions() : main(NULL), setup(NULL) {}
17 ProcessFunctions(TestMainFunctionPtr main, SetupFunctionPtr setup)
18 : main(main), setup(setup) {}
19 TestMainFunctionPtr main;
20 SetupFunctionPtr setup;
21 };
22
23 typedef std::map<std::string, ProcessFunctions> MultiProcessTestMap;
24
25 // Retrieve a reference to the global 'func name' -> func ptr map.
26 MultiProcessTestMap& GetMultiprocessFuncMap() {
27 static MultiProcessTestMap test_name_to_func_ptr_map;
28 return test_name_to_func_ptr_map;
29 }
30
31 } // namespace
32
33 AppendMultiProcessTest::AppendMultiProcessTest(
34 std::string test_name,
35 TestMainFunctionPtr main_func_ptr,
36 SetupFunctionPtr setup_func_ptr) {
37 GetMultiprocessFuncMap()[test_name] =
38 ProcessFunctions(main_func_ptr, setup_func_ptr);
39 }
40
41 int InvokeChildProcessTest(std::string test_name) {
42 MultiProcessTestMap& func_lookup_table = GetMultiprocessFuncMap();
43 MultiProcessTestMap::iterator it = func_lookup_table.find(test_name);
44 if (it != func_lookup_table.end()) {
45 const ProcessFunctions& process_functions = it->second;
46 if (process_functions.setup)
47 (*process_functions.setup)();
48 if (process_functions.main)
49 return (*process_functions.main)();
50 }
51
52 return -1;
53 }
54
55 } // namespace multi_process_function_list
OLDNEW
« no previous file with comments | « testing/multiprocess_func_list.h ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698