X-Git-Url: http://git.liburcu.org/?a=blobdiff_plain;f=src%2Ftest%2Fjava%2Forg%2Flttng%2Fust%2Fagent%2Futils%2FLttngSession.java;h=9d0b4ab52234aa94a19a31b3efce6e0212f0d924;hb=7dfd1adfc507b63e62004efd3a9a74ae7d1f0d3e;hp=8869ef5da8c901acac2de140b3ee63772d394aa2;hpb=64c5b50cb82ce2f0ac490972372371aad35e0baf;p=lttng-ust-java-tests.git diff --git a/src/test/java/org/lttng/ust/agent/utils/LttngSession.java b/src/test/java/org/lttng/ust/agent/utils/LttngSession.java index 8869ef5..9d0b4ab 100644 --- a/src/test/java/org/lttng/ust/agent/utils/LttngSession.java +++ b/src/test/java/org/lttng/ust/agent/utils/LttngSession.java @@ -18,8 +18,9 @@ package org.lttng.ust.agent.utils; +import static org.lttng.ust.agent.utils.ShellUtils.executeCommand; + import java.io.IOException; -import java.lang.ProcessBuilder.Redirect; import java.nio.file.FileVisitResult; import java.nio.file.Files; import java.nio.file.Path; @@ -28,7 +29,6 @@ import java.nio.file.SimpleFileVisitor; import java.nio.file.attribute.BasicFileAttributes; import java.util.Arrays; import java.util.List; -import java.util.StringJoiner; import java.util.UUID; import java.util.stream.Collectors; @@ -182,7 +182,7 @@ public class LttngSession implements AutoCloseable { * @return The output of Babeltrace on the session's current trace */ public List view() { - return MiscTestUtils.getOutputFromCommand(Arrays.asList("lttng", "view", sessionName)); + return ShellUtils.getOutputFromCommand(true, Arrays.asList("lttng", "view", sessionName)); } /** @@ -232,38 +232,4 @@ public class LttngSession implements AutoCloseable { return true; } - /** - * Simple command to test that the environment / stdout are working - * correctly. - * - * @param args - * Command-line arguments - */ - public static void main(String[] args) { - List command = Arrays.asList("ls", "-l"); - executeCommand(command); - } - - private static boolean executeCommand(List command) { - try { - /* "echo" the command to stdout */ - StringJoiner sj = new StringJoiner(" ", "$ ", ""); - command.stream().forEach(sj::add); - System.out.println(sj.toString()); - - ProcessBuilder builder = new ProcessBuilder(command); - builder.redirectErrorStream(true); - builder.redirectOutput(Redirect.INHERIT); - - Process p = builder.start(); - int ret = p.waitFor(); - - System.out.println("(returned from command)"); - - return (ret == 0); - - } catch (IOException | InterruptedException e) { - return false; - } - } }