|
18 | 18 | raise Exception('do not run this file directly; do something like: test/runner')
|
19 | 19 |
|
20 | 20 | from tools.shared import PIPE
|
21 |
| -from tools.shared import EMCC, EMAR, FILE_PACKAGER |
| 21 | +from tools.shared import EMCC, EMAR, FILE_PACKAGER, LLVM_PROFDATA, LLVM_COV |
22 | 22 | from tools.utils import WINDOWS, MACOS, LINUX, write_file, delete_file
|
23 | 23 | from tools import shared, building, config, utils, webassembly
|
24 | 24 | import common
|
@@ -9452,6 +9452,32 @@ def test_abort_on_exceptions_main(self):
|
9452 | 9452 | self.assertNotContained('unhandled exception', output)
|
9453 | 9453 | self.assertNotContained('Aborted', output)
|
9454 | 9454 |
|
| 9455 | + def test_fcoverage_mapping(self): |
| 9456 | + expected = ''' 1| |/* |
| 9457 | + 2| | * Copyright 2016 The Emscripten Authors. All rights reserved. |
| 9458 | + 3| | * Emscripten is available under two separate licenses, the MIT license and the |
| 9459 | + 4| | * University of Illinois/NCSA Open Source License. Both these licenses can be |
| 9460 | + 5| | * found in the LICENSE file. |
| 9461 | + 6| | */ |
| 9462 | + 7| | |
| 9463 | + 8| |#include <stdio.h> |
| 9464 | + 9| 1|int main() { |
| 9465 | + 10| 1| printf("hello, world!\\n"); |
| 9466 | + 11| 1| return 0; |
| 9467 | + 12| 1|} |
| 9468 | +
|
| 9469 | +''' |
| 9470 | + self.emcc_args.append('-fprofile-instr-generate') |
| 9471 | + self.emcc_args.append('-fcoverage-mapping') |
| 9472 | + self.emcc_args.append('-g') |
| 9473 | + self.set_setting('NODERAWFS') |
| 9474 | + self.set_setting('EXIT_RUNTIME') |
| 9475 | + self.do_core_test('test_hello_world.c') |
| 9476 | + self.assertExists('default.profraw') |
| 9477 | + self.run_process([LLVM_PROFDATA, 'merge', '-sparse', 'default.profraw', '-o', 'out.profdata']) |
| 9478 | + self.assertExists('out.profdata') |
| 9479 | + self.assertEquals(expected, self.run_process([LLVM_COV, 'show', 'test_hello_world.wasm', '-instr-profile=out.profdata'], stdout=PIPE).stdout) |
| 9480 | + |
9455 | 9481 | @node_pthreads
|
9456 | 9482 | @flaky('https://github.com/emscripten-core/emscripten/issues/20067')
|
9457 | 9483 | def test_abort_on_exceptions_pthreads(self):
|
|
0 commit comments