You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@maven.apache.org by ti...@apache.org on 2019/10/24 23:05:27 UTC
[maven-surefire] branch docker-alpine updated: [JDK 11 Alpine
Linux] long etime within hours has format 2h00 on busybox
This is an automated email from the ASF dual-hosted git repository.
tibordigana pushed a commit to branch docker-alpine
in repository https://gitbox.apache.org/repos/asf/maven-surefire.git
The following commit(s) were added to refs/heads/docker-alpine by this push:
new 437e286 [JDK 11 Alpine Linux] long etime within hours has format 2h00 on busybox
437e286 is described below
commit 437e286b7eafd4389ea2c71acb7e5975f7082b43
Author: tibordigana <ti...@apache.org>
AuthorDate: Fri Oct 25 01:05:16 2019 +0200
[JDK 11 Alpine Linux] long etime within hours has format 2h00 on busybox
---
.../apache/maven/surefire/booter/PpidChecker.java | 25 ++++++++++++++++++++++
.../maven/surefire/booter/PpidCheckerTest.java | 15 +++++++++++++
2 files changed, 40 insertions(+)
diff --git a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/PpidChecker.java b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/PpidChecker.java
index 475fb71..461a7b2 100644
--- a/surefire-booter/src/main/java/org/apache/maven/surefire/booter/PpidChecker.java
+++ b/surefire-booter/src/main/java/org/apache/maven/surefire/booter/PpidChecker.java
@@ -76,6 +76,8 @@ final class PpidChecker
*/
static final Pattern UNIX_CMD_OUT_PATTERN = compile( "^(((\\d+)-)?(\\d{1,2}):)?(\\d{1,2}):(\\d{1,2})\\s+(\\d+)$" );
+ static final Pattern BUSYBOX_CMD_OUT_PATTERN = compile( "^(\\d+)[hH](\\d{1,2})\\s+(\\d+)$" );
+
private final String ppid;
private volatile ProcessInfo parentProcessInfo;
@@ -178,6 +180,12 @@ final class PpidChecker
+ fromSeconds( matcher );
return unixProcessInfo( ppid, pidUptime );
}
+ matcher = BUSYBOX_CMD_OUT_PATTERN.matcher( line );
+ if ( matcher.matches() && ppid.equals( fromBusyboxPID( matcher ) ) )
+ {
+ long pidUptime = fromBusyboxHours( matcher ) + fromBusyboxMinutes( matcher );
+ return unixProcessInfo( ppid, pidUptime );
+ }
}
return previousOutputLine;
}
@@ -310,6 +318,23 @@ final class PpidChecker
return matcher.group( 7 );
}
+ static long fromBusyboxHours( Matcher matcher )
+ {
+ String s = matcher.group( 1 );
+ return s == null ? 0L : HOURS.toSeconds( parseLong( s ) );
+ }
+
+ static long fromBusyboxMinutes( Matcher matcher )
+ {
+ String s = matcher.group( 2 );
+ return s == null ? 0L : MINUTES.toSeconds( parseLong( s ) );
+ }
+
+ static String fromBusyboxPID( Matcher matcher )
+ {
+ return matcher.group( 3 );
+ }
+
private static void checkValid( Scanner scanner )
throws IOException
{
diff --git a/surefire-booter/src/test/java/org/apache/maven/surefire/booter/PpidCheckerTest.java b/surefire-booter/src/test/java/org/apache/maven/surefire/booter/PpidCheckerTest.java
index 2801ffd..cbe1ce3 100644
--- a/surefire-booter/src/test/java/org/apache/maven/surefire/booter/PpidCheckerTest.java
+++ b/surefire-booter/src/test/java/org/apache/maven/surefire/booter/PpidCheckerTest.java
@@ -231,6 +231,21 @@ public class PpidCheckerTest
}
@Test
+ public void shouldParseBusyboxHoursEtime()
+ {
+ Matcher m = PpidChecker.BUSYBOX_CMD_OUT_PATTERN.matcher( "38 1234567890" );
+ assertThat( m.matches() )
+ .isFalse();
+
+ m = PpidChecker.BUSYBOX_CMD_OUT_PATTERN.matcher( "05h38 1234567890" );
+ assertThat( m.matches() )
+ .isTrue();
+ assertThat( PpidChecker.fromBusyboxHours( m ) ).isEqualTo( 3600 * 5L );
+ assertThat( PpidChecker.fromBusyboxMinutes( m ) ).isEqualTo( 60 * 38L );
+ assertThat( PpidChecker.fromBusyboxPID( m ) ).isEqualTo( "1234567890" );
+ }
+
+ @Test
public void shouldHaveSystemPathToWmicOnWindows() throws Exception
{
assumeTrue( IS_OS_WINDOWS );