diff --git a/tests/commands/run/test_integration.py b/tests/commands/run/test_integration.py index 795e1b73..c38f4621 100644 --- a/tests/commands/run/test_integration.py +++ b/tests/commands/run/test_integration.py @@ -455,8 +455,8 @@ def test_mem_limit_kill(create_package, time_tool): end_time = time.time() assert e.value.code == 1 - assert end_time - start_time < 5 # The solution runs for 20 seconds, but it immediately exceeds memory limit, - # so it should be killed. + assert end_time - start_time < 10 # The solution runs for 20 seconds, but it immediately exceeds memory limit, + # so it should be killed. @pytest.mark.parametrize("create_package", [get_undocumented_options_package_path()], indirect=True) diff --git a/tests/packages/lim/prog/lim2.cpp b/tests/packages/lim/prog/lim2.cpp index bc919d5e..8a8677d7 100644 --- a/tests/packages/lim/prog/lim2.cpp +++ b/tests/packages/lim/prog/lim2.cpp @@ -2,17 +2,27 @@ #include using namespace std; -using namespace std::chrono_literals; +using namespace std::chrono; + +int wait(int secs) { + auto start = high_resolution_clock::now(); + int i = 0; + while (duration_cast(high_resolution_clock::now() - start).count() < secs) + i++; + return i; +} int main() { int a, b; cin >> a >> b; if (a == 2 && b == 1) { - this_thread::sleep_for(6s); + int i = wait(6); + a += i - i; } else { - this_thread::sleep_for(2s); + int i = wait(2); + a += i - i; } cout << a + b << endl; diff --git a/tests/packages/vso/prog/vso4.cpp b/tests/packages/vso/prog/vso4.cpp index d8511f87..a25076ed 100644 --- a/tests/packages/vso/prog/vso4.cpp +++ b/tests/packages/vso/prog/vso4.cpp @@ -8,17 +8,26 @@ #include using namespace std; +using namespace std::chrono; int rnd() { return rand() % 100; } +int wait(int secs) { + auto start = high_resolution_clock::now(); + int i = 0; + while (duration_cast(high_resolution_clock::now() - start).count() < secs) + i++; + return i; +} + int main() { int a, b; cin >> a >> b; if (a == 1 && b == 1) { - this_thread::sleep_for(chrono::seconds(3)); - cout << a + b; + int i = wait(3); + cout << a + b + i - i; } else if (a == 1 && b == 2) { vector v; diff --git a/tests/packages/vso/prog/vso7.cpp b/tests/packages/vso/prog/vso7.cpp index 43addfd5..9bb6181c 100644 --- a/tests/packages/vso/prog/vso7.cpp +++ b/tests/packages/vso/prog/vso7.cpp @@ -8,11 +8,20 @@ #include using namespace std; +using namespace std::chrono; int rnd() { return rand() % 100; } +int wait(int secs) { + auto start = high_resolution_clock::now(); + int i = 0; + while (duration_cast(high_resolution_clock::now() - start).count() < secs) + i++; + return i; +} + int main() { int a, b; cin >> a >> b; @@ -23,8 +32,8 @@ int main() { cout << a + b; } else if (a == 1 && b == 3) { - this_thread::sleep_for(chrono::seconds(3)); - cout << a + b; + int i = wait(3); + cout << a + b + i - i; } else if (a == 1 && b == 4) { int c = 0;