Add tests for non-existent file and file with too long name
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68
diff --git a/test.c b/test.c
index d99fd52..f7a20d7 100644
--- a/test.c
+++ b/test.c
@@ -83,6 +83,8 @@ int main()
int (*nonexistentfunction)( void );
int ret;
HMODULE library3;
+ char toolongfile[32767];
+ DWORD code;
#ifdef _DEBUG
_CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE);
@@ -93,6 +95,54 @@ int main()
_CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDOUT);
#endif
+ library = dlopen( "nonexistentfile.dll", RTLD_GLOBAL );
+ if( library )
+ {
+ printf( "ERROR\tNon-existent file nonexistentfile.dll was opened via dlopen\n" );
+ RETURN_ERROR;
+ }
+ error = dlerror( );
+ if( !error )
+ {
+ printf( "ERROR\tNo error from dlopen for non-existent file\n" );
+ RETURN_ERROR;
+ }
+ else
+ printf( "SUCCESS\tCould not open non-existent file nonexistentfile.dll: %s\n", error );
+
+ memset( toolongfile, 'X', sizeof( toolongfile ) - 5 );
+ memcpy( toolongfile + sizeof( toolongfile ) - 5, ".dll", 5 );
+
+ library = dlopen( toolongfile, RTLD_GLOBAL );
+ if( library )
+ {
+ printf( "ERROR\tFile with too long file name was opened via dlopen\n" );
+ RETURN_ERROR;
+ }
+ error = dlerror( );
+ if( !error )
+ {
+ printf( "ERROR\tNo error from dlopen for file with too long file name\n" );
+ RETURN_ERROR;
+ }
+ else
+ printf( "SUCCESS\tCould not open file with too long file name: %s\n", error );
+
+ library3 = LoadLibraryA( toolongfile );
+ code = GetLastError( );
+ if( library3 )
+ {
+ printf( "ERROR\tFile with too long file name was opened via WINAPI\n" );
+ RETURN_ERROR;
+ }
+ else if( code != ERROR_FILENAME_EXCED_RANGE )
+ {
+ printf( "ERROR\tFile with too long file name was processed via WINAPI: %lu\n", (unsigned long)code );
+ RETURN_ERROR;
+ }
+ else
+ printf( "SUCCESS\tCould not open file with too long file name via WINAPI: %lu\n", (unsigned long)code );
+
library2 = dlopen( "testdll2.dll", RTLD_GLOBAL );
if( !library2 )
{