Isolate the functions for executing shell commands in a new ShellUtils
[lttng-ust-java-tests.git] / src / test / java / org / lttng / ust / agent / utils / LttngSession.java
index 9c77f59b8395ca8e7bdd41d58aa1afa8daaa9302..9d0b4ab52234aa94a19a31b3efce6e0212f0d924 100644 (file)
@@ -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;
@@ -181,7 +182,7 @@ public class LttngSession implements AutoCloseable {
      * @return The output of Babeltrace on the session's current trace
      */
     public List<String> view() {
-        return MiscTestUtils.getOutputFromCommand(Arrays.asList("lttng", "view", sessionName));
+        return ShellUtils.getOutputFromCommand(true, Arrays.asList("lttng", "view", sessionName));
     }
 
     /**
@@ -231,30 +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<String> command = Arrays.asList("ls", "-l");
-        executeCommand(command);
-    }
-
-    private static boolean executeCommand(List<String> command) {
-        try {
-            ProcessBuilder builder = new ProcessBuilder(command);
-            builder.redirectErrorStream(true);
-            builder.redirectOutput(Redirect.INHERIT);
-
-            Process p = builder.start();
-            int ret = p.waitFor();
-            return (ret == 0);
-
-        } catch (IOException | InterruptedException e) {
-            return false;
-        }
-    }
 }
This page took 0.023233 seconds and 4 git commands to generate.