def test_get_shared_library_arch(self): """Test analysing a library on Windows.""" dirname = os.path.join(os.path.dirname(__file__), "fakelibs") for f, a in zip(["_32", "_64", "_64_2"], ["I386", "IA64", "AMD64"]): arch = util.get_shared_library_arch( os.path.join(dirname, "fakelib_good%s.dll" % f)) assert arch == a arch = util.get_shared_library_arch( os.path.join(dirname, "fakelib_good_unknown.dll")) assert arch == "UNKNOWN" with pytest.raises(Exception) as e: util.get_shared_library_arch( os.path.join(dirname, "fakelib_bad_magic.dll")) assert "Not an executable" in e.exconly() with pytest.raises(Exception) as e: util.get_shared_library_arch( os.path.join(dirname, "fakelib_not_pe.dll")) assert "Not a PE executable" in e.exconly()
def test_get_shared_library_arch(self): """Test analysing a library on Windows. """ dirname = os.path.join(os.path.dirname(__file__), "fakelibs") for f, a in zip(["_32", "_64", "_64_2"], ["I386", "IA64", "AMD64"]): arch = util.get_shared_library_arch( os.path.join(dirname, "fakelib_good%s.dll" % f)) self.assertEqual(arch, a) arch = util.get_shared_library_arch( os.path.join(dirname, "fakelib_good_unknown.dll")) self.assertEqual(arch, "UNKNOWN") with self.assertRaises(Exception) as e: util.get_shared_library_arch( os.path.join(dirname, "fakelib_bad_magic.dll")) self.assertIn("Not an executable", e.exception.args[0]) with self.assertRaises(Exception) as e: util.get_shared_library_arch( os.path.join(dirname, "fakelib_not_pe.dll")) self.assertIn("Not a PE executable", e.exception.args[0])