(self)
| 1281 | self.do_run(js_out, 'Caught exception: Hello\nDone.', args=['2'], no_build=True) |
| 1282 | |
| 1283 | def test_exceptions_allowed(self): |
| 1284 | self.set_setting('EXCEPTION_CATCHING_ALLOWED', ["_Z12somefunctionv"]) |
| 1285 | # otherwise it is inlined and not identified |
| 1286 | self.set_setting('INLINING_LIMIT') |
| 1287 | |
| 1288 | self.do_core_test('test_exceptions_allowed.cpp') |
| 1289 | js_out = self.output_name('test_exceptions_allowed') |
| 1290 | size = os.path.getsize(js_out) |
| 1291 | if self.is_wasm(): |
| 1292 | size += os.path.getsize('test_exceptions_allowed.wasm') |
| 1293 | shutil.copy(js_out, 'orig.js') |
| 1294 | |
| 1295 | # check that an empty allow list works properly (as in, same as exceptions disabled) |
| 1296 | |
| 1297 | self.set_setting('EXCEPTION_CATCHING_ALLOWED', []) |
| 1298 | self.do_core_test('test_exceptions_allowed.cpp', out_suffix='_empty', assert_returncode=NON_ZERO) |
| 1299 | empty_size = os.path.getsize(js_out) |
| 1300 | if self.is_wasm(): |
| 1301 | empty_size += os.path.getsize('test_exceptions_allowed.wasm') |
| 1302 | shutil.copy(js_out, 'empty.js') |
| 1303 | |
| 1304 | self.set_setting('EXCEPTION_CATCHING_ALLOWED', ['fake']) |
| 1305 | self.do_core_test('test_exceptions_allowed.cpp', out_suffix='_empty', assert_returncode=NON_ZERO) |
| 1306 | fake_size = os.path.getsize(js_out) |
| 1307 | if self.is_wasm(): |
| 1308 | fake_size += os.path.getsize('test_exceptions_allowed.wasm') |
| 1309 | shutil.copy(js_out, 'fake.js') |
| 1310 | |
| 1311 | self.clear_setting('EXCEPTION_CATCHING_ALLOWED') |
| 1312 | self.do_core_test('test_exceptions_allowed.cpp', out_suffix='_empty', assert_returncode=NON_ZERO) |
| 1313 | disabled_size = os.path.getsize(js_out) |
| 1314 | if self.is_wasm(): |
| 1315 | disabled_size += os.path.getsize('test_exceptions_allowed.wasm') |
| 1316 | shutil.copy(js_out, 'disabled.js') |
| 1317 | |
| 1318 | print('size: %d' % size) |
| 1319 | print('empty_size: %d' % empty_size) |
| 1320 | print('fake_size: %d' % fake_size) |
| 1321 | print('disabled_size: %d' % disabled_size) |
| 1322 | # empty list acts the same as fully disabled |
| 1323 | self.assertEqual(empty_size, disabled_size) |
| 1324 | # big change when we disable exception catching of the function |
| 1325 | if '-fsanitize=leak' not in self.cflags: |
| 1326 | self.assertGreater(size - empty_size, 0.01 * size) |
| 1327 | # full disable can remove a little bit more |
| 1328 | # For some reason this no longer holds true at high optimizations |
| 1329 | # levels: https://github.com/emscripten-core/emscripten/issues/18312 |
| 1330 | if not any(o in self.cflags for o in ('-O3', '-Oz', '-Os')): |
| 1331 | self.assertLess(disabled_size, fake_size) |
| 1332 | |
| 1333 | def test_exceptions_allowed_2(self): |
| 1334 | self.set_setting('EXCEPTION_CATCHING_ALLOWED', ["main"]) |
nothing calls this directly
no test coverage detected