Skip to content

Commit 115e74d

Browse files
Ilarion NakonechnyyYuri Nesterenko
authored andcommitted
8239365: ProcessBuilder test modifications for AIX execution
Backport-of: 2785fe5621bd3af64450f1f5069dc2a4b47785fe
1 parent 89a08b3 commit 115e74d

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

jdk/test/java/lang/ProcessBuilder/Basic.java

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,10 @@ public class Basic {
6262
/* used for AIX only */
6363
static final String libpath = System.getenv("LIBPATH");
6464

65+
/* Used for regex String matching for long error messages */
66+
static final String PERMISSION_DENIED_ERROR_MSG = "(Permission denied|error=13)";
67+
static final String NO_SUCH_FILE_ERROR_MSG = "(No such file|error=2)";
68+
6569
/**
6670
* Returns the number of milliseconds since time given by
6771
* startNanoTime, which must have been previously returned from a
@@ -295,7 +299,7 @@ static void checkPermissionDenied(ProcessBuilder pb) {
295299
} catch (IOException e) {
296300
String m = e.getMessage();
297301
if (EnglishUnix.is() &&
298-
! matches(m, "Permission denied"))
302+
! matches(m, PERMISSION_DENIED_ERROR_MSG))
299303
unexpected(e);
300304
} catch (Throwable t) { unexpected(t); }
301305
}
@@ -403,7 +407,7 @@ public static void main(String args[]) throws Throwable {
403407
} catch (IOException e) {
404408
String m = e.getMessage();
405409
if (EnglishUnix.is() &&
406-
! matches(m, "No such file"))
410+
! matches(m, NO_SUCH_FILE_ERROR_MSG))
407411
unexpected(e);
408412
} catch (Throwable t) { unexpected(t); }
409413

@@ -416,7 +420,7 @@ public static void main(String args[]) throws Throwable {
416420
} catch (IOException e) {
417421
String m = e.getMessage();
418422
if (EnglishUnix.is() &&
419-
! matches(m, "No such file"))
423+
! matches(m, NO_SUCH_FILE_ERROR_MSG))
420424
unexpected(e);
421425
} catch (Throwable t) { unexpected(t); }
422426

@@ -1854,7 +1858,7 @@ public void doIt(Map<String,String> environ) {
18541858
} catch (IOException e) {
18551859
String m = e.getMessage();
18561860
if (EnglishUnix.is() &&
1857-
! matches(m, "No such file or directory"))
1861+
! matches(m, NO_SUCH_FILE_ERROR_MSG))
18581862
unexpected(e);
18591863
} catch (Throwable t) { unexpected(t); }
18601864

@@ -1871,7 +1875,7 @@ public void doIt(Map<String,String> environ) {
18711875
Pattern p = Pattern.compile(programName);
18721876
if (! matches(m, programName)
18731877
|| (EnglishUnix.is()
1874-
&& ! matches(m, "No such file or directory")))
1878+
&& ! matches(m, NO_SUCH_FILE_ERROR_MSG)))
18751879
unexpected(e);
18761880
} catch (Throwable t) { unexpected(t); }
18771881

@@ -1887,7 +1891,7 @@ public void doIt(Map<String,String> environ) {
18871891
String m = e.getMessage();
18881892
if (! matches(m, "in directory")
18891893
|| (EnglishUnix.is() &&
1890-
! matches(m, "No such file or directory")))
1894+
! matches(m, NO_SUCH_FILE_ERROR_MSG)))
18911895
unexpected(e);
18921896
} catch (Throwable t) { unexpected(t); }
18931897

@@ -2122,7 +2126,7 @@ public void run() {
21222126
new File("./emptyCommand").delete();
21232127
String m = e.getMessage();
21242128
if (EnglishUnix.is() &&
2125-
! matches(m, "Permission denied"))
2129+
! matches(m, PERMISSION_DENIED_ERROR_MSG))
21262130
unexpected(e);
21272131
} catch (Throwable t) { unexpected(t); }
21282132

0 commit comments

Comments
 (0)