m/test/e2e: use concise-style logging
Making our test logs look like LogEntry.ConciseString() means we have
significantly more readable test logs.
Change-Id: I0b1eab6a5a837bb2001f3b32779c23df2feaa381
Reviewed-on: https://review.monogon.dev/c/monogon/+/1362
Reviewed-by: Leopold Schabel <leo@monogon.tech>
Tested-by: Jenkins CI
diff --git a/metropolis/test/launch/log.go b/metropolis/test/launch/log.go
new file mode 100644
index 0000000..2637e24
--- /dev/null
+++ b/metropolis/test/launch/log.go
@@ -0,0 +1,28 @@
+package launch
+
+import (
+ "fmt"
+ "os"
+ "strings"
+)
+
+// Log is compatible with the output of ConciseString as used in the Metropolis
+// console log, making the output more readable in unified test logs.
+func Log(f string, args ...any) {
+ formatted := fmt.Sprintf(f, args...)
+ for i, line := range strings.Split(formatted, "\n") {
+ if len(line) == 0 {
+ continue
+ }
+ if i == 0 {
+ fmt.Printf("TT| %20s ! %s\n", "test launch", line)
+ } else {
+ fmt.Printf("TT| %20s | %s\n", "", line)
+ }
+ }
+}
+
+func Fatal(f string, args ...any) {
+ Log(f, args...)
+ os.Exit(1)
+}