diff options
-rw-r--r-- | make/build-test.xml | 5 | ||||
-rwxr-xr-x | make/scripts/java-win32.bat | 10 | ||||
-rwxr-xr-x | make/scripts/java-win64.bat | 10 | ||||
-rwxr-xr-x | make/scripts/runtest-x64.bat | 2 | ||||
-rwxr-xr-x | make/scripts/runtest.sh | 11 | ||||
-rw-r--r-- | src/junit/com/jogamp/gluegen/test/junit/generation/Test1p2DynamicLibraryBundle.java | 271 |
6 files changed, 293 insertions, 16 deletions
diff --git a/make/build-test.xml b/make/build-test.xml index 736a82a..8fc595e 100644 --- a/make/build-test.xml +++ b/make/build-test.xml @@ -437,8 +437,11 @@ chmod 644 ${results}/* \${line.separator} <jvmarg value="-Drootrel.build=${rootrel.build}"/> <!-- <jvmarg value="-Djogamp.debug.NativeLibrary=true"/> - <jvmarg value="-Djogamp.debug.ProcAddressHelper=true"/> <jvmarg value="-Djogamp.debug.JNILibLoader=true"/> + <jvmarg value="-Djogamp.debug.TempFileCache=true"/> + <jvmarg value="-Djogamp.debug.JarUtil=true"/> + <jvmarg value="-Djogamp.debug.TempJarCache=true"/> + <jvmarg value="-Djogamp.debug.ProcAddressHelper=true"/> <jvmarg value="-verbose:jni"/> <jvmarg value="-client"/> --> diff --git a/make/scripts/java-win32.bat b/make/scripts/java-win32.bat index 2ed87c3..436d68b 100755 --- a/make/scripts/java-win32.bat +++ b/make/scripts/java-win32.bat @@ -7,10 +7,10 @@ set ANT_PATH=C:\apache-ant-1.10.5 set BLD_DIR=..\%BLD_SUB%
REM set LIB_DIR=..\%BLD_SUB%\obj;..\%BLD_SUB%\test\build\natives
-REM set LIB_DIR=..\%BLD_SUB%\test\build\natives
+set LIB_DIR=..\%BLD_SUB%\test\build\natives
-REM set PATH=%JAVA_HOME%\bin;%ANT_PATH%\bin;c:\mingw32\bin;%LIB_DIR%;%PATH%
-set PATH=%JAVA_HOME%\bin;%ANT_PATH%\bin;c:\mingw32\bin;%PATH%
+set PATH=%JAVA_HOME%\bin;%ANT_PATH%\bin;c:\mingw32\bin;%LIB_DIR%;%PATH%
+REM set PATH=%JAVA_HOME%\bin;%ANT_PATH%\bin;c:\mingw32\bin;%PATH%
set CP_ALL=.;lib\junit.jar;%ANT_PATH%\lib\ant.jar;%ANT_PATH%\lib\ant-junit.jar;lib/semantic-versioning/semver.jar;%BLD_DIR%\gluegen-rt.jar;%BLD_DIR%\gluegen.jar;%BLD_DIR%\gluegen-test-util.jar;%BLD_DIR%\test\build\gluegen-test.jar
@@ -21,5 +21,5 @@ REM set D_ARGS="-Djogamp.debug.Platform" "-Djogamp.debug.NativeLibrary" set D_ARGS="-Djogamp.debug.IOUtil" "-Djogamp.debug.IOUtil.Exe"
REM set D_ARGS="-Djogamp.debug=all"
-REM %J2RE_HOME%\bin\java -classpath %CP_ALL% %X_ARGS% %D_ARGS% "-Djava.library.path=%LIB_DIR%" "-Dsun.java2d.noddraw=true" "-Dsun.awt.noerasebackground=true" %1 %2 %3 %4 %5 %6 %7 %8 %9 > java-win32.log 2>&1
-%J2RE_HOME%\bin\java -classpath %CP_ALL% %X_ARGS% %D_ARGS% "-Dsun.java2d.noddraw=true" "-Dsun.awt.noerasebackground=true" %1 %2 %3 %4 %5 %6 %7 %8 %9 > java-win32.log 2>&1
+%J2RE_HOME%\bin\java -classpath %CP_ALL% %X_ARGS% %D_ARGS% "-Djava.library.path=%LIB_DIR%" "-Dsun.java2d.noddraw=true" "-Dsun.awt.noerasebackground=true" %1 %2 %3 %4 %5 %6 %7 %8 %9 > java-win32.log 2>&1
+REM %J2RE_HOME%\bin\java -classpath %CP_ALL% %X_ARGS% %D_ARGS% "-Dsun.java2d.noddraw=true" "-Dsun.awt.noerasebackground=true" %1 %2 %3 %4 %5 %6 %7 %8 %9 > java-win32.log 2>&1
diff --git a/make/scripts/java-win64.bat b/make/scripts/java-win64.bat index 283fe4c..575d937 100755 --- a/make/scripts/java-win64.bat +++ b/make/scripts/java-win64.bat @@ -7,10 +7,10 @@ set ANT_PATH=C:\apache-ant-1.10.5 set BLD_DIR=..\%BLD_SUB%
REM set LIB_DIR=..\%BLD_SUB%\obj;..\%BLD_SUB%\test\build\natives
-REM set LIB_DIR=..\%BLD_SUB%\test\build\natives
+set LIB_DIR=..\%BLD_SUB%\test\build\natives
-REM set PATH=%JAVA_HOME%\bin;%ANT_PATH%\bin;c:\mingw64\bin;%LIB_DIR%;%PATH%
-set PATH=%JAVA_HOME%\bin;%ANT_PATH%\bin;c:\mingw64\bin;%PATH%
+set PATH=%JAVA_HOME%\bin;%ANT_PATH%\bin;c:\mingw64\bin;%LIB_DIR%;%PATH%
+REM set PATH=%JAVA_HOME%\bin;%ANT_PATH%\bin;c:\mingw64\bin;%PATH%
set CP_ALL=.;lib\junit.jar;%ANT_PATH%\lib\ant.jar;%ANT_PATH%\lib\ant-junit.jar;lib/semantic-versioning/semver.jar;lib\TestJarsInJar.jar;%BLD_DIR%\gluegen-rt.jar;%BLD_DIR%\gluegen.jar;%BLD_DIR%\gluegen-test-util.jar;%BLD_DIR%\test\build\gluegen-test.jar
@@ -24,6 +24,6 @@ REM set D_ARGS="-Djogamp.debug.IOUtil" "-Djogamp.debug.TempFileCache" "-Djogamp. REM set D_ARGS="-Djogamp.debug.IOUtil" "-Djogamp.debug.TempFileCache" "-Djogamp.debug.TempJarCache" "-Djava.io.tmpdir=c:\temp_noexec"
REM set D_ARGS="-Djogamp.debug=all"
-REM %J2RE_HOME%\bin\java -classpath %CP_ALL% %X_ARGS% %D_ARGS% "-Djava.library.path=%LIB_DIR%" "-Dsun.java2d.noddraw=true" "-Dsun.awt.noerasebackground=true" %1 %2 %3 %4 %5 %6 %7 %8 %9 > java-win64.log 2>&1
-%J2RE_HOME%\bin\java -classpath %CP_ALL% %X_ARGS% %D_ARGS% "-Dsun.java2d.noddraw=true" "-Dsun.awt.noerasebackground=true" %1 %2 %3 %4 %5 %6 %7 %8 %9 > java-win64.log 2>&1
+%J2RE_HOME%\bin\java -classpath %CP_ALL% %X_ARGS% %D_ARGS% "-Djava.library.path=%LIB_DIR%" "-Dsun.java2d.noddraw=true" "-Dsun.awt.noerasebackground=true" %1 %2 %3 %4 %5 %6 %7 %8 %9 > java-win64.log 2>&1
+REM %J2RE_HOME%\bin\java -classpath %CP_ALL% %X_ARGS% %D_ARGS% "-Dsun.java2d.noddraw=true" "-Dsun.awt.noerasebackground=true" %1 %2 %3 %4 %5 %6 %7 %8 %9 > java-win64.log 2>&1
diff --git a/make/scripts/runtest-x64.bat b/make/scripts/runtest-x64.bat index 1457174..3507046 100755 --- a/make/scripts/runtest-x64.bat +++ b/make/scripts/runtest-x64.bat @@ -10,6 +10,8 @@ REM scripts\java-win64.bat com.jogamp.gluegen.jcpp.IncludeAbsoluteTest REM scripts\java-win64.bat com.jogamp.gluegen.test.junit.generation.Test1p1JavaEmitter REM scripts\java-win64.bat com.jogamp.gluegen.test.junit.generation.Test1p2ProcAddressEmitter +REM scripts\java-win64.bat com.jogamp.gluegen.test.junit.generation.Test1p2LoadJNIAndImplLib +REM scripts\java-win64.bat com.jogamp.gluegen.test.junit.generation.Test1p2DynamicLibraryBundle REM scripts\java-win64.bat com.jogamp.common.util.TestTempJarCache REM scripts\java-win64.bat com.jogamp.common.os.TestElfReader01 REM scripts\java-win64.bat com.jogamp.common.util.TestPlatform01 diff --git a/make/scripts/runtest.sh b/make/scripts/runtest.sh index 0ce33bd..72279a6 100755 --- a/make/scripts/runtest.sh +++ b/make/scripts/runtest.sh @@ -50,7 +50,7 @@ X_ARGS="-Drootrel.build=$ROOTREL_BUILD -Dgluegen.root=$GLUEGEN_ROOT" #D_ARGS="-Djogamp.debug.TempJarCache" #D_ARGS="-Djogamp.debug.TempFileCache" #D_ARGS="-Djogamp.debug.IOUtil -Djogamp.debug.JNILibLoader -Djogamp.debug.TempFileCache -Djogamp.debug.JarUtil -Djava.io.tmpdir=/run/tmp" -#D_ARGS="-Djogamp.debug.IOUtil -Djogamp.debug.JNILibLoader -Djogamp.debug.TempFileCache -Djogamp.debug.JarUtil -Djogamp.debug.TempJarCache" +#D_ARGS="-Djogamp.debug.IOUtil -Djogamp.debug.NativeLibrary -Djogamp.debug.JNILibLoader -Djogamp.debug.TempFileCache -Djogamp.debug.JarUtil -Djogamp.debug.TempJarCache" #D_ARGS="-Djogamp.debug.IOUtil -Djogamp.debug.JarUtil -Djogamp.debug.TempJarCache -Djogamp.debug.Uri -Djogamp.debug.Uri.ShowFix" #D_ARGS="-Djogamp.debug.Uri -Djogamp.debug.Uri.ShowFix" #D_ARGS="-Djogamp.debug.JNILibLoader -Djogamp.gluegen.UseTempJarCache=false" @@ -83,10 +83,10 @@ function onetest() { echo LD_LIBRARY_PATH $LD_LIBRARY_PATH echo USE_CLASSPATH $USE_CLASSPATH which java - #echo java -cp $USE_CLASSPATH $X_ARGS $D_ARGS -Djava.library.path=$libspath $* - #java -cp $USE_CLASSPATH $X_ARGS $D_ARGS -Djava.library.path="$libspath" $* - echo java -cp "$USE_CLASSPATH" $X_ARGS $D_ARGS $* - java -cp "$USE_CLASSPATH" $X_ARGS $D_ARGS $* + echo java -cp "$USE_CLASSPATH" $X_ARGS $D_ARGS -Djava.library.path=$libspath $* + java -cp "$USE_CLASSPATH" $X_ARGS $D_ARGS -Djava.library.path="$libspath" $* + #echo java -cp "$USE_CLASSPATH" $X_ARGS $D_ARGS $* + #java -cp "$USE_CLASSPATH" $X_ARGS $D_ARGS $* #j3 -cp "$USE_CLASSPATH" $X_ARGS $D_ARGS $* echo } @@ -151,6 +151,7 @@ onetest com.jogamp.common.util.TestVersionInfo 2>&1 | tee -a $LOG #onetest com.jogamp.gluegen.test.junit.generation.Test1p1JavaEmitter 2>&1 | tee -a $LOG #onetest com.jogamp.gluegen.test.junit.generation.Test1p2ProcAddressEmitter 2>&1 | tee -a $LOG #onetest com.jogamp.gluegen.test.junit.generation.Test1p2LoadJNIAndImplLib 2>&1 | tee -a $LOG +#onetest com.jogamp.gluegen.test.junit.generation.Test1p2DynamicLibraryBundle 2>&1 | tee -a $LOG #onetest com.jogamp.gluegen.test.junit.structgen.TestStructGen01 2>&1 | tee -a $LOG #onetest com.jogamp.gluegen.test.junit.structgen.TestStructGen02 2>&1 | tee -a $LOG diff --git a/src/junit/com/jogamp/gluegen/test/junit/generation/Test1p2DynamicLibraryBundle.java b/src/junit/com/jogamp/gluegen/test/junit/generation/Test1p2DynamicLibraryBundle.java new file mode 100644 index 0000000..c063d15 --- /dev/null +++ b/src/junit/com/jogamp/gluegen/test/junit/generation/Test1p2DynamicLibraryBundle.java @@ -0,0 +1,271 @@ +/** + * Copyright 2019 JogAmp Community. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without modification, are + * permitted provided that the following conditions are met: + * + * 1. Redistributions of source code must retain the above copyright notice, this list of + * conditions and the following disclaimer. + * + * 2. Redistributions in binary form must reproduce the above copyright notice, this list + * of conditions and the following disclaimer in the documentation and/or other materials + * provided with the distribution. + * + * THIS SOFTWARE IS PROVIDED BY JogAmp Community ``AS IS'' AND ANY EXPRESS OR IMPLIED + * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND + * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL JogAmp Community OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR + * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON + * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + * + * The views and conclusions contained in the software and documentation are those of the + * authors and should not be interpreted as representing official policies, either expressed + * or implied, of JogAmp Community. + */ + +package com.jogamp.gluegen.test.junit.generation; + +import com.jogamp.gluegen.test.junit.generation.impl.Bindingtest1p2Impl; +import com.jogamp.common.os.DynamicLibraryBundle; +import com.jogamp.common.os.DynamicLibraryBundleInfo; +import com.jogamp.common.os.NativeLibrary; +import com.jogamp.common.util.RunnableExecutor; +import com.jogamp.common.util.TestIOUtil01; + +import java.util.ArrayList; +import java.util.List; + +import org.junit.AfterClass; +import org.junit.Assert; +import org.junit.BeforeClass; +import org.junit.Test; +import org.junit.FixMethodOrder; +import org.junit.runners.MethodSorters; + +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +public class Test1p2DynamicLibraryBundle extends BaseClass { + + static DynamicLibraryBundle dlb; + + /** + * Verifies loading of the new library. + */ + @BeforeClass + public static void chapter__TestLoadLibrary() throws Exception { + dlb = new DynamicLibraryBundle(new Test1DynLibBundleInfo()); + Assert.assertTrue("DynamicLibraryBundle failed", dlb.isLibComplete()); + + Bindingtest1p2Impl.resetProcAddressTable(dlb); + } + + /** + * Verifies the existence and creation of the generated class. + */ + @Test + public void chapter00TestClassExist() throws Exception { + testClassExist("test1p2"); + } + + /** + * Verifies if all generated method signatures are completed, + * ie a compilation only coverage test without functional tests. + */ + public void chapter__TestCoverageSignature() throws Exception { + chapter__TestCoverageSignature(new Bindingtest1p2Impl()); + } + + /** + * Verifies if all generated static constant values are completed, + * and whether their value is as expected! + * <p> + * Covers all enumerates and defines. + * </p> + */ + @Test + public void chapter01TestStaticConstants() throws Exception { + chapter01TestStaticConstants(new Bindingtest1p2Impl()); + } + + /** + * Verifies if all methods / signatures are properly generated, + * can be invoked and functions. + * This is a compilation (coverage) and runtime time (semantic) test. + * This covers indirect primitive arrays and direct NIO buffers. + */ + @Test + public void chapter03aTestCoverageFunctionalityDirectNIOAndPrimitiveArray() throws Exception { + chapter03TestCoverageFunctionalityNIOAndPrimitiveArray(new Bindingtest1p2Impl(), true); + } + + /** + * Verifies if all methods / signatures are properly generated, + * can be invoked and functions. + * This is a compilation (coverage) and runtime time (semantic) test. + * This covers indirect primitive arrays and indirect NIO buffers (nio using arrays). + */ + @Test + public void chapter03bTestCoverageFunctionalityIndirectNIOAndPrimitiveArray() throws Exception { + chapter03TestCoverageFunctionalityNIOAndPrimitiveArray(new Bindingtest1p2Impl(), false); + } + + /** + * This covers direct / indirect pointer buffers + */ + @Test + public void chapter04TestPointerBuffer() throws Exception { + this.chapter04TestPointerBuffer(new Bindingtest1p2Impl()); + } + + /** + * This covers indirect primitive arrays and indirect NIO buffers. + */ + @Test + public void chapter05TestSomeFunctionsAllIndirect() throws Exception { + chapter05TestSomeFunctionsAllIndirect(new Bindingtest1p2Impl()); + } + + /** + * This covers compounds (structs) data alignment + */ + @Test + public void chapter09TestCompoundAlignment() throws Exception { + chapter09TestCompoundAlignment(new Bindingtest1p2Impl()); + } + + /** + * This covers compounds (structs) call-by-reference + */ + @Test + public void chapter10TestCompoundCallByReference() throws Exception { + chapter10TestCompoundCallByReference(new Bindingtest1p2Impl()); + } + + /** + * This covers compounds (structs) call-by-value + */ + @Test + public void chapter11TestCompoundCallByValue() throws Exception { + chapter11TestCompoundCallByValue(new Bindingtest1p2Impl()); + } + + /** + * Test compound access read-only + */ + @Test + public void chapter12TestStructArrayModelConst() throws Exception { + chapter12TestStructArrayModelConst(new Bindingtest1p2Impl()); + } + + /** + * Test compound access read-write + */ + @Test + public void chapter13TestStructArrayModelMutable() throws Exception { + chapter13TestStructArrayModelMutable(new Bindingtest1p2Impl()); + } + + /** + * Verifies unloading of the new library. + */ + @AfterClass + public static void chapter0XTestUnloadLibrary() throws Exception { + Assert.assertNotNull(dlb); + dlb.destroy(); + dlb = null; + } + + @SuppressWarnings("unused") + public static void main(final String args[]) throws Exception { + if( false ) { + chapter__TestLoadLibrary(); + final Test1p2DynamicLibraryBundle tst = new Test1p2DynamicLibraryBundle(); + tst.chapter00TestClassExist(); + } else { + final String tstname = Test1p2DynamicLibraryBundle.class.getName(); + org.junit.runner.JUnitCore.main(tstname); + } + } + + public static class Test1DynLibBundleInfo implements DynamicLibraryBundleInfo { + private static final List<String> glueLibNames; + static { + glueLibNames = new ArrayList<String>(); + glueLibNames.add("Bindingtest1p2"); + } + + protected Test1DynLibBundleInfo() { + } + + /** + * <p> + * Returns <code>true</code>, + * since we might load the library and allow symbol access to subsequent libs. + * </p> + */ + @Override + public final boolean shallLinkGlobal() { return true; } + + /** + * {@inheritDoc} + * <p> + * Returns <code>false</code>. + * </p> + */ + @Override + public final boolean shallLookupGlobal() { return false; } + + @Override + public final List<String> getGlueLibNames() { + return glueLibNames; + } + + @Override + public final boolean searchToolLibInSystemPath() { + return true; + } + + @Override + public final boolean searchToolLibSystemPathFirst() { + return true; + } + + @Override + public final List<List<String>> getToolLibNames() { + final List<List<String>> libNamesList = new ArrayList<List<String>>(); + + final List<String> libNames = new ArrayList<String>(); + { + // this is the default AL lib name, according to the spec + // libNames.add("libtest1.so"); // unix + libNames.add("test1"); // windows, OSX + } + libNamesList.add(libNames); + + return libNamesList; + } + + @Override + public final List<String> getToolGetProcAddressFuncNameList() { + return null; + } + + @Override + public final long toolGetProcAddress(final long toolGetProcAddressHandle, final String funcName) { + return 0; + } + + @Override + public final boolean useToolGetProcAdressFirst(final String funcName) { + return false; + } + + @Override + public final RunnableExecutor getLibLoaderExecutor() { + return DynamicLibraryBundle.getDefaultRunnableExecutor(); + } + } + +} |