Echo the commands being executed
[lttng-ust-java-tests.git] / src / test / java / org / lttng / ust / agent / utils / MiscTestUtils.java
index dd5505c7effb06f203b83110edbf21db739246e9..fe717367e9996668f94e2a882a50334c2237bf91 100644 (file)
@@ -24,6 +24,7 @@ import java.nio.file.Files;
 import java.nio.file.Path;
 import java.util.Arrays;
 import java.util.List;
+import java.util.StringJoiner;
 
 import org.lttng.ust.agent.jul.LttngLogHandler;
 import org.lttng.ust.agent.log4j.LttngLogAppender;
@@ -91,6 +92,12 @@ public final class MiscTestUtils {
         }
     }
 
+    /**
+     * Check if there is a user session daemon currently running on the system.
+     * It needs to be of the same user as the application running this program.
+     *
+     * @return If there is a user session daemon currently running
+     */
     public static boolean checkForUserSessiond() {
         String userName = System.getProperty("user.name");
 
@@ -104,6 +111,12 @@ public final class MiscTestUtils {
                 .anyMatch(s -> s.startsWith(shortUserName));
     }
 
+    /**
+     * Check if there is a root user session daemon daemon currently running on
+     * the system.
+     *
+     * @return If there is a root session daemon currently running
+     */
     public static boolean checkForRootSessiond() {
         List<String> command = Arrays.asList("ps", "-e", "u");
         List<String> output = getOutputFromCommand(false, command);
@@ -119,6 +132,11 @@ public final class MiscTestUtils {
 
     static List<String> getOutputFromCommand(boolean print, List<String> command) {
         try {
+            /* "echo" the command to stdout */
+            StringJoiner sj = new StringJoiner(" ", "$ ", "");
+            command.stream().forEach(sj::add);
+            System.out.println(sj.toString());
+
             Path tempFile = Files.createTempFile("test-output", null);
 
             ProcessBuilder builder = new ProcessBuilder(command);
@@ -133,9 +151,12 @@ public final class MiscTestUtils {
 
             if (print) {
                 /* Also print the output to the console */
-                lines.stream().forEach(s -> System.out.println(s));
+                lines.stream().forEach(System.out::println);
+            } else {
+                System.out.println("(output silenced)");
             }
 
+            System.out.println("(returned from command)");
             return lines;
 
         } catch (IOException | InterruptedException e) {
This page took 0.02681 seconds and 4 git commands to generate.