@@ -3,24 +3,12 @@ extern crate libloading;
33use libloading:: os:: windows:: * ;
44use std:: ffi:: CStr ;
55use std:: os:: raw:: c_void;
6- // The ordinal DLL contains exactly one function (other than DllMain, that is) with ordinal number
7- // 1. This function has the sugnature `fn() -> *const c_char` and returns a string "bunny\0" (in
8- // reference to WindowsBunny).
9- //
10- // Both x86_64 and x86 versions of the .dll are functionally the same. Ideally we would compile the
11- // dlls with well known ordinals from our own testing helpers library, but rustc does not allow
12- // specifying a custom .def file (https://github.com/rust-lang/rust/issues/35089)
13- //
14- // The DLLs were kindly compiled by WindowsBunny (aka. @retep998).
156
16- #[ cfg( target_arch = "x86" ) ]
17- fn load_ordinal_lib ( ) -> Library {
18- unsafe { Library :: new ( "tests/nagisa32.dll" ) . expect ( "nagisa32.dll" ) }
19- }
20-
21- #[ cfg( target_arch = "x86_64" ) ]
7+ #[ cfg( any( target_arch = "x86" , target_arch = "x86_64" ) ) ]
228fn load_ordinal_lib ( ) -> Library {
23- unsafe { Library :: new ( "tests/nagisa64.dll" ) . expect ( "nagisa64.dll" ) }
9+ let path = super :: functions:: lib_path ( ) ;
10+ super :: functions:: make_helpers ( ) ;
11+ unsafe { Library :: new ( path. display ( ) . to_string ( ) ) . expect ( "Windows test dll not found" ) }
2412}
2513
2614#[ cfg( any( target_arch = "x86" , target_arch = "x86_64" ) ) ]
@@ -49,7 +37,8 @@ fn test_try_into_ptr() {
4937fn test_ordinal_missing_fails ( ) {
5038 let lib = load_ordinal_lib ( ) ;
5139 unsafe {
52- let r: Result < Symbol < unsafe fn ( ) -> * const i8 > , _ > = lib. get_ordinal ( 2 ) ;
40+ // there are a few other symbols in the test DLL
41+ let r: Result < Symbol < unsafe fn ( ) -> * const i8 > , _ > = lib. get_ordinal ( 8 ) ;
5342 r. err ( ) . unwrap ( ) ;
5443 let r: Result < Symbol < unsafe fn ( ) -> * const i8 > , _ > = lib. get_ordinal ( !0 ) ;
5544 r. err ( ) . unwrap ( ) ;
0 commit comments