0
|
1 %% Copyright (c) 2014 Erik Mackdanz <erikmack@gmail.com>
|
|
2
|
|
3 %% Permission to use, copy, modify, and distribute this software for any
|
|
4 %% purpose with or without fee is hereby granted, provided that the above
|
|
5 %% copyright notice and this permission notice appear in all copies.
|
|
6
|
|
7 %% THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
|
8 %% WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
|
9 %% MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
|
10 %% ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
|
11 %% WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
|
12 %% ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
|
13 %% OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
|
14
|
|
15 -module(misc_SUITE).
|
|
16 -compile(export_all).
|
|
17 -include("../include/dyncall.hrl").
|
|
18
|
|
19 -define(VMSZ, 1024).
|
|
20
|
|
21 all() ->
|
|
22 [
|
|
23 set_mode,
|
|
24 set_bad_mode,
|
|
25 reset_after_call,
|
|
26 reset_before_call
|
|
27 ].
|
|
28
|
|
29 set_mode(_) ->
|
|
30 {ok,CallVm} = dyncall:new_call_vm(?VMSZ),
|
|
31 dyncall:mode(CallVm,?DC_CALL_C_DEFAULT),
|
|
32 {ok,?DC_ERROR_NONE} = dyncall:get_error(CallVm).
|
|
33
|
|
34 set_bad_mode(_) ->
|
|
35 {ok,CallVm} = dyncall:new_call_vm(?VMSZ),
|
|
36 dyncall:mode(CallVm,?DC_CALL_C_X86_WIN32_FAST_MS),
|
|
37 {ok,?DC_ERROR_UNSUPPORTED_MODE} = dyncall:get_error(CallVm).
|
|
38
|
|
39 reset_after_call(_) ->
|
|
40 {ok,Lib} = dyncall:load_library("erldc_testtargets"),
|
|
41 {ok,Sym} = dyncall:find_symbol(Lib, "add_one"),
|
|
42 {ok,CallVm} = dyncall:new_call_vm(?VMSZ),
|
|
43 ok = dyncall:arg_int(CallVm,100),
|
|
44 {ok,101} = dyncall:call_int(CallVm,Sym),
|
|
45
|
|
46 ok = dyncall:reset(CallVm),
|
|
47
|
|
48 {ok,Sym2} = dyncall:find_symbol(Lib, "add_seven"),
|
|
49 {ok,107} = dyncall:call_int(CallVm,Sym2).
|
|
50
|
|
51 reset_before_call(_) ->
|
|
52 {ok,Lib} = dyncall:load_library("erldc_testtargets"),
|
|
53 {ok,_Sym} = dyncall:find_symbol(Lib, "add_one"),
|
|
54 {ok,CallVm} = dyncall:new_call_vm(?VMSZ),
|
|
55 ok = dyncall:arg_int(CallVm,100),
|
|
56
|
|
57 ok = dyncall:reset(CallVm),
|
|
58
|
|
59 {ok,Sym2} = dyncall:find_symbol(Lib, "add_seven"),
|
|
60 ok = dyncall:arg_int(CallVm,200),
|
|
61 {ok,207} = dyncall:call_int(CallVm,Sym2).
|
|
62
|
|
63
|