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 | |
Greg Clayton | 7b8f738 | 2013-03-18 22:34:00 +0000 | [diff] [blame^] | 15 | namespace lldb_perf |
Enrico Granata | f58cece | 2013-03-08 20:29:13 +0000 | [diff] [blame] | 16 | { |
| 17 | class TestCase |
| 18 | { |
| 19 | public: |
| 20 | TestCase(); |
| 21 | |
| 22 | struct ActionWanted |
| 23 | { |
| 24 | enum class Type |
| 25 | { |
Greg Clayton | 7b8f738 | 2013-03-18 22:34:00 +0000 | [diff] [blame^] | 26 | eNext, |
| 27 | eContinue, |
| 28 | eFinish, |
| 29 | eKill |
Enrico Granata | f58cece | 2013-03-08 20:29:13 +0000 | [diff] [blame] | 30 | } type; |
Greg Clayton | 7b8f738 | 2013-03-18 22:34:00 +0000 | [diff] [blame^] | 31 | lldb::SBThread thread; |
| 32 | |
| 33 | ActionWanted () : |
| 34 | type (Type::eContinue), |
| 35 | thread () |
| 36 | { |
| 37 | } |
| 38 | |
| 39 | void |
| 40 | Continue() |
| 41 | { |
| 42 | type = Type::eContinue; |
| 43 | thread = lldb::SBThread(); |
| 44 | } |
| 45 | |
| 46 | void |
| 47 | Next (lldb::SBThread t) |
| 48 | { |
| 49 | type = Type::eNext; |
| 50 | thread = t; |
| 51 | } |
| 52 | |
| 53 | void |
| 54 | Finish (lldb::SBThread t) |
| 55 | { |
| 56 | type = Type::eFinish; |
| 57 | thread = t; |
| 58 | } |
| 59 | |
| 60 | void |
| 61 | Kill () |
| 62 | { |
| 63 | type = Type::eKill; |
| 64 | thread = lldb::SBThread(); |
| 65 | } |
Enrico Granata | f58cece | 2013-03-08 20:29:13 +0000 | [diff] [blame] | 66 | }; |
| 67 | |
| 68 | virtual |
| 69 | ~TestCase () |
| 70 | {} |
| 71 | |
| 72 | virtual void |
| 73 | Setup (int argc, const char** argv); |
| 74 | |
Greg Clayton | 7b8f738 | 2013-03-18 22:34:00 +0000 | [diff] [blame^] | 75 | virtual void |
| 76 | TestStep (int counter, ActionWanted &next_action) = 0; |
Enrico Granata | f58cece | 2013-03-08 20:29:13 +0000 | [diff] [blame] | 77 | |
| 78 | bool |
| 79 | Launch (const char** args, const char* cwd); |
| 80 | |
| 81 | void |
| 82 | Loop(); |
| 83 | |
| 84 | void |
| 85 | SetVerbose (bool); |
| 86 | |
| 87 | bool |
| 88 | GetVerbose (); |
| 89 | |
| 90 | virtual void |
| 91 | Results () = 0; |
| 92 | |
| 93 | template <typename G,typename A> |
Enrico Granata | 8691057 | 2013-03-14 19:00:42 +0000 | [diff] [blame] | 94 | 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] | 95 | { |
Enrico Granata | 8691057 | 2013-03-14 19:00:42 +0000 | [diff] [blame] | 96 | return Measurement<G,A> (a,name, description); |
| 97 | } |
| 98 | |
| 99 | template <typename A> |
| 100 | TimeMeasurement<A> CreateTimeMeasurement (A a, const char* name = NULL, const char* description = NULL) |
| 101 | { |
| 102 | return TimeMeasurement<A> (a,name, description); |
Enrico Granata | f58cece | 2013-03-08 20:29:13 +0000 | [diff] [blame] | 103 | } |
| 104 | |
| 105 | static void |
| 106 | Run (TestCase& test, int argc, const char** argv); |
| 107 | |
| 108 | protected: |
Greg Clayton | 7b8f738 | 2013-03-18 22:34:00 +0000 | [diff] [blame^] | 109 | lldb::SBDebugger m_debugger; |
| 110 | lldb::SBTarget m_target; |
| 111 | lldb::SBProcess m_process; |
| 112 | lldb::SBThread m_thread; |
| 113 | lldb::SBListener m_listener; |
Enrico Granata | f58cece | 2013-03-08 20:29:13 +0000 | [diff] [blame] | 114 | bool m_verbose; |
| 115 | }; |
Greg Clayton | 7b8f738 | 2013-03-18 22:34:00 +0000 | [diff] [blame^] | 116 | } |
Enrico Granata | f58cece | 2013-03-08 20:29:13 +0000 | [diff] [blame] | 117 | |
| 118 | #endif /* defined(__PerfTestDriver__TestCase__) */ |