< prev index next >
test/jdk/com/sun/tools/jextract/JextractToolProviderTest.java
Print this page
*** 21,38 ****
--- 21,40 ----
* questions.
*/
import org.testng.annotations.Test;
+ import java.lang.reflect.Field;
import java.lang.reflect.Method;
import java.foreign.annotations.NativeHeader;
import java.foreign.annotations.NativeLocation;
import java.foreign.memory.Pointer;
import java.nio.file.Files;
import java.nio.file.Path;
import java.util.Arrays;
import java.util.List;
+ import java.util.stream.Stream;
import static org.testng.Assert.assertEquals;
import static org.testng.Assert.assertFalse;
import static org.testng.Assert.assertNotNull;
import static org.testng.Assert.assertNull;
*** 45,73 ****
* @run testng/othervm -Duser.language=en JextractToolProviderTest
*/
public class JextractToolProviderTest extends JextractToolRunner {
@Test
public void testHelp() {
! checkFailure(null); // no options
! checkSuccess(null, "--help");
! checkSuccess(null, "-h");
! checkSuccess(null, "-?");
}
// error for non-existent header file
@Test
public void testNonExistentHeader() {
! checkFailure("Cannot open header file", "--dry-run",
! getInputFilePath("non_existent.h").toString());
}
@Test
public void testDryRun() {
// only dry-run, don't produce any output
Path simpleJar = getOutputFilePath("simple.jar");
deleteFile(simpleJar);
! checkSuccess(null, "--dry-run", getInputFilePath("simple.h").toString());
try {
assertFalse(Files.isRegularFile(simpleJar));
} finally {
deleteFile(simpleJar);
}
--- 47,76 ----
* @run testng/othervm -Duser.language=en JextractToolProviderTest
*/
public class JextractToolProviderTest extends JextractToolRunner {
@Test
public void testHelp() {
! run().checkFailure(); // no options
! run("--help").checkSuccess();
! run("-h").checkSuccess();
! run("-?").checkSuccess();
}
// error for non-existent header file
@Test
public void testNonExistentHeader() {
! run("--dry-run", getInputFilePath("non_existent.h").toString())
! .checkFailure()
! .checkContainsOutput("Cannot open header file");
}
@Test
public void testDryRun() {
// only dry-run, don't produce any output
Path simpleJar = getOutputFilePath("simple.jar");
deleteFile(simpleJar);
! run("--dry-run", getInputFilePath("simple.h").toString()).checkSuccess();
try {
assertFalse(Files.isRegularFile(simpleJar));
} finally {
deleteFile(simpleJar);
}
*** 76,87 ****
@Test
public void testOutputFileOption() {
// simple output file check
Path simpleJar = getOutputFilePath("simple.jar");
deleteFile(simpleJar);
! checkSuccess(null, "-o", simpleJar.toString(),
! getInputFilePath("simple.h").toString());
try {
assertTrue(Files.isRegularFile(simpleJar));
} finally {
deleteFile(simpleJar);
}
--- 79,90 ----
@Test
public void testOutputFileOption() {
// simple output file check
Path simpleJar = getOutputFilePath("simple.jar");
deleteFile(simpleJar);
! run("-o", simpleJar.toString(),
! getInputFilePath("simple.h").toString()).checkSuccess();
try {
assertTrue(Files.isRegularFile(simpleJar));
} finally {
deleteFile(simpleJar);
}
*** 90,100 ****
@Test
public void testOutputClass() {
Path helloJar = getOutputFilePath("hello.jar");
deleteFile(helloJar);
Path helloH = getInputFilePath("hello.h");
! checkSuccess(null, "-o", helloJar.toString(), helloH.toString());
try {
Class<?> cls = loadClass("hello", helloJar);
// check NativeHeader annotation
NativeHeader header = cls.getAnnotation(NativeHeader.class);
assertNotNull(header);
--- 93,103 ----
@Test
public void testOutputClass() {
Path helloJar = getOutputFilePath("hello.jar");
deleteFile(helloJar);
Path helloH = getInputFilePath("hello.h");
! run("-o", helloJar.toString(), helloH.toString()).checkSuccess();
try {
Class<?> cls = loadClass("hello", helloJar);
// check NativeHeader annotation
NativeHeader header = cls.getAnnotation(NativeHeader.class);
assertNotNull(header);
*** 110,120 ****
private void testTargetPackage(String targetPkgOption) {
Path helloJar = getOutputFilePath("hello.jar");
deleteFile(helloJar);
Path helloH = getInputFilePath("hello.h");
! checkSuccess(null, targetPkgOption, "com.acme", "-o", helloJar.toString(), helloH.toString());
try {
Class<?> cls = loadClass("com.acme.hello", helloJar);
// check NativeHeader annotation
NativeHeader header = cls.getAnnotation(NativeHeader.class);
assertNotNull(header);
--- 113,123 ----
private void testTargetPackage(String targetPkgOption) {
Path helloJar = getOutputFilePath("hello.jar");
deleteFile(helloJar);
Path helloH = getInputFilePath("hello.h");
! run(targetPkgOption, "com.acme", "-o", helloJar.toString(), helloH.toString()).checkSuccess();
try {
Class<?> cls = loadClass("com.acme.hello", helloJar);
// check NativeHeader annotation
NativeHeader header = cls.getAnnotation(NativeHeader.class);
assertNotNull(header);
*** 138,166 ****
}
private void testPackageMapping(String pkgMapOption) {
Path worldJar = getOutputFilePath("world.jar");
deleteFile(worldJar);
- Path mytypesJar = getOutputFilePath("mytypes.jar");
- deleteFile(mytypesJar);
-
Path worldH = getInputFilePath("world.h");
Path include = getInputFilePath("include");
- // generate jar for mytypes.h
- checkSuccess(null, "-t", "com.acme", "-o", mytypesJar.toString(),
- include.resolve("mytypes.h").toString());
// world.h include mytypes.h, use appropriate package for stuff from mytypes.h
! checkSuccess(null, "-I", include.toString(), pkgMapOption, include.toString() + "=com.acme",
! "-o", worldJar.toString(), worldH.toString());
try {
! Class<?> cls = loadClass("world", worldJar, mytypesJar);
Method m = findFirstMethod(cls, "distance");
Class<?>[] params = m.getParameterTypes();
assertEquals(params[0].getName(), "com.acme.mytypes$Point");
} finally {
deleteFile(worldJar);
- deleteFile(mytypesJar);
}
}
@Test
public void testPackageDirMappingOption() {
--- 141,162 ----
}
private void testPackageMapping(String pkgMapOption) {
Path worldJar = getOutputFilePath("world.jar");
deleteFile(worldJar);
Path worldH = getInputFilePath("world.h");
Path include = getInputFilePath("include");
// world.h include mytypes.h, use appropriate package for stuff from mytypes.h
! run("-I", include.toString(), pkgMapOption, include.toString() + "=com.acme",
! "-o", worldJar.toString(), worldH.toString()).checkSuccess();
try {
! Class<?> cls = loadClass("world", worldJar);
Method m = findFirstMethod(cls, "distance");
Class<?>[] params = m.getParameterTypes();
assertEquals(params[0].getName(), "com.acme.mytypes$Point");
} finally {
deleteFile(worldJar);
}
}
@Test
public void testPackageDirMappingOption() {
*** 172,204 ****
testPackageMapping("--package-map");
}
@Test
public void test_no_input_files() {
! String err = "No input files";
! checkFailure(err, "-L", "foo");
}
@Test
public void test_option_L_without_l() {
Path helloJar = getOutputFilePath("hello.jar");
deleteFile(helloJar);
Path helloH = getInputFilePath("hello.h");
Path linkDir = getInputFilePath("libs");
String warning = "WARNING: -L option specified without any -l option";
! checkSuccess(warning, "-L", linkDir.toString(), "-o", helloJar.toString(), helloH.toString());
}
@Test
public void test_option_rpath_without_l() {
Path helloJar = getOutputFilePath("hello.jar");
deleteFile(helloJar);
Path helloH = getInputFilePath("hello.h");
Path rpathDir = getInputFilePath("libs");
String warning = "WARNING: -rpath option specified without any -l option";
try {
! checkSuccess(warning, "-rpath", rpathDir.toString(), "-o", helloJar.toString(), helloH.toString());
} finally {
deleteFile(helloJar);
}
}
--- 168,205 ----
testPackageMapping("--package-map");
}
@Test
public void test_no_input_files() {
! run("-L", "foo")
! .checkContainsOutput("No input files")
! .checkFailure();
}
@Test
public void test_option_L_without_l() {
Path helloJar = getOutputFilePath("hello.jar");
deleteFile(helloJar);
Path helloH = getInputFilePath("hello.h");
Path linkDir = getInputFilePath("libs");
String warning = "WARNING: -L option specified without any -l option";
! run("-L", linkDir.toString(), "-o", helloJar.toString(), helloH.toString())
! .checkContainsOutput(warning)
! .checkSuccess();
}
@Test
public void test_option_rpath_without_l() {
Path helloJar = getOutputFilePath("hello.jar");
deleteFile(helloJar);
Path helloH = getInputFilePath("hello.h");
Path rpathDir = getInputFilePath("libs");
String warning = "WARNING: -rpath option specified without any -l option";
try {
! run("-rpath", rpathDir.toString(), "-o", helloJar.toString(), helloH.toString())
! .checkContainsOutput(warning)
! .checkSuccess();
} finally {
deleteFile(helloJar);
}
}
*** 208,220 ****
deleteFile(helloJar);
Path helloH = getInputFilePath("hello.h");
Path rpathDir = getInputFilePath("libs");
String warning = "WARNING: -infer-rpath used in conjunction with explicit -rpath paths";
try {
! checkSuccess(warning, "-rpath", rpathDir.toString(),
"-infer-rpath",
! "-o", helloJar.toString(), helloH.toString());
} finally {
deleteFile(helloJar);
}
}
--- 209,223 ----
deleteFile(helloJar);
Path helloH = getInputFilePath("hello.h");
Path rpathDir = getInputFilePath("libs");
String warning = "WARNING: -infer-rpath used in conjunction with explicit -rpath paths";
try {
! run("-rpath", rpathDir.toString(),
"-infer-rpath",
! "-o", helloJar.toString(), helloH.toString())
! .checkContainsOutput(warning)
! .checkSuccess();
} finally {
deleteFile(helloJar);
}
}
*** 223,235 ****
Path helloJar = getOutputFilePath("hello.jar");
deleteFile(helloJar);
Path helloH = getInputFilePath("hello.h");
String warning = "WARNING: -infer-rpath option specified without any -L option";
try {
! checkSuccess(warning,
! "-infer-rpath",
! "-o", helloJar.toString(), helloH.toString());
} finally {
deleteFile(helloJar);
}
}
--- 226,239 ----
Path helloJar = getOutputFilePath("hello.jar");
deleteFile(helloJar);
Path helloH = getInputFilePath("hello.h");
String warning = "WARNING: -infer-rpath option specified without any -L option";
try {
! run("-infer-rpath",
! "-o", helloJar.toString(), helloH.toString())
! .checkContainsOutput(warning)
! .checkSuccess();
} finally {
deleteFile(helloJar);
}
}
*** 238,262 ****
Path helloJar = getOutputFilePath("hello.jar");
deleteFile(helloJar);
Path helloH = getInputFilePath("hello.h");
String warning = "WARNING: Some library names could not be resolved";
try {
! checkSuccess(warning,
! "-L", "nonExistent",
"-l", "nonExistent",
! "-o", helloJar.toString(), helloH.toString());
} finally {
deleteFile(helloJar);
}
}
@Test
public void test_option_l() {
Path helloJar = getOutputFilePath("hello.jar");
deleteFile(helloJar);
Path helloH = getInputFilePath("hello.h");
! checkSuccess(null, "-l", "hello", "-o", helloJar.toString(), helloH.toString());
try {
Class<?> cls = loadClass("hello", helloJar);
// check that NativeHeader annotation captures -l value
NativeHeader header = cls.getAnnotation(NativeHeader.class);
assertNotNull(header);
--- 242,267 ----
Path helloJar = getOutputFilePath("hello.jar");
deleteFile(helloJar);
Path helloH = getInputFilePath("hello.h");
String warning = "WARNING: Some library names could not be resolved";
try {
! run("-L", "nonExistent",
"-l", "nonExistent",
! "-o", helloJar.toString(), helloH.toString())
! .checkContainsOutput(warning)
! .checkSuccess();
} finally {
deleteFile(helloJar);
}
}
@Test
public void test_option_l() {
Path helloJar = getOutputFilePath("hello.jar");
deleteFile(helloJar);
Path helloH = getInputFilePath("hello.h");
! run("-l", "hello", "-o", helloJar.toString(), helloH.toString()).checkSuccess();
try {
Class<?> cls = loadClass("hello", helloJar);
// check that NativeHeader annotation captures -l value
NativeHeader header = cls.getAnnotation(NativeHeader.class);
assertNotNull(header);
*** 273,284 ****
public void test_option_l_and_rpath() {
Path helloJar = getOutputFilePath("hello.jar");
deleteFile(helloJar);
Path helloH = getInputFilePath("hello.h");
Path rpathDir = getInputFilePath("libs");
! checkSuccess(null, "-l", "hello", "-rpath", rpathDir.toString(),
! "-o", helloJar.toString(), helloH.toString());
try {
Class<?> cls = loadClass("hello", helloJar);
// check that NativeHeader annotation captures -l and -rpath values
NativeHeader header = cls.getAnnotation(NativeHeader.class);
assertNotNull(header);
--- 278,289 ----
public void test_option_l_and_rpath() {
Path helloJar = getOutputFilePath("hello.jar");
deleteFile(helloJar);
Path helloH = getInputFilePath("hello.h");
Path rpathDir = getInputFilePath("libs");
! run("-l", "hello", "-rpath", rpathDir.toString(),
! "-o", helloJar.toString(), helloH.toString()).checkSuccess();
try {
Class<?> cls = loadClass("hello", helloJar);
// check that NativeHeader annotation captures -l and -rpath values
NativeHeader header = cls.getAnnotation(NativeHeader.class);
assertNotNull(header);
*** 295,305 ****
public void testUnionDeclaration() {
Path uniondeclJar = getOutputFilePath("uniondecl.jar");
deleteFile(uniondeclJar);
Path uniondeclH = getInputFilePath("uniondecl.h");
try {
! checkSuccess(null, "-o", uniondeclJar.toString(), uniondeclH.toString());
Class<?> unionCls = loadClass("uniondecl", uniondeclJar);
assertNotNull(unionCls);
boolean found = Arrays.stream(unionCls.getClasses()).
map(Class::getSimpleName).
filter(n -> n.equals("IntOrFloat")).
--- 300,310 ----
public void testUnionDeclaration() {
Path uniondeclJar = getOutputFilePath("uniondecl.jar");
deleteFile(uniondeclJar);
Path uniondeclH = getInputFilePath("uniondecl.h");
try {
! run("-o", uniondeclJar.toString(), uniondeclH.toString()).checkSuccess();
Class<?> unionCls = loadClass("uniondecl", uniondeclJar);
assertNotNull(unionCls);
boolean found = Arrays.stream(unionCls.getClasses()).
map(Class::getSimpleName).
filter(n -> n.equals("IntOrFloat")).
*** 322,332 ****
public void testAnonymousEnum() {
Path anonenumJar = getOutputFilePath("anonenum.jar");
deleteFile(anonenumJar);
Path anonenumH = getInputFilePath("anonenum.h");
try {
! checkSuccess(null, "-o", anonenumJar.toString(), anonenumH.toString());
Class<?> anonenumCls = loadClass("anonenum", anonenumJar);
assertNotNull(anonenumCls);
testEnumConstGetters(anonenumCls, List.of("RED", "GREEN", "BLUE"));
testEnumConstGetters(anonenumCls, List.of(
"Java", "C", "CPP", "Python", "Ruby"));
--- 327,337 ----
public void testAnonymousEnum() {
Path anonenumJar = getOutputFilePath("anonenum.jar");
deleteFile(anonenumJar);
Path anonenumH = getInputFilePath("anonenum.h");
try {
! run("-o", anonenumJar.toString(), anonenumH.toString()).checkSuccess();
Class<?> anonenumCls = loadClass("anonenum", anonenumJar);
assertNotNull(anonenumCls);
testEnumConstGetters(anonenumCls, List.of("RED", "GREEN", "BLUE"));
testEnumConstGetters(anonenumCls, List.of(
"Java", "C", "CPP", "Python", "Ruby"));
*** 357,367 ****
@Test
public void testExcludeSymbols() {
Path helloJar = getOutputFilePath("hello.jar");
deleteFile(helloJar);
Path helloH = getInputFilePath("hello.h");
! checkSuccess(null, "-o", helloJar.toString(), helloH.toString());
try {
Class<?> cls = loadClass("hello", helloJar);
// check a method for "void func()"
assertNotNull(findMethod(cls, "func", Object[].class));
assertNotNull(findMethod(cls, "func2", Object[].class));
--- 362,372 ----
@Test
public void testExcludeSymbols() {
Path helloJar = getOutputFilePath("hello.jar");
deleteFile(helloJar);
Path helloH = getInputFilePath("hello.h");
! run("-o", helloJar.toString(), helloH.toString()).checkSuccess();
try {
Class<?> cls = loadClass("hello", helloJar);
// check a method for "void func()"
assertNotNull(findMethod(cls, "func", Object[].class));
assertNotNull(findMethod(cls, "func2", Object[].class));
*** 373,383 ****
} finally {
deleteFile(helloJar);
}
// try with --exclude-symbols" this time.
! checkSuccess(null, "--exclude-symbols", "junk.*", "-o", helloJar.toString(), helloH.toString());
try {
Class<?> cls = loadClass("hello", helloJar);
// check a method for "void func()"
assertNotNull(findMethod(cls, "func", Object[].class));
assertNotNull(findMethod(cls, "func2", Object[].class));
--- 378,389 ----
} finally {
deleteFile(helloJar);
}
// try with --exclude-symbols" this time.
! run("--exclude-symbols", "junk.*", "-o", helloJar.toString(), helloH.toString())
! .checkSuccess();
try {
Class<?> cls = loadClass("hello", helloJar);
// check a method for "void func()"
assertNotNull(findMethod(cls, "func", Object[].class));
assertNotNull(findMethod(cls, "func2", Object[].class));
*** 394,404 ****
@Test
public void testIncludeSymbols() {
Path helloJar = getOutputFilePath("hello.jar");
deleteFile(helloJar);
Path helloH = getInputFilePath("hello.h");
! checkSuccess(null, "-o", helloJar.toString(), helloH.toString());
try {
Class<?> cls = loadClass("hello", helloJar);
// check a method for "void func()"
assertNotNull(findMethod(cls, "func", Object[].class));
assertNotNull(findMethod(cls, "func2", Object[].class));
--- 400,410 ----
@Test
public void testIncludeSymbols() {
Path helloJar = getOutputFilePath("hello.jar");
deleteFile(helloJar);
Path helloH = getInputFilePath("hello.h");
! run("-o", helloJar.toString(), helloH.toString()).checkSuccess();
try {
Class<?> cls = loadClass("hello", helloJar);
// check a method for "void func()"
assertNotNull(findMethod(cls, "func", Object[].class));
assertNotNull(findMethod(cls, "func2", Object[].class));
*** 410,420 ****
} finally {
deleteFile(helloJar);
}
// try with --include-symbols" this time.
! checkSuccess(null, "--include-symbols", "junk.*", "-o", helloJar.toString(), helloH.toString());
try {
Class<?> cls = loadClass("hello", helloJar);
// check a method for "void junk()"
assertNotNull(findMethod(cls, "junk", Object[].class));
assertNotNull(findMethod(cls, "junk2", Object[].class));
--- 416,426 ----
} finally {
deleteFile(helloJar);
}
// try with --include-symbols" this time.
! run("--include-symbols", "junk.*", "-o", helloJar.toString(), helloH.toString()).checkSuccess();
try {
Class<?> cls = loadClass("hello", helloJar);
// check a method for "void junk()"
assertNotNull(findMethod(cls, "junk", Object[].class));
assertNotNull(findMethod(cls, "junk2", Object[].class));
*** 431,441 ****
@Test
public void testNoLocations() {
Path simpleJar = getOutputFilePath("simple.jar");
deleteFile(simpleJar);
Path simpleH = getInputFilePath("simple.h");
! checkSuccess(null, "--no-locations", "-o", simpleJar.toString(), simpleH.toString());
try {
Class<?> simpleCls = loadClass("simple", simpleJar);
Method func = findFirstMethod(simpleCls, "func");
assertFalse(func.isAnnotationPresent(NativeLocation.class));
Class<?> anonymousCls = loadClass("simple$anonymous", simpleJar);
--- 437,447 ----
@Test
public void testNoLocations() {
Path simpleJar = getOutputFilePath("simple.jar");
deleteFile(simpleJar);
Path simpleH = getInputFilePath("simple.h");
! run("--no-locations", "-o", simpleJar.toString(), simpleH.toString()).checkSuccess();
try {
Class<?> simpleCls = loadClass("simple", simpleJar);
Method func = findFirstMethod(simpleCls, "func");
assertFalse(func.isAnnotationPresent(NativeLocation.class));
Class<?> anonymousCls = loadClass("simple$anonymous", simpleJar);
*** 448,458 ****
@Test
public void testIncludeExcludeSymbols() {
Path helloJar = getOutputFilePath("hello.jar");
deleteFile(helloJar);
Path helloH = getInputFilePath("hello.h");
! checkSuccess(null, "-o", helloJar.toString(), helloH.toString());
try {
Class<?> cls = loadClass("hello", helloJar);
// check a method for "void func()"
assertNotNull(findMethod(cls, "func", Object[].class));
assertNotNull(findMethod(cls, "func2", Object[].class));
--- 454,464 ----
@Test
public void testIncludeExcludeSymbols() {
Path helloJar = getOutputFilePath("hello.jar");
deleteFile(helloJar);
Path helloH = getInputFilePath("hello.h");
! run("-o", helloJar.toString(), helloH.toString()).checkSuccess();
try {
Class<?> cls = loadClass("hello", helloJar);
// check a method for "void func()"
assertNotNull(findMethod(cls, "func", Object[].class));
assertNotNull(findMethod(cls, "func2", Object[].class));
*** 464,475 ****
} finally {
deleteFile(helloJar);
}
// try with --include-symbols" this time.
! checkSuccess(null, "--include-symbols", "junk.*", "--exclude-symbols", "junk3",
! "-o", helloJar.toString(), helloH.toString());
try {
Class<?> cls = loadClass("hello", helloJar);
// check a method for "void junk()"
assertNotNull(findMethod(cls, "junk", Object[].class));
assertNotNull(findMethod(cls, "junk2", Object[].class));
--- 470,481 ----
} finally {
deleteFile(helloJar);
}
// try with --include-symbols" this time.
! run("--include-symbols", "junk.*", "--exclude-symbols", "junk3",
! "-o", helloJar.toString(), helloH.toString()).checkSuccess();
try {
Class<?> cls = loadClass("hello", helloJar);
// check a method for "void junk()"
assertNotNull(findMethod(cls, "junk", Object[].class));
assertNotNull(findMethod(cls, "junk2", Object[].class));
*** 488,498 ****
public void testNestedStructsUnions() {
Path nestedJar = getOutputFilePath("nested.jar");
deleteFile(nestedJar);
Path nestedH = getInputFilePath("nested.h");
try {
! checkSuccess(null, "-o", nestedJar.toString(), nestedH.toString());
Class<?> headerCls = loadClass("nested", nestedJar);
assertNotNull(headerCls);
Class<?> fooCls = loadClass("nested$Foo", nestedJar);
assertNotNull(fooCls);
--- 494,504 ----
public void testNestedStructsUnions() {
Path nestedJar = getOutputFilePath("nested.jar");
deleteFile(nestedJar);
Path nestedH = getInputFilePath("nested.h");
try {
! run("-o", nestedJar.toString(), nestedH.toString()).checkSuccess();
Class<?> headerCls = loadClass("nested", nestedJar);
assertNotNull(headerCls);
Class<?> fooCls = loadClass("nested$Foo", nestedJar);
assertNotNull(fooCls);
*** 575,585 ****
public void testAnonymousStructTypeGlobalVar() {
Path elaboratedTypeJar = getOutputFilePath("elaboratedtype.jar");
deleteFile(elaboratedTypeJar);
Path elaboratedTypeH = getInputFilePath("elaboratedtype.h");
try {
! checkSuccess(null, "-o", elaboratedTypeJar.toString(), elaboratedTypeH.toString());
Class<?> headerCls = loadClass("elaboratedtype", elaboratedTypeJar);
assertNotNull(findGlobalVariableGet(headerCls, "point"));
assertNotNull(findGlobalVariableGet(headerCls, "long_or_int"));
assertNotNull(findMethod(headerCls, "func", Pointer.class));
} finally {
--- 581,591 ----
public void testAnonymousStructTypeGlobalVar() {
Path elaboratedTypeJar = getOutputFilePath("elaboratedtype.jar");
deleteFile(elaboratedTypeJar);
Path elaboratedTypeH = getInputFilePath("elaboratedtype.h");
try {
! run("-o", elaboratedTypeJar.toString(), elaboratedTypeH.toString()).checkSuccess();
Class<?> headerCls = loadClass("elaboratedtype", elaboratedTypeJar);
assertNotNull(findGlobalVariableGet(headerCls, "point"));
assertNotNull(findGlobalVariableGet(headerCls, "long_or_int"));
assertNotNull(findMethod(headerCls, "func", Pointer.class));
} finally {
*** 589,599 ****
private void testBuiltinInclude(String name) {
Path fileJar = getOutputFilePath(name + "inc.jar");
deleteFile(fileJar);
Path fileH = getInputFilePath(name + "inc.h");
! checkSuccess(null, "-o", fileJar.toString(), fileH.toString());
deleteFile(fileJar);
}
@Test
public void testBuiltinHeader() {
--- 595,605 ----
private void testBuiltinInclude(String name) {
Path fileJar = getOutputFilePath(name + "inc.jar");
deleteFile(fileJar);
Path fileH = getInputFilePath(name + "inc.h");
! run("-o", fileJar.toString(), fileH.toString()).checkSuccess();
deleteFile(fileJar);
}
@Test
public void testBuiltinHeader() {
*** 604,614 ****
@Test
public void testGlobalFuncPointerCallback() {
Path globalFuncPointerJar = getOutputFilePath("globalFuncPointer.jar");
deleteFile(globalFuncPointerJar);
Path globalFuncPointerH = getInputFilePath("globalFuncPointer.h");
! checkSuccess(null, "-o", globalFuncPointerJar.toString(), globalFuncPointerH.toString());
Class<?> callbackCls = loadClass("globalFuncPointer$FI1", globalFuncPointerJar);
Method callback = findFirstMethod(callbackCls, "fn");
assertNotNull(callback);
assertTrue(callback.isVarArgs());
deleteFile(globalFuncPointerJar);
--- 610,620 ----
@Test
public void testGlobalFuncPointerCallback() {
Path globalFuncPointerJar = getOutputFilePath("globalFuncPointer.jar");
deleteFile(globalFuncPointerJar);
Path globalFuncPointerH = getInputFilePath("globalFuncPointer.h");
! run("-o", globalFuncPointerJar.toString(), globalFuncPointerH.toString()).checkSuccess();
Class<?> callbackCls = loadClass("globalFuncPointer$FI1", globalFuncPointerJar);
Method callback = findFirstMethod(callbackCls, "fn");
assertNotNull(callback);
assertTrue(callback.isVarArgs());
deleteFile(globalFuncPointerJar);
*** 617,627 ****
@Test
public void testFuncPtrTypedef() {
Path funcPtrTypedefJar = getOutputFilePath("funcPtrTypedef.jar");
deleteFile(funcPtrTypedefJar);
Path funcPtrTypedefH = getInputFilePath("funcPtrTypedef.h");
! checkSuccess(null, "-o", funcPtrTypedefJar.toString(), funcPtrTypedefH.toString());
// force parsing of class, method
Class<?> headerCls = loadClass("funcPtrTypedef", funcPtrTypedefJar);
Method getter = findFirstMethod(headerCls, "my_function$get");
assertNotNull(getter);
assertNotNull(getter.getGenericParameterTypes());
--- 623,633 ----
@Test
public void testFuncPtrTypedef() {
Path funcPtrTypedefJar = getOutputFilePath("funcPtrTypedef.jar");
deleteFile(funcPtrTypedefJar);
Path funcPtrTypedefH = getInputFilePath("funcPtrTypedef.h");
! run("-o", funcPtrTypedefJar.toString(), funcPtrTypedefH.toString()).checkSuccess();
// force parsing of class, method
Class<?> headerCls = loadClass("funcPtrTypedef", funcPtrTypedefJar);
Method getter = findFirstMethod(headerCls, "my_function$get");
assertNotNull(getter);
assertNotNull(getter.getGenericParameterTypes());
*** 631,641 ****
@Test
public void testDuplicatedecls() {
Path duplicatedeclsJar = getOutputFilePath("duplicatedecls.jar");
deleteFile(duplicatedeclsJar);
Path duplicatedeclsH = getInputFilePath("duplicatedecls.h");
! checkSuccess(null, "-o", duplicatedeclsJar.toString(), duplicatedeclsH.toString());
// load the class to make sure no duplicate methods generated in it
Class<?> headerCls = loadClass("duplicatedecls", duplicatedeclsJar);
assertNotNull(headerCls);
deleteFile(duplicatedeclsJar);
}
--- 637,647 ----
@Test
public void testDuplicatedecls() {
Path duplicatedeclsJar = getOutputFilePath("duplicatedecls.jar");
deleteFile(duplicatedeclsJar);
Path duplicatedeclsH = getInputFilePath("duplicatedecls.h");
! run("-o", duplicatedeclsJar.toString(), duplicatedeclsH.toString()).checkSuccess();
// load the class to make sure no duplicate methods generated in it
Class<?> headerCls = loadClass("duplicatedecls", duplicatedeclsJar);
assertNotNull(headerCls);
deleteFile(duplicatedeclsJar);
}
< prev index next >