Skip to content

Commit

Permalink
tests: simlib: conver: further harden tests against failing under sys…
Browse files Browse the repository at this point in the history
…tem load
  • Loading branch information
varqox committed May 15, 2024
1 parent ad6a4b8 commit 3f45be4
Show file tree
Hide file tree
Showing 12 changed files with 64 additions and 55 deletions.
4 changes: 2 additions & 2 deletions subprojects/simlib/include/simlib/concurrent/job_processor.hh
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,8 @@ public:
void run() {
const int workers_no = meta::max(
static_cast<int>(std::thread::hardware_concurrency()) - 1,
1
); // One has to remain to prevent deadlock if queue gets full
1 // One has to remain to prevent deadlock if queue gets full.
);
std::vector<std::thread> workers(workers_no);
spawn_workers(workers);
generate_jobs_and_signal_no_more();
Expand Down
6 changes: 3 additions & 3 deletions subprojects/simlib/test/conver.cc
Original file line number Diff line number Diff line change
Expand Up @@ -317,7 +317,7 @@ class ConverTestCaseRunner {
}
}

void round_post_judge_simfile_time_limits_to_multiple_of_4_seconds() {
void round_post_judge_simfile_time_limits_to_multiple_of_one_seconds() {
using std::chrono_literals::operator""s;
// This should remove the problem with random time limit if they
// were set using the model solution.
Expand All @@ -326,13 +326,13 @@ class ConverTestCaseRunner {
// Time limits should not have been set to 0
EXPECT_GT(test.time_limit, 0s) << "^ test " << test_case_name_;
test.time_limit =
std::chrono::duration_cast<std::chrono::seconds>(test.time_limit / 4 + 0.5s) * 4;
std::chrono::duration_cast<std::chrono::seconds>(test.time_limit + 0.5s);
}
}
}

