Skip to content

Commit

Permalink
Bring LinuxSandboxedSpawnRunnerTest.java back into the world of the t…
Browse files Browse the repository at this point in the history
…ested.

PiperOrigin-RevId: 525424690
Change-Id: I6cb64de3abd60d90d518e2592df9f322f4213a6f
  • Loading branch information
larsrc-google authored and copybara-github committed Apr 19, 2023
1 parent 0dc0c7e commit 71b4342
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 22 deletions.
9 changes: 9 additions & 0 deletions src/test/java/com/google/devtools/build/lib/sandbox/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -136,6 +136,7 @@ java_test(
srcs = [
"DarwinSandboxedSpawnRunnerTest.java",
"LinuxSandboxCommandLineBuilderTest.java",
"LinuxSandboxedSpawnRunnerTest.java",
"ProcessWrapperSandboxedSpawnRunnerTest.java",
],
data = ["//src/test/java/com/google/devtools/build/lib:embedded_scripts"],
Expand All @@ -148,23 +149,31 @@ java_test(
":testutil",
"//src/main/java/com/google/devtools/build/lib:runtime",
"//src/main/java/com/google/devtools/build/lib/actions",
"//src/main/java/com/google/devtools/build/lib/actions:artifacts",
"//src/main/java/com/google/devtools/build/lib/actions:localhost_capacity",
"//src/main/java/com/google/devtools/build/lib/exec:bin_tools",
"//src/main/java/com/google/devtools/build/lib/exec:spawn_runner",
"//src/main/java/com/google/devtools/build/lib/exec:tree_deleter",
"//src/main/java/com/google/devtools/build/lib/sandbox:darwin_sandbox",
"//src/main/java/com/google/devtools/build/lib/sandbox:linux_sandbox",
"//src/main/java/com/google/devtools/build/lib/sandbox:linux_sandbox_command_line_builder",
"//src/main/java/com/google/devtools/build/lib/sandbox:process_wrapper_sandbox",
"//src/main/java/com/google/devtools/build/lib/sandbox:sandbox_helpers",
"//src/main/java/com/google/devtools/build/lib/sandbox:sandboxed_spawns",
"//src/main/java/com/google/devtools/build/lib/sandbox:sandboxfs_process",
"//src/main/java/com/google/devtools/build/lib/sandbox:tree_deleter",
"//src/main/java/com/google/devtools/build/lib/util:os",
"//src/main/java/com/google/devtools/build/lib/util/io",
"//src/main/java/com/google/devtools/build/lib/vfs",
"//src/main/java/com/google/devtools/build/lib/vfs:pathfragment",
"//src/main/java/com/google/devtools/build/lib/vfs/inmemoryfs",
"//src/test/java/com/google/devtools/build/lib/actions/util",
"//src/test/java/com/google/devtools/build/lib/exec/util",
"//src/test/java/com/google/devtools/build/lib/testutil",
"//third_party:guava",
"//third_party:junit4",
"//third_party:truth",
"@com_google_testparameterinjector//:testparameterinjector",
],
)

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
package com.google.devtools.build.lib.sandbox;

import static com.google.common.truth.Truth.assertThat;
import static com.google.common.truth.Truth8.assertThat;
import static com.google.common.truth.TruthJUnit.assume;
import static java.nio.charset.StandardCharsets.UTF_8;

Expand Down Expand Up @@ -71,7 +70,7 @@ public void exec_echoCommand_executesSuccessfully() throws Exception {
assertThat(spawnResult.status()).isEqualTo(SpawnResult.Status.SUCCESS);
assertThat(spawnResult.exitCode()).isEqualTo(0);
assertThat(spawnResult.setupSuccess()).isTrue();
assertThat(spawnResult.getWallTime()).isPresent();
assertThat(spawnResult.getWallTimeInMs()).isGreaterThan(0);
assertThat(FileSystemUtils.readLines(stdout, UTF_8)).containsExactly("echolalia");
}

