comparison erlang/erldc/test/linkload_SUITE.erl @ 0:0cfcc391201f

initial from svn dyncall-1745
author Daniel Adler
date Thu, 19 Mar 2015 22:26:28 +0100
parents
children
comparison
equal deleted inserted replaced
-1:000000000000 0:0cfcc391201f
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(linkload_SUITE).
16 -compile(export_all).
17
18 -define(VMSZ, 1024).
19
20 all() ->
21 [create_vm,
22 create_vm_badsz,
23 load_lib,
24 no_such_lib,
25 bad_lib,
26 bad_sym,
27 bad_sym_2,
28 load_sym
29 ].
30
31 create_vm(_) ->
32 {ok,Vm} = dyncall:new_call_vm(?VMSZ),
33 true = is_binary(Vm).
34
35 create_vm_badsz(_) ->
36 {error,bad_vm_size} = dyncall:new_call_vm("Hello badarg").
37
38 load_lib(_) ->
39 {ok,Lib} = dyncall:load_library("libm"),
40 true = is_binary(Lib).
41
42 no_such_lib(_) ->
43 {error,lib_not_found} = dyncall:load_library("foobarbaz").
44
45 bad_lib(_) ->
46 {error,invalid_lib} = dyncall:load_library(12).
47
48 bad_sym(_) ->
49 {ok,Lib} = dyncall:load_library("libm"),
50 {error,symbol_not_found} = dyncall:find_symbol(Lib,"bogussymbol").
51
52 bad_sym_2(_) ->
53 {ok,Lib} = dyncall:load_library("libm"),
54 {error,invalid_symbol} = dyncall:find_symbol(Lib,9).
55
56 load_sym(_) ->
57 {ok,Lib} = dyncall:load_library("libm"),
58 {ok,_Partner} = dyncall:find_symbol(Lib,"sqrt").
59
60
61