1
1
/*
2
- * Copyright (c) 2017, Oracle and/or its affiliates. All rights reserved.
2
+ * Copyright (c) 2017, 2023, Oracle and/or its affiliates. All rights reserved.
3
3
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
4
4
*
5
5
* This code is free software; you can redistribute it and/or modify it
23
23
24
24
/*
25
25
* @test
26
- * @bug 8175000
26
+ * @bug 8175000 8314491
27
27
* @summary test jexec
28
+ * @requires os.family == "linux"
28
29
* @build TestHelper
29
30
* @run main Jexec
30
31
*/
31
32
32
33
import java .io .File ;
33
34
import java .io .IOException ;
35
+ import java .nio .file .Path ;
34
36
35
37
public class Jexec extends TestHelper {
36
38
private final File testJar ;
@@ -54,20 +56,12 @@ public class Jexec extends TestHelper {
54
56
}
55
57
56
58
public static void main (String ... args ) throws Exception {
57
- // linux is the only supported platform, give the others a pass
58
- if (!isLinux ) {
59
- System .err .println ("Warning: unsupported platform test passes vacuously" );
60
- return ;
61
- }
62
- // ok to run the test now
63
59
Jexec t = new Jexec ();
64
60
t .run (null );
65
61
}
66
62
67
- @ Test
68
- void jexec () throws Exception {
69
- TestResult tr = doExec (jexecCmd .getAbsolutePath (),
70
- testJar .getAbsolutePath (), message );
63
+ private void runTest (String ... cmds ) throws Exception {
64
+ TestResult tr = doExec (cmds );
71
65
if (!tr .isOK ()) {
72
66
System .err .println (tr );
73
67
throw new Exception ("incorrect exit value" );
@@ -77,4 +71,17 @@ void jexec() throws Exception {
77
71
throw new Exception ("expected message \' " + message + "\' not found" );
78
72
}
79
73
}
74
+
75
+ @ Test
76
+ void jexec () throws Exception {
77
+ runTest (jexecCmd .getAbsolutePath (),
78
+ testJar .getAbsolutePath (), message );
79
+ }
80
+
81
+ @ Test
82
+ void jexecInPath () throws Exception {
83
+ Path jexec = Path .of (jexecCmd .getAbsolutePath ());
84
+ runTest ("/bin/sh" , "-c" ,
85
+ String .format ("PATH=%s ; jexec %s '%s'" ,jexec .getParent (), testJar .getAbsolutePath (), message ));
86
+ }
80
87
}
0 commit comments