Expand Down Expand Up @@ -153,18 +152,16 @@ public void exec_collectsExecutionStatistics() throws Exception {
assertThat(spawnResult.status()).isEqualTo(SpawnResult.Status.SUCCESS);
assertThat(spawnResult.exitCode()).isEqualTo(0);
assertThat(spawnResult.setupSuccess()).isTrue();
assertThat(spawnResult.getWallTime()).isPresent();
assertThat(spawnResult.getWallTime().get()).isAtLeast(minimumWallTimeToSpend);
assertThat(spawnResult.getWallTime().get()).isAtMost(maximumWallTimeToSpend);
assertThat(spawnResult.getUserTime()).isPresent();
assertThat(spawnResult.getUserTime().get()).isAtLeast(minimumUserTimeToSpend);
assertThat(spawnResult.getUserTime().get()).isAtMost(maximumUserTimeToSpend);
assertThat(spawnResult.getSystemTime()).isPresent();
assertThat(spawnResult.getSystemTime().get()).isAtLeast(minimumSystemTimeToSpend);
assertThat(spawnResult.getSystemTime().get()).isAtMost(maximumSystemTimeToSpend);
assertThat(spawnResult.getNumBlockOutputOperations().get()).isAtLeast(0L);
assertThat(spawnResult.getNumBlockInputOperations().get()).isAtLeast(0L);
assertThat(spawnResult.getNumInvoluntaryContextSwitches().get()).isAtLeast(0L);
assertThat(spawnResult.getWallTimeInMs()).isAtLeast((int) minimumWallTimeToSpend.toMillis());
assertThat(spawnResult.getWallTimeInMs()).isAtMost((int) maximumWallTimeToSpend.toMillis());
assertThat(spawnResult.getUserTimeInMs()).isAtLeast((int) minimumUserTimeToSpend.toMillis());
assertThat(spawnResult.getUserTimeInMs()).isAtMost((int) maximumUserTimeToSpend.toMillis());
assertThat(spawnResult.getSystemTimeInMs())
.isAtLeast((int) minimumSystemTimeToSpend.toMillis());
assertThat(spawnResult.getSystemTimeInMs()).isAtMost((int) maximumSystemTimeToSpend.toMillis());
assertThat(spawnResult.getNumBlockOutputOperations()).isAtLeast(0L);
assertThat(spawnResult.getNumBlockInputOperations()).isAtLeast(0L);
assertThat(spawnResult.getNumInvoluntaryContextSwitches()).isAtLeast(0L);
}

@Test
Expand Down Expand Up @@ -192,14 +189,13 @@ public void exec_statisticsCollectionDisabled_returnsEmptyStatistics() throws Ex
assertThat(spawnResult.status()).isEqualTo(SpawnResult.Status.SUCCESS);
assertThat(spawnResult.exitCode()).isEqualTo(0);
assertThat(spawnResult.setupSuccess()).isTrue();
assertThat(spawnResult.getWallTime()).isPresent();
assertThat(spawnResult.getWallTime().get()).isAtLeast(minimumWallTimeToSpend);
assertThat(spawnResult.getWallTime().get()).isAtMost(maximumWallTimeToSpend);
assertThat(spawnResult.getUserTime()).isEmpty();
assertThat(spawnResult.getSystemTime()).isEmpty();
assertThat(spawnResult.getNumBlockOutputOperations()).isEmpty();
assertThat(spawnResult.getNumBlockInputOperations()).isEmpty();
assertThat(spawnResult.getNumInvoluntaryContextSwitches()).isEmpty();
assertThat(spawnResult.getWallTimeInMs()).isAtLeast((int) minimumWallTimeToSpend.toMillis());
assertThat(spawnResult.getWallTimeInMs()).isAtMost((int) maximumWallTimeToSpend.toMillis());
assertThat(spawnResult.getUserTimeInMs()).isEqualTo(0);
assertThat(spawnResult.getSystemTimeInMs()).isEqualTo(0);
assertThat(spawnResult.getNumBlockOutputOperations()).isNull();
assertThat(spawnResult.getNumBlockInputOperations()).isNull();
assertThat(spawnResult.getNumInvoluntaryContextSwitches()).isNull();
}

@Test
Expand Down

0 comments on commit 71b4342

Please sign in to comment.