benchmark silo added
[c11concurrency-benchmarks.git] / silo / masstree / testrunner.hh
1 #ifndef MASSTREE_TESTRUNNER_HH
2 #define MASSTREE_TESTRUNNER_HH
3 #include "string.hh"
4 #include <stdio.h>
5
6 class testrunner_base {
7   public:
8     testrunner_base(const lcdf::String& name)
9         : name_(name), next_(0) {
10         thehead ? thetail->next_ = this : thehead = this;
11         thetail = this;
12     }
13     virtual ~testrunner_base() {
14     }
15     const lcdf::String& name() const {
16         return name_;
17     }
18     static testrunner_base* first() {
19         return thehead;
20     }
21     static testrunner_base* find(const lcdf::String& name) {
22         testrunner_base* t = thehead;
23         while (t && t->name_ != name)
24             t = t->next_;
25         return t;
26     }
27     static void print_names(FILE* stream, int maxcol);
28   private:
29     static testrunner_base* thehead;
30     static testrunner_base* thetail;
31     lcdf::String name_;
32     testrunner_base* next_;
33 };
34
35 #ifdef TESTRUNNER_CLIENT_TYPE
36
37 class testrunner : public testrunner_base {
38   public:
39     inline testrunner(const lcdf::String& name)
40         : testrunner_base(name) {
41     }
42     static testrunner* first() {
43         return static_cast<testrunner*>(testrunner_base::first());
44     }
45     static testrunner* find(const lcdf::String& name) {
46         return static_cast<testrunner*>(testrunner_base::find(name));
47     }
48     virtual void run(TESTRUNNER_CLIENT_TYPE) = 0;
49 };
50
51 #define MAKE_TESTRUNNER(name, text)                    \
52     namespace {                                        \
53     class testrunner_##name : public testrunner {      \
54     public:                                            \
55         testrunner_##name() : testrunner(#name) {}     \
56         void run(TESTRUNNER_CLIENT_TYPE client) { text; client.finish(); } \
57     }; static testrunner_##name testrunner_##name##_instance; }
58
59 #endif
60 #endif