1 /*DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64
4 for INTEL64(R), AMD64(R)
6 Copyright(C) 2007-2009 Koine Yuusuke(koinec). All rights reserved.
8 Redistribution and use in source and binary forms, with or without
9 modification, are permitted provided that the following conditions are met:
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.
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.
29 DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64DrDeAmOn64*/
31 /* File Info -----------------------------------------------------------
35 ----------------------------------------------------------------------*/
37 #define DRD64_SRC_TEST_LIBGOBLIN_LOADPROG
38 #include"drd64_libgoblin.h"
39 #include"test_libgoblin.h"
42 /* LibGoblin_LoadProgram() API ****************************************/
43 /*--------------------------------------------------------------------*/
44 void Test_LibGoblin_LoadProg_API_LoadProgram_test00_001( void )
51 char *pstr_env_ldlibpath;
53 LibGoblin_ObjectFilePath t_objpath;
55 i_result = LibBrownie_Init();
56 CU_ASSERT( 0x00 == i_result );
58 pstr_ldpath = LibBrownie_GetLoadLibraryPath( LIBBROWNIE_LDHINTS_ELF64 );
59 if( NULL == pstr_ldpath )
60 { goto goto_Test_LibGoblin_LoadProg_API_LoadProgram_test00_001_post; }
62 pstr_env_ldlibpath = getenv("LD_LIBRARY_PATH");
64 i_result = LibGoblin_Init();
65 CU_ASSERT( 0x00 == i_result );
67 i_pgid = LibGoblin_AllocProgInfo();
68 CU_ASSERT( 0x00 <= i_result );
70 i_bid[0] = LibGoblin_LoadProgram_Main( i_pgid, "../testdata/dwarftest",
71 "../testdata/dwarftest" );
72 CU_ASSERT( 0x00 == i_bid[0] );
74 i_bid[i_cnt] = LibGoblin_GetUnresolv_ObjectFilePath( i_pgid, &t_objpath );
75 while( 0x00 < i_bid[i_cnt] ) {
76 i_result = LibBrownie_GetLibraryPath(
77 t_objpath.str_localpath,
78 t_objpath.str_filename,
80 t_objpath.str_runpath,
84 CU_ASSERT( 0x00 < i_result );
85 if( 0x00 >= i_result )
86 { goto goto_Test_LibGoblin_LoadProg_API_LoadProgram_test00_001_post; }
88 printf(" file= %s, DT_RPATH= %s, DT_RUNPATH=%s\n => localpath: %s [bid= %d]\n",
89 t_objpath.str_filename, t_objpath.str_rpath,
90 t_objpath.str_runpath, t_objpath.str_localpath, i_bid[i_cnt] );
92 i_result = LibGoblin_SetPathAndLoad_ObjectFilePath( &t_objpath );
93 CU_ASSERT( 0x00 == i_result );
94 if( 0x00 != i_result )
95 { goto goto_Test_LibGoblin_LoadProg_API_LoadProgram_test00_001_post; }
98 i_bid[i_cnt] = LibGoblin_GetUnresolv_ObjectFilePath( i_pgid, &t_objpath );
101 i_result = LibGoblin_AnalyzeMainProgram( i_pgid );
102 CU_ASSERT( 0x00 == i_result );
104 //i_result = LibGoblin_AnalyzeLibrary( i_pgid, i_bid[2], 0x80000000 );
105 //CU_ASSERT( 0x00 == i_result );
107 i_result = LibGoblin_FreeProgInfo( i_pgid );
108 CU_ASSERT( 0x00 == i_result );
110 i_result = LibGoblin_Term();
111 CU_ASSERT( 0x00 == i_result );
113 LibBrownie_FreeLoadLibraryPath( LIBBROWNIE_LDHINTS_ELF64 );
115 goto_Test_LibGoblin_LoadProg_API_LoadProgram_test00_001_post:
122 /*----------------------------------------------------------------------
123 ----------------------------------------------------------------------*/
124 DRD64_TEST_LIBGOBLIN_LOADPROG_EXTERN
126 Test_LibGoblin_LoadProg(
131 pt_goblin = CU_add_suite( "LibGoblin_LoadProg", NULL, NULL );
133 CU_add_test( pt_goblin, "LibGoblin_LoadProg_test00_001",
134 Test_LibGoblin_LoadProg_API_LoadProgram_test00_001 );
141 /* EOF of drd64_.c ----------------------------------- */