24 /* |
24 /* |
25 * @test |
25 * @test |
26 * @bug 4199068 4738465 4937983 4930681 4926230 4931433 4932663 4986689 |
26 * @bug 4199068 4738465 4937983 4930681 4926230 4931433 4932663 4986689 |
27 * 5026830 5023243 5070673 4052517 4811767 6192449 6397034 6413313 |
27 * 5026830 5023243 5070673 4052517 4811767 6192449 6397034 6413313 |
28 * 6464154 6523983 6206031 4960438 6631352 6631966 6850957 6850958 |
28 * 6464154 6523983 6206031 4960438 6631352 6631966 6850957 6850958 |
|
29 * 4947220 |
29 * @summary Basic tests for Process and Environment Variable code |
30 * @summary Basic tests for Process and Environment Variable code |
30 * @run main/othervm Basic |
31 * @run main/othervm Basic |
31 * @author Martin Buchholz |
32 * @author Martin Buchholz |
32 */ |
33 */ |
33 |
34 |
1454 try { |
1455 try { |
1455 String canonicalUserDir = |
1456 String canonicalUserDir = |
1456 new File(System.getProperty("user.dir")).getCanonicalPath(); |
1457 new File(System.getProperty("user.dir")).getCanonicalPath(); |
1457 String[] sdirs = new String[] |
1458 String[] sdirs = new String[] |
1458 {".", "..", "/", "/bin", |
1459 {".", "..", "/", "/bin", |
1459 "C:", "c:", "C:/", "c:\\", "\\", "\\bin" }; |
1460 "C:", "c:", "C:/", "c:\\", "\\", "\\bin", |
|
1461 "c:\\windows ", "c:\\Program Files", "c:\\Program Files\\" }; |
1460 for (String sdir : sdirs) { |
1462 for (String sdir : sdirs) { |
1461 File dir = new File(sdir); |
1463 File dir = new File(sdir); |
1462 if (! (dir.isDirectory() && dir.exists())) |
1464 if (! (dir.isDirectory() && dir.exists())) |
1463 continue; |
1465 continue; |
1464 out.println("Testing directory " + dir); |
1466 out.println("Testing directory " + dir); |
1465 dir = new File(dir.getCanonicalPath()); |
1467 //dir = new File(dir.getCanonicalPath()); |
1466 |
1468 |
1467 ProcessBuilder pb = new ProcessBuilder(); |
1469 ProcessBuilder pb = new ProcessBuilder(); |
1468 equal(pb.directory(), null); |
1470 equal(pb.directory(), null); |
1469 equal(pwdInChild(pb), canonicalUserDir); |
1471 equal(pwdInChild(pb), canonicalUserDir); |
1470 |
1472 |
1471 pb.directory(dir); |
1473 pb.directory(dir); |
1472 equal(pb.directory(), dir); |
1474 equal(pb.directory(), dir); |
1473 equal(pwdInChild(pb), dir.toString()); |
1475 equal(pwdInChild(pb), dir.getCanonicalPath()); |
1474 |
1476 |
1475 pb.directory(null); |
1477 pb.directory(null); |
1476 equal(pb.directory(), null); |
1478 equal(pb.directory(), null); |
1477 equal(pwdInChild(pb), canonicalUserDir); |
1479 equal(pwdInChild(pb), canonicalUserDir); |
1478 |
1480 |
1479 pb.directory(dir); |
1481 pb.directory(dir); |
|
1482 } |
|
1483 } catch (Throwable t) { unexpected(t); } |
|
1484 |
|
1485 //---------------------------------------------------------------- |
|
1486 // Working directory with Unicode in child |
|
1487 //---------------------------------------------------------------- |
|
1488 try { |
|
1489 if (UnicodeOS.is()) { |
|
1490 File dir = new File(System.getProperty("test.dir", "."), |
|
1491 "ProcessBuilderDir\u4e00\u4e02"); |
|
1492 try { |
|
1493 if (!dir.exists()) |
|
1494 dir.mkdir(); |
|
1495 out.println("Testing Unicode directory:" + dir); |
|
1496 ProcessBuilder pb = new ProcessBuilder(); |
|
1497 pb.directory(dir); |
|
1498 equal(pwdInChild(pb), dir.getCanonicalPath()); |
|
1499 } finally { |
|
1500 if (dir.exists()) |
|
1501 dir.delete(); |
|
1502 } |
1480 } |
1503 } |
1481 } catch (Throwable t) { unexpected(t); } |
1504 } catch (Throwable t) { unexpected(t); } |
1482 |
1505 |
1483 //---------------------------------------------------------------- |
1506 //---------------------------------------------------------------- |
1484 // OOME in child allocating maximally sized array |
1507 // OOME in child allocating maximally sized array |