Part 1
요약·해설
다섯 가지 공식 기준과 YAML harness 예제, README 필수 항목을 원문 순서대로 설명합니다.
Purpose
Reference application
Build
Twister + YAML
Docs
README.rst required
Part 2
접을 수 있는 영어 원문 전체
영어 원문 전체 펼치기
원문 SHA-256
1B57E6779B01987D0348FC0E0DF09DADEE8326777D454B86F95817CA9F7B1613
.. _definition_and_criteria:
Sample Definition and Criteria
##############################
Definition
==========
A sample is a concise Zephyr application that provides an accessible overview of one or
more features, subsystems, or modules. This includes kernel services, drivers, protocols, etc.
Samples should be limited in scope and should focus only on demonstrating non-trivial or
essential aspects of the subsystem(s) or module(s) being highlighted.
Sample Criteria
===============
1. Samples must not be used as a testcase.
++++++++++++++++++++++++++++++++++++++++++
* The primary purpose of a sample is to provide a reference to the user.
* Samples must not use Zephyr's testing framework.
* Must not use :kconfig:option:`CONFIG_ZTEST`
* Must not use zasserts in samples.
* If a sample can provide output that can be verified, then output should be evaluated against
expected value to have some level of testing for the sample itself.
Refer to :ref:`twister_script` for more details.
* Samples are optional.
2. Twister should be able to build every sample.
++++++++++++++++++++++++++++++++++++++++++++++++
* Every sample must have a YAML file. Reference: :ref:`twister_script`.
**For example:**
.. code-block:: yaml
tests:
sample.kernel.cond_var:
integration_platforms:
- native_sim
tags: kernel condition_variables
harness: console
harness_config:
type: one_line
regex:
- ".*Waited and joined with 3 threads"
**Guidelines for Samples:**
* Minimize the use of ``platform_allow`` and architecture filters.
* Do not mark the test as build only unless necessary.
* Any test case-specific configuration options are added using ``extra_args`` or
``extra_configs`` options in the YAML file. The `prj.conf` file should have the in-common
configuration options.
* The sample itself can be evaluated using multiple configurations in the sample's YAML file.
For example, the sample is used to run with different logging modes using multiple scenarios
in ``samples/subsys/logging/syst``.
* Sample output can be validated leveraging the ``harness_config`` regex option,
wherever applicable.
3. Samples should target multiple platforms and architectures.
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
* Minimize the use of ``platform_allow`` and architecture filters as it limits the scope
of testing to the mentioned platforms and architectures.
Reference: :ref:`twister_script`
* Make use of ``integration_platforms`` to limit the scope when there are timing or
resource constraints.
* Make the sample as generic as possible. Avoid making a sample platform specific unless it is
for particular hardware.
4. A sample should provide sufficient coverage of a subsystem, feature, or module.
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
**DO's:**
* Cover the most common and important use cases of the functionality.
* Keep the code simple and easy to read. Example: :zephyr_file:`samples/philosophers`.
**DONT's:**
* Samples must not test the negative or edge case behaviors.
* Must not be unit tests.
5. Samples must be documented.
++++++++++++++++++++++++++++++
* Samples must have a ``README.rst`` file in the samples folder.
Example: ``samples/subsys/foo/README.rst``. clearly explaining the purpose of the sample, its
HW requirements, and the expected sample output, if applicable.
* Ensure that the ``README.rst`` file is accessible in the sample hierarchy starting at
``samples/index.rst``.
**README Template:**
* Overview, if applicable.
* SW/HW requirements
* Building & Running instructions
* Sample output, if applicable.
As a starting point, this sample is a good example to refer to
:zephyr_file:`samples/kernel/condition_variables/condvar`.
Part 3
한국어 전문 번역
정의
Sample은 하나 이상의 feature, subsystem 또는 module을 쉽게 살펴볼 수 있게 만든 간결한 Zephyr application입니다. 여기에는 kernel service, driver, protocol 등이 포함됩니다. Sample의 범위는 제한적이어야 하며, 소개하려는 subsystem이나 module에서 사소하지 않거나 꼭 필요한 측면만 보여 주는 데 집중해야 합니다.
Sample 기준
1. Sample을 testcase로 사용해서는 안 됩니다
- Sample의 주된 목적은 사용자에게 참고용 구현을 제공하는 것입니다.
- Sample에서 Zephyr testing framework를 사용해서는 안 됩니다.
CONFIG_ZTEST를 사용해서는 안 됩니다.- Sample에서
zassert계열 assertion을 사용해서는 안 됩니다.
- 검증할 수 있는 output을 만드는 sample이라면, sample 자체도 어느 정도 시험되도록 그 output을 expected value와 비교해야 합니다. 자세한 내용은 Test Runner(Twister)를 참고하십시오.
- Sample은 선택 사항입니다.
2. Twister가 모든 sample을 build할 수 있어야 합니다
- 모든 sample에는 YAML file이 있어야 합니다. 참고: Test Runner(Twister).
예:
tests:
sample.kernel.cond_var:
integration_platforms:
- native_sim
tags: kernel condition_variables
harness: console
harness_config:
type: one_line
regex:
- ".*Waited and joined with 3 threads"
Sample 지침:
platform_allow와 architecture filter 사용을 최소화합니다.- 필요한 경우가 아니라면 test를 build-only로 표시하지 않습니다.
- Testcase별 configuration option은 YAML file의
extra_args또는extra_configsoption으로 추가합니다.prj.conf에는 여러 testcase가 공통으로 사용하는 configuration option을 둡니다. - Sample YAML file에 여러 configuration을 두어 동일 sample을 평가할 수 있습니다. 예를 들어
samples/subsys/logging/syst는 여러 scenario를 사용해 서로 다른 logging mode로 sample을 실행합니다. - 적용할 수 있다면
harness_config의 regular expression option으로 sample output을 검증할 수 있습니다.
3. Sample은 여러 platform과 architecture를 대상으로 해야 합니다
platform_allow와 architecture filter는 명시한 platform과 architecture로 시험 범위를 제한하므로 사용을 최소화합니다. 참고: Test Runner(Twister).- Timing 또는 resource 제약이 있을 때는
integration_platforms를 사용해 시험 범위를 제한합니다. - Sample을 가능한 한 범용으로 만듭니다. 특정 hardware를 위한 sample이 아니라면 platform 전용으로 만들지 않습니다.
4. Sample은 subsystem, feature 또는 module을 충분히 다뤄야 합니다
해야 할 일:
- 기능에서 가장 일반적이고 중요한 사용 사례를 다룹니다.
- Code를 단순하고 읽기 쉽게 유지합니다. 예: Dining Philosophers sample.
하지 말아야 할 일:
- Sample에서 negative behavior나 edge-case behavior를 시험해서는 안 됩니다.
- Unit test여서는 안 됩니다.
5. Sample에는 문서가 있어야 합니다
- Sample folder에는
README.rstfile이 있어야 합니다. 예:samples/subsys/foo/README.rst. 이 문서는 sample의 목적, hardware 요구 사항, 해당하는 경우 예상 output을 명확히 설명해야 합니다. README.rst가samples/index.rst에서 시작하는 sample hierarchy를 통해 접근 가능한지 확인합니다.
README template:
- 해당하는 경우 개요
- Software와 hardware 요구 사항
- Build 및 실행 지침
- 해당하는 경우 sample output
출발점으로 참고하기 좋은 sample은 condition variable sample입니다.
Source
출처
영어 원문에는 문단, 문서 지시문, 표, 코드, 코드 심벌, 경로를 그대로 보존했습니다.