-
Notifications
You must be signed in to change notification settings - Fork 2
/
InvocationResult.cpp
130 lines (100 loc) · 2.94 KB
/
InvocationResult.cpp
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
#include "InvocationResult.h"
#include "InvocationVerdict.h"
#include "Configuration.h"
#include "Run.h"
#include <string>
using namespace runexe;
using namespace std;
InvocationVerdict verdictByState(const ProcessState &state) {
if (state == BEFORE || state == RUNNING || state == FAILED)
return FAIL;
if (state == EXITED)
return SUCCESS;
if (state == TIME_EXCEEDED)
return TIME_LIMIT_EXCEEDED;
if (state == MEMORY_EXCEEDED)
return MEMORY_LIMIT_EXCEEDED;
if (state == IDLENESS_EXCEEDED)
return IDLENESS_LIMIT_EXCEEDED;
fail("Unexpected state");
return FAIL;
}
InvocationResult::InvocationResult() {
setDefaults();
}
InvocationResult::InvocationResult(const InvocationVerdict &invocationVerdict,
const string &comment) {
if (invocationVerdict != CRASH && invocationVerdict != FAIL)
fail("Crash/Fail InvocationResult constructor invoked for verdict " +
invocationVerdictToString(invocationVerdict));
setDefaults();
verdict = invocationVerdict;
this->comment = comment;
}
InvocationResult::InvocationResult(const ProcessOutcome &outcome) {
setDefaults();
exitCode = outcome.exit_code;
comment = outcome.comment;
verdict = verdictByState(outcome.state);
userTime = outcome.time;
memory = outcome.memory;
passedTime = outcome.passed_time;
}
InvocationVerdict InvocationResult::getInvocationVerdict() const {
return verdict;
}
int InvocationResult::getExitCode() const {
return exitCode;
}
long long InvocationResult::getUserTime() const {
return userTime;
}
long long InvocationResult::getKernelTime() const {
return kernelTime;
}
long long InvocationResult::getMemory() const {
return memory;
}
string InvocationResult::getComment() const {
return comment;
}
long long InvocationResult::getPassedTime() const {
return passedTime;
}
std::string InvocationResult::getProgramName() const {
return programName;
}
void InvocationResult::setDefaults() {
verdict = FAIL;
exitCode = RUN_EXIT_FAILURE;
userTime = 0;
kernelTime = 0;
memory = 0;
passedTime = 0;
comment = "";
programName = "program";
}
void InvocationResult::setInvocationVerdict(const InvocationVerdict &verdict) {
this->verdict = verdict;
}
void InvocationResult::setExitCode(int exitCode) {
this->exitCode = exitCode;
}
void InvocationResult::setUserTime(long long userTime) {
this->userTime = userTime;
}
void InvocationResult::setKernelTime(long long kernelTime) {
this->kernelTime = kernelTime;
}
void InvocationResult::setMemory(long long memory) {
this->memory = memory;
}
void InvocationResult::setPassedTime(long long passedTime) {
this->passedTime = passedTime;
}
void InvocationResult::setComment(std::string comment) {
this->comment = comment;
}
void InvocationResult::setProgramName(std::string programName) {
this->programName = programName;
}