-
Notifications
You must be signed in to change notification settings - Fork 27
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Refactor: finally have integration tests for UnixOperatingSystem
- Loading branch information
Showing
20 changed files
with
226 additions
and
82 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
1 change: 0 additions & 1 deletion
1
test/integration/resources/evaluator/scorer/custom/contestant_err_bogus.out
This file was deleted.
Oops, something went wrong.
1 change: 0 additions & 1 deletion
1
test/integration/resources/evaluator/scorer/custom/contestant_err_crash.out
This file was deleted.
Oops, something went wrong.
2 changes: 0 additions & 2 deletions
2
test/integration/resources/evaluator/scorer/custom/contestant_ok.out
This file was deleted.
Oops, something went wrong.
2 changes: 0 additions & 2 deletions
2
test/integration/resources/evaluator/scorer/custom/contestant_wa.out
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
42 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#include <bits/stdc++.h> | ||
using namespace std; | ||
|
||
int N; | ||
int main() { | ||
cin >> N; | ||
cout << N + 1 << endl; | ||
cerr << N + 2 << endl; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#include <bits/stdc++.h> | ||
using namespace std; | ||
|
||
int main() { | ||
return 42; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#include <bits/stdc++.h> | ||
using namespace std; | ||
|
||
int main() { | ||
vector<int> v; | ||
int a = 1; | ||
|
||
return a / (int)v.size(); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
#include <bits/stdc++.h> | ||
using namespace std; | ||
|
||
int data[10000000]; | ||
|
||
int main() { | ||
return data[42]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#include <bits/stdc++.h> | ||
using namespace std; | ||
|
||
int main() { | ||
while (true); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
112 changes: 112 additions & 0 deletions
112
test/integration/tcframe/os/UnixOperatingSystemIntegrationTests.cpp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
#include "gmock/gmock.h" | ||
|
||
#include <cstdlib> | ||
|
||
#include "tcframe/os/UnixOperatingSystem.hpp" | ||
#include "tcframe/util.hpp" | ||
|
||
using ::testing::Eq; | ||
using ::testing::Test; | ||
|
||
namespace tcframe { | ||
|
||
class UnixOperatingSystemIntegrationTests : public Test { | ||
protected: | ||
UnixOperatingSystem os; | ||
|
||
static string readFile(const string& path) { | ||
ifstream in(path); | ||
string contents = StringUtils::streamToString(&in); | ||
in.close(); | ||
return contents; | ||
} | ||
}; | ||
|
||
TEST_F(UnixOperatingSystemIntegrationTests, Execution_Successful) { | ||
system( | ||
"g++ -o " | ||
"test-integration/os/program " | ||
"test-integration/os/program.cpp"); | ||
|
||
ExecutionResult result = os.execute(ExecutionRequestBuilder() | ||
.setCommand("test-integration/os/program") | ||
.setInputFilename("test-integration/os/1.in") | ||
.setOutputFilename("test-integration/os/1.out") | ||
.build()); | ||
|
||
EXPECT_TRUE(result.isSuccessful()); | ||
EXPECT_THAT(result.exitCode(), Eq(optional<int>(0))); | ||
EXPECT_FALSE(result.exitSignal()); | ||
|
||
EXPECT_THAT(readFile("test-integration/os/1.out"), Eq("43\n")); | ||
EXPECT_THAT(result.standardError(), Eq("44\n")); | ||
} | ||
|
||
TEST_F(UnixOperatingSystemIntegrationTests, Execution_ExceededTimeLimits) { | ||
system( | ||
"g++ -o " | ||
"test-integration/os/program_tl " | ||
"test-integration/os/program_tl.cpp"); | ||
|
||
ExecutionResult result = os.execute(ExecutionRequestBuilder() | ||
.setCommand("test-integration/os/program_tl") | ||
.setTimeLimit(1) | ||
.build()); | ||
|
||
EXPECT_FALSE(result.isSuccessful()); | ||
EXPECT_FALSE(result.exitCode()); | ||
EXPECT_TRUE(result.exitSignal()); | ||
EXPECT_TRUE(result.exceededCpuLimits()); | ||
} | ||
|
||
#ifndef __APPLE__ | ||
|
||
TEST_F(UnixOperatingSystemIntegrationTests, Execution_ExceededMemoryLimits) { | ||
system( | ||
"g++ -o " | ||
"test-integration/os/program_ml " | ||
"test-integration/os/program_ml.cpp"); | ||
|
||
ExecutionResult result = os.execute(ExecutionRequestBuilder() | ||
.setCommand("test-integration/os/program_ml") | ||
.setMemoryLimit(16) | ||
.build()); | ||
|
||
EXPECT_FALSE(result.isSuccessful()); | ||
EXPECT_FALSE(result.exitCode()); | ||
EXPECT_TRUE(result.exitSignal()); | ||
} | ||
|
||
#endif | ||
|
||
TEST_F(UnixOperatingSystemIntegrationTests, Execution_Crashed_ExitCode) { | ||
system( | ||
"g++ -o " | ||
"test-integration/os/program_exit-code " | ||
"test-integration/os/program_exit-code.cpp"); | ||
|
||
ExecutionResult result = os.execute(ExecutionRequestBuilder() | ||
.setCommand("test-integration/os/program_exit-code") | ||
.build()); | ||
|
||
EXPECT_FALSE(result.isSuccessful()); | ||
EXPECT_THAT(result.exitCode(), Eq(optional<int>(42))); | ||
EXPECT_FALSE(result.exitSignal()); | ||
} | ||
|
||
TEST_F(UnixOperatingSystemIntegrationTests, Execution_Crashed_ExitSignal) { | ||
system( | ||
"g++ -o " | ||
"test-integration/os/program_exit-signal " | ||
"test-integration/os/program_exit-signal.cpp"); | ||
|
||
ExecutionResult result = os.execute(ExecutionRequestBuilder() | ||
.setCommand("test-integration/os/program_exit-signal") | ||
.build()); | ||
|
||
EXPECT_FALSE(result.isSuccessful()); | ||
EXPECT_FALSE(result.exitCode()); | ||
EXPECT_TRUE(result.exitSignal()); | ||
} | ||
|
||
} |
Oops, something went wrong.