• Home
Name Date Size #Lines LOC

..--

build/12-May-2024-1,2391,093

checksum/12-May-2024-586352

figures/12-May-2024-

hcpptest/12-May-2024-144134

hctest/12-May-2024-827589

others/query/12-May-2024-222169

reliability/12-May-2024-540413

repackage/12-May-2024-138101

BUILD.gnD12-May-20241.1 KiB3330

LICENSED12-May-202410.1 KiB177150

OAT.xmlD12-May-20243.8 KiB6310

README.mdD12-May-202430.7 KiB531416

README_zh.mdD12-May-202429.2 KiB531416

build.shD12-May-20244 KiB12095

buildFun.shD12-May-20245.8 KiB11896

buildUtils.shD12-May-2024955 3116

runtest.shD12-May-20244.2 KiB156132

README.md

1# X Test Suite<a name="EN-US_TOPIC_0000001132537809"></a>
2
3-   [Introduction](#section465982318513)
4-   [Devices](#section125090457443)
5-   [Directory Structure](#section161941989596)
6-   [Constraints](#section119744591305)
7-   [Usage Guidelines](#section137768191623)
8-   [Test Case Development Guidelines](#section3695134065513)
9    -   [C-based Test Case Development and Compilation \(for Mini-System Devices\)](#section1551164914237)
10    -   [C-based Test Case Execution \(for Mini-System Devices\)](#section10100701294)
11    -   [C++-based Test Case Development and Compilation \(for Small-, Standard-, and Large-System Devices\)](#section5714177113113)
12    -   [C++-based Test Case Execution \(for Small-, Standard-, and Large-System Devices\)](#section42281924184)
13
14-   [Repositories Involved](#section1371113476307)
15
16## Introduction<a name="section465982318513"></a>
17
18The X test suite \(XTS\) subsystem contains a set of OpenHarmony certification test suites, including the currently supported application compatibility test suite \(ACTS\) and the device compatibility test suite \(DCTS\) that will be supported in the future.
19
20This subsystem contains the ACTS and  **tools**  software package.
21
22-   The  **acts**  directory stores the source code and configuration files of ACTS test cases. The ACTS helps device vendors detect the software incompatibility as early as possible and ensures that the software is compatible to OpenHarmony during the entire development process.
23-   The  **tools**  software package stores the test case development framework related to  **acts**.
24
25## Devices<a name="section125090457443"></a>
26
27OpenHarmony supports the following device types:
28
29-   **Mini-System Devices \(reference memory ≥ 128 KB\)**
30
31    Such devices are equipped with MCU processors such as ARM Cortex-M and 32-bit RISC-V. They provide rich short-distance connection and peripheral bus access capabilities. Typical products include LinkIoT module devices and sensors in the smart home field. The LinkIoT module is usually used for smart Internet of Things \(IoT\) devices as the hardware module that implements connectivity functions. In the smart home field, the LinkIoT module is integrated into devices by vendors. For example, a LinkIoT module provides WLAN/Bluetooth access and data connection, and it usually communicates with the chip of smart home devices via a universal asynchronous receiver-transmitter \(UART\) or general-purpose input/output \(GPIO\) interface.
32
33-   **Small-System Devices \(reference memory ≥ 1 MB\)**
34
35    Such devices are equipped with application processors such as ARM Cortex-A. They provide higher security capabilities, standard graphics framework, and multimedia capabilities for video encoding and decoding. Typical products include IP cameras, electronic cat eyes, and routers in the smart home field, as well as event data recorders \(EDRs\) in the smart travel field.
36
37
38-   **Standard-System Devices \(reference memory ≥ 128 MB\)**
39
40    Such devices are equipped with application processors such as ARM Cortex-A. They provide a complete application framework supporting enhanced interaction, 3D GPU, hardware composer, diverse components, and rich animations. Typical products include high-end refrigerator displays.
41
42-   **Large-System Devices \(reference memory ≥ 1 GB\)**
43
44    Such devices are equipped with application processors such as ARM Cortex-A and provide a complete compatible application framework. Typical products include smart TVs and smart watches.
45
46
47## Directory Structure<a name="section161941989596"></a>
48
49```
50/test/xts
51├── acts                 # Test code
52│   └── subsystem       # Source code of subsystem test cases for large-system devices
53│   └── subsystem_lite  # Source code of subsystems test cases for mini- and small-system devices
54│   └── BUILD.gn        # Build configuration of test cases for large-system devices
55│   └── build_lite      # Build configuration of test cases for mini-and small-system devices
56│       └── build_lite    # Build configuration
57└── tools                # Test tool code
58```
59
60## Constraints<a name="section119744591305"></a>
61
62Test cases for mini system devices must be developed based on C, and those for small system devices must be developed based on C++.
63
64## Usage Guidelines<a name="section137768191623"></a>
65
66**Table  1**  Test case levels
67
68<a name="table12856113719456"></a>
69<table><thead align="left"><tr id="row88561737114517"><th class="cellrowborder" valign="top" width="33.333333333333336%" id="mcps1.2.4.1.1"><p id="p54711456452"><a name="p54711456452"></a><a name="p54711456452"></a>Level</p>
70</th>
71<th class="cellrowborder" valign="top" width="33.283328332833285%" id="mcps1.2.4.1.2"><p id="p114834544518"><a name="p114834544518"></a><a name="p114834544518"></a>Definition</p>
72</th>
73<th class="cellrowborder" valign="top" width="33.383338333833386%" id="mcps1.2.4.1.3"><p id="p348154574518"><a name="p348154574518"></a><a name="p348154574518"></a>Scope</p>
74</th>
75</tr>
76</thead>
77<tbody><tr id="row78561137134514"><td class="cellrowborder" valign="top" width="33.333333333333336%" headers="mcps1.2.4.1.1 "><p id="p17481345124512"><a name="p17481345124512"></a><a name="p17481345124512"></a>Level0</p>
78</td>
79<td class="cellrowborder" valign="top" width="33.283328332833285%" headers="mcps1.2.4.1.2 "><p id="p1548945204514"><a name="p1548945204514"></a><a name="p1548945204514"></a>Smoke</p>
80</td>
81<td class="cellrowborder" valign="top" width="33.383338333833386%" headers="mcps1.2.4.1.3 "><p id="p174824517456"><a name="p174824517456"></a><a name="p174824517456"></a>Verifies basic functionalities of key features and basic DFX attributes with the most common input. The pass result indicates that the features are runnable.</p>
82</td>
83</tr>
84<tr id="row28563372451"><td class="cellrowborder" valign="top" width="33.333333333333336%" headers="mcps1.2.4.1.1 "><p id="p448445144512"><a name="p448445144512"></a><a name="p448445144512"></a>Level1</p>
85</td>
86<td class="cellrowborder" valign="top" width="33.283328332833285%" headers="mcps1.2.4.1.2 "><p id="p44813452452"><a name="p44813452452"></a><a name="p44813452452"></a>Basic</p>
87</td>
88<td class="cellrowborder" valign="top" width="33.383338333833386%" headers="mcps1.2.4.1.3 "><p id="p648184584514"><a name="p648184584514"></a><a name="p648184584514"></a>Verifies basic functionalities of key features and basic DFX attributes with common input. The pass result indicates that the features are testable.</p>
89</td>
90</tr>
91<tr id="row12856137204514"><td class="cellrowborder" valign="top" width="33.333333333333336%" headers="mcps1.2.4.1.1 "><p id="p164834520453"><a name="p164834520453"></a><a name="p164834520453"></a>Level2</p>
92</td>
93<td class="cellrowborder" valign="top" width="33.283328332833285%" headers="mcps1.2.4.1.2 "><p id="p148245184511"><a name="p148245184511"></a><a name="p148245184511"></a>Major</p>
94</td>
95<td class="cellrowborder" valign="top" width="33.383338333833386%" headers="mcps1.2.4.1.3 "><p id="p348945124510"><a name="p348945124510"></a><a name="p348945124510"></a>Verifies basic functionalities of key features and basic DFX attributes with common input and errors. The pass result indicates that the features are functional and ready for beta testing.</p>
96</td>
97</tr>
98<tr id="row48571137204514"><td class="cellrowborder" valign="top" width="33.333333333333336%" headers="mcps1.2.4.1.1 "><p id="p7481545184513"><a name="p7481545184513"></a><a name="p7481545184513"></a>Level3</p>
99</td>
100<td class="cellrowborder" valign="top" width="33.283328332833285%" headers="mcps1.2.4.1.2 "><p id="p1748184514455"><a name="p1748184514455"></a><a name="p1748184514455"></a>Regular</p>
101</td>
102<td class="cellrowborder" valign="top" width="33.383338333833386%" headers="mcps1.2.4.1.3 "><p id="p8481245104519"><a name="p8481245104519"></a><a name="p8481245104519"></a>Verifies functionalities of all key features, and all DFX attributes with common and uncommon input combinations or normal and abnormal preset conditions.</p>
103</td>
104</tr>
105<tr id="row14857133712451"><td class="cellrowborder" valign="top" width="33.333333333333336%" headers="mcps1.2.4.1.1 "><p id="p1248144515456"><a name="p1248144515456"></a><a name="p1248144515456"></a>Level4</p>
106</td>
107<td class="cellrowborder" valign="top" width="33.283328332833285%" headers="mcps1.2.4.1.2 "><p id="p94804514519"><a name="p94804514519"></a><a name="p94804514519"></a>Rare</p>
108</td>
109<td class="cellrowborder" valign="top" width="33.383338333833386%" headers="mcps1.2.4.1.3 "><p id="p1248445164516"><a name="p1248445164516"></a><a name="p1248445164516"></a>Verifies functionalities of key features under extremely abnormal presets and uncommon input combinations.</p>
110</td>
111</tr>
112</tbody>
113</table>
114
115**Table  2**  Test case granularities
116
117<a name="table1690733521014"></a>
118<table><thead align="left"><tr id="row9907143516105"><th class="cellrowborder" valign="top" width="19.591959195919593%" id="mcps1.2.4.1.1"><p id="p1141312416102"><a name="p1141312416102"></a><a name="p1141312416102"></a>Test Scale</p>
119</th>
120<th class="cellrowborder" valign="top" width="35.17351735173517%" id="mcps1.2.4.1.2"><p id="p34131416109"><a name="p34131416109"></a><a name="p34131416109"></a>Test Objects</p>
121</th>
122<th class="cellrowborder" valign="top" width="45.23452345234523%" id="mcps1.2.4.1.3"><p id="p12413141171010"><a name="p12413141171010"></a><a name="p12413141171010"></a>Test Environment</p>
123</th>
124</tr>
125</thead>
126<tbody><tr id="row2907335181017"><td class="cellrowborder" valign="top" width="19.591959195919593%" headers="mcps1.2.4.1.1 "><p id="p6414134117109"><a name="p6414134117109"></a><a name="p6414134117109"></a>LargeTest</p>
127</td>
128<td class="cellrowborder" valign="top" width="35.17351735173517%" headers="mcps1.2.4.1.2 "><p id="p20414104113101"><a name="p20414104113101"></a><a name="p20414104113101"></a>Service functionalities, all-scenario features, and mechanical power environment (MPE) and scenario-level DFX</p>
129</td>
130<td class="cellrowborder" valign="top" width="45.23452345234523%" headers="mcps1.2.4.1.3 "><p id="p5414841121013"><a name="p5414841121013"></a><a name="p5414841121013"></a>Devices close to real devices</p>
131</td>
132</tr>
133<tr id="row10907635131015"><td class="cellrowborder" valign="top" width="19.591959195919593%" headers="mcps1.2.4.1.1 "><p id="p19414134117104"><a name="p19414134117104"></a><a name="p19414134117104"></a>MediumTest</p>
134</td>
135<td class="cellrowborder" valign="top" width="35.17351735173517%" headers="mcps1.2.4.1.2 "><p id="p114141241141018"><a name="p114141241141018"></a><a name="p114141241141018"></a>Modules, subsystem functionalities after module integration, and DFX</p>
136</td>
137<td class="cellrowborder" valign="top" width="45.23452345234523%" headers="mcps1.2.4.1.3 "><p id="p14414941111015"><a name="p14414941111015"></a><a name="p14414941111015"></a>Single device that is actually used. You can perform message simulation, but do not mock functions.</p>
138</td>
139</tr>
140<tr id="row1990713353100"><td class="cellrowborder" valign="top" width="19.591959195919593%" headers="mcps1.2.4.1.1 "><p id="p641414110109"><a name="p641414110109"></a><a name="p641414110109"></a>SmallTest</p>
141</td>
142<td class="cellrowborder" valign="top" width="35.17351735173517%" headers="mcps1.2.4.1.2 "><p id="p54141541181018"><a name="p54141541181018"></a><a name="p54141541181018"></a>Modules, classes, and functions</p>
143</td>
144<td class="cellrowborder" valign="top" width="45.23452345234523%" headers="mcps1.2.4.1.3 "><p id="p1841494131013"><a name="p1841494131013"></a><a name="p1841494131013"></a>Local PC. Use a large number of mocks to replace dependencies with other modules.</p>
145</td>
146</tr>
147</tbody>
148</table>
149
150**Table  3**  Test types
151
152<a name="table18811230124619"></a>
153<table><thead align="left"><tr id="row48163019466"><th class="cellrowborder" valign="top" width="19.040000000000003%" id="mcps1.2.3.1.1"><p id="p1791784418465"><a name="p1791784418465"></a><a name="p1791784418465"></a>Type</p>
154</th>
155<th class="cellrowborder" valign="top" width="80.96%" id="mcps1.2.3.1.2"><p id="p2917164444614"><a name="p2917164444614"></a><a name="p2917164444614"></a>Definition</p>
156</th>
157</tr>
158</thead>
159<tbody><tr id="row682630104615"><td class="cellrowborder" valign="top" width="19.040000000000003%" headers="mcps1.2.3.1.1 "><p id="p1091784414469"><a name="p1091784414469"></a><a name="p1091784414469"></a>Function</p>
160</td>
161<td class="cellrowborder" valign="top" width="80.96%" headers="mcps1.2.3.1.2 "><p id="p16917344104618"><a name="p16917344104618"></a><a name="p16917344104618"></a>Tests the correctness of both service and platform functionalities provided by the tested object for end users or developers.</p>
162</td>
163</tr>
164<tr id="row1821930154611"><td class="cellrowborder" valign="top" width="19.040000000000003%" headers="mcps1.2.3.1.1 "><p id="p591714474612"><a name="p591714474612"></a><a name="p591714474612"></a>Performance</p>
165</td>
166<td class="cellrowborder" valign="top" width="80.96%" headers="mcps1.2.3.1.2 "><p id="p15917154410463"><a name="p15917154410463"></a><a name="p15917154410463"></a>Tests the processing capability of the tested object under specific preset conditions and load models. The processing capability is measured by the service volume that can be processed in a unit time, for example, call per second, frame per second, or event processing volume per second.</p>
167</td>
168</tr>
169<tr id="row13821030104616"><td class="cellrowborder" valign="top" width="19.040000000000003%" headers="mcps1.2.3.1.1 "><p id="p691711440467"><a name="p691711440467"></a><a name="p691711440467"></a>Power</p>
170</td>
171<td class="cellrowborder" valign="top" width="80.96%" headers="mcps1.2.3.1.2 "><p id="p159171544104616"><a name="p159171544104616"></a><a name="p159171544104616"></a>Tests the power consumption of the tested object in a certain period of time under specific preset conditions and load models.</p>
172</td>
173</tr>
174<tr id="row6821330114618"><td class="cellrowborder" valign="top" width="19.040000000000003%" headers="mcps1.2.3.1.1 "><p id="p13917164454612"><a name="p13917164454612"></a><a name="p13917164454612"></a>Reliability</p>
175</td>
176<td class="cellrowborder" valign="top" width="80.96%" headers="mcps1.2.3.1.2 "><p id="p11917194416465"><a name="p11917194416465"></a><a name="p11917194416465"></a>Tests the service performance of the tested object under common and uncommon input conditions, or specified service volume pressure and long-term continuous running pressure. The test covers stability, pressure handling, fault injection, and Monkey test times.</p>
177</td>
178</tr>
179<tr id="row11821930184612"><td class="cellrowborder" valign="top" width="19.040000000000003%" headers="mcps1.2.3.1.1 "><p id="p1691774474618"><a name="p1691774474618"></a><a name="p1691774474618"></a>Security</p>
180</td>
181<td class="cellrowborder" valign="top" width="80.96%" headers="mcps1.2.3.1.2 "><a name="ul112421652121513"></a><a name="ul112421652121513"></a><ul id="ul112421652121513"><li>Tests the capability of defending against security threats, including but not limited to unauthorized access, use, disclosure, damage, modification, and destruction, to ensure information confidentiality, integrity, and availability.</li><li>Tests the privacy protection capability to ensure that the collection, use, retention, disclosure, and disposal of users' private data comply with laws and regulations.</li><li>Tests the compliance with various security specifications, such as security design, security requirements, and security certification of the Ministry of Industry and Information Technology (MIIT).</li></ul>
182</td>
183</tr>
184<tr id="row16825307467"><td class="cellrowborder" valign="top" width="19.040000000000003%" headers="mcps1.2.3.1.1 "><p id="p129188444462"><a name="p129188444462"></a><a name="p129188444462"></a>Global</p>
185</td>
186<td class="cellrowborder" valign="top" width="80.96%" headers="mcps1.2.3.1.2 "><p id="p179186444465"><a name="p179186444465"></a><a name="p179186444465"></a>Tests the internationalized data and localization capabilities of the tested object, including multi-language display, various input/output habits, time formats, and regional features, such as currency, time, and culture taboos.</p>
187</td>
188</tr>
189<tr id="row08211308464"><td class="cellrowborder" valign="top" width="19.040000000000003%" headers="mcps1.2.3.1.1 "><p id="p191814447465"><a name="p191814447465"></a><a name="p191814447465"></a>Compatibility</p>
190</td>
191<td class="cellrowborder" valign="top" width="80.96%" headers="mcps1.2.3.1.2 "><a name="ul186961827111612"></a><a name="ul186961827111612"></a><ul id="ul186961827111612"><li>Tests backward compatibility of an application with its own data, the forward and backward compatibility with the system, and the compatibility with different user data, such as audio file content of the player and smart SMS messages.</li><li>Tests system backward compatibility with its own data and the compatibility of common applications in the ecosystem.</li><li>Tests software compatibility with related hardware.</li></ul>
192</td>
193</tr>
194<tr id="row1782730124618"><td class="cellrowborder" valign="top" width="19.040000000000003%" headers="mcps1.2.3.1.1 "><p id="p13918144134614"><a name="p13918144134614"></a><a name="p13918144134614"></a>User</p>
195</td>
196<td class="cellrowborder" valign="top" width="80.96%" headers="mcps1.2.3.1.2 "><p id="p1291844494611"><a name="p1291844494611"></a><a name="p1291844494611"></a>Tests user experience of the object in real user scenarios. All conclusions and comments should come from the users, which are all subjective evaluation in this case.</p>
197</td>
198</tr>
199<tr id="row58243024617"><td class="cellrowborder" valign="top" width="19.040000000000003%" headers="mcps1.2.3.1.1 "><p id="p1291884474614"><a name="p1291884474614"></a><a name="p1291884474614"></a>Standard</p>
200</td>
201<td class="cellrowborder" valign="top" width="80.96%" headers="mcps1.2.3.1.2 "><p id="p0918124424614"><a name="p0918124424614"></a><a name="p0918124424614"></a>Tests the compliance with industry and company-specific standards, protocols, and specifications. The standards here do not include any security standards that should be classified into the security test.</p>
202</td>
203</tr>
204<tr id="row382830124619"><td class="cellrowborder" valign="top" width="19.040000000000003%" headers="mcps1.2.3.1.1 "><p id="p119181044164619"><a name="p119181044164619"></a><a name="p119181044164619"></a>Safety</p>
205</td>
206<td class="cellrowborder" valign="top" width="80.96%" headers="mcps1.2.3.1.2 "><p id="p1291818443468"><a name="p1291818443468"></a><a name="p1291818443468"></a>Tests the safety property of the tested object to avoid possible hazards to personal safety, health, and the object itself.</p>
207</td>
208</tr>
209<tr id="row1083153014465"><td class="cellrowborder" valign="top" width="19.040000000000003%" headers="mcps1.2.3.1.1 "><p id="p39187441469"><a name="p39187441469"></a><a name="p39187441469"></a>Resilience</p>
210</td>
211<td class="cellrowborder" valign="top" width="80.96%" headers="mcps1.2.3.1.2 "><p id="p891815444462"><a name="p891815444462"></a><a name="p891815444462"></a>Tests the resilience property of the tested object to ensure that it can withstand and maintain the defined running status (including downgrading) when being attacked, and recover from and adapt defense to the attacks to approach mission assurance.</p>
212</td>
213</tr>
214</tbody>
215</table>
216
217## Test Case Development Guidelines<a name="section3695134065513"></a>
218
219You should select the appropriate programming language and your target test framework to develop test cases for the devices to test.
220
221**Table  4**  Test frameworks and test case languages for different devices
222
223<a name="table4418343171415"></a>
224<table><thead align="left"><tr id="row34183435145"><th class="cellrowborder" valign="top" width="33.33333333333333%" id="mcps1.2.4.1.1"><p id="p941874311148"><a name="p941874311148"></a><a name="p941874311148"></a>Device Type</p>
225</th>
226<th class="cellrowborder" valign="top" width="33.33333333333333%" id="mcps1.2.4.1.2"><p id="p1841804341413"><a name="p1841804341413"></a><a name="p1841804341413"></a>Test Framework</p>
227</th>
228<th class="cellrowborder" valign="top" width="33.33333333333333%" id="mcps1.2.4.1.3"><p id="p2418104311148"><a name="p2418104311148"></a><a name="p2418104311148"></a>Language</p>
229</th>
230</tr>
231</thead>
232<tbody><tr id="row8419164319148"><td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.1 "><p id="p7419194312143"><a name="p7419194312143"></a><a name="p7419194312143"></a>Mini-system devices</p>
233</td>
234<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.2 "><p id="p10419124312145"><a name="p10419124312145"></a><a name="p10419124312145"></a>HCTest</p>
235</td>
236<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.3 "><p id="p11419643191410"><a name="p11419643191410"></a><a name="p11419643191410"></a>C</p>
237</td>
238</tr>
239<tr id="row141915438147"><td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.1 "><p id="p441911436141"><a name="p441911436141"></a><a name="p441911436141"></a>Small-system devices</p>
240</td>
241<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.2 "><p id="p541916432142"><a name="p541916432142"></a><a name="p541916432142"></a>HCPPTest</p>
242</td>
243<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.3 "><p id="p54191643131416"><a name="p54191643131416"></a><a name="p54191643131416"></a>C++</p>
244</td>
245</tr>
246<tr id="row4419134341417"><td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.1 "><p id="p341964313143"><a name="p341964313143"></a><a name="p341964313143"></a>Standard-system devices</p>
247</td>
248<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.2 "><p id="p10419443171416"><a name="p10419443171416"></a><a name="p10419443171416"></a>HJUnit and HCPPTest</p>
249</td>
250<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.3 "><p id="p9419143181414"><a name="p9419143181414"></a><a name="p9419143181414"></a>Java and C++</p>
251</td>
252</tr>
253<tr id="row42451815115215"><td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.1 "><p id="p324511515528"><a name="p324511515528"></a><a name="p324511515528"></a>Large-system devices</p>
254</td>
255<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.2 "><p id="p724516151520"><a name="p724516151520"></a><a name="p724516151520"></a>HJUnit and HCPPTest</p>
256</td>
257<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.3 "><p id="p748417474533"><a name="p748417474533"></a><a name="p748417474533"></a>Java and C++</p>
258</td>
259</tr>
260</tbody>
261</table>
262
263### C-based Test Case Development and Compilation \(for Mini-System Devices\)<a name="section1551164914237"></a>
264
265**Developing test cases for mini-system devices**
266
267The HCTest framework is used to support test cases developed with the C language. HCTest is enhanced and adapted based on the open-source test framework Unity.
268
2691.  Access the  **test/xts/acts**  repository where the test cases will be stored.
270
271    ```
272    ├── acts
273    │ └──subsystem_lite
274    │ │ └── module_hal
275    │ │ │ └── BUILD.gn
276    │ │ │ └── src
277    │ └──build_lite
278    │ │ └── BUILD.gn
279    ```
280
2812.  Write the test case in the  **src**  directory.
282
283    1 Import the test framework header file.
284
285    ```
286    #include "hctest.h"
287    ```
288
289    2. Use the  **LITE\_TEST\_SUIT**  macro to define names of the subsystem, module, and test suite.
290
291    ```
292    /**
293    * @brief  Registers a test suite named IntTestSuite.
294    * @param  test Subsystem name
295    * @param  example Module name
296    * @param  IntTestSuite Test suite name
297    */
298    LITE_TEST_SUIT(test, example, IntTestSuite);
299    ```
300
301    3. Define Setup and TearDown.
302
303    Format: Test suite name+Setup, Test suite name+TearDown.
304
305    The Setup and TearDown functions must exist, but function bodies can be empty.
306
307    4. Use the  **LITE\_TEST\_CASE**  macro to write the test case.
308
309    Three parameters are involved: test suite name, test case name, and test case properties \(including type, granularity, and level\).
310
311    ```
312    LITE_TEST_CASE(IntTestSuite, TestCase001, Function | MediumTest | Level1)
313    {
314      // Do something
315    };
316    ```
317
318    5. Use the  **RUN\_TEST\_SUITE**  macro to register the test suite.
319
320    ```
321    RUN_TEST_SUITE(IntTestSuite);
322    ```
323
3243.  Create the configuration file \(**BUILD.gn**\) of the test module.
325
326    Create a  **BUILD.gn**  \(example\) compilation file in each test module directory. Specify the name of the compiled static library and its dependent header file and library in the compilation file. The format is as follows:
327
328    ```
329    import("//test/xts/tools/lite/build/suite_lite.gni")
330    hctest_suite("ActsDemoTest") {
331        suite_name = "acts"
332        sources = [
333            "src/test_demo.c",
334        ]
335        include_dirs = [ ]
336        cflags = [ "-Wno-error" ]
337    }
338    ```
339
3404.  Add compilation options to the  **BUILD.gn**  file in the  **acts**  directory.
341
342    You need to add the test module to the  **test/xts/acts/build\_lite/BUILD.gn**  script in the  **acts**  directory.
343
344    ```
345    lite_component("acts") {
346        ...
347        if(board_name == "liteos_m") {
348            features += [
349                ...
350                "//xts/acts/subsystem_lite/module_hal:ActsDemoTest"
351            ]
352        }
353    }
354    ```
355
3565.  Run compilation commands.
357
358    Test suites are compiled along with version compilation. The ACTS is compiled together with the debug version.
359
360    >![](figures/icon-note.gif) **NOTE:**
361    >The ACTS compiles middleware as a static library, which will be linked to the image.
362
363
364### C-based Test Case Execution \(for Mini-System Devices\)<a name="section10100701294"></a>
365
366**Executing test cases for mini-system devices**
367
368Burn the image into the development board.
369
370**Executing the test**
371
3721.  Use a serial port tool to log in to the development board and save information about the serial port.
3732.  Restart the device and view serial port logs.
374
375**Analyzing the test result**
376
377View the serial port logs, whose format is as follows:
378
379The log for each test suite starts with  **Start to run test suite:**  and ends with  **xx Tests xx Failures xx Ignored**.
380
381### C++-based Test Case Development and Compilation \(for Small-, Standard-, and Large-System Devices\)<a name="section5714177113113"></a>
382
383**Developing test cases for small-system devices**
384
385The HCPPTest framework is enhanced and adapted based on the open-source framework Googletest.
386
3871.  Access the  **test/xts/acts**  repository where the test cases will be stored.
388
389    ```
390    ├── acts
391    │ └──subsystem_lite
392    │ │ └── module_posix
393    │ │ │ └── BUILD.gn
394    │ │ │ └── src
395    │ └──build_lite
396    │ │ └── BUILD.gn
397    ```
398
3992.  Write the test case in the  **src**  directory.
400
401    1. Import the test framework header file.
402
403    The following statement includes  **gtest.h**.
404
405    ```
406    #include "gtest/gtest.h"
407    ```
408
409    2. Define Setup and TearDown.
410
411    ```
412    using namespace std;
413    using namespace testing::ext;
414    class TestSuite: public testing::Test {
415    protected:
416    // Preset action of the test suite, which is executed before the first test case
417    static void SetUpTestCase(void){
418    }
419    // Test suite cleanup action, which is executed after the last test case
420    static void TearDownTestCase(void){
421    }
422    // Preset action of the test case
423    virtual void SetUp()
424    {
425    }
426    // Cleanup action of the test case
427    virtual void TearDown()
428    {
429    }
430    };
431    ```
432
433    3. Use the  **HWTEST**  or  **HWTEST\_F**  macro to write the test case.
434
435    **HWTEST**: definition of common test cases, including the test suite name, test case name, and case annotation.
436
437    **HWTEST\_F**: definition of SetUp and TearDown test cases, including the test suite name, test case name, and case annotation.
438
439    Three parameters are involved: test suite name, test case name, and test case properties \(including type, granularity, and level\).
440
441    ```
442    HWTEST_F(TestSuite, TestCase_0001, Function | MediumTest | Level1) {
443    // Do something
444    }
445    ```
446
4473.  Create a configuration file \(**BUILD.gn**\) of the test module.
448
449    Create a  **BUILD.gn**  compilation file in each test module directory. Specify the name of the compiled static library and its dependent header file and library in the compilation file. Each test module is independently compiled into a  **.bin**  executable file, which can be directly mounted to the development board for testing.
450
451    Example:
452
453    ```
454    import("//test/xts/tools/lite/build/suite_lite.gni")
455    hcpptest_suite("ActsDemoTest") {
456        suite_name = "acts"
457        sources = [
458            "src/TestDemo.cpp"
459        ]
460
461        include_dirs = [
462            "src",
463            ...
464        ]
465        deps = [
466            ...
467        ]
468        cflags = [ "-Wno-error" ]
469    }
470
471    ```
472
4734.  Add compilation options to the  **BUILD.gn**  file in the  **acts**  directory.
474
475    Add the test module to the  **test/xts/acts/build\_lite/BUILD.gn**  script in the  **acts**  directory.
476
477    ```
478     lite_component("acts") {
479    ...
480    else if(board_name == "liteos_a") {
481            features += [
482                ...
483                "//xts/acts/subsystem_lite/module_posix:ActsDemoTest"
484            ]
485        }
486    }
487    ```
488
4895.  Run compilation commands.
490
491    Test suites are compiled along with the version compilation. The ACTS is compiled together with the debug version.
492
493    >![](figures/icon-note.gif) **NOTE:**
494    >The ACTS for a small system device is independently compiled to an executable file \(.bin\) and archived in the  **suites\\acts**  directory of the compilation result.
495
496
497### C++-based Test Case Execution \(for Small-, Standard-, and Large-System Devices\)<a name="section42281924184"></a>
498
499**Executing test cases for small-system devices**
500
501Currently, test cases are shared by the NFS and mounted to the development board for execution.
502
503**Setting up the environment**
504
5051.  Use a network cable or wireless network to connect the development board to your PC.
5062.  Configure the IP address, subnet mask, and gateway for the development board. Ensure that the development board and the PC are in the same network segment.
5073.  Install and register the NFS server on the PC and start the NFS service.
5084.  Run the  **mount**  command for the development board to ensure that the development board can access NFS shared files on the PC.
509
510    Format:  **mount** _NFS server IP address_**:/**_NFS shared directory_ **/**_development board directory_ **nfs**
511
512    Example:
513
514    ```
515    mount 192.168.1.10:/nfs /nfs nfs
516    ```
517
518
519**Executing test cases**
520
521Execute  **ActsDemoTest.bin**  to trigger test case execution, and analyze serial port logs generated after the execution is complete.
522
523## Repositories Involved<a name="section1371113476307"></a>
524
525[X Test Suite](https://gitee.com/openharmony/docs/blob/master/en/readme/xts.md)
526
527[xts\_acts](https://gitee.com/openharmony/xts_acts/blob/master/README.md)
528
529**xts\_tools**
530
531

README_zh.md

1# XTS认证子系统开发指南<a name="ZH-CN_TOPIC_0000001132537809"></a>
2
3-   [简介](#section465982318513)
4-   [设备类型](#section125090457443)
5-   [目录](#section161941989596)
6-   [约束](#section119744591305)
7-   [使用说明](#section137768191623)
8-   [用例开发指导](#section3695134065513)
9    -   [C语言用例开发编译指导(适用于轻量系统类设备产品用例开发)](#section1551164914237)
10    -   [C语言用例执行指导(适用于轻量系统类设备产品用例开发)](#section10100701294)
11    -   [C++语言用例开发编译指导(适用于小型系统类设备、标准系统类设备、大型系统类设备用例开发)](#section5714177113113)
12    -   [C++语言用例执行指导(适用于小型系统类设备、标准系统类设备、大型系统类设备用例开发)](#section42281924184)
13
14-   [相关仓](#section1371113476307)
15
16## 简介<a name="section465982318513"></a>
17
18XTS子系统是OpenHarmony生态认证测试套件的集合,当前包括acts(application compatibility test suite)应用兼容性测试套件,后续会拓展dcts(device compatibility test suite)设备兼容性测试套件等。
19
20XTS子系统当前包括acts与tools软件包:
21
22-   acts,存放acts相关测试用例源码与配置文件,其目的是帮助终端设备厂商尽早发现软件与OpenHarmony的不兼容性,确保软件在整个开发过程中满足OpenHarmony的兼容性要求。
23-   tools,存放acts相关测试用例开发框架。
24
25## 设备类型<a name="section125090457443"></a>
26
27OpenHarmony支持如下几种设备类型:
28
29-   **轻量系统类设备(参考内存≥128KB)**
30
31    面向MCU类处理器,例如Arm Cortex-M、RISC-V 32位的设备,资源极其有限,参考内存≥128KB,提供丰富的近距连接能力以及丰富的外设总线访问能力。典型产品有智能家居领域的联接类模组、传感器设备等。联接类模组通常应用在智能物联网设备中,负责实现联接部分的硬件模块,在智能家居领域由厂家集成到其设备中。例如:联接类模组提供WLAN/Bluetooth的接入和数据的联接,模组与厂家家居的芯片通常通过UART或GPIO等总线接口进行通信。
32
33-   **小型系统类设备(参考内存≥1MB)**
34
35    面向应用处理器,例如Arm Cortex-A的设备,参考内存≥1MB,提供更高的安全能力,提供标准的图形框架,提供视频编解码的多媒体能力。典型产品有智能家居领域的IPCamera、电子猫眼、路由器以及智慧出行域的行车记录仪等。
36
37
38-   **标准系统类设备(参考内存≥128MB)**
39
40    面向应用处理器,例如Arm Cortex-A的设备,参考内存≥128MB,提供增强的交互能力,提供3D GPU以及硬件合成能力,提供更多控件以及动效更丰富的图形能力,提供完整的应用框架。典型产品有高端的冰箱显示屏等。
41
42-   **大型系统类设备(参考内存≥1GB)**
43
44    面向应用处理器,例如Arm Cortex-A的设备,参考内存≥1GB,提供完整的兼容应用框架。典型的产品有智慧屏、智能手表等。
45
46
47## 目录<a name="section161941989596"></a>
48
49```
50/test/xts
51├── acts                 # 测试代码存放目录
52│   └── subsystem       # 大型系统类设备子系统测试用例源码存放目录
53│   └── subsystem_lite  # 轻量系统类设备、小型系统类设备子系统测试用例源码存放目录
54│   └── BUILD.gn        # 大型系统类设备测试用例编译配置
55│   └── build_lite      # 轻量系统类设备、小型系统类设备测试用例编译配置存放目录
56│       └── BUILD.gn    # 轻量系统类设备、小型系统类设备测试用例编译配置
57└── tools                # 测试工具代码存放目录
58```
59
60## 约束<a name="section119744591305"></a>
61
62轻量系统类设备用例开发语言是C,小型系统类设备用例开发语言是C++。
63
64## 使用说明<a name="section137768191623"></a>
65
66**表 1**  用例级别说明
67
68<a name="table12856113719456"></a>
69<table><thead align="left"><tr id="row88561737114517"><th class="cellrowborder" valign="top" width="33.333333333333336%" id="mcps1.2.4.1.1"><p id="p54711456452"><a name="p54711456452"></a><a name="p54711456452"></a>级别名称</p>
70</th>
71<th class="cellrowborder" valign="top" width="33.283328332833285%" id="mcps1.2.4.1.2"><p id="p114834544518"><a name="p114834544518"></a><a name="p114834544518"></a>基本定义</p>
72</th>
73<th class="cellrowborder" valign="top" width="33.383338333833386%" id="mcps1.2.4.1.3"><p id="p348154574518"><a name="p348154574518"></a><a name="p348154574518"></a>测试范围</p>
74</th>
75</tr>
76</thead>
77<tbody><tr id="row78561137134514"><td class="cellrowborder" valign="top" width="33.333333333333336%" headers="mcps1.2.4.1.1 "><p id="p17481345124512"><a name="p17481345124512"></a><a name="p17481345124512"></a>Level0</p>
78</td>
79<td class="cellrowborder" valign="top" width="33.283328332833285%" headers="mcps1.2.4.1.2 "><p id="p1548945204514"><a name="p1548945204514"></a><a name="p1548945204514"></a>冒烟</p>
80</td>
81<td class="cellrowborder" valign="top" width="33.383338333833386%" headers="mcps1.2.4.1.3 "><p id="p174824517456"><a name="p174824517456"></a><a name="p174824517456"></a>验证关键功能点基本功能/最基本DFX属性在最常见输入下的表现,通过表示功能基本可运行。</p>
82</td>
83</tr>
84<tr id="row28563372451"><td class="cellrowborder" valign="top" width="33.333333333333336%" headers="mcps1.2.4.1.1 "><p id="p448445144512"><a name="p448445144512"></a><a name="p448445144512"></a>Level1</p>
85</td>
86<td class="cellrowborder" valign="top" width="33.283328332833285%" headers="mcps1.2.4.1.2 "><p id="p44813452452"><a name="p44813452452"></a><a name="p44813452452"></a>基本</p>
87</td>
88<td class="cellrowborder" valign="top" width="33.383338333833386%" headers="mcps1.2.4.1.3 "><p id="p648184584514"><a name="p648184584514"></a><a name="p648184584514"></a>验证各功能点基本功能/基本DFX属性在常见输入下的表现,通过表示功能基本可测试。</p>
89</td>
90</tr>
91<tr id="row12856137204514"><td class="cellrowborder" valign="top" width="33.333333333333336%" headers="mcps1.2.4.1.1 "><p id="p164834520453"><a name="p164834520453"></a><a name="p164834520453"></a>Level2</p>
92</td>
93<td class="cellrowborder" valign="top" width="33.283328332833285%" headers="mcps1.2.4.1.2 "><p id="p148245184511"><a name="p148245184511"></a><a name="p148245184511"></a>重要</p>
94</td>
95<td class="cellrowborder" valign="top" width="33.383338333833386%" headers="mcps1.2.4.1.3 "><p id="p348945124510"><a name="p348945124510"></a><a name="p348945124510"></a>验证各功能点的基本功能/基本DFX属性在常规输入/常见异常情况下的表现,通过表示功能基本正常可用,可开展Beta。</p>
96</td>
97</tr>
98<tr id="row48571137204514"><td class="cellrowborder" valign="top" width="33.333333333333336%" headers="mcps1.2.4.1.1 "><p id="p7481545184513"><a name="p7481545184513"></a><a name="p7481545184513"></a>Level3</p>
99</td>
100<td class="cellrowborder" valign="top" width="33.283328332833285%" headers="mcps1.2.4.1.2 "><p id="p1748184514455"><a name="p1748184514455"></a><a name="p1748184514455"></a>一般</p>
101</td>
102<td class="cellrowborder" valign="top" width="33.383338333833386%" headers="mcps1.2.4.1.3 "><p id="p8481245104519"><a name="p8481245104519"></a><a name="p8481245104519"></a>验证各功能点的全部功能/全部DFX属性在各种常规/非常规输入组合下,或各种正常/异常预置条件组合下的表现。</p>
103</td>
104</tr>
105<tr id="row14857133712451"><td class="cellrowborder" valign="top" width="33.333333333333336%" headers="mcps1.2.4.1.1 "><p id="p1248144515456"><a name="p1248144515456"></a><a name="p1248144515456"></a>Level4</p>
106</td>
107<td class="cellrowborder" valign="top" width="33.283328332833285%" headers="mcps1.2.4.1.2 "><p id="p94804514519"><a name="p94804514519"></a><a name="p94804514519"></a>生僻</p>
108</td>
109<td class="cellrowborder" valign="top" width="33.383338333833386%" headers="mcps1.2.4.1.3 "><p id="p1248445164516"><a name="p1248445164516"></a><a name="p1248445164516"></a>验证关键功能点在极端异常预置条件下、用户难以触及的异常输入组合下的表现。</p>
110</td>
111</tr>
112</tbody>
113</table>
114
115**表 2**  用例粒度说明
116
117<a name="table1690733521014"></a>
118<table><thead align="left"><tr id="row9907143516105"><th class="cellrowborder" valign="top" width="19.591959195919593%" id="mcps1.2.4.1.1"><p id="p1141312416102"><a name="p1141312416102"></a><a name="p1141312416102"></a>用例规模</p>
119</th>
120<th class="cellrowborder" valign="top" width="35.17351735173517%" id="mcps1.2.4.1.2"><p id="p34131416109"><a name="p34131416109"></a><a name="p34131416109"></a>被测试对象</p>
121</th>
122<th class="cellrowborder" valign="top" width="45.23452345234523%" id="mcps1.2.4.1.3"><p id="p12413141171010"><a name="p12413141171010"></a><a name="p12413141171010"></a>测试环境</p>
123</th>
124</tr>
125</thead>
126<tbody><tr id="row2907335181017"><td class="cellrowborder" valign="top" width="19.591959195919593%" headers="mcps1.2.4.1.1 "><p id="p6414134117109"><a name="p6414134117109"></a><a name="p6414134117109"></a>LargeTest</p>
127</td>
128<td class="cellrowborder" valign="top" width="35.17351735173517%" headers="mcps1.2.4.1.2 "><p id="p20414104113101"><a name="p20414104113101"></a><a name="p20414104113101"></a>业务功能/全场景特性/整机及场景级DFX</p>
129</td>
130<td class="cellrowborder" valign="top" width="45.23452345234523%" headers="mcps1.2.4.1.3 "><p id="p5414841121013"><a name="p5414841121013"></a><a name="p5414841121013"></a>尽量使用贴近真实的环境设备</p>
131</td>
132</tr>
133<tr id="row10907635131015"><td class="cellrowborder" valign="top" width="19.591959195919593%" headers="mcps1.2.4.1.1 "><p id="p19414134117104"><a name="p19414134117104"></a><a name="p19414134117104"></a>MediumTest</p>
134</td>
135<td class="cellrowborder" valign="top" width="35.17351735173517%" headers="mcps1.2.4.1.2 "><p id="p114141241141018"><a name="p114141241141018"></a><a name="p114141241141018"></a>模块/子系统集成至设备后的功能/DFX</p>
136</td>
137<td class="cellrowborder" valign="top" width="45.23452345234523%" headers="mcps1.2.4.1.3 "><p id="p14414941111015"><a name="p14414941111015"></a><a name="p14414941111015"></a>使用真实的单设备进行验证,可进行消息模拟,尽量不对函数进行MOCK</p>
138</td>
139</tr>
140<tr id="row1990713353100"><td class="cellrowborder" valign="top" width="19.591959195919593%" headers="mcps1.2.4.1.1 "><p id="p641414110109"><a name="p641414110109"></a><a name="p641414110109"></a>SmallTest</p>
141</td>
142<td class="cellrowborder" valign="top" width="35.17351735173517%" headers="mcps1.2.4.1.2 "><p id="p54141541181018"><a name="p54141541181018"></a><a name="p54141541181018"></a>模块/类/函数</p>
143</td>
144<td class="cellrowborder" valign="top" width="45.23452345234523%" headers="mcps1.2.4.1.3 "><p id="p1841494131013"><a name="p1841494131013"></a><a name="p1841494131013"></a>在开发者个人环境进行测试,尽量不依赖其他模块,存在大量的MOCK</p>
145</td>
146</tr>
147</tbody>
148</table>
149
150**表 3**  测试类型说明
151
152<a name="table18811230124619"></a>
153<table><thead align="left"><tr id="row48163019466"><th class="cellrowborder" valign="top" width="19.040000000000003%" id="mcps1.2.3.1.1"><p id="p1791784418465"><a name="p1791784418465"></a><a name="p1791784418465"></a>测试类型名称</p>
154</th>
155<th class="cellrowborder" valign="top" width="80.96%" id="mcps1.2.3.1.2"><p id="p2917164444614"><a name="p2917164444614"></a><a name="p2917164444614"></a>测试类型定义</p>
156</th>
157</tr>
158</thead>
159<tbody><tr id="row682630104615"><td class="cellrowborder" valign="top" width="19.040000000000003%" headers="mcps1.2.3.1.1 "><p id="p1091784414469"><a name="p1091784414469"></a><a name="p1091784414469"></a>Function</p>
160</td>
161<td class="cellrowborder" valign="top" width="80.96%" headers="mcps1.2.3.1.2 "><p id="p16917344104618"><a name="p16917344104618"></a><a name="p16917344104618"></a>验证被测对象提供给用户的业务功能实现正确性的测试项,这里的“用户”可以是终端用户或开发者,功能包括业务功能及平台功能</p>
162</td>
163</tr>
164<tr id="row1821930154611"><td class="cellrowborder" valign="top" width="19.040000000000003%" headers="mcps1.2.3.1.1 "><p id="p591714474612"><a name="p591714474612"></a><a name="p591714474612"></a>Performance</p>
165</td>
166<td class="cellrowborder" valign="top" width="80.96%" headers="mcps1.2.3.1.2 "><p id="p15917154410463"><a name="p15917154410463"></a><a name="p15917154410463"></a>验证被测对象在特定预置条件/负载模型下的处理能力的测试项,“处理能力”一般以单位时间内可处理的业务量来衡量,如呼叫/秒,帧率/秒,事件处理量/秒等</p>
167</td>
168</tr>
169<tr id="row13821030104616"><td class="cellrowborder" valign="top" width="19.040000000000003%" headers="mcps1.2.3.1.1 "><p id="p691711440467"><a name="p691711440467"></a><a name="p691711440467"></a>Power</p>
170</td>
171<td class="cellrowborder" valign="top" width="80.96%" headers="mcps1.2.3.1.2 "><p id="p159171544104616"><a name="p159171544104616"></a><a name="p159171544104616"></a>验证被测对象在特定预置条件/负载模型下在一定时间内能源消耗量的测试项</p>
172</td>
173</tr>
174<tr id="row6821330114618"><td class="cellrowborder" valign="top" width="19.040000000000003%" headers="mcps1.2.3.1.1 "><p id="p13917164454612"><a name="p13917164454612"></a><a name="p13917164454612"></a>Reliability</p>
175</td>
176<td class="cellrowborder" valign="top" width="80.96%" headers="mcps1.2.3.1.2 "><p id="p11917194416465"><a name="p11917194416465"></a><a name="p11917194416465"></a>验证被测对象在正常/异常输入情况下,或业务量压力和长时间连续运行压力情况下业务表现的测试项,含稳定性、压力、故障注入、Monkey测试项</p>
177</td>
178</tr>
179<tr id="row11821930184612"><td class="cellrowborder" valign="top" width="19.040000000000003%" headers="mcps1.2.3.1.1 "><p id="p1691774474618"><a name="p1691774474618"></a><a name="p1691774474618"></a>Security</p>
180</td>
181<td class="cellrowborder" valign="top" width="80.96%" headers="mcps1.2.3.1.2 "><p id="p1791784410463"><a name="p1791784410463"></a><a name="p1791784410463"></a>验证系统对恶意威胁的防护能力,威胁包括但不限于未授权访问、使用、泄露、破坏、修改、毁灭,以保障信息的机密性、完整性和可用性; 验证系统对用户隐私的保护能力,保障用户的隐私数据被收集、使用、保有、披露和处置符合法律规范,保障用户的隐私权; 验证对各类安全规范的遵从情况,如安全设计规范、安全红线、工信部安全认证规范等,保障安全相关法律法规的合规。</p>
182</td>
183</tr>
184<tr id="row16825307467"><td class="cellrowborder" valign="top" width="19.040000000000003%" headers="mcps1.2.3.1.1 "><p id="p129188444462"><a name="p129188444462"></a><a name="p129188444462"></a>Global</p>
185</td>
186<td class="cellrowborder" valign="top" width="80.96%" headers="mcps1.2.3.1.2 "><p id="p179186444465"><a name="p179186444465"></a><a name="p179186444465"></a>验证被测对象在是否具有国际化数据支持和本地化能力的测试项,包括语言显示、输入/输出习惯、时间显示、区域特性如货币时间禁忌等等</p>
187</td>
188</tr>
189<tr id="row08211308464"><td class="cellrowborder" valign="top" width="19.040000000000003%" headers="mcps1.2.3.1.1 "><p id="p191814447465"><a name="p191814447465"></a><a name="p191814447465"></a>Compatibility</p>
190</td>
191<td class="cellrowborder" valign="top" width="80.96%" headers="mcps1.2.3.1.2 "><p id="p99181344144613"><a name="p99181344144613"></a><a name="p99181344144613"></a>当被测对象为应用时,包括被测对象对于自身数据的后向兼容性、对于系统的前后向兼容性、对于不同用户数据(如播放器之音频文件格式/智能短信之用户短信内容)的兼容性测试项; 当被测对象为系统时,包括被测系统对于系统自身数据的后向兼容性、以及对于生态中常用应用的兼容性测试项;当被测对象为软件时,包括被测系统对于相关的硬件的兼容性;</p>
192</td>
193</tr>
194<tr id="row1782730124618"><td class="cellrowborder" valign="top" width="19.040000000000003%" headers="mcps1.2.3.1.1 "><p id="p13918144134614"><a name="p13918144134614"></a><a name="p13918144134614"></a>User</p>
195</td>
196<td class="cellrowborder" valign="top" width="80.96%" headers="mcps1.2.3.1.2 "><p id="p1291844494611"><a name="p1291844494611"></a><a name="p1291844494611"></a>验证被测对象在真实用户场景下的用户体验感受的测试项,注意此种情况下没有客观的“正确”与“失败”,所有的结论及评价都应该来自于用户</p>
197</td>
198</tr>
199<tr id="row58243024617"><td class="cellrowborder" valign="top" width="19.040000000000003%" headers="mcps1.2.3.1.1 "><p id="p1291884474614"><a name="p1291884474614"></a><a name="p1291884474614"></a>Standard</p>
200</td>
201<td class="cellrowborder" valign="top" width="80.96%" headers="mcps1.2.3.1.2 "><p id="p0918124424614"><a name="p0918124424614"></a><a name="p0918124424614"></a>验证被测对象对于行业及公司内标准/协议/规范的遵从情况的测试项,注意此处的“标准”不包含任何安全标准,针对安全标准的测试项划归为“安全测试”类型</p>
202</td>
203</tr>
204<tr id="row382830124619"><td class="cellrowborder" valign="top" width="19.040000000000003%" headers="mcps1.2.3.1.1 "><p id="p119181044164619"><a name="p119181044164619"></a><a name="p119181044164619"></a>Safety</p>
205</td>
206<td class="cellrowborder" valign="top" width="80.96%" headers="mcps1.2.3.1.2 "><p id="p1291818443468"><a name="p1291818443468"></a><a name="p1291818443468"></a>验证被测对象的Safety属性,避免产品可能对人身安全、健康以及产品本身带来的危害。</p>
207</td>
208</tr>
209<tr id="row1083153014465"><td class="cellrowborder" valign="top" width="19.040000000000003%" headers="mcps1.2.3.1.1 "><p id="p39187441469"><a name="p39187441469"></a><a name="p39187441469"></a>Resilience</p>
210</td>
211<td class="cellrowborder" valign="top" width="80.96%" headers="mcps1.2.3.1.2 "><p id="p891815444462"><a name="p891815444462"></a><a name="p891815444462"></a>验证被测对象的韧性属性,确保系统受攻击时承受并保持在有定义的运行状态(包括降级)、恢复并适应攻击以保障Mission达成。</p>
212</td>
213</tr>
214</tbody>
215</table>
216
217## 用例开发指导<a name="section3695134065513"></a>
218
219根据测试设备选择测试框架和对应测试用例语言。
220
221**表 4**  设备和测试框架、开发语言对应关系
222
223<a name="table4418343171415"></a>
224<table><thead align="left"><tr id="row34183435145"><th class="cellrowborder" valign="top" width="33.33333333333333%" id="mcps1.2.4.1.1"><p id="p941874311148"><a name="p941874311148"></a><a name="p941874311148"></a>设备</p>
225</th>
226<th class="cellrowborder" valign="top" width="33.33333333333333%" id="mcps1.2.4.1.2"><p id="p1841804341413"><a name="p1841804341413"></a><a name="p1841804341413"></a>测试框架</p>
227</th>
228<th class="cellrowborder" valign="top" width="33.33333333333333%" id="mcps1.2.4.1.3"><p id="p2418104311148"><a name="p2418104311148"></a><a name="p2418104311148"></a>语言</p>
229</th>
230</tr>
231</thead>
232<tbody><tr id="row8419164319148"><td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.1 "><p id="p7419194312143"><a name="p7419194312143"></a><a name="p7419194312143"></a>轻量系统类设备</p>
233</td>
234<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.2 "><p id="p10419124312145"><a name="p10419124312145"></a><a name="p10419124312145"></a>hctest</p>
235</td>
236<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.3 "><p id="p11419643191410"><a name="p11419643191410"></a><a name="p11419643191410"></a>c</p>
237</td>
238</tr>
239<tr id="row141915438147"><td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.1 "><p id="p441911436141"><a name="p441911436141"></a><a name="p441911436141"></a>小型系统类设备</p>
240</td>
241<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.2 "><p id="p541916432142"><a name="p541916432142"></a><a name="p541916432142"></a>hcpptest</p>
242</td>
243<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.3 "><p id="p54191643131416"><a name="p54191643131416"></a><a name="p54191643131416"></a>c++</p>
244</td>
245</tr>
246<tr id="row4419134341417"><td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.1 "><p id="p341964313143"><a name="p341964313143"></a><a name="p341964313143"></a>标准系统类设备</p>
247</td>
248<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.2 "><p id="p10419443171416"><a name="p10419443171416"></a><a name="p10419443171416"></a>HJUnit、hcpptest</p>
249</td>
250<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.3 "><p id="p9419143181414"><a name="p9419143181414"></a><a name="p9419143181414"></a>java、c++</p>
251</td>
252</tr>
253<tr id="row42451815115215"><td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.1 "><p id="p324511515528"><a name="p324511515528"></a><a name="p324511515528"></a>大型系统类设备</p>
254</td>
255<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.2 "><p id="p724516151520"><a name="p724516151520"></a><a name="p724516151520"></a>HJUnit、hcpptest</p>
256</td>
257<td class="cellrowborder" valign="top" width="33.33333333333333%" headers="mcps1.2.4.1.3 "><p id="p748417474533"><a name="p748417474533"></a><a name="p748417474533"></a>java、c++</p>
258</td>
259</tr>
260</tbody>
261</table>
262
263### C语言用例开发编译指导(适用于轻量系统类设备产品用例开发)<a name="section1551164914237"></a>
264
265**示例:轻量系统类设备测试用例开发**
266
267当前使用的测试框架是hctest,hctest测试框架支持使用C语言编写测试用例,是在开源测试框架unity的基础上进行增强和适配。
268
2691.  用例目录规范:测试用例存储到test/xts/acts仓中
270
271    ```
272    ├── acts
273    │ └──subsystem_lite
274    │ │ └── module_hal
275    │ │ │ └── BUILD.gn
276    │ │ │ └── src
277    │ └──build_lite
278    │ │ └── BUILD.gn
279    ```
280
2812.  src目录下用例编写样例。
282
283    1.引用测试框架
284
285    ```
286    #include "hctest.h"
287    ```
288
289    2. 使用宏定义LITE\_TEST\_SUIT定义子系统、模块、测试套件名称
290
291    ```
292    /**
293    * @brief  register a test suit named "IntTestSuite"
294    * @param  test subsystem name
295    * @param  example module name
296    * @param  IntTestSuite test suit name
297    */
298    LITE_TEST_SUIT(test, example, IntTestSuite);
299    ```
300
301    3. 定义Setup与TearDown
302
303    命名方式:测试套件名称+Setup,测试套件名称+TearDown。
304
305    Setup与TearDown必须存在,可以为空函数。
306
307    4. 使用宏定义LITE\_TEST\_CASE写测试用例
308
309    包括三个参数:测试套件名称,测试用例名称,用例属性(测试类型、用例粒度、用例级别)。
310
311    ```
312    LITE_TEST_CASE(IntTestSuite, TestCase001, Function | MediumTest | Level1)
313    {
314      //do something
315    };
316    ```
317
318    5. 使用宏定义 RUN\_TEST\_SUITE注册测试套件
319
320    ```
321    RUN_TEST_SUITE(IntTestSuite);
322    ```
323
3243.  测试模块的配置文件(BUILD.gn)样例:
325
326    在每个测试模块目录下新建BUILD.gn编译文件,用于指定编译后静态库的名称、依赖的头文件、依赖的库等;具体写法如下:
327
328    ```
329    import("//test/xts/tools/lite/build/suite_lite.gni")
330    hctest_suite("ActsDemoTest") {
331        suite_name = "acts"
332        sources = [
333            "src/test_demo.c",
334        ]
335        include_dirs = [ ]
336        cflags = [ "-Wno-error" ]
337    }
338    ```
339
3404.  acts下BUILD.gn增加编译选项。
341
342    需要将测试模块加入到acts目录下的编译脚本中,编译脚本路径:test/xts/acts/build\_lite/BUILD.gn343
344    ```
345    lite_component("acts") {
346        ...
347        if(board_name == "liteos_m") {
348            features += [
349                ...
350                "//xts/acts/subsystem_lite/module_hal:ActsDemoTest"
351            ]
352        }
353    }
354    ```
355
3565.  测试套件编译命令。
357
358    随版本编译,debug版本编译时会同步编译acts测试套件
359
360    >![](figures/icon-note.gif) **说明:**
361    >acts测试套件编译中间件为静态库,最终链接到版本镜像中 。
362
363
364### C语言用例执行指导(适用于轻量系统类设备产品用例开发)<a name="section10100701294"></a>
365
366**示例:轻量系统类设备测试用例执行**
367
368将版本镜像烧录进开发板。
369
370**测试步骤**
371
3721.  使用串口工具登录开发板,并保存串口打印信息。
3732.  重启设备,查看串口日志。
374
375**测试结果分析指导**
376
377基于串口打印日志进行分析;
378
379每个测试套件执行以Start to run test suite开始,以xx Tests xx Failures xx Ignored结束。
380
381### C++语言用例开发编译指导(适用于小型系统类设备、标准系统类设备、大型系统类设备用例开发)<a name="section5714177113113"></a>
382
383**示例:小型系统类设备测试用例开发**
384
385当前使用的测试框架是hcpptest,hcpptest测试框架是在开源的googletest测试框架的基础上进行的增强和适配。
386
3871.  规范用例目录:测试用例存储到test/xts/acts仓中。
388
389    ```
390    ├── acts
391    │ └──subsystem_lite
392    │ │ └── module_posix
393    │ │ │ └── BUILD.gn
394    │ │ │ └── src
395    │ └──build_lite
396    │ │ └── BUILD.gn
397    ```
398
3992.  测试模块src下用例编写样例:
400
401    1. 引用测试框架:
402
403    需要引用gtest.h  如:\#include "gtest/gtest.h"
404
405    ```
406    #include "gtest/gtest.h"
407    ```
408
409    2. 定义Setup与TearDown
410
411    ```
412    using namespace std;
413    using namespace testing::ext;
414    class TestSuite: public testing::Test {
415    protected:
416    // Preset action of the test suite, which is executed before the first test case
417    static void SetUpTestCase(void){
418    }
419    // Test suite cleanup action, which is executed after the last test case
420    static void TearDownTestCase(void){
421    }
422    // Preset action of the test case
423    virtual void SetUp()
424    {
425    }
426    // Cleanup action of the test case
427    virtual void TearDown()
428    {
429    }
430    };
431    ```
432
433    3. 使用宏定义HWTEST或HWTEST\_F写测试用例
434
435    普通测试用例的定义:HWTEST(测试套名称, 测试用例名称, 用例标注)。
436
437    包含SetUp和TearDown的测试用例的定义 :HWTEST\_F(测试套名称, 测试用例名称,用例标注)。
438
439    宏定义包括三个参数:测试套件名称,测试用例名称,用例属性(测试类型、用例粒度、用例级别)。
440
441    ```
442    HWTEST_F(TestSuite, TestCase_0001, Function | MediumTest | Level1) {
443    // do something
444    }
445    ```
446
4473.  测试模块下用例配置文件(BUILD.gn)样例:
448
449    每个测试模块目录下新建BUILD.gn编译文件,用于指定编译后可执行文件的名称、依赖的头文件、依赖的库等;具体写法如下。每个测试模块将独立编译成.bin可执行文件, 该文件可直接mount到单板上进行测试。
450
451    举例:
452
453    ```
454    import("//test/xts/tools/lite/build/suite_lite.gni")
455    hcpptest_suite("ActsDemoTest") {
456        suite_name = "acts"
457        sources = [
458            "src/TestDemo.cpp"
459        ]
460
461        include_dirs = [
462            "src",
463            ...
464        ]
465        deps = [
466            ...
467        ]
468        cflags = [ "-Wno-error" ]
469    }
470
471    ```
472
4734.  acts目录下增加编译选项(BUILD.gn)样例:
474
475    将测试模块加入到acts目录下的编译脚本中,编译脚本为:test/xts/acts/build\_lite/BUILD.gn476
477    ```
478     lite_component("acts") {
479    ...
480    else if(board_name == "liteos_a") {
481            features += [
482                ...
483                "//xts/acts/subsystem_lite/module_posix:ActsDemoTest"
484            ]
485        }
486    }
487    ```
488
4895.  测试套件编译命令。
490
491    随版本编译,debug版本编译时会同步编译acts测试套件
492
493    >![](figures/icon-note.gif) **说明:**
494    >小型系统类设备acts独立编译成可执行文件(bin格式), 在编译产物的suites\\acts目录下归档。
495
496
497### C++语言用例执行指导(适用于小型系统类设备、标准系统类设备、大型系统类设备用例开发)<a name="section42281924184"></a>
498
499**示例:小型系统类设备测试用例执行**
500
501目前的用例执行采用nfs共享的方式,mount到单板去执行。
502
503**环境搭建**
504
5051.  使用有限网线或无线将开发板与PC进行连接。
5062.  开发板配置IP、子网掩码、网关,确保开发板与PC处于同一个网段。
5073.  PC安装nfs服务器并完成注册,启动nfs服务。
5084.  开发板配置mount命令,确保开发板可以访问PC端的nfs共享文件。
509
510    格式:mount \[nfs服务器IP\]:\[/nfs共享目录\] \[/开发板目录\] nfs
511
512    举例:
513
514    ```
515    mount 192.168.1.10:/nfs /nfs nfs
516    ```
517
518
519**用例执行**
520
521测试套件执行 ActsDemoTest.bin 触发用例执行,基于串口打印日志进行分析。
522
523## 相关仓<a name="section1371113476307"></a>
524
525[XTS认证子系统](https://gitee.com/openharmony/docs/blob/master/zh-cn/readme/XTS%E5%AD%90%E7%B3%BB%E7%BB%9F.md)
526
527[xts\_acts](https://gitee.com/openharmony/xts_acts/blob/master/README_zh.md)
528
529**xts\_tools**
530
531