-
Notifications
You must be signed in to change notification settings - Fork 79
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
8 changed files
with
121 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
int | ||
old_answer(void) | ||
{ | ||
return 41; | ||
} | ||
|
||
int | ||
new_answer(void) | ||
{ | ||
return 42; | ||
} | ||
|
||
__asm__(".symver old_answer,answer@VERS_1.0"); | ||
__asm__(".symver new_answer,answer@@VERS_1.1"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
VERS_1.0 {}; | ||
VERS_1.1 {}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
package com.kenai.jffi; | ||
|
||
import org.junit.Test; | ||
|
||
import com.kenai.jffi.InvokerTest.HeapInvoker; | ||
import com.kenai.jffi.InvokerTest.NativeInvoker; | ||
import com.kenai.jffi.UnitHelper.Address; | ||
|
||
import static org.junit.Assert.assertEquals; | ||
|
||
public class VersionTest { | ||
|
||
public VersionTest() { | ||
} | ||
|
||
@Test public void old_answer() { | ||
Invoker invoker = new NativeInvoker(); | ||
|
||
Address sym = UnitHelper.findSymbolWithVersion("answer", "VERS_1.0"); | ||
Function function = new Function(sym.address, Type.SINT); | ||
CallContext ctx = new CallContext(Type.SINT); | ||
|
||
long res = invoker.invokeN0(ctx, function.getFunctionAddress()); | ||
|
||
assertEquals(41, res); | ||
} | ||
|
||
@Test public void new_answer() { | ||
Invoker invoker = new HeapInvoker(); | ||
|
||
Address sym = UnitHelper.findSymbolWithVersion("answer", "VERS_1.1"); | ||
Function function = new Function(sym.address, Type.SINT); | ||
CallContext ctx = new CallContext(Type.SINT); | ||
|
||
long res = invoker.invokeN0(ctx, function.getFunctionAddress()); | ||
|
||
assertEquals(42, res); | ||
} | ||
|
||
@Test(expected = UnsatisfiedLinkError.class) | ||
public void future_answer() { | ||
UnitHelper.findSymbolWithVersion("answer", "VERS_1.2"); | ||
} | ||
} |