comparison packages/services/loader/current/tests/loadfoo.cxx @ 184:022f1e506033

Merge from eCos master repository on 2001-10-02-17:59:22-BST
author jlarmour
date Tue, 02 Oct 2001 18:28:24 +0000
parents
children e0c0827131d1
comparison
equal deleted inserted replaced
183:9160a8005d76 184:022f1e506033
1 //==========================================================================
2 //
3 // loadfoo.cxx
4 //
5 // Dynamic library test program
6 //
7 //==========================================================================
8 //####COPYRIGHTBEGIN####
9 //
10 // -------------------------------------------
11 // The contents of this file are subject to the Red Hat eCos Public License
12 // Version 1.1 (the "License"); you may not use this file except in
13 // compliance with the License. You may obtain a copy of the License at
14 // http://www.redhat.com/
15 //
16 // Software distributed under the License is distributed on an "AS IS"
17 // basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See the
18 // License for the specific language governing rights and limitations under
19 // the License.
20 //
21 // The Original Code is eCos - Embedded Configurable Operating System,
22 // released September 30, 1998.
23 //
24 // The Initial Developer of the Original Code is Red Hat.
25 // Portions created by Red Hat are
26 // Copyright (C) 1998, 1999, 2000 Red Hat, Inc.
27 // All Rights Reserved.
28 // -------------------------------------------
29 //
30 //####COPYRIGHTEND####
31 //==========================================================================
32 //#####DESCRIPTIONBEGIN####
33 //
34 // Author(s): nickg
35 // Contributors: nickg
36 // Date: 2000-11-20
37 // Description: Dynamic library test
38 //
39 //####DESCRIPTIONEND####
40 //==========================================================================
41
42 #include <pkgconf/kernel.h>
43 #include <pkgconf/hal.h>
44
45 #include <cyg/infra/testcase.h>
46
47 //#include <cyg/loader/loader.hxx>
48
49 #include <dlfcn.h>
50
51 //==========================================================================
52 // Include a version of the library ELF file converted to a C table
53
54 #include "tests/libfoo.so.c"
55
56 //==========================================================================
57
58 externC void cyg_dl_force(void);
59
60 typedef void vfn();
61
62 int fee_data = 0;
63
64 //int main( int argc, char **argv )
65 externC void cyg_start()
66 {
67 CYG_TEST_INIT();
68
69 CYG_TEST_INFO( "LoadFoo: started" );
70 #if 0
71 Cyg_LoaderStream_Mem memstream(libfoo, sizeof( libfoo ) );
72
73 Cyg_LoadObject *obj;
74
75 // cyg_dl_force();
76
77 Cyg_Loader::loader->load( memstream, 0, &obj );
78
79 vfn *foo = (vfn *)obj->symbol( "foo" );
80
81 #else
82
83 void *fooh = dlopenmem( libfoo, sizeof(libfoo), RTLD_NOW );
84
85 vfn *foo = (vfn *)dlsym( fooh, "foo" );
86
87 #endif
88
89
90 if( foo )
91 {
92 CYG_TEST_INFO( "LoadFoo: foo() call" );
93 foo();
94 CYG_TEST_INFO( "LoadFoo: foo() returned" );
95 }
96 else
97 {
98 CYG_TEST_FAIL_FINISH( "LoadFoo: foo() NULL!!!" );
99 }
100
101 CYG_TEST_PASS_FINISH("LoadFoo: OK");
102
103 }
104
105 //==========================================================================
106
107 externC void fee(int x)
108 {
109 CYG_TEST_INFO( "LoadFoo: fee() called" );
110 fee_data = x;
111 CYG_TEST_INFO( "LoadFoo: fee() returning" );
112 }
113
114 //==========================================================================
115 // EOF loadfoo.cxx