Description:
[grader] extracted test_request info into new stat columns
git-svn-id: http://theory.cpe.ku.ac.th/grader/judge/trunk/scripts@163 6386c4cd-e34a-4fa8-8920-d93eb39b512e
Commit status:
[Not Reviewed]
References:
Diff options:
Comments:
0 Commit comments
0 Inline Comments
Unresolved TODOs:
There are no unresolved TODOs
r41:d4e37450ddbc - - 3 files changed: 37 inserted, 7 deleted
@@ -104,7 +104,7 | |||
|
104 | 104 | end |
|
105 | 105 | |
|
106 | 106 | def report_error(test_request, msg) |
|
107 | - save_result(test_request, {:running_stat => "#{msg}"}) | |
|
107 | + save_result(test_request, {:running_stat => {:msg => "#{msg}"}}) | |
|
108 | 108 | end |
|
109 | 109 | |
|
110 | 110 | protected |
@@ -129,7 +129,7 | |||
|
129 | 129 | :cmp_msg => cmp_msg} |
|
130 | 130 | else |
|
131 | 131 | return { |
|
132 |
- :running_stat => |
|
|
132 | + :running_stat => nil, | |
|
133 | 133 | :comment => "Compilation error", |
|
134 | 134 | :cmp_msg => cmp_msg} |
|
135 | 135 | end |
@@ -138,18 +138,27 | |||
|
138 | 138 | def format_running_stat(results) |
|
139 | 139 | running_time_line = results[-1] |
|
140 | 140 | |
|
141 | + # extract exit status line | |
|
141 | 142 | run_stat = "" |
|
142 | 143 | if !(/[Cc]orrect/.match(results[0])) |
|
143 | 144 | run_stat = results[0].chomp |
|
145 | + else | |
|
146 | + run_stat = 'Program exited normally' | |
|
144 | 147 | end |
|
145 | 148 | |
|
149 | + # extract running time | |
|
146 | 150 | if res = /r(.*)u(.*)s/.match(running_time_line) |
|
147 | 151 | seconds = (res[1].to_f + res[2].to_f) |
|
148 | 152 | time_stat = "Time used: #{seconds} sec." |
|
149 | 153 | else |
|
154 | + seconds = nil | |
|
150 | 155 | time_stat = "Time used: n/a sec." |
|
151 | 156 | end |
|
152 | - return "#{run_stat}\n#{time_stat}" | |
|
157 | + return { | |
|
158 | + :msg => "#{run_stat}\n#{time_stat}", | |
|
159 | + :running_time => seconds, | |
|
160 | + :exit_status => run_stat | |
|
161 | + } | |
|
153 | 162 | end |
|
154 | 163 | |
|
155 | 164 | def save_result(test_request,result) |
@@ -160,7 +169,14 | |||
|
160 | 169 | test_request.graded_at = Time.now |
|
161 | 170 | test_request.compiler_message = (result[:cmp_msg] or '') |
|
162 | 171 | test_request.grader_comment = (result[:comment] or '') |
|
163 | - test_request.running_stat = (result[:running_stat] or '') | |
|
172 | + if result[:running_stat]!=nil | |
|
173 | + test_request.running_stat = (result[:running_stat][:msg] or '') | |
|
174 | + test_request.running_time = (result[:running_stat][:running_time] or nil) | |
|
175 | + test_request.exit_status = (result[:running_stat][:exit_status]) | |
|
176 | + test_request.memory_usage = nil # should be added later | |
|
177 | + else | |
|
178 | + test_request.running_stat = '' | |
|
179 | + end | |
|
164 | 180 | test_request.save |
|
165 | 181 | end |
|
166 | 182 |
@@ -1,5 +1,6 | |||
|
1 | 1 | #include <stdio.h> |
|
2 | 2 | #include <stdlib.h> |
|
3 | + #include <unistd.h> | |
|
3 | 4 | |
|
4 | 5 | int main() |
|
5 | 6 | { |
@@ -10,12 +11,13 | |||
|
10 | 11 | scanf("%d %d",&a,&b); |
|
11 | 12 | printf("%d\n",a+b); |
|
12 | 13 | |
|
13 | - for(a=0; a<2; a++) { | |
|
14 | - while(c<1550000000) { | |
|
14 | + sleep(1); | |
|
15 | + | |
|
16 | + c = 0; | |
|
17 | + while(c<1000000000) { | |
|
15 | 18 |
|
|
16 | 19 |
|
|
17 | 20 |
|
|
18 | - } | |
|
19 | 21 | exit(0); |
|
20 | 22 | } |
|
21 | 23 |
@@ -172,6 +172,9 | |||
|
172 | 172 | :compiler_message= => '', |
|
173 | 173 | :grader_comment= => '', |
|
174 | 174 | :running_stat= => /template not found/, |
|
175 | + :running_time= => nil, | |
|
176 | + :exit_status= => nil, | |
|
177 | + :memory_usage= => nil, | |
|
175 | 178 | :save => nil}) |
|
176 | 179 | end |
|
177 | 180 | |
@@ -189,6 +192,9 | |||
|
189 | 192 | :output_file_name= => lambda { |fname| |
|
190 | 193 | File.exists?(fname).should be_true |
|
191 | 194 | }, |
|
195 | + :running_time= => nil, | |
|
196 | + :exit_status= => nil, | |
|
197 | + :memory_usage= => nil, | |
|
192 | 198 | :save => nil}) |
|
193 | 199 | end |
|
194 | 200 | |
@@ -204,6 +210,9 | |||
|
204 | 210 | :grader_comment= => '', |
|
205 | 211 | :running_stat= => nil, |
|
206 | 212 | :output_file_name= => nil, |
|
213 | + :running_time= => nil, | |
|
214 | + :exit_status= => nil, | |
|
215 | + :memory_usage= => nil, | |
|
207 | 216 | :save => nil}) |
|
208 | 217 | File.exists?(@config.user_result_dir + "/test_request/test_normal/test_cases/1/input-1.txt").should be_false |
|
209 | 218 | end |
@@ -236,6 +245,9 | |||
|
236 | 245 | :output_file_name= => lambda { |fname| |
|
237 | 246 | File.exists?(fname).should be_true |
|
238 | 247 | }, |
|
248 | + :running_time= => nil, | |
|
249 | + :exit_status= => /10/, | |
|
250 | + :memory_usage= => nil, | |
|
239 | 251 | :save => nil}) |
|
240 | 252 | end |
|
241 | 253 |
You need to be logged in to leave comments.
Login now