aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPali Rohár <pali.rohar@gmail.com>2019-05-23 20:24:12 +0200
committerPali Rohár <pali.rohar@gmail.com>2019-05-23 20:24:12 +0200
commit27319bfc884c2817c7c5f4fd1046903dc2e419e0 (patch)
treeb805bc8f9d9d6b99995914be37d015bf9029459f
parentf6f6dd2dcff42b0f7c0cee047f1e9862412a3f02 (diff)
downloaddlfcn-win32-27319bfc884c2817c7c5f4fd1046903dc2e419e0.tar.gz
dlfcn-win32-27319bfc884c2817c7c5f4fd1046903dc2e419e0.tar.bz2
dlfcn-win32-27319bfc884c2817c7c5f4fd1046903dc2e419e0.zip
Add tests for non-existent file and file with too long name
-rw-r--r--test.c50
1 files changed, 50 insertions, 0 deletions
diff --git a/test.c b/test.c
index d99fd52..f7a20d7 100644
--- a/test.c
+++ b/test.c
@@ -83,6 +83,8 @@ int main()
83 int (*nonexistentfunction)( void ); 83 int (*nonexistentfunction)( void );
84 int ret; 84 int ret;
85 HMODULE library3; 85 HMODULE library3;
86 char toolongfile[32767];
87 DWORD code;
86 88
87#ifdef _DEBUG 89#ifdef _DEBUG
88 _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE); 90 _CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE);
@@ -93,6 +95,54 @@ int main()
93 _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDOUT); 95 _CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDOUT);
94#endif 96#endif
95 97
98 library = dlopen( "nonexistentfile.dll", RTLD_GLOBAL );
99 if( library )
100 {
101 printf( "ERROR\tNon-existent file nonexistentfile.dll was opened via dlopen\n" );
102 RETURN_ERROR;
103 }
104 error = dlerror( );
105 if( !error )
106 {
107 printf( "ERROR\tNo error from dlopen for non-existent file\n" );
108 RETURN_ERROR;
109 }
110 else
111 printf( "SUCCESS\tCould not open non-existent file nonexistentfile.dll: %s\n", error );
112
113 memset( toolongfile, 'X', sizeof( toolongfile ) - 5 );
114 memcpy( toolongfile + sizeof( toolongfile ) - 5, ".dll", 5 );
115
116 library = dlopen( toolongfile, RTLD_GLOBAL );
117 if( library )
118 {
119 printf( "ERROR\tFile with too long file name was opened via dlopen\n" );
120 RETURN_ERROR;
121 }
122 error = dlerror( );
123 if( !error )
124 {
125 printf( "ERROR\tNo error from dlopen for file with too long file name\n" );
126 RETURN_ERROR;
127 }
128 else
129 printf( "SUCCESS\tCould not open file with too long file name: %s\n", error );
130
131 library3 = LoadLibraryA( toolongfile );
132 code = GetLastError( );
133 if( library3 )
134 {
135 printf( "ERROR\tFile with too long file name was opened via WINAPI\n" );
136 RETURN_ERROR;
137 }
138 else if( code != ERROR_FILENAME_EXCED_RANGE )
139 {
140 printf( "ERROR\tFile with too long file name was processed via WINAPI: %lu\n", (unsigned long)code );
141 RETURN_ERROR;
142 }
143 else
144 printf( "SUCCESS\tCould not open file with too long file name via WINAPI: %lu\n", (unsigned long)code );
145
96 library2 = dlopen( "testdll2.dll", RTLD_GLOBAL ); 146 library2 = dlopen( "testdll2.dll", RTLD_GLOBAL );
97 if( !library2 ) 147 if( !library2 )
98 { 148 {