Enrico Granata | f58cece | 2013-03-08 20:29:13 +0000 | [diff] [blame] | 1 | // |
| 2 | // TestCase.h |
| 3 | // PerfTestDriver |
| 4 | // |
| 5 | // Created by Enrico Granata on 3/7/13. |
| 6 | // Copyright (c) 2013 Apple Inc. All rights reserved. |
| 7 | // |
| 8 | |
| 9 | #ifndef __PerfTestDriver__TestCase__ |
| 10 | #define __PerfTestDriver__TestCase__ |
| 11 | |
| 12 | #include "lldb/API/LLDB.h" |
| 13 | #include "Measurement.h" |
| 14 | |
| 15 | using namespace lldb; |
| 16 | |
| 17 | namespace lldb { namespace perf |
| 18 | { |
| 19 | class TestCase |
| 20 | { |
| 21 | public: |
| 22 | TestCase(); |
| 23 | |
| 24 | struct ActionWanted |
| 25 | { |
| 26 | enum class Type |
| 27 | { |
| 28 | eAWNext, |
| 29 | eAWContinue, |
| 30 | eAWFinish, |
| 31 | eAWKill |
| 32 | } type; |
| 33 | SBThread thread; |
| 34 | }; |
| 35 | |
| 36 | virtual |
| 37 | ~TestCase () |
| 38 | {} |
| 39 | |
| 40 | virtual void |
| 41 | Setup (int argc, const char** argv); |
| 42 | |
| 43 | virtual ActionWanted |
| 44 | TestStep (int counter) = 0; |
| 45 | |
| 46 | bool |
| 47 | Launch (const char** args, const char* cwd); |
| 48 | |
| 49 | void |
| 50 | Loop(); |
| 51 | |
| 52 | void |
| 53 | SetVerbose (bool); |
| 54 | |
| 55 | bool |
| 56 | GetVerbose (); |
| 57 | |
| 58 | virtual void |
| 59 | Results () = 0; |
| 60 | |
| 61 | template <typename G,typename A> |
Enrico Granata | 8691057 | 2013-03-14 19:00:42 +0000 | [diff] [blame] | 62 | Measurement<G,A> CreateMeasurement (A a, const char* name = NULL, const char* description = NULL) |
Enrico Granata | f58cece | 2013-03-08 20:29:13 +0000 | [diff] [blame] | 63 | { |
Enrico Granata | 8691057 | 2013-03-14 19:00:42 +0000 | [diff] [blame] | 64 | return Measurement<G,A> (a,name, description); |
| 65 | } |
| 66 | |
| 67 | template <typename A> |
| 68 | TimeMeasurement<A> CreateTimeMeasurement (A a, const char* name = NULL, const char* description = NULL) |
| 69 | { |
| 70 | return TimeMeasurement<A> (a,name, description); |
Enrico Granata | f58cece | 2013-03-08 20:29:13 +0000 | [diff] [blame] | 71 | } |
| 72 | |
| 73 | static void |
| 74 | Run (TestCase& test, int argc, const char** argv); |
| 75 | |
| 76 | protected: |
| 77 | SBDebugger m_debugger; |
| 78 | SBTarget m_target; |
| 79 | SBProcess m_process; |
| 80 | SBThread m_thread; |
| 81 | SBListener m_listener; |
| 82 | bool m_verbose; |
| 83 | }; |
| 84 | } } |
| 85 | |
| 86 | #endif /* defined(__PerfTestDriver__TestCase__) */ |