blob: 56fb11b0ccf43b4e6fd7a32725866caff8a9792b [file] [log] [blame]
<html devsite><head>
<meta name="book_path" value="/_book.yaml"/>
<meta name="project_path" value="/_project.yaml"/>
</head>
<body>
<!--
Copyright 2018 The Android Open Source Project
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->
<h1 id="native_metric_tests" class="page-title">原生指标测试</h1>
<p>原生指标测试通常用于执行硬件抽象层 (HAL) 或直接与较低级别的系统服务交互。要利用连续测试服务,应使用 <a href="https://github.com/google/benchmark" class="external">google-benchmark</a> 框架编译原生指标测试。</p>
<h2 id="example">示例</h2>
<p>请参阅示例原生测试模块设置,位于:<a href="https://android.googlesource.com/platform/bionic/+/master/benchmarks/bionic_benchmarks.cpp">bionic/benchmarks/bionic-benchmarks</a></p>
<h2 id="summary_of_steps">步骤总结</h2>
<ol>
<li>测试模块配置文件应使用 <code>BUILD_NATIVE_BENCHMARK</code> 编译规则,以便自动包含 google-benchmark 依赖项。</li>
<li><p>使用 make 命令编译测试模块:</p>
<pre class="prettyprint lang-shell"><code>make -j40 bionic-benchmarks
</code></pre></li>
<li><p>使用 Trade Federation 自动化测试框架自动安装和运行:</p>
<pre class="prettyprint"><code>make tradefed-all -j
tradefed.sh run template/local_min --template:map test=bionic-benchmarks
</code></pre></li>
<li><p>手动安装并运行,如下所示:</p>
<ol>
<li><p>将生成的测试二进制文件推送到设备:</p>
<pre class="prettyprint"><code>adb push ${OUT}/data/benchmarktest/bionic-benchmarks/bionic-benchmarks32 \
/data/benchmarktest/bionic-benchmarks/bionic-benchmarks32
</code></pre></li>
<li><p>通过在设备上调用测试二进制文件执行测试:</p>
<pre class="prettyprint"><code>adb shell /data/benchmarktest/bionic-benchmarks/bionic-benchmarks32
</code></pre></li>
</ol></li>
</ol>
</body></html>