gcc/libjava/testsuite/libjava.lang/Process_7.java
David Daney 290b7f64b5 re PR libgcj/23758 (java::lang::ConcreteProcess::nativeSpawn unsafe)
PR libgcj/23758
	* java/lang/natPosixProcess.cc (nativeSpawn): Move building of
	environment before the fork.
	* testsuite/libjava.lang/Process_7.java: New test.
	* testsuite/libjava.lang/Process_7.out: Its expected results.
	* testsuite/libjava.lang/Process_7.jar: Generated file.

From-SVN: r123676
2007-04-09 17:40:20 +00:00

46 lines
1003 B
Java

// Verify we can modify the environment.
import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.Map;
public class Process_7
{
public static void main(String[] args)
{
try
{
ProcessBuilder pb = new ProcessBuilder("env");
Map<String, String> e = pb.environment();
e.clear();
String v = "process7_value";
String k = "PROCESS_7_KEY";
e.put(k, v);
Process p = pb.start();
InputStream is = p.getInputStream();
InputStreamReader isr = new InputStreamReader(is);
BufferedReader br = new BufferedReader(isr);
boolean found = false;
String result;
while ((result = br.readLine()) != null)
{
if (result.equals(k + '=' + v))
found = true;
}
if (!found)
{
System.out.println("bad");
return;
}
System.out.println("ok");
}
catch (Exception ex)
{
System.out.println(ex.toString());
}
}
}