Archive

Posts Tagged ‘Code Coverage’

SpiderMonkey 开始计划提供 JS 覆盖率信息

September 9th, 2015 No comments

Mozilla Bugzilla 上已经有了对应的 meta bug. 具体的实现可能需要再等一到两个月.

Nicolas B. Pierron [:nbp] 2015-07-30 08:05:23 PDT
This is a meta bug to add Code Coverage for JavaScript code executed in SpiderMonkey. We have multiple reasons to do that:

The most important is to support release management team, by producing Code Coverage information over executed JavaScript code, and producing gcov-like data files. This would help improve the quality of Firefox, and help evaluate the quality of our tests to accept/refuse new features.

The second reason is to expose this information to the dev-tools, such that JavaScript developers do not have to instrument their code to have code coverage results within the dev-tools.

The third, if the overhead is neglectable, is to make use of the same information to improve IonMonkey register allocation and removal of unused basic blocks ahead of time.

SpiderMonkey 回归测试的代码覆盖度

August 8th, 2015 No comments

最简单的方法还是用 GCC/GCOV/LCOV 系列. 以下是方法:

获取之后就可以直接用浏览器打开看了.

mozjs-coverage-regression-tests-20150807

需要注意的是这个只能看到函数覆盖率和代码行覆盖. 更细致的覆盖度, 例如路径覆盖, 可能需要别的工具了(not sure).

从代码覆盖度上看, 还是有一些代码是没有测试到的. 看了一下原因可以分成几类:

  1. 我编译 SpiderMonkey 的时候使用了’–enable-debug’编译, 有一些调试代码没有执行到;
  2. 测试使用的是Mozilla自带的回归测试脚本, 用于交互式执行的部分, 例如 editline, 都没有执行到;
  3. 硬件配置相关的部分, 由于我使用的机器是 X86_64 SSE4.2, 所以有一些特定的代码也是覆盖不到的;
  4. 最后, 就是测试集可以覆盖但是没有覆盖到的代码部分.

完整的覆盖信息可以看 http://hellocompiler.com/spidermonkey/lcov/index.html