From 95e2d58dc175a3a6da4faa719a40be96b90a8756 Mon Sep 17 00:00:00 2001 From: Dmitry Samersoff Date: Fri, 8 Jul 2016 17:36:34 +0300 Subject: [PATCH] 8159925: sun/tools/jps/TestJpsJar.java still fails after fix for JDK-8153278 Check user.dir property Reviewed-by: dcubed, sspitsyn --- jdk/test/sun/tools/jps/JpsBase.java | 20 +++++++++++++++++--- jdk/test/sun/tools/jps/TestJpsJar.java | 3 ++- 2 files changed, 19 insertions(+), 4 deletions(-) diff --git a/jdk/test/sun/tools/jps/JpsBase.java b/jdk/test/sun/tools/jps/JpsBase.java index d13a4053bd8..1b810f357bb 100644 --- a/jdk/test/sun/tools/jps/JpsBase.java +++ b/jdk/test/sun/tools/jps/JpsBase.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -59,7 +59,17 @@ public final class JpsBase { return JpsBase.class.getName(); } + private static boolean userDirSanityCheck(String fullProcessName) { + String userDir = System.getProperty("user.dir"); + if (!fullProcessName.startsWith(userDir)) { + System.err.printf("Test skipped. user.dir '%s' is not a prefix of '%s'\n", userDir, fullProcessName); + return false; + } + return true; + } + public static void main(String[] args) throws Exception { + System.out.printf("INFO: user.dir: '%s''\n", System.getProperty("user.dir")); long pid = ProcessTools.getProcessId(); List> combinations = JpsHelper.JpsArg.generateCombinations(); @@ -85,8 +95,12 @@ public final class JpsBase { // 30673 /tmp/jtreg/jtreg-workdir/scratch/JpsBase.jar ... isFull = true; String fullProcessName = getFullProcessName(); - pattern = "^" + pid + "\\s+" + replaceSpecialChars(fullProcessName) + ".*"; - output.shouldMatch(pattern); + // Skip the test if user.dir is not a prefix of the current path + // It's possible if the test is run from symlinked dir or windows alias drive + if (userDirSanityCheck(fullProcessName)) { + pattern = "^" + pid + "\\s+" + replaceSpecialChars(fullProcessName) + ".*"; + output.shouldMatch(pattern); + } break; case m: // If '-m' is specified output should contain the arguments passed to the main method: diff --git a/jdk/test/sun/tools/jps/TestJpsJar.java b/jdk/test/sun/tools/jps/TestJpsJar.java index c0b862756db..00cc5423018 100644 --- a/jdk/test/sun/tools/jps/TestJpsJar.java +++ b/jdk/test/sun/tools/jps/TestJpsJar.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -52,6 +52,7 @@ public class TestJpsJar { cmd.addAll(JpsHelper.getVmArgs()); cmd.add("-Dtest.jdk=" + testJdk); cmd.add("-Dtest.src=" + testSrc); + cmd.add("-Duser.dir=" + System.getProperty("user.dir")); cmd.add("-jar"); cmd.add(jar.getAbsolutePath()); cmd.add("monkey");