diff options
author | Mathieu Féry <[email protected]> | 2023-08-04 19:37:14 +0200 |
---|---|---|
committer | Mathieu Féry <[email protected]> | 2023-08-04 19:37:48 +0200 |
commit | 2abb40b0ca9a6a06bdbe3e66b4235301ed15c693 (patch) | |
tree | 2d95e75c5d670712aa9551eeabba93be44213ad5 /src/junit | |
parent | 9b0335ea91c39469b586b4005dfae35d4b2cc84b (diff) |
wip(test_case): Example of test case for issue related of 927bbc7160a812bb29c0e7120d4a3009bfb13bbf
Almost done
Diffstat (limited to 'src/junit')
14 files changed, 650 insertions, 193 deletions
diff --git a/src/junit/com/jogamp/gluegen/test/junit/generation/Test2FuncPtr.java b/src/junit/com/jogamp/gluegen/test/junit/generation/BaseTest2FuncPtr.java index 915b3eb..595ecbc 100644 --- a/src/junit/com/jogamp/gluegen/test/junit/generation/Test2FuncPtr.java +++ b/src/junit/com/jogamp/gluegen/test/junit/generation/BaseTest2FuncPtr.java @@ -28,56 +28,17 @@ package com.jogamp.gluegen.test.junit.generation; -import java.io.IOException; - -import com.jogamp.gluegen.test.junit.generation.impl.Bindingtest2Impl; -import com.jogamp.common.os.NativeLibrary; - -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; /** * Test {@link Bindingtest2} with {@link T2_InitializeOptions} instance and function pointer... */ -@FixMethodOrder(MethodSorters.NAME_ASCENDING) -public class Test2FuncPtr extends BaseClass { - - static NativeLibrary dynamicLookupHelper; - - /** - * Verifies loading of the new library. - */ - @BeforeClass - public static void chapter__TestLoadLibrary() throws Exception { - BindingJNILibLoader.loadBindingtest2(); - dynamicLookupHelper = NativeLibrary.open("test2", false, false, Test2FuncPtr.class.getClassLoader(), true); - Assert.assertNotNull("NativeLibrary.open(test2) failed", dynamicLookupHelper); - - Bindingtest2Impl.resetProcAddressTable(dynamicLookupHelper); - } - - /** - * Verifies unloading of the new library. - */ - @AfterClass - public static void chapter0XTestUnloadLibrary() throws Exception { - Assert.assertNotNull(dynamicLookupHelper); - dynamicLookupHelper.close(); - dynamicLookupHelper = null; - } +public class BaseTest2FuncPtr extends BaseClass { /** * Test Bindingtest2 with T2_InitializeOptions instance and function pointer */ - @Test - public void chapter01() throws Exception { - final Bindingtest2 bt2 = new Bindingtest2Impl(); - + public void chapter01(final Bindingtest2 bt2) throws Exception { final T2_InitializeOptions options = T2_InitializeOptions.create(); Assert.assertEquals(true, options.isOverrideThreadAffinityNull()); Assert.assertEquals(true, options.isProductNameNull()); @@ -162,8 +123,4 @@ public class Test2FuncPtr extends BaseClass { Assert.assertEquals(0, options.getCustomFuncB2()); } - public static void main(final String args[]) throws IOException { - final String tstname = Test2FuncPtr.class.getName(); - org.junit.runner.JUnitCore.main(tstname); - } } diff --git a/src/junit/com/jogamp/gluegen/test/junit/generation/Test3PtrStorage.java b/src/junit/com/jogamp/gluegen/test/junit/generation/BaseTest3PtrStorage.java index 2bf82a8..f255c31 100644 --- a/src/junit/com/jogamp/gluegen/test/junit/generation/Test3PtrStorage.java +++ b/src/junit/com/jogamp/gluegen/test/junit/generation/BaseTest3PtrStorage.java @@ -28,61 +28,24 @@ package com.jogamp.gluegen.test.junit.generation; -import java.io.IOException; import java.nio.IntBuffer; import com.jogamp.common.nio.Buffers; import com.jogamp.common.nio.ElementBuffer; -import com.jogamp.common.os.NativeLibrary; -import com.jogamp.gluegen.test.junit.generation.impl.Bindingtest2Impl; -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; /** * Test {@link Bindingtest2} with {@link T2_PointerStorage} instance and pointer pointer.. */ -@FixMethodOrder(MethodSorters.NAME_ASCENDING) -public class Test3PtrStorage extends BaseClass { - - static NativeLibrary dynamicLookupHelper; - - /** - * Verifies loading of the new library. - */ - @BeforeClass - public static void chapter__TestLoadLibrary() throws Exception { - BindingJNILibLoader.loadBindingtest2(); - dynamicLookupHelper = NativeLibrary.open("test2", false, false, Test2FuncPtr.class.getClassLoader(), true); - Assert.assertNotNull("NativeLibrary.open(test2) failed", dynamicLookupHelper); - - Bindingtest2Impl.resetProcAddressTable(dynamicLookupHelper); - } - - /** - * Verifies unloading of the new library. - */ - @AfterClass - public static void chapter0XTestUnloadLibrary() throws Exception { - Assert.assertNotNull(dynamicLookupHelper); - dynamicLookupHelper.close(); - dynamicLookupHelper = null; - } - +public class BaseTest3PtrStorage extends BaseClass { /** * Test {@link Bindingtest2} with {@link T2_PointerStorage} instance and pointer pointer */ - @Test - public void chapter01() throws Exception { + public void chapter01(final Bindingtest2 bt2) throws Exception { Assert.assertEquals(false, T2_PointerStorage.usesNativeCode()); - final Bindingtest2 bt2 = new Bindingtest2Impl(); final T2_PointerStorage store = bt2.createT2PointerStorage(); // final T2_PointerStorage store = T2_PointerStorage.create(); final long[] int32PtrArray = store.getInt32PtrArray(0, new long[10], 0, 10); // 0, 1, 2, 3, 4, 5, 6, 7, 8, 9 @@ -132,8 +95,4 @@ public class Test3PtrStorage extends BaseClass { bt2.destroyT2PointerStorage(store); } - public static void main(final String args[]) throws IOException { - final String tstname = Test3PtrStorage.class.getName(); - org.junit.runner.JUnitCore.main(tstname); - } } diff --git a/src/junit/com/jogamp/gluegen/test/junit/generation/Test4JavaCallback.java b/src/junit/com/jogamp/gluegen/test/junit/generation/BaseTest4JavaCallback.java index 92ab2f6..28e31fd 100644 --- a/src/junit/com/jogamp/gluegen/test/junit/generation/Test4JavaCallback.java +++ b/src/junit/com/jogamp/gluegen/test/junit/generation/BaseTest4JavaCallback.java @@ -46,7 +46,6 @@ import com.jogamp.gluegen.test.junit.generation.Bindingtest2.T2_CallbackFunc11; import com.jogamp.gluegen.test.junit.generation.Bindingtest2.T2_CallbackFunc12a; import com.jogamp.gluegen.test.junit.generation.Bindingtest2.T2_CallbackFunc12b; import com.jogamp.gluegen.test.junit.generation.Bindingtest2.T2_CallbackFunc13; -import com.jogamp.gluegen.test.junit.generation.impl.Bindingtest2Impl; import org.junit.AfterClass; import org.junit.Assert; @@ -59,31 +58,7 @@ import org.junit.runners.MethodSorters; /** * Test {@link Bindingtest2} with {@link T2_PointerStorage} instance and pointer pointer.. */ -@FixMethodOrder(MethodSorters.NAME_ASCENDING) -public class Test4JavaCallback extends BaseClass { - static NativeLibrary dynamicLookupHelper; - - /** - * Verifies loading of the new library. - */ - @BeforeClass - public static void chapter__TestLoadLibrary() throws Exception { - BindingJNILibLoader.loadBindingtest2(); - dynamicLookupHelper = NativeLibrary.open("test2", false, false, Test2FuncPtr.class.getClassLoader(), true); - Assert.assertNotNull("NativeLibrary.open(test2) failed", dynamicLookupHelper); - - Bindingtest2Impl.resetProcAddressTable(dynamicLookupHelper); - } - - /** - * Verifies unloading of the new library. - */ - @AfterClass - public static void chapter0XTestUnloadLibrary() throws Exception { - Assert.assertNotNull(dynamicLookupHelper); - dynamicLookupHelper.close(); - dynamicLookupHelper = null; - } +public class BaseTest4JavaCallback extends BaseClass { private static class MyUserParam01 { final long i; @@ -109,10 +84,7 @@ public class Test4JavaCallback extends BaseClass { /** * Test Bindingtest2 with T2_CallbackFunc JavaCallback */ - @Test - public void chapter01() throws Exception { - final Bindingtest2 bt2 = new Bindingtest2Impl(); - + public void chapter01(final Bindingtest2 bt2) throws Exception { final long[] id_res = { -1 }; final String[] msg_res = { null }; final T2_CallbackFunc01 myCallback01 = new T2_CallbackFunc01() { @@ -225,10 +197,7 @@ public class Test4JavaCallback extends BaseClass { * Test Bindingtest2 with ALBUFFERCALLBACKTYPESOFT JavaCallback via alBufferCallback1() * using the default AlBufferCallback1Key class. */ - @Test - public void chapter02() throws Exception { - final Bindingtest2 bt2 = new Bindingtest2Impl(); - + public void chapter02(final Bindingtest2 bt2) throws Exception { final long[] id_res = { -1 }; final ALBUFFERCALLBACKTYPESOFT myCallback01 = new ALBUFFERCALLBACKTYPESOFT() { @Override @@ -477,10 +446,7 @@ public class Test4JavaCallback extends BaseClass { * Test Bindingtest2 with ALBUFFERCALLBACKTYPESOFT JavaCallback via alBufferCallback1() * using our custom CustomAlBufferCallback1Key class. */ - @Test - public void chapter03() throws Exception { - final Bindingtest2 bt2 = new Bindingtest2Impl(); - + public void chapter03(final Bindingtest2 bt2) throws Exception { final long[] id_res = { -1 }; final ALBUFFERCALLBACKTYPESOFT myCallback01 = new ALBUFFERCALLBACKTYPESOFT() { @Override @@ -682,10 +648,7 @@ public class Test4JavaCallback extends BaseClass { * Test in depth lifecycle of Bindingtest2 with ALBUFFERCALLBACKTYPESOFT JavaCallback via alBufferCallback1() * using the default AlBufferCallback1Key class. */ - @Test - public void chapter04() throws Exception { - final Bindingtest2 bt2 = new Bindingtest2Impl(); - + public void chapter04(final Bindingtest2 bt2) throws Exception { final long[] id_res = { -1 }; final ALBUFFERCALLBACKTYPESOFT myCallback01 = new ALBUFFERCALLBACKTYPESOFT() { @Override @@ -938,10 +901,7 @@ public class Test4JavaCallback extends BaseClass { * Test Bindingtest2 with ALEVENTPROCSOFT JavaCallback * on alEventCallback0(..) having the 'Object userParam` as single key. */ - @Test - public void chapter05a() throws Exception { - final Bindingtest2 bt2 = new Bindingtest2Impl(); - + public void chapter05a(final Bindingtest2 bt2) throws Exception { final int[] id_res = { -1 }; final String[] msg_res = { null }; final ALEVENTPROCSOFT myCallback01 = new ALEVENTPROCSOFT() { @@ -1061,10 +1021,7 @@ public class Test4JavaCallback extends BaseClass { * Test Bindingtest2 with ALEVENTPROCSOFT JavaCallback * on alEventCallback0(..) having the 'Object userParam` and `int object` as keys. */ - @Test - public void chapter05b() throws Exception { - final Bindingtest2 bt2 = new Bindingtest2Impl(); - + public void chapter05b(final Bindingtest2 bt2) throws Exception { final int[] id_res = { -1 }; final String[] msg_res = { null }; final ALEVENTPROCSOFT myCallback01 = new ALEVENTPROCSOFT() { @@ -1196,10 +1153,7 @@ public class Test4JavaCallback extends BaseClass { * Test Bindingtest2 with T2_CallbackFunc11 JavaCallback via MessageCallback11a() * using the default MessageCallback11aKey class. */ - @Test - public void chapter11a() throws Exception { - final Bindingtest2 bt2 = new Bindingtest2Impl(); - + public void chapter11a(final Bindingtest2 bt2) throws Exception { final long userParam01Ptr = 0xAFFEBEAFC0FFEEL; final long userParam02Ptr = 0xC0FFEEDEADBEAFL; @@ -1420,10 +1374,7 @@ public class Test4JavaCallback extends BaseClass { * Test Bindingtest2 with T2_CallbackFunc11 JavaCallback via MessageCallback11b() * using the default MessageCallback11bKey class. */ - @Test - public void chapter11b() throws Exception { - final Bindingtest2 bt2 = new Bindingtest2Impl(); - + public void chapter11b(final Bindingtest2 bt2) throws Exception { final long userParam01Ptr = 0xAFFEBEAFC0FFEEL; final long userParam02Ptr = 0xC0FFEEDEADBEAFL; @@ -1617,10 +1568,7 @@ public class Test4JavaCallback extends BaseClass { /** * Test Bindingtest2 with T2_CallbackFunc12a JavaCallback via SetLogCallBack12a() */ - @Test - public void chapter12a() throws Exception { - final Bindingtest2 bt2 = new Bindingtest2Impl(); - + public void chapter12a(final Bindingtest2 bt2) throws Exception { final AtomicReference<T2_Callback12LogMessage> messageExpected = new AtomicReference<>(null); final AtomicReference<String> messageReturned = new AtomicReference<>(null); final T2_CallbackFunc12a logCallBack = new T2_CallbackFunc12a() { @@ -1672,10 +1620,7 @@ public class Test4JavaCallback extends BaseClass { /** * Test Bindingtest2 with T2_CallbackFunc12a JavaCallback via SetLogCallBack12a() */ - @Test - public void chapter12b() throws Exception { - final Bindingtest2 bt2 = new Bindingtest2Impl(); - + public void chapter12b(final Bindingtest2 bt2) throws Exception { final AtomicReference<T2_Callback12LogMessage> expMessage = new AtomicReference<>(null); final AtomicReference<String> hasReturnedMsg = new AtomicReference<>(null); final T2_CallbackFunc12b logCallBack = new T2_CallbackFunc12b() { @@ -1740,10 +1685,7 @@ public class Test4JavaCallback extends BaseClass { /** * Test Bindingtest2 with T2_CallbackFunc13 JavaCallback via MessageCallback13() */ - @Test - public void chapter13() throws Exception { - final Bindingtest2 bt2 = new Bindingtest2Impl(); - + public void chapter13(final Bindingtest2 bt2) throws Exception { // // Key 1 // @@ -1907,8 +1849,4 @@ public class Test4JavaCallback extends BaseClass { static private String toHexString(final int v) { return "0x"+Integer.toHexString(v); } - public static void main(final String args[]) throws IOException { - final String tstname = Test4JavaCallback.class.getName(); - org.junit.runner.JUnitCore.main(tstname); - } } diff --git a/src/junit/com/jogamp/gluegen/test/junit/generation/BindingJNILibLoader.java b/src/junit/com/jogamp/gluegen/test/junit/generation/BindingJNILibLoader.java index 67f4918..8180204 100644 --- a/src/junit/com/jogamp/gluegen/test/junit/generation/BindingJNILibLoader.java +++ b/src/junit/com/jogamp/gluegen/test/junit/generation/BindingJNILibLoader.java @@ -55,11 +55,21 @@ public class BindingJNILibLoader extends JNILibLoaderBase { }); } - public static void loadBindingtest2() { + public static void loadBindingtest2p1() { SecurityUtil.doPrivileged(new PrivilegedAction<Object>() { @Override public Object run() { - loadLibrary("Bindingtest2", null, true, BindingJNILibLoader.class.getClassLoader()); + loadLibrary("Bindingtest2p1", null, true, BindingJNILibLoader.class.getClassLoader()); + return null; + } + }); + } + + public static void loadBindingtest2p2() { + SecurityUtil.doPrivileged(new PrivilegedAction<Object>() { + @Override + public Object run() { + loadLibrary("Bindingtest2p2", null, true, BindingJNILibLoader.class.getClassLoader()); return null; } }); diff --git a/src/junit/com/jogamp/gluegen/test/junit/generation/Test2p1FuncPtr.java b/src/junit/com/jogamp/gluegen/test/junit/generation/Test2p1FuncPtr.java new file mode 100644 index 0000000..82247ce --- /dev/null +++ b/src/junit/com/jogamp/gluegen/test/junit/generation/Test2p1FuncPtr.java @@ -0,0 +1,75 @@ +/** + * Copyright 2023 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.common.os.NativeLibrary; +import com.jogamp.gluegen.test.junit.generation.impl.Bindingtest2p1Impl; +import org.junit.*; +import org.junit.runners.MethodSorters; + +import java.io.IOException; + +/** + * Test {@link Bindingtest2p1} with {@link T2_InitializeOptions} instance and function pointer... + */ +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +public class Test2p1FuncPtr extends BaseTest2FuncPtr { + + static NativeLibrary dynamicLookupHelper; + + /** + * Verifies loading of the new library. + */ + @BeforeClass + public static void chapter__TestLoadLibrary() throws Exception { + BindingJNILibLoader.loadBindingtest2p1(); + dynamicLookupHelper = NativeLibrary.open("test2", false, false, Test2p1FuncPtr.class.getClassLoader(), true); + Assert.assertNotNull("NativeLibrary.open(test2) failed", dynamicLookupHelper); + } + + /** + * Verifies unloading of the new library. + */ + @AfterClass + public static void chapter0XTestUnloadLibrary() throws Exception { + Assert.assertNotNull(dynamicLookupHelper); + dynamicLookupHelper.close(); + dynamicLookupHelper = null; + } + + @Test + public void chapter01() throws Exception { + chapter01(new Bindingtest2p1Impl()); + } + + public static void main(final String args[]) throws IOException { + final String tstname = Test2p1FuncPtr.class.getName(); + org.junit.runner.JUnitCore.main(tstname); + } +} diff --git a/src/junit/com/jogamp/gluegen/test/junit/generation/Test2p2FuncPtr.java b/src/junit/com/jogamp/gluegen/test/junit/generation/Test2p2FuncPtr.java new file mode 100644 index 0000000..6a553d8 --- /dev/null +++ b/src/junit/com/jogamp/gluegen/test/junit/generation/Test2p2FuncPtr.java @@ -0,0 +1,77 @@ +/** + * Copyright 2023 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.common.os.NativeLibrary; +import com.jogamp.gluegen.test.junit.generation.impl.Bindingtest2p2Impl; +import org.junit.*; +import org.junit.runners.MethodSorters; + +import java.io.IOException; + +/** + * Test {@link Bindingtest2p1} with {@link T2_InitializeOptions} instance and function pointer... + */ +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +public class Test2p2FuncPtr extends BaseTest2FuncPtr { + + static NativeLibrary dynamicLookupHelper; + + /** + * Verifies loading of the new library. + */ + @BeforeClass + public static void chapter__TestLoadLibrary() throws Exception { + BindingJNILibLoader.loadBindingtest2p2(); + dynamicLookupHelper = NativeLibrary.open("test2", false, false, Test2p2FuncPtr.class.getClassLoader(), true); + Assert.assertNotNull("NativeLibrary.open(test2) failed", dynamicLookupHelper); + + Bindingtest2p2Impl.resetProcAddressTable(dynamicLookupHelper); + } + + /** + * Verifies unloading of the new library. + */ + @AfterClass + public static void chapter0XTestUnloadLibrary() throws Exception { + Assert.assertNotNull(dynamicLookupHelper); + dynamicLookupHelper.close(); + dynamicLookupHelper = null; + } + + @Test + public void chapter01() throws Exception { + chapter01(new Bindingtest2p2Impl()); + } + + public static void main(final String args[]) throws IOException { + final String tstname = Test2p2FuncPtr.class.getName(); + org.junit.runner.JUnitCore.main(tstname); + } +} diff --git a/src/junit/com/jogamp/gluegen/test/junit/generation/Test3p1PtrStorage.java b/src/junit/com/jogamp/gluegen/test/junit/generation/Test3p1PtrStorage.java new file mode 100644 index 0000000..bbe7986 --- /dev/null +++ b/src/junit/com/jogamp/gluegen/test/junit/generation/Test3p1PtrStorage.java @@ -0,0 +1,75 @@ +/** + * Copyright 2023 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.common.os.NativeLibrary; +import com.jogamp.gluegen.test.junit.generation.impl.Bindingtest2p1Impl; +import org.junit.*; +import org.junit.runners.MethodSorters; + +import java.io.IOException; + +/** + * Test {@link Bindingtest2p1} with {@link T2_PointerStorage} instance and pointer pointer.. + */ +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +public class Test3p1PtrStorage extends BaseTest3PtrStorage { + + static NativeLibrary dynamicLookupHelper; + + /** + * Verifies loading of the new library. + */ + @BeforeClass + public static void chapter__TestLoadLibrary() throws Exception { + BindingJNILibLoader.loadBindingtest2p1(); + dynamicLookupHelper = NativeLibrary.open("test2", false, false, Test3p1PtrStorage.class.getClassLoader(), true); + Assert.assertNotNull("NativeLibrary.open(test2) failed", dynamicLookupHelper); + } + + /** + * Verifies unloading of the new library. + */ + @AfterClass + public static void chapter0XTestUnloadLibrary() throws Exception { + Assert.assertNotNull(dynamicLookupHelper); + dynamicLookupHelper.close(); + dynamicLookupHelper = null; + } + + @Test + public void chapter01() throws Exception { + chapter01(new Bindingtest2p1Impl()); + } + + public static void main(final String args[]) throws IOException { + final String tstname = Test3p1PtrStorage.class.getName(); + org.junit.runner.JUnitCore.main(tstname); + } +} diff --git a/src/junit/com/jogamp/gluegen/test/junit/generation/Test3p2PtrStorage.java b/src/junit/com/jogamp/gluegen/test/junit/generation/Test3p2PtrStorage.java new file mode 100644 index 0000000..cd61d2c --- /dev/null +++ b/src/junit/com/jogamp/gluegen/test/junit/generation/Test3p2PtrStorage.java @@ -0,0 +1,77 @@ +/** + * Copyright 2023 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.common.os.NativeLibrary; +import com.jogamp.gluegen.test.junit.generation.impl.Bindingtest2p2Impl; +import org.junit.*; +import org.junit.runners.MethodSorters; + +import java.io.IOException; + +/** + * Test {@link Bindingtest2p2} with {@link T2_PointerStorage} instance and pointer pointer.. + */ +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +public class Test3p2PtrStorage extends BaseTest3PtrStorage { + + static NativeLibrary dynamicLookupHelper; + + /** + * Verifies loading of the new library. + */ + @BeforeClass + public static void chapter__TestLoadLibrary() throws Exception { + BindingJNILibLoader.loadBindingtest2p2(); + dynamicLookupHelper = NativeLibrary.open("test2", false, false, Test3p2PtrStorage.class.getClassLoader(), true); + Assert.assertNotNull("NativeLibrary.open(test2) failed", dynamicLookupHelper); + + Bindingtest2p2Impl.resetProcAddressTable(dynamicLookupHelper); + } + + /** + * Verifies unloading of the new library. + */ + @AfterClass + public static void chapter0XTestUnloadLibrary() throws Exception { + Assert.assertNotNull(dynamicLookupHelper); + dynamicLookupHelper.close(); + dynamicLookupHelper = null; + } + + @Test + public void chapter01() throws Exception { + chapter01(new Bindingtest2p2Impl()); + } + + public static void main(final String args[]) throws IOException { + final String tstname = Test3p2PtrStorage.class.getName(); + org.junit.runner.JUnitCore.main(tstname); + } +} diff --git a/src/junit/com/jogamp/gluegen/test/junit/generation/Test4p1JavaCallback.java b/src/junit/com/jogamp/gluegen/test/junit/generation/Test4p1JavaCallback.java new file mode 100644 index 0000000..b07faa7 --- /dev/null +++ b/src/junit/com/jogamp/gluegen/test/junit/generation/Test4p1JavaCallback.java @@ -0,0 +1,125 @@ +/** + * Copyright 2023 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.common.os.NativeLibrary; +import com.jogamp.gluegen.test.junit.generation.impl.Bindingtest2p1Impl; +import org.junit.*; +import org.junit.runners.MethodSorters; + +import java.io.IOException; + +/** + * Test {@link Bindingtest2p1} with {@link T2_PointerStorage} instance and pointer pointer.. + */ +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +public class Test4p1JavaCallback extends BaseTest4JavaCallback { + + static NativeLibrary dynamicLookupHelper; + + /** + * Verifies loading of the new library. + */ + @BeforeClass + public static void chapter__TestLoadLibrary() throws Exception { + BindingJNILibLoader.loadBindingtest2p1(); + dynamicLookupHelper = NativeLibrary.open("test2", false, false, Test4p1JavaCallback.class.getClassLoader(), true); + Assert.assertNotNull("NativeLibrary.open(test2) failed", dynamicLookupHelper); + } + + /** + * Verifies unloading of the new library. + */ + @AfterClass + public static void chapter0XTestUnloadLibrary() throws Exception { + Assert.assertNotNull(dynamicLookupHelper); + dynamicLookupHelper.close(); + dynamicLookupHelper = null; + } + + @Test + public void chapter01() throws Exception { + chapter01(new Bindingtest2p1Impl()); + } + + @Test + public void chapter02() throws Exception { + chapter02(new Bindingtest2p1Impl()); + } + + @Test + public void chapter03() throws Exception { + chapter03(new Bindingtest2p1Impl()); + } + + @Test + public void chapter04() throws Exception { + chapter04(new Bindingtest2p1Impl()); + } + + @Test + public void chapter05a() throws Exception { + chapter05a(new Bindingtest2p1Impl()); + } + + @Test + public void chapter05b() throws Exception { + chapter05b(new Bindingtest2p1Impl()); + } + + @Test + public void chapter11a() throws Exception { + chapter11a(new Bindingtest2p1Impl()); + } + + @Test + public void chapter11b() throws Exception { + chapter11b(new Bindingtest2p1Impl()); + } + + @Test + public void chapter12a() throws Exception { + chapter12a(new Bindingtest2p1Impl()); + } + + @Test + public void chapter12b() throws Exception { + chapter12b(new Bindingtest2p1Impl()); + } + + @Test + public void chapter13() throws Exception { + chapter13(new Bindingtest2p1Impl()); + } + + public static void main(final String args[]) throws IOException { + final String tstname = Test4p1JavaCallback.class.getName(); + org.junit.runner.JUnitCore.main(tstname); + } +} diff --git a/src/junit/com/jogamp/gluegen/test/junit/generation/Test4p2JavaCallback.java b/src/junit/com/jogamp/gluegen/test/junit/generation/Test4p2JavaCallback.java new file mode 100644 index 0000000..3f94565 --- /dev/null +++ b/src/junit/com/jogamp/gluegen/test/junit/generation/Test4p2JavaCallback.java @@ -0,0 +1,127 @@ +/** + * Copyright 2023 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.common.os.NativeLibrary; +import com.jogamp.gluegen.test.junit.generation.impl.Bindingtest2p2Impl; +import org.junit.*; +import org.junit.runners.MethodSorters; + +import java.io.IOException; + +/** + * Test {@link Bindingtest2p2} with {@link T2_PointerStorage} instance and pointer pointer.. + */ +@FixMethodOrder(MethodSorters.NAME_ASCENDING) +public class Test4p2JavaCallback extends BaseTest4JavaCallback { + + static NativeLibrary dynamicLookupHelper; + + /** + * Verifies loading of the new library. + */ + @BeforeClass + public static void chapter__TestLoadLibrary() throws Exception { + BindingJNILibLoader.loadBindingtest2p1(); + dynamicLookupHelper = NativeLibrary.open("test2", false, false, Test4p2JavaCallback.class.getClassLoader(), true); + Assert.assertNotNull("NativeLibrary.open(test2) failed", dynamicLookupHelper); + + Bindingtest2p2Impl.resetProcAddressTable(dynamicLookupHelper); + } + + /** + * Verifies unloading of the new library. + */ + @AfterClass + public static void chapter0XTestUnloadLibrary() throws Exception { + Assert.assertNotNull(dynamicLookupHelper); + dynamicLookupHelper.close(); + dynamicLookupHelper = null; + } + + @Test + public void chapter01() throws Exception { + chapter01(new Bindingtest2p2Impl()); + } + + @Test + public void chapter02() throws Exception { + chapter02(new Bindingtest2p2Impl()); + } + + @Test + public void chapter03() throws Exception { + chapter03(new Bindingtest2p2Impl()); + } + + @Test + public void chapter04() throws Exception { + chapter04(new Bindingtest2p2Impl()); + } + + @Test + public void chapter05a() throws Exception { + chapter05a(new Bindingtest2p2Impl()); + } + + @Test + public void chapter05b() throws Exception { + chapter05b(new Bindingtest2p2Impl()); + } + + @Test + public void chapter11a() throws Exception { + chapter11a(new Bindingtest2p2Impl()); + } + + @Test + public void chapter11b() throws Exception { + chapter11b(new Bindingtest2p2Impl()); + } + + @Test + public void chapter12a() throws Exception { + chapter12a(new Bindingtest2p2Impl()); + } + + @Test + public void chapter12b() throws Exception { + chapter12b(new Bindingtest2p2Impl()); + } + + @Test + public void chapter13() throws Exception { + chapter13(new Bindingtest2p2Impl()); + } + + public static void main(final String args[]) throws IOException { + final String tstname = Test4p2JavaCallback.class.getName(); + org.junit.runner.JUnitCore.main(tstname); + } +} diff --git a/src/junit/com/jogamp/gluegen/test/junit/generation/test2.cfg b/src/junit/com/jogamp/gluegen/test/junit/generation/test2-common.cfg index 44b6468..d187577 100644 --- a/src/junit/com/jogamp/gluegen/test/junit/generation/test2.cfg +++ b/src/junit/com/jogamp/gluegen/test/junit/generation/test2-common.cfg @@ -1,24 +1,3 @@ -Package com.jogamp.gluegen.test.junit.generation -JavaClass Bindingtest2 -Style InterfaceAndImpl -JavaOutputDir classes -NativeOutputDir native - -# Use a ProcAddressTable so we dynamically look up the routines -EmitProcAddressTable true -ProcAddressTableClassName Bindingtest2ProcAddressTable -GetProcAddressTableExpr _table -ProcAddressNameExpr PFN $UPPERCASE({0}) PROC - -# Force all of the methods to be emitted using dynamic linking so we -# don't need to link against any emulation library on the desktop or -# depend on the presence of an import library for a particular device -ForceProcAddressGen __ALL__ - -# Also force the calling conventions of the locally generated function -# pointer typedefs for these routines to MYAPIENTRY -# LocalProcAddressCallingConvention __ALL__ MYAPIENTRY - # Opaque long void* # Undefined struct forward declaration, implementation secret: 'struct T2_UndefStruct;' @@ -127,7 +106,7 @@ JavaCallbackKey alBufferCallback0 0 ALBUFFERCALLBACKTYPESOFT 0 # - `boolean isAlBufferCallback1Mapped(int buffer)` queries whether `alBufferCallback1` is mapped to `buffer`. # - `ALBUFFERCALLBACKTYPESOFT getAlBufferCallback1(int buffer)` returns the `buffer` mapped ALEVENTPROCSOFT, null if not mapped # - `ALCcontext getAlBufferCallback1UserParam(int buffer)` returns the `buffer` mapped `userptr` object, null if not mapped -JavaCallbackDef alBufferCallback1 0 ALBUFFERCALLBACKTYPESOFT 1 ALCcontext com.jogamp.gluegen.test.junit.generation.Test4JavaCallback.CustomAlBufferCallback1Key +JavaCallbackDef alBufferCallback1 0 ALBUFFERCALLBACKTYPESOFT 1 ALCcontext com.jogamp.gluegen.test.junit.generation.BaseTest4JavaCallback.CustomAlBufferCallback1Key JavaCallbackKey alBufferCallback1 1 ALBUFFERCALLBACKTYPESOFT 0 # # End JavaCallback @@ -168,7 +147,7 @@ IncludeAs CustomJavaCode Bindingtest2Impl test2-CustomJavaImplCode.java.stub # typedef void ( * T2_CallbackFunc11)(size_t id, const T2_Callback11UserType* usrParam); # void MessageCallback11a(size_t id /* key */, T2_CallbackFunc11 cbFunc, const T2_Callback11UserType* usrParam); # void MessageCallback11aInject(size_t id); -#JavaCallbackDef MessageCallback11a T2_CallbackFunc11 1 Object com.jogamp.gluegen.test.junit.generation.Test4JavaCallback.CustomMessageCallback11Key +#JavaCallbackDef MessageCallback11a T2_CallbackFunc11 1 Object com.jogamp.gluegen.test.junit.generation.BaseTest4JavaCallback.CustomMessageCallback11Key JavaCallbackDef MessageCallback11a 2 T2_CallbackFunc11 1 JavaCallbackKey MessageCallback11a 0 T2_CallbackFunc11 0 # @@ -227,10 +206,5 @@ Import com.jogamp.gluegen.test.junit.generation.T2_Callback11UserType Import com.jogamp.gluegen.test.junit.generation.T2_Callback12LogMessage Import com.jogamp.gluegen.test.junit.generation.T2_Callback13UserType Import com.jogamp.gluegen.test.junit.generation.T2_Callback13UserKey1 -Import com.jogamp.gluegen.test.junit.generation.Test4JavaCallback.ALCcontext - -CustomJavaCode Bindingtest2Impl private static Bindingtest2ProcAddressTable _table = new Bindingtest2ProcAddressTable(); -CustomJavaCode Bindingtest2Impl public static void resetProcAddressTable(DynamicLookupHelper lookup) { -CustomJavaCode Bindingtest2Impl _table.reset(lookup); -CustomJavaCode Bindingtest2Impl } +Import com.jogamp.gluegen.test.junit.generation.BaseTest4JavaCallback.ALCcontext diff --git a/src/junit/com/jogamp/gluegen/test/junit/generation/test2-gluegen.cfg b/src/junit/com/jogamp/gluegen/test/junit/generation/test2-gluegen.cfg new file mode 100644 index 0000000..6531a7b --- /dev/null +++ b/src/junit/com/jogamp/gluegen/test/junit/generation/test2-gluegen.cfg @@ -0,0 +1,11 @@ +Package com.jogamp.gluegen.test.junit.generation +Style AllStatic +JavaClass Bindingtest2 +Style InterfaceOnly +JavaOutputDir classes +NativeOutputDir native + +Include test2-common.cfg + + + diff --git a/src/junit/com/jogamp/gluegen/test/junit/generation/test2p1.cfg b/src/junit/com/jogamp/gluegen/test/junit/generation/test2p1.cfg new file mode 100644 index 0000000..58dc44e --- /dev/null +++ b/src/junit/com/jogamp/gluegen/test/junit/generation/test2p1.cfg @@ -0,0 +1,16 @@ +Package com.jogamp.gluegen.test.junit.generation +JavaClass Bindingtest2p1 +Style InterfaceAndImpl +JavaOutputDir classes +NativeOutputDir native + +Extends Bindingtest2p1 Bindingtest2 + +ExtendedInterfaceSymbolsIgnore ../build-temp/gensrc/classes/com/jogamp/gluegen/test/junit/generation/Bindingtest2.java + +Include test2-common.cfg + +Import com.jogamp.gluegen.test.junit.generation.Bindingtest2 +Import com.jogamp.gluegen.test.junit.generation.Bindingtest2p1 + + diff --git a/src/junit/com/jogamp/gluegen/test/junit/generation/test2p2.cfg b/src/junit/com/jogamp/gluegen/test/junit/generation/test2p2.cfg new file mode 100644 index 0000000..4aecb5f --- /dev/null +++ b/src/junit/com/jogamp/gluegen/test/junit/generation/test2p2.cfg @@ -0,0 +1,36 @@ +Package com.jogamp.gluegen.test.junit.generation +JavaClass Bindingtest2p2 +Style InterfaceAndImpl +JavaOutputDir classes +NativeOutputDir native + +Extends Bindingtest2p2 Bindingtest2 + +ExtendedInterfaceSymbolsIgnore ../build-temp/gensrc/classes/com/jogamp/gluegen/test/junit/generation/Bindingtest2.java + +# Use a ProcAddressTable so we dynamically look up the routines +EmitProcAddressTable true +ProcAddressTableClassName Bindingtest2p2ProcAddressTable +GetProcAddressTableExpr _table +ProcAddressNameExpr PFN $UPPERCASE({0}) PROC + +# Force all of the methods to be emitted using dynamic linking so we +# don't need to link against any emulation library on the desktop or +# depend on the presence of an import library for a particular device +ForceProcAddressGen __ALL__ + +# Also force the calling conventions of the locally generated function +# pointer typedefs for these routines to MYAPIENTRY +# LocalProcAddressCallingConvention __ALL__ MYAPIENTRY + +Include test2-common.cfg + +Import com.jogamp.gluegen.test.junit.generation.Bindingtest2 +Import com.jogamp.gluegen.test.junit.generation.Bindingtest2p2 + +CustomJavaCode Bindingtest2p2Impl private static Bindingtest2p2ProcAddressTable _table = new Bindingtest2p2ProcAddressTable(); +CustomJavaCode Bindingtest2p2Impl public static void resetProcAddressTable(DynamicLookupHelper lookup) { +CustomJavaCode Bindingtest2Ip2mpl _table.reset(lookup); +CustomJavaCode Bindingtest2p2Impl } + + |