diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/java/com/jogamp/common/util/IOUtil.java | 34 | ||||
-rw-r--r-- | src/junit/com/jogamp/common/util/TestPlatform01.java | 2 | ||||
-rwxr-xr-x | src/native/tinype/make.sh | 7 | ||||
-rw-r--r-- | src/native/tinype/tiny2.c | 8 |
4 files changed, 37 insertions, 14 deletions
diff --git a/src/java/com/jogamp/common/util/IOUtil.java b/src/java/com/jogamp/common/util/IOUtil.java index 3ed28db..9bbb09b 100644 --- a/src/java/com/jogamp/common/util/IOUtil.java +++ b/src/java/com/jogamp/common/util/IOUtil.java @@ -64,11 +64,13 @@ import com.jogamp.common.os.Platform; public class IOUtil { public static final boolean DEBUG; private static final boolean DEBUG_EXE; + private static final boolean DEBUG_EXE_NOSTREAM; static { Debug.initSingleton(); DEBUG = Debug.debug("IOUtil"); DEBUG_EXE = PropertyAccess.isPropertyDefined("jogamp.debug.IOUtil.Exe", true); + DEBUG_EXE_NOSTREAM = PropertyAccess.isPropertyDefined("jogamp.debug.IOUtil.Exe.NoStream", true); } /** Std. temporary directory property key <code>java.io.tmpdir</code>. */ @@ -906,8 +908,16 @@ public class IOUtil { final long t0 = debug ? System.currentTimeMillis() : 0; final File exeTestFile; + final boolean existingExe; try { - exeTestFile = File.createTempFile("jogamp_exe_tst", getExeTestFileSuffix(), dir); + final File permExeTestFile = DEBUG_EXE ? new File(dir, "jogamp_exe_tst"+getExeTestFileSuffix()) : null; + if( null != permExeTestFile && permExeTestFile.exists() ) { + exeTestFile = permExeTestFile; + existingExe = true; + } else { + exeTestFile = File.createTempFile("jogamp_exe_tst", getExeTestFileSuffix(), dir); + existingExe = false; + } } catch (final SecurityException se) { throw se; // fwd Security exception } catch (final IOException e) { @@ -918,18 +928,22 @@ public class IOUtil { } final long t1 = debug ? System.currentTimeMillis() : 0; int res = -1; - if(exeTestFile.setExecutable(true /* exec */, true /* ownerOnly */)) { + int exitValue = -1; + if( existingExe || exeTestFile.setExecutable(true /* exec */, true /* ownerOnly */) ) { try { - fillExeTestFile(exeTestFile); - + if( !existingExe ) { + fillExeTestFile(exeTestFile); + } // Using 'Process.exec(String[])' avoids StringTokenizer of 'Process.exec(String)' // and hence splitting up command by spaces! - final Process pr = Runtime.getRuntime().exec( getExeTestCommandArgs( exeTestFile.getCanonicalPath() ) ); - if( DEBUG_EXE ) { + // Note: All no-exec cases throw an IOExceptions at ProcessBuilder.start(), i.e. below exec() call! + final Process pr = Runtime.getRuntime().exec( getExeTestCommandArgs( exeTestFile.getCanonicalPath() ), null, null ); + if( DEBUG_EXE && !DEBUG_EXE_NOSTREAM ) { new StreamMonitor(new InputStream[] { pr.getInputStream(), pr.getErrorStream() }, System.err, "Exe-Tst: "); } pr.waitFor() ; - res = pr.exitValue(); + exitValue = pr.exitValue(); // Note: Bug 1219 Comment 50: On reporter's machine exit value 1 is being returned + res = 0; // file has been executed } catch (final SecurityException se) { throw se; // fwd Security exception } catch (final Throwable t) { @@ -941,14 +955,12 @@ public class IOUtil { } } final boolean ok = 0 == res; - if( !DEBUG_EXE ) { + if( !DEBUG_EXE && !existingExe ) { exeTestFile.delete(); } if( debug ) { final long t2 = System.currentTimeMillis(); - if( DEBUG_EXE ) { - System.err.println("IOUtil.testDirExec(): test-exe <"+exeTestFile.getAbsolutePath()+">"); - } + System.err.println("IOUtil.testDirExec(): test-exe <"+exeTestFile.getAbsolutePath()+">, existingFile "+existingExe+", returned "+exitValue); System.err.println("IOUtil.testDirExec(): abs-path <"+dir.getAbsolutePath()+">: res "+res+" -> "+ok); System.err.println("IOUtil.testDirExec(): total "+(t2-t0)+"ms, create "+(t1-t0)+"ms, execute "+(t2-t1)+"ms"); } diff --git a/src/junit/com/jogamp/common/util/TestPlatform01.java b/src/junit/com/jogamp/common/util/TestPlatform01.java index 6f1fe0e..bf3e79d 100644 --- a/src/junit/com/jogamp/common/util/TestPlatform01.java +++ b/src/junit/com/jogamp/common/util/TestPlatform01.java @@ -44,7 +44,7 @@ public class TestPlatform01 extends SingletonJunitCase { @Test public void testInfo00() { System.err.println(); - System.err.println(); + System.err.print(Platform.getNewline()); System.err.println("OS name/type: "+Platform.getOSName()+", "+Platform.getOSType()); System.err.println("OS version: "+Platform.getOSVersion()+", "+Platform.getOSVersionNumber()); System.err.println(); diff --git a/src/native/tinype/make.sh b/src/native/tinype/make.sh index 2a81c6b..9a68f0d 100755 --- a/src/native/tinype/make.sh +++ b/src/native/tinype/make.sh @@ -1,4 +1,7 @@ +/cygdrive/c/mingw/bin/gcc -nodefaultlibs -nostdlib -s -Os -mwindows -o tiny2-win32-i386.exe tiny2.c + /cygdrive/c/mingw/bin/gcc -nodefaultlibs -nostdlib -s -Os -mwindows -o tiny-win32-i386.exe tiny.c gzip -9 -c tiny-win32-i386.exe > tiny-win32-i386.exe.gz -/cygdrive/c/mingw64/bin/gcc -nodefaultlibs -nostdlib -s -Os -mwindows -o tiny-win32-x86_64.exe tiny.c -gzip -9 -c tiny-win32-x86_64.exe > tiny-win32-x86_64.exe.gz + +#/cygdrive/c/mingw64/bin/gcc -nodefaultlibs -nostdlib -s -Os -mwindows -o tiny-win32-x86_64.exe tiny.c +#gzip -9 -c tiny-win32-x86_64.exe > tiny-win32-x86_64.exe.gz diff --git a/src/native/tinype/tiny2.c b/src/native/tinype/tiny2.c new file mode 100644 index 0000000..d24c287 --- /dev/null +++ b/src/native/tinype/tiny2.c @@ -0,0 +1,8 @@ +#include <stdio.h> +const char * id = "JogAmp Windows Universal Test PE Executable"; + +int main() +{ + fprintf(stderr, "%s\n", id); + return 42; +} |