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

Side by Side Diff: testing/multiprocess_func_list.h

Issue 10387218: Make GlobalDescriptors::MaybeGet return -1 when the key is not found. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Modifying the MULTIPROCESS_TEST_MAIN macro so it can be passed a setup method. Created 8 years, 6 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2008 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2008 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 #ifndef TESTING_MULTIPROCESS_FUNC_LIST_H_ 5 #ifndef TESTING_MULTIPROCESS_FUNC_LIST_H_
6 #define TESTING_MULTIPROCESS_FUNC_LIST_H_ 6 #define TESTING_MULTIPROCESS_FUNC_LIST_H_
7 7
8 #include <string> 8 #include <string>
9 9
10 // This file provides the plumbing to register functions to be executed 10 // This file provides the plumbing to register functions to be executed
11 // as the main function of a child process in a multi-process test. 11 // as the main function of a child process in a multi-process test.
12 // This complements the MultiProcessTest class which provides facilities 12 // This complements the MultiProcessTest class which provides facilities
13 // for launching such tests. 13 // for launching such tests.
14 // 14 //
15 // The MULTIPROCESS_TEST_MAIN() macro registers a string -> func_ptr mapping 15 // The MULTIPROCESS_TEST_MAIN() macro registers a string -> func_ptr mapping
16 // by creating a new global instance of the AppendMultiProcessTest() class 16 // by creating a new global instance of the AppendMultiProcessTest() class
17 // this means that by the time that we reach our main() function the mapping 17 // this means that by the time that we reach our main() function the mapping
18 // is already in place. 18 // is already in place.
19 // 19 //
20 // Example usage: 20 // Example usage:
21 // MULTIPROCESS_TEST_MAIN(a_test_func) { 21 // MULTIPROCESS_TEST_MAIN(a_test_func, a_setup_fun) {
jeremy 2012/06/13 19:25:55 Need to document what setup_func does...
Jay Civelli 2012/06/13 20:40:49 I documented it in the comment for the new macro M
22 // // Code here runs in a child process. 22 // // Code here runs in a child process.
23 // return 0; 23 // return 0;
24 // } 24 // }
25 // 25 //
26 // The prototype of a_test_func is implicitly 26 // The prototype of a_test_func and a_setup_func is implicitly:
27 // int test_main_func_name(); 27 // int test_main_func_name();
28 //
29 // The setup function is optional. if non NULL it is run before the main
30 // function. Its return valus is ignored
28 31
29 namespace multi_process_function_list { 32 namespace multi_process_function_list {
30 33
31 // Type for child process main functions. 34 // Type for child process main functions.
32 typedef int (*ChildFunctionPtr)(); 35 typedef int (*ChildFunctionPtr)();
33 36
34 // Helper class to append a test function to the global mapping. 37 // Helper class to append a test function to the global mapping.
35 // Used by the MULTIPROCESS_TEST_MAIN macro. 38 // Used by the MULTIPROCESS_TEST_MAIN macro.
36 class AppendMultiProcessTest { 39 class AppendMultiProcessTest {
37 public: 40 public:
38 AppendMultiProcessTest(std::string test_name, ChildFunctionPtr func_ptr); 41 AppendMultiProcessTest(std::string test_name,
42 ChildFunctionPtr main_func_ptr,
43 ChildFunctionPtr setup_func_ptr);
39 }; 44 };
40 45
41 // Invoke the main function of a test previously registered with 46 // Invoke the main function of a test previously registered with
42 // MULTIPROCESS_TEST_MAIN() 47 // MULTIPROCESS_TEST_MAIN()
43 int InvokeChildProcessTest(std::string test_name); 48 int InvokeChildProcessTest(std::string test_name);
44 49
45 // This macro creates a global MultiProcessTest::AppendMultiProcessTest object 50 // This macro creates a global MultiProcessTest::AppendMultiProcessTest object
46 // whose constructor does the work of adding the global mapping. 51 // whose constructor does the work of adding the global mapping.
47 #define MULTIPROCESS_TEST_MAIN(test_main) \ 52 #define MULTIPROCESS_TEST_MAIN(test_main, test_setup) \
jeremy 2012/06/13 19:25:55 I think you want to create 2 versions of this macr
Jay Civelli 2012/06/13 20:40:49 Done.
48 int test_main(); \ 53 int test_main(); \
49 namespace { \ 54 namespace { \
50 multi_process_function_list::AppendMultiProcessTest \ 55 multi_process_function_list::AppendMultiProcessTest \
51 AddMultiProcessTest##_##test_main(#test_main, (test_main)); \ 56 AddMultiProcessTest##_##test_main(#test_main, (test_main), (test_setup)); \
52 } \ 57 } \
53 int test_main() 58 int test_main()
54 59
55 } // namespace multi_process_function_list 60 } // namespace multi_process_function_list
56 61
57 #endif // TESTING_MULTIPROCESS_FUNC_LIST_H_ 62 #endif // TESTING_MULTIPROCESS_FUNC_LIST_H_
OLDNEW
« ipc/ipc_tests.h ('K') | « testing/gtest.gyp ('k') | testing/multiprocess_func_list.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698