Skip to content

Commit

Permalink
Added more logging to test failing in github action only
Browse files Browse the repository at this point in the history
  • Loading branch information
hypfvieh committed Oct 4, 2023
1 parent 2a0965f commit e69b382
Showing 1 changed file with 16 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import org.junit.jupiter.api.Test;

import java.io.IOException;
import java.util.Map.Entry;
import java.util.concurrent.atomic.AtomicReference;

/**
Expand Down Expand Up @@ -80,9 +81,20 @@ public void testStartStop() throws Exception {
assertEquals(null, exception.get()); // assertEquals() gives a better error message
}

long dbusDaemonThreadCnt = Thread.getAllStackTraces().keySet().stream()
.filter(e -> e.getName().startsWith(DBusDaemon.class.getSimpleName()))
.count();
assertEquals(0, dbusDaemonThreadCnt, "All dbus daemon threads should have been terminated");
Entry<Thread, StackTraceElement[]> elems = null;
for (Entry<Thread, StackTraceElement[]> stacks : Thread.getAllStackTraces().entrySet()) {
if (stacks.getKey().getName().startsWith(DBusDaemon.class.getSimpleName())) {
elems = stacks;
break;
}
}

if (elems != null) {
System.out.println("Found possibly running instances: " + elems.getKey().getName());
for (StackTraceElement st : elems.getValue()) {
System.out.println("\t" + st.toString());
}
fail("All dbus daemon threads should have been terminated");
}
}
}

0 comments on commit e69b382

Please sign in to comment.