forked from nvmecompliance/tnvme
-
Notifications
You must be signed in to change notification settings - Fork 0
/
testResults.h
89 lines (76 loc) · 2.6 KB
/
testResults.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
/*
* Copyright (c) 2011, Intel Corporation.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef TEST_RESULTS_H
#define TEST_RESULTS_H
#include "globals.h"
/* TR desc */
#define TR_TABLE \
ZZ(TR_SUCCESS, "passed") \
ZZ(TR_FAIL, "failed") \
ZZ(TR_SKIPPING, "skipped") \
ZZ(TR_INFORMATIVE, "informative") \
ZZ(TR_NOTFOUND, "N/F")
#define ZZ(a, b) a,
typedef enum {
TR_TABLE
TR_FENCE // always must be the last element
} TestResult;
#undef ZZ
/**
* This class represents a set of test results. Contains a count of each
* valid test result.
*
* @ note This class will not throw exceptions.
*/
class TestResults
{
public:
TestResults();
virtual ~TestResults();
virtual TestResults *Clone() const
{ return new TestResults(*this); }
TestResults &operator=(const TestResults &other);
TestResults(const TestResults &other);
/**
* Add 1 to the count for the given test result.
*
* @param testResult the result to increment
* @param amount the amount to increment the result by
*/
void addResult(TestResult testResult, int amount = 1);
/**
* Do all currently reported results signify passing status?
*
* @return false if there are any failing results; true otherwise
*/
bool allTestsPass() const;
/**
* Log current results.
*
* @param numIters number of iterations of test set which have been executed
* @param numGrps number of groups which have been executed
*/
void report(const size_t numIters, const int numGrps) const;
protected:
virtual TestResults &assign(const TestResults &other);
private:
int results[TR_FENCE];
/**
* Descriptions of the test results for logging purposes
*/
static const char *resultDesc[];
};
#endif /*TEST_RESULTS_H*/