mirror of
https://github.com/google/sandboxed-api.git
synced 2024-03-22 13:11:30 +08:00
Copy environ in sandbox2_test to get better coverage data
PiperOrigin-RevId: 518544187 Change-Id: Id13a5503060817e1dead7ee4a5e310d322de3a5e
This commit is contained in:
parent
99931c2ad6
commit
8a38e4de47
|
@ -58,8 +58,9 @@ class Executor final {
|
||||||
|
|
||||||
// Executor will own this file-descriptor, so if intend to use it, pass here
|
// Executor will own this file-descriptor, so if intend to use it, pass here
|
||||||
// dup(fd) instead
|
// dup(fd) instead
|
||||||
Executor(int exec_fd, absl::Span<const std::string> argv,
|
Executor(
|
||||||
absl::Span<const std::string> envp)
|
int exec_fd, absl::Span<const std::string> argv,
|
||||||
|
absl::Span<const std::string> envp = absl::MakeConstSpan(CopyEnviron()))
|
||||||
: exec_fd_(exec_fd),
|
: exec_fd_(exec_fd),
|
||||||
argv_(argv.begin(), argv.end()),
|
argv_(argv.begin(), argv.end()),
|
||||||
envp_(envp.begin(), envp.end()) {
|
envp_(envp.begin(), envp.end()) {
|
||||||
|
|
|
@ -105,8 +105,7 @@ TEST(ExecutorTest, ExecutorFdConstructor) {
|
||||||
ASSERT_NE(fd, -1);
|
ASSERT_NE(fd, -1);
|
||||||
|
|
||||||
std::vector<std::string> args = {absl::StrCat("FD:", fd)};
|
std::vector<std::string> args = {absl::StrCat("FD:", fd)};
|
||||||
std::vector<std::string> envs;
|
auto executor = std::make_unique<Executor>(fd, args);
|
||||||
auto executor = std::make_unique<Executor>(fd, args, envs);
|
|
||||||
|
|
||||||
SAPI_ASSERT_OK_AND_ASSIGN(auto policy,
|
SAPI_ASSERT_OK_AND_ASSIGN(auto policy,
|
||||||
CreateDefaultPermissiveTestPolicy(path).TryBuild());
|
CreateDefaultPermissiveTestPolicy(path).TryBuild());
|
||||||
|
@ -122,8 +121,7 @@ TEST_P(Sandbox2Test, SandboxeeExternalKill) {
|
||||||
const std::string path = GetTestSourcePath("sandbox2/testcases/sleep");
|
const std::string path = GetTestSourcePath("sandbox2/testcases/sleep");
|
||||||
|
|
||||||
std::vector<std::string> args = {path};
|
std::vector<std::string> args = {path};
|
||||||
std::vector<std::string> envs;
|
auto executor = std::make_unique<Executor>(path, args);
|
||||||
auto executor = std::make_unique<Executor>(path, args, envs);
|
|
||||||
|
|
||||||
SAPI_ASSERT_OK_AND_ASSIGN(auto policy,
|
SAPI_ASSERT_OK_AND_ASSIGN(auto policy,
|
||||||
CreateDefaultTestPolicy(path).TryBuild());
|
CreateDefaultTestPolicy(path).TryBuild());
|
||||||
|
@ -142,8 +140,7 @@ TEST_P(Sandbox2Test, SandboxeeTimeoutDisabledStacktraces) {
|
||||||
const std::string path = GetTestSourcePath("sandbox2/testcases/sleep");
|
const std::string path = GetTestSourcePath("sandbox2/testcases/sleep");
|
||||||
|
|
||||||
std::vector<std::string> args = {path};
|
std::vector<std::string> args = {path};
|
||||||
std::vector<std::string> envs;
|
auto executor = std::make_unique<Executor>(path, args);
|
||||||
auto executor = std::make_unique<Executor>(path, args, envs);
|
|
||||||
|
|
||||||
SAPI_ASSERT_OK_AND_ASSIGN(auto policy, CreateDefaultTestPolicy(path)
|
SAPI_ASSERT_OK_AND_ASSIGN(auto policy, CreateDefaultTestPolicy(path)
|
||||||
.CollectStacktracesOnTimeout(false)
|
.CollectStacktracesOnTimeout(false)
|
||||||
|
@ -162,8 +159,7 @@ TEST(Sandbox2Test, SandboxeeViolationDisabledStacktraces) {
|
||||||
const std::string path = GetTestSourcePath("sandbox2/testcases/sleep");
|
const std::string path = GetTestSourcePath("sandbox2/testcases/sleep");
|
||||||
|
|
||||||
std::vector<std::string> args = {path};
|
std::vector<std::string> args = {path};
|
||||||
std::vector<std::string> envs;
|
auto executor = std::make_unique<Executor>(path, args);
|
||||||
auto executor = std::make_unique<Executor>(path, args, envs);
|
|
||||||
|
|
||||||
SAPI_ASSERT_OK_AND_ASSIGN(
|
SAPI_ASSERT_OK_AND_ASSIGN(
|
||||||
auto policy, PolicyBuilder()
|
auto policy, PolicyBuilder()
|
||||||
|
@ -196,8 +192,7 @@ TEST(StarvationTest, MonitorIsNotStarvedByTheSandboxee) {
|
||||||
const std::string path = GetTestSourcePath("sandbox2/testcases/starve");
|
const std::string path = GetTestSourcePath("sandbox2/testcases/starve");
|
||||||
|
|
||||||
std::vector<std::string> args = {path};
|
std::vector<std::string> args = {path};
|
||||||
std::vector<std::string> envs;
|
auto executor = std::make_unique<Executor>(path, args);
|
||||||
auto executor = std::make_unique<Executor>(path, args, envs);
|
|
||||||
executor->limits()->set_walltime_limit(absl::Seconds(5));
|
executor->limits()->set_walltime_limit(absl::Seconds(5));
|
||||||
|
|
||||||
SAPI_ASSERT_OK_AND_ASSIGN(auto policy,
|
SAPI_ASSERT_OK_AND_ASSIGN(auto policy,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user