Skip to content

Commit e1a9928

Browse files
committed
test
1 parent eb7de01 commit e1a9928

File tree

2 files changed

+29
-1
lines changed

2 files changed

+29
-1
lines changed

test/test_core.py

+27-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
raise Exception('do not run this file directly; do something like: test/runner')
1919

2020
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
2222
from tools.utils import WINDOWS, MACOS, LINUX, write_file, delete_file
2323
from tools import shared, building, config, utils, webassembly
2424
import common
@@ -9452,6 +9452,32 @@ def test_abort_on_exceptions_main(self):
94529452
self.assertNotContained('unhandled exception', output)
94539453
self.assertNotContained('Aborted', output)
94549454

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+
94559481
@node_pthreads
94569482
@flaky('https://github.com/emscripten-core/emscripten/issues/20067')
94579483
def test_abort_on_exceptions_pthreads(self):

tools/shared.py

+2
Original file line numberDiff line numberDiff line change
@@ -754,6 +754,8 @@ class OFormat(Enum):
754754
LLVM_OBJCOPY = os.path.expanduser(build_llvm_tool_path(exe_suffix('llvm-objcopy')))
755755
LLVM_STRIP = os.path.expanduser(build_llvm_tool_path(exe_suffix('llvm-strip')))
756756
WASM_LD = os.path.expanduser(build_llvm_tool_path(exe_suffix('wasm-ld')))
757+
LLVM_PROFDATA = 'llvm-profdata-20'#os.path.expanduser(build_llvm_tool_path(exe_suffix('llvm-profdata')))
758+
LLVM_COV = 'llvm-cov-20'#os.path.expanduser(build_llvm_tool_path(exe_suffix('llvm-cov')))
757759

758760
EMCC = bat_suffix(path_from_root('emcc'))
759761
EMXX = bat_suffix(path_from_root('em++'))

0 commit comments

Comments
 (0)