annotate erlang/erldc/test/misc_SUITE.erl @ 17:739c40f35a6a

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