1 //===-- TestCase.h ----------------------------------------------*- C++ -*-===//
3 // The LLVM Compiler Infrastructure
5 // This file is distributed under the University of Illinois Open Source
6 // License. See LICENSE.TXT for details.
8 //===----------------------------------------------------------------------===//
10 #ifndef __PerfTestDriver__TestCase__
11 #define __PerfTestDriver__TestCase__
13 #include "Measurement.h"
14 #include "lldb/API/LLDB.h"
35 lldb::SBThread thread;
36 lldb::SBLaunchInfo launch_info;
38 ActionWanted() : type(Type::eContinue), thread(), launch_info(NULL) {}
42 thread = lldb::SBThread();
46 type = Type::eContinue;
47 thread = lldb::SBThread();
50 void StepOver(lldb::SBThread t) {
51 type = Type::eStepOver;
55 void StepOut(lldb::SBThread t) {
56 type = Type::eStepOut;
60 void Relaunch(lldb::SBLaunchInfo l) {
61 type = Type::eRelaunch;
62 thread = lldb::SBThread();
68 thread = lldb::SBThread();
72 type = Type::eCallNext;
73 thread = lldb::SBThread();
77 virtual ~TestCase() {}
79 virtual bool Setup(int &argc, const char **&argv);
81 virtual void TestStep(int counter, ActionWanted &next_action) = 0;
83 bool Launch(lldb::SBLaunchInfo &launch_info);
85 bool Launch(std::initializer_list<const char *> args = {});
89 void SetVerbose(bool);
93 virtual void WriteResults(Results &results) = 0;
95 template <typename G, typename A>
96 Measurement<G, A> CreateMeasurement(A a, const char *name = NULL,
97 const char *description = NULL) {
98 return Measurement<G, A>(a, name, description);
101 template <typename A>
102 TimeMeasurement<A> CreateTimeMeasurement(A a, const char *name = NULL,
103 const char *description = NULL) {
104 return TimeMeasurement<A>(a, name, description);
107 template <typename A>
108 MemoryMeasurement<A> CreateMemoryMeasurement(A a, const char *name = NULL,
109 const char *description = NULL) {
110 return MemoryMeasurement<A>(a, name, description);
113 static int Run(TestCase &test, int argc, const char **argv);
115 virtual bool ParseOption(int short_option, const char *optarg) {
119 virtual struct option *GetLongOptions() { return NULL; }
121 lldb::SBDebugger &GetDebugger() { return m_debugger; }
123 lldb::SBTarget &GetTarget() { return m_target; }
125 lldb::SBProcess &GetProcess() { return m_process; }
127 lldb::SBThread &GetThread() { return m_thread; }
129 int GetStep() { return m_step; }
131 static const int RUN_SUCCESS = 0;
132 static const int RUN_SETUP_ERROR = 100;
135 lldb::SBDebugger m_debugger;
136 lldb::SBTarget m_target;
137 lldb::SBProcess m_process;
138 lldb::SBThread m_thread;
139 lldb::SBListener m_listener;
145 #endif /* defined(__PerfTestDriver__TestCase__) */