void check_result() {
round_post_judge_simfile_time_limits_to_multiple_of_4_seconds();
round_post_judge_simfile_time_limits_to_multiple_of_one_seconds();
if (regenerate_outs) {
overwrite_test_output_files();
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Krzysztof Małysa
#include <iostream>
#include <unistd.h>

using namespace std;

Expand All @@ -9,7 +10,10 @@ int main() {

cout << "! ?\n" << flush;

for (;;) {} // Solution should be killed after checker verdicts WRONG
// Solution should be killed after checker verdicts WRONG
for (;;) {
pause(); // To minimize CPU time consumption under load
}

return 0;
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
// Krzysztof Małysa
#include <iostream>
#include <unistd.h>

using namespace std;

Expand All @@ -9,7 +10,10 @@ int main() {

cout << "! 1\n? 1\n" << flush;

for (;;) {} // Solution should be killed after checker verdicts WRONG
// Solution should be killed after checker verdicts WRONG
for (;;) {
pause(); // To minimize CPU time consumption under load
}

return 0;
}
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
// Krzysztof Małysa
#include <exception>
#include <iostream>

using namespace std;
Expand All @@ -7,13 +8,13 @@ int main() {
ios::sync_with_stdio(false);
cin.tie(nullptr);

int n;
cin >> n;

cout << "! -3\n" << flush;

for (;;)
new char; // Runtime error happens after the checker exited with WRONG
// Wait for checker to exit with WRONG
string s;
while (getline(cin, s)) {}
// Runtime error
std::terminate();

return 0;
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,17 @@ statement: foo.txt
solutions: [sol.c]
memory_limit: 32
limits: [
000 12
6ocen 12
000 11
6ocen 11

1a 12
1d 12
1file 12
1a 11
1d 11
1file 11

3 12 9
3file 12
3 11 9
3file 11

5 12
5 11
]
scoring: [
000 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ checker: checker/checker.cc
solutions: [prog/sol_mle.cc, prog/sol.cc, prog/rte1.cc, prog/sol_slow1.cc, prog/sol_slow2.cc, prog/sol_slow_wa.cc, prog/sol_tle1.cc, prog/sol_tle2.cc, prog/sol_wa1.cc, prog/sol_wa2.cc, prog/sol_wa3.cc, prog/tle1.cc, prog/tle2.cc, prog/wa1.cc, prog/wa2.cc, prog/wa3.cc, prog/wa4.cc, prog/wa5.cc]
memory_limit: 32
limits: [
4a 4
4a 3
]
scoring: [
4 100
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@ checker: checker/checker.cc
solutions: [prog/rte1.cc, prog/sol.cc, prog/sol_mle.cc, prog/sol_slow1.cc, prog/sol_slow2.cc, prog/sol_slow_wa.cc, prog/sol_tle1.cc, prog/sol_tle2.cc, prog/sol_wa1.cc, prog/sol_wa2.cc, prog/sol_wa3.cc, prog/tle1.cc, prog/tle2.cc, prog/wa1.cc, prog/wa2.cc, prog/wa3.cc, prog/wa4.cc, prog/wa5.cc]
memory_limit: 32
limits: [
0 4
0 3

1 4
1 3

2a 4
2b 4
2a 3
2b 3

3a 4
3b 4
3a 3
3b 3

4a 4
4b 4
4a 3
4b 3
]
scoring: [
0 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ label: null
interactive: null
memory_limit: null
global_time_limit: null
max_time_limit: 2
max_time_limit: 5
reset_time_limits_using_main_solution: true
ignore_simfile: false
seek_for_new_tests: true
Expand Down
Original file line number Diff line number Diff line change
@@ -1,17 +1,17 @@
Judging (initial): {
0 [ TL: 1.25 s ML: 32768 KiB ] Status: WA (Line 4: Read '?', expected EOF) Checker: [ ML: 262144 KiB ]
0 [ TL: 3.31 s ML: 32768 KiB ] Status: WA (Line 4: Read '?', expected EOF) Checker: [ ML: 262144 KiB ]
Score: 0 / 0 (ratio: 0.0000)
}
Judging (final): {
1 [ TL: 1.25 s ML: 32768 KiB ] Status: OK (Used 1 queries out of 1) Checker: [ ML: 262144 KiB ]
1 [ TL: 3.31 s ML: 32768 KiB ] Status: OK (Used 1 queries out of 1) Checker: [ ML: 262144 KiB ]
Score: 25 / 25 (ratio: 1.0000)
2a [ TL: 1.25 s ML: 32768 KiB ] Status: WA (Line 3: Read '?', expected EOF) Checker: [ ML: 262144 KiB ]
2b [ TL: 1.25 s ML: 32768 KiB ] Status: WA (Line 3: Read '?', expected EOF) Checker: [ ML: 262144 KiB ]
2a [ TL: 3.31 s ML: 32768 KiB ] Status: WA (Line 3: Read '?', expected EOF) Checker: [ ML: 262144 KiB ]
2b [ TL: 3.31 s ML: 32768 KiB ] Status: WA (Line 3: Read '?', expected EOF) Checker: [ ML: 262144 KiB ]
Score: 0 / 25 (ratio: 0.0000)
3a [ TL: 1.25 s ML: 32768 KiB ] Status: OK (Used 3 queries out of 2) Checker: [ ML: 262144 KiB ]
3b [ TL: 1.25 s ML: 32768 KiB ] Status: WA (Line 3: Read '?', expected EOF) Checker: [ ML: 262144 KiB ]
3a [ TL: 3.31 s ML: 32768 KiB ] Status: OK (Used 3 queries out of 2) Checker: [ ML: 262144 KiB ]
3b [ TL: 3.31 s ML: 32768 KiB ] Status: WA (Line 3: Read '?', expected EOF) Checker: [ ML: 262144 KiB ]
Score: 0 / 25 (ratio: 0.0000)
4a [ TL: 1.25 s ML: 32768 KiB ] Status: WA (Line 493: Read '?', expected EOF) Checker: [ ML: 262144 KiB ]
4b [ TL: 1.25 s ML: 32768 KiB ] Status: WA (Line 336: Read '?', expected EOF) Checker: [ ML: 262144 KiB ]
4a [ TL: 3.31 s ML: 32768 KiB ] Status: WA (Line 493: Read '?', expected EOF) Checker: [ ML: 262144 KiB ]
4b [ TL: 3.31 s ML: 32768 KiB ] Status: WA (Line 336: Read '?', expected EOF) Checker: [ ML: 262144 KiB ]
Score: 0 / 25 (ratio: 0.0000)
}
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,18 @@ checker: checker/checker.cc
solutions: [prog/sol_slow_wa.cc, prog/sol.cc, prog/rte1.cc, prog/sol_mle.cc, prog/sol_slow1.cc, prog/sol_slow2.cc, prog/sol_tle1.cc, prog/sol_tle2.cc, prog/sol_wa1.cc, prog/sol_wa2.cc, prog/sol_wa3.cc, prog/tle1.cc, prog/tle2.cc, prog/wa1.cc, prog/wa2.cc, prog/wa3.cc, prog/wa4.cc, prog/wa5.cc]
memory_limit: 32
limits: [
0 1.258
0 3.312

1 1.258
1 3.312

2a 1.258
2b 1.258
2a 3.312
2b 3.312

3a 1.258
3b 1.258
3a 3.312
3b 3.312

4a 1.258
4b 1.258
4a 3.312
4b 3.312
]
scoring: [
0 0
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,19 @@ statement: foo.txt
solutions: [sol.c]
memory_limit: 32
limits: [
some 12
some 11

0 12
6ocen 12
0 11
6ocen 11

1a 12
1d 12
1file 12
1a 11
1d 11
1file 11

3 12 9
3file 12
3 11 9
3file 11

5 12
5 11
]
scoring: [
'"" 47'
Expand Down

0 comments on commit 3f45be4

Please sign in to comment.