File tree Expand file tree Collapse file tree 1 file changed +32
-0
lines changed
Expand file tree Collapse file tree 1 file changed +32
-0
lines changed Original file line number Diff line number Diff line change @@ -123,5 +123,37 @@ def test_find_library_with_ld(self):
123123 self .assertNotEqual (find_library ('c' ), None )
124124
125125
126+ @unittest .skipUnless (sys .platform .startswith ('emscripten' ),
127+ 'Test only valid for Emscripten' )
128+ class FindLibraryEmscripten (unittest .TestCase ):
129+ def test_find_on_libpath (self ):
130+ import tempfile
131+
132+ # A very simple wasm module
133+ # In WAT format: (module)
134+ wasm_module = b'\x00 asm\x01 \x00 \x00 \x00 \x00 \x08 \x04 name\x02 \x01 \x00 '
135+
136+ with tempfile .TemporaryDirectory () as d :
137+ libname = 'dummy'
138+ dstname = os .path .join (d , 'lib%s.so' % libname )
139+ with open (dstname , 'wb' ) as f :
140+ f .write (wasm_module )
141+
142+ # now check that the .so can't be found (since not in
143+ # LD_LIBRARY_PATH)
144+ self .assertIsNone (find_library (libname ))
145+ # now add the location to LD_LIBRARY_PATH
146+ with os_helper .EnvironmentVarGuard () as env :
147+ KEY = 'LD_LIBRARY_PATH'
148+ if KEY not in env :
149+ v = d
150+ else :
151+ v = '%s:%s' % (env [KEY ], d )
152+ env .set (KEY , v )
153+ # now check that the .so can be found (since in
154+ # LD_LIBRARY_PATH)
155+ self .assertEqual (find_library (libname ), dstname )
156+
157+
126158if __name__ == "__main__" :
127159 unittest .main ()
You can’t perform that action at this time.
0 commit comments