PageRenderTime 18ms CodeModel.GetById 12ms app.highlight 2ms RepoModel.GetById 1ms app.codeStats 0ms

/test/lib/foreign_interface/test_fi02.e

http://github.com/tybor/Liberty
Specman e | 49 lines | 35 code | 12 blank | 2 comment | 0 complexity | 9fa8421b1ef40636afe7e148be21da3a MD5 | raw file
 1class TEST_FI02
 2
 3-- test DLL
 4
 5insert
 6   EIFFELTEST_TOOLS
 7   FOREIGN_DLL_HANDLER
 8   WRAPPER_HANDLER
 9   DL_FLAGS
10
11create {}
12   make
13
14feature {}
15   make
16      local
17         loader: FOREIGN_DLL_LOADER
18         dll: FOREIGN_DLL
19         a: FOREIGN_AGENT
20         dlopen: FOREIGN_TYPED_OBJECT[POINTER]
21         params: FOREIGN_PARAMETERS
22      do
23         dll := loader.library("libdl.so")
24         label_assert("dll loaded", dll /= Void)
25         label_assert("dll well named", dll.filename.is_equal("libdl.so"))
26
27         label_assert("dll singleton", dll = loader.library("libdl.so"))
28
29         a := dll.function("dlopen", << types.c_string, types.sint32 >>, types.pointer)
30         label_assert("function exists", a /= Void)
31
32         die_with_code(0)
33
34         -- TODO: the following does not work, I don't know why:
35
36         params.set(<<
37                    types.create_string("libdl.so"),
38                    types.create_sint32(rtld_noload)
39                    >>)
40         dlopen ?= a.item(params)
41
42         label_assert("ffi-loaded dll not void", dlopen /= Void)
43         label_assert("ffi-loaded dll pointer not null", dlopen.item.is_not_null)
44         label_assert("ffi-loaded dll pointer is the same as foreign pointer", dlopen.item = dll.dso.handle)
45      end
46
47   types: FOREIGN_TYPES
48
49end