OSDN Git Service

2019/01/01(Tue) 12:13
[drdeamon64/drdeamon64.git] / libbrownie / test_libbrownie_searchlib.c
1 /*DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64
2
3                          D r . D e a m o n  6 4
4                         for INTEL64(R), AMD64(R)
5         
6    Copyright(C) 2007-2009 Koine Yuusuke(koinec). All rights reserved.
7
8 Redistribution and use in source and binary forms, with or without
9 modification, are permitted provided that the following conditions are met:
10
11  1. Redistributions of source code must retain the above copyright notice,
12     this list of conditions and the following disclaimer.
13  2. Redistributions in binary form must reproduce the above copyright
14     notice, this list of conditions and the following disclaimer in the
15     documentation and/or other materials provided with the distribution.
16
17 THIS SOFTWARE IS PROVIDED BY Koine Yuusuke(koinec) ``AS IS'' AND ANY
18 EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
19 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
20 DISCLAIMED. IN NO EVENT SHALL Koine Yuusuke(koinec) OR CONTRIBUTORS BE
21 LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
22 CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
23 SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
24 INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
25 CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
26 ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
27 OF THE POSSIBILITY OF SUCH DAMAGE.
28
29 DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64*/
30
31 /* File Info -----------------------------------------------------------
32 File: drd64_.c
33 Function: 
34 Comment: 
35 ----------------------------------------------------------------------*/
36
37 #define DRD64_SRC_TEST_LIBBROWNIE_SEARCHLIB
38 #include"test_libbrownie.h"
39 #include"drd64_libbrownie.h"
40
41 /*----------------------------------------------------------------------
42 1/2.RPATH 
43 ----------------------------------------------------------------------*/
44 void Test_LibBrownie_SearchLib_test01_sub(
45                 int i_testid, char *pstr_env_ldlibpath, char *pstr_ldhints, char *pstr_solibname)
46 {
47         int             i_result;
48         char    str_resolvpath[DRD64_MAX_PATH];
49         
50
51         i_result        = LibBrownie_GetLibraryPath(
52                                                 str_resolvpath, pstr_solibname, ".:..:../testdata", NULL,
53                                                 pstr_env_ldlibpath, pstr_ldhints );
54         CU_ASSERT( 0x00 < i_result );
55
56         printf(" SearchLib Test1%02d: %s [%d]\n", i_testid, str_resolvpath, i_result );
57
58         return;
59 }
60
61 /*----------------------------------------------------------------------
62 4.RUNPATH 
63 ----------------------------------------------------------------------*/
64 void Test_LibBrownie_SearchLib_test04_sub(
65                 int i_testid, char *pstr_env_ldlibpath, char *pstr_ldhints, char *pstr_solibname)
66 {
67         int             i_result;
68         char    str_resolvpath[DRD64_MAX_PATH];
69         
70
71         i_result        = LibBrownie_GetLibraryPath(
72                                                 str_resolvpath, pstr_solibname, NULL, ".:..:../testdata", 
73                                                 pstr_env_ldlibpath, pstr_ldhints );
74         CU_ASSERT( 0x00 < i_result );
75
76         printf(" SearchLib Test4%02d: %s [%d]\n", i_testid, str_resolvpath, i_result );
77
78         return;
79 }
80
81 /*----------------------------------------------------------------------
82 LDHINTS files
83 ----------------------------------------------------------------------*/
84 void Test_LibBrownie_SearchLib_test05_sub(
85                 int i_testid, char *pstr_env_ldlibpath, char *pstr_ldhints, char *pstr_solibname)
86 {
87         int             i_result;
88         char    str_resolvpath[DRD64_MAX_PATH];
89         
90
91         i_result        = LibBrownie_GetLibraryPath(
92                                                 str_resolvpath, pstr_solibname, NULL, NULL,
93                                                 pstr_env_ldlibpath, pstr_ldhints );
94         CU_ASSERT( 0x00 < i_result );
95
96         printf(" SearchLib Test5%02d: %s [%d]\n", i_testid, str_resolvpath, i_result );
97
98         return;
99 }
100
101 /*----------------------------------------------------------------------
102 ----------------------------------------------------------------------*/
103 void Test_LibBrownie_SearchLib_test00_001(void)
104 {
105         int             i_result;
106         char    *pstr_ldhints;
107         char    *pstr_env_ldlibpath;
108
109         pstr_ldhints    = LibBrownie_GetLoadLibraryPath( LIBBROWNIE_LDHINTS_ELF64 );
110         CU_ASSERT( NULL != pstr_ldhints );
111
112         pstr_env_ldlibpath      = getenv( LIBBROWNIE_SEARCHLIB_ENV_LDLIBPATH );
113         
114         i_result        = LibBrownie_Init();
115         CU_ASSERT( i_result == 0x00 );
116
117         Test_LibBrownie_SearchLib_test01_sub( 1, pstr_env_ldlibpath, pstr_ldhints, "libsotest.so" );
118
119         Test_LibBrownie_SearchLib_test04_sub( 1, pstr_env_ldlibpath, pstr_ldhints, "libsonodbg.so" );
120
121         Test_LibBrownie_SearchLib_test05_sub( 1, pstr_env_ldlibpath, pstr_ldhints, "libc.so.7" );
122         Test_LibBrownie_SearchLib_test05_sub( 2, pstr_env_ldlibpath, pstr_ldhints, "libbz2.so.4" );
123         Test_LibBrownie_SearchLib_test05_sub( 3, pstr_env_ldlibpath, pstr_ldhints, "libX11.so.6" );
124         Test_LibBrownie_SearchLib_test05_sub( 4, pstr_env_ldlibpath, pstr_ldhints, "libLTO.so" );
125
126
127         LibBrownie_FreeLoadLibraryPath( LIBBROWNIE_LDHINTS_ELF64 );
128
129         LibBrownie_Term();
130
131         return;
132 }
133
134
135
136 /*----------------------------------------------------------------------
137 ----------------------------------------------------------------------*/
138 DRD64_TEST_LIBBROWNIE_SEARCHLIB_EXTERN
139 int
140         Test_LibBrownie_SearchLib(
141                         void )
142 {
143         CU_pSuite       pt_brownie;
144         
145         pt_brownie      = CU_add_suite( "LibBrownie_SearchLib", NULL, NULL );
146
147         CU_add_test( pt_brownie, "LibBrownie_SearchLib_test00_001",
148                                                                          Test_LibBrownie_SearchLib_test00_001 );
149
150         return 0x00;
151 }
152
153
154 /* EOF of drd64_.c ----------------------------------- */