diff 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
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/erlang/erldc/test/linkload_SUITE.erl	Thu Mar 19 22:26:28 2015 +0100
@@ -0,0 +1,61 @@
+%%  Copyright (c) 2014 Erik Mackdanz <erikmack@gmail.com>
+
+%%  Permission to use, copy, modify, and distribute this software for any
+%%  purpose with or without fee is hereby granted, provided that the above
+%%  copyright notice and this permission notice appear in all copies.
+
+%%  THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
+%%  WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
+%%  MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
+%%  ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
+%%  WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
+%%  ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
+%%  OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.          
+
+-module(linkload_SUITE).
+-compile(export_all).
+
+-define(VMSZ, 1024).
+
+all() ->
+    [create_vm,
+     create_vm_badsz,
+     load_lib,
+     no_such_lib,
+     bad_lib,
+     bad_sym,
+     bad_sym_2,
+     load_sym
+    ].
+
+create_vm(_) ->
+    {ok,Vm} = dyncall:new_call_vm(?VMSZ),
+    true = is_binary(Vm).
+
+create_vm_badsz(_) ->
+    {error,bad_vm_size} = dyncall:new_call_vm("Hello badarg").
+
+load_lib(_) ->
+    {ok,Lib} = dyncall:load_library("libm"),
+    true = is_binary(Lib).
+    
+no_such_lib(_) ->
+    {error,lib_not_found} = dyncall:load_library("foobarbaz").
+
+bad_lib(_) ->
+    {error,invalid_lib} = dyncall:load_library(12).
+
+bad_sym(_) ->
+    {ok,Lib} = dyncall:load_library("libm"),
+    {error,symbol_not_found} = dyncall:find_symbol(Lib,"bogussymbol").
+    
+bad_sym_2(_) ->
+    {ok,Lib} = dyncall:load_library("libm"),
+    {error,invalid_symbol} = dyncall:find_symbol(Lib,9).
+    
+load_sym(_) ->
+    {ok,Lib} = dyncall:load_library("libm"),
+    {ok,_Partner} = dyncall:find_symbol(Lib,"sqrt").
+    
+    
+