424 deleteFile(nestedJar); 425 } 426 } 427 428 @Test 429 public void testAnonymousStructTypeGlobalVar() { 430 Path elaboratedTypeJar = getOutputFilePath("elaboratedtype.jar"); 431 deleteFile(elaboratedTypeJar); 432 Path elaboratedTypeH = getInputFilePath("elaboratedtype.h"); 433 try { 434 checkSuccess(null, "-o", elaboratedTypeJar.toString(), elaboratedTypeH.toString()); 435 Class<?> headerCls = loadClass("elaboratedtype", elaboratedTypeJar); 436 assertNotNull(findGlobalVariableGet(headerCls, "point")); 437 assertNotNull(findGlobalVariableGet(headerCls, "long_or_int")); 438 assertNotNull(findMethod(headerCls, "func", Pointer.class)); 439 } finally { 440 deleteFile(elaboratedTypeJar); 441 } 442 } 443 444 @Test 445 public void testBuiltinHeader() { 446 Path stdargincJar = getOutputFilePath("stdarginc.jar"); 447 deleteFile(stdargincJar); 448 Path stdargincH = getInputFilePath("stdarginc.h"); 449 checkSuccess(null, "-o", stdargincJar.toString(), stdargincH.toString()); 450 deleteFile(stdargincJar); 451 } 452 453 @Test 454 public void testGlobalFuncPointerCallback() { 455 Path globalFuncPointerJar = getOutputFilePath("globalFuncPointer.jar"); 456 deleteFile(globalFuncPointerJar); 457 Path globalFuncPointerH = getInputFilePath("globalFuncPointer.h"); 458 checkSuccess(null, "-o", globalFuncPointerJar.toString(), globalFuncPointerH.toString()); 459 Class<?> callbackCls = loadClass("globalFuncPointer$FI1", globalFuncPointerJar); 460 Method callback = findFirstMethod(callbackCls, "fn"); 461 assertNotNull(callback); 462 assertTrue(callback.isVarArgs()); 463 deleteFile(globalFuncPointerJar); 464 } 465 466 @Test 467 public void testFuncPtrTypedef() { 468 Path funcPtrTypedefJar = getOutputFilePath("funcPtrTypedef.jar"); 469 deleteFile(funcPtrTypedefJar); 470 Path funcPtrTypedefH = getInputFilePath("funcPtrTypedef.h"); | 424 deleteFile(nestedJar); 425 } 426 } 427 428 @Test 429 public void testAnonymousStructTypeGlobalVar() { 430 Path elaboratedTypeJar = getOutputFilePath("elaboratedtype.jar"); 431 deleteFile(elaboratedTypeJar); 432 Path elaboratedTypeH = getInputFilePath("elaboratedtype.h"); 433 try { 434 checkSuccess(null, "-o", elaboratedTypeJar.toString(), elaboratedTypeH.toString()); 435 Class<?> headerCls = loadClass("elaboratedtype", elaboratedTypeJar); 436 assertNotNull(findGlobalVariableGet(headerCls, "point")); 437 assertNotNull(findGlobalVariableGet(headerCls, "long_or_int")); 438 assertNotNull(findMethod(headerCls, "func", Pointer.class)); 439 } finally { 440 deleteFile(elaboratedTypeJar); 441 } 442 } 443 444 private void testBuiltinInclude(String name) { 445 Path fileJar = getOutputFilePath(name + "inc.jar"); 446 deleteFile(fileJar); 447 Path fileH = getInputFilePath(name + "inc.h"); 448 checkSuccess(null, "-o", fileJar.toString(), fileH.toString()); 449 deleteFile(fileJar); 450 } 451 452 @Test 453 public void testBuiltinHeader() { 454 testBuiltinInclude("stdarg"); 455 testBuiltinInclude("stdbool"); 456 } 457 458 @Test 459 public void testGlobalFuncPointerCallback() { 460 Path globalFuncPointerJar = getOutputFilePath("globalFuncPointer.jar"); 461 deleteFile(globalFuncPointerJar); 462 Path globalFuncPointerH = getInputFilePath("globalFuncPointer.h"); 463 checkSuccess(null, "-o", globalFuncPointerJar.toString(), globalFuncPointerH.toString()); 464 Class<?> callbackCls = loadClass("globalFuncPointer$FI1", globalFuncPointerJar); 465 Method callback = findFirstMethod(callbackCls, "fn"); 466 assertNotNull(callback); 467 assertTrue(callback.isVarArgs()); 468 deleteFile(globalFuncPointerJar); 469 } 470 471 @Test 472 public void testFuncPtrTypedef() { 473 Path funcPtrTypedefJar = getOutputFilePath("funcPtrTypedef.jar"); 474 deleteFile(funcPtrTypedefJar); 475 Path funcPtrTypedefH = getInputFilePath("funcPtrTypedef.h"); |