1The test project depends on the source code compilation. Prepare the environment on which the compilation depends by referring to *Build and Installation Guide* to ensure that the source code can be correctly compiled. 2 3## 1. Test Environment Preparation 4 5| **Name**| **Recommended Version**| **Description** | 6| -------- | ------------ | --------------------------------------------------- | 7| Gcc | ≥ 7.3.0 | Linux | 8| Python | ≥ 3.5 | Linux | 9| CMake | ≥ 3.16 | Linux | 10| Sctp | No restriction on versions | Linux | 11 12## 2. Test Code Directory Structure 13 14``` 15./testcode/ 16├── CMakeLists.txt 17├── common 18│ ├── execute_base.c 19│ └── execute_test.c 20├── demo 21├── framework 22│ ├── crypto 23│ ├── gen_test 24│ ├── include 25│ ├── process 26│ ├── stub 27│ └── tls 28├── output 29├── script 30│ ├── all_mini_test.sh 31│ ├── build_hitls.sh 32│ ├── build_sdv.sh 33│ ├── execute_sdv.sh 34│ └── mini_build_test.sh 35├── sdv 36│ ├── CMakeLists.txt 37│ ├── log 38│ ├── report 39│ └── testcase 40└── testdata 41 ├── cert 42 └── tls 43``` 44Where: 45 46- common: common test framework code 47- demo: openHiTLS function test demo 48- framework: framework code of the openHiTLS test case 49- output: output directory of case test results and process files 50- script: directory of test script code 51- sdv: code of the openHiTLS test case for function scenarios 52- testdata: directory of test data 53 54## 3. Function Test Execution Guide 55 56### 3.1 Test Framework Description 57 58A test framework developed by the community provides public configurations and methods for community developers to compile and execute the test code. A test unit consists of a function file (.c) and a data file (.data), which store test functions and test data, respectively. 59 60 61 62### 3.2 Script Parameter Description 63 64| **Command** | **Description** | 65| --------------------------- | ------------------------------------------------------------ | 66| bash build_hitls.sh | Compiles all source codes. | 67| bash build_sdv.sh | Compiles all test codes. | 68| bash execute_sdv.sh | Executes test cases.| 69 70- Parameters of the **build_hitls.sh** script 71 72| **Script Parameter**|**Execution Mode** | **Parameter Description** | 73| -------- | ------------ | --------------------------------------------------- | 74| gcov | bash build_hitls.sh gcov |Enables the capability of obtaining the coverage rate. | 75| debug | bash build_hitls.sh debug |Enables the debug capability. | 76| asan | bash build_hitls.sh asan |Enables the memory monitoring capability. | 77 78- Parameters of the **build_sdv.sh** script 79 80| **Script Parameter**| **Execution Mode** | **Parameter Description** | 81| -------- | ------------ | --------------------------------------------------- | 82| --help or -h | bash build_sdv.sh --help |Obtains help information. | 83| no-crypto | bash build_sdv.sh no-crypto |Deletes the test cases of the crypto module. | 84| no-bsl | bash build_sdv.sh no-bsl | Deletes the test cases of the bsl module. | 85| no-tls | bash build_sdv.sh no-tls | Deletes the test cases of the tls module. | 86| no-pki | bash build_sdv.sh no-pki | Deletes the test cases of the pki module. | 87| no-auth | bash build_sdv.sh no-auth | Deletes the test cases of the auth module. | 88| verbose |bash build_sdv.sh verbose |Displays the detailed information about the build process. | 89| gcov | bash build_sdv.sh gcov | Enables the capability of obtaining the coverage rate. | 90| asan | bash build_sdv.sh asan | Enables the memory monitoring capability. | 91| big-endian |bash build_sdv.sh big-endian | Implements compilation in the big-endian environment. | 92| run-tests | bash build_sdv.sh run-tests=xxx1xxx2xxx3 | Compiles a specified test suite. | 93 94- Parameters of the **execute_sdv.sh** script 95 96| **Script Parameter**| **Execution Mode**| **Parameter Description** | 97| -------- | ------------ | --------------------------------------------------- | 98| \<file name\> | bash execute_sdv.sh test_suites_xxx ... | Executes all test cases in a specified file.| 99| \<test name\> | bash execute_sdv.sh UT_CRYPTO_xxx SDV_CRYPTO_xxx ... |Executes a test case with a specified name. | 100 101Remarks: Parameters can be transferred to the script in combination mode. For example: 102 103- Build the source code in default mode: bash build_hitls.sh 104- Enable ASan, debug, and coverage during source code build: bash build_hitls.sh asan gcov debug 105- Enable ASan and coverage during test code build, and display build details: bash build_sdv.sh asan gcov verbose 106- Build the source code in default mode: bash build_hitls.sh 107- Execute all test cases in default mode: bash execute_sdv.sh 108- Execute a specified test set: bash execute_sdv.sh test_suites_xxx1 test_suites_xxx2 109 110### 3.3 Test Case Execution Process 111 112The test project depends on the following scripts: 113 114- **build_hitls.sh**: script for building the source code in one-click mode 115- **build_sdv.sh**: script for building test cases in one-click mode 116- **execute_sdv.sh**: script for executing test cases in one-click mode 117  118 119### 3.4 Viewing Test Case Results 120 121After the test is complete, you can go to the **output/log** directory to view the test case execution results. If a problem is found in the community repository, check whether there is a trouble ticket in the repository issue. If there is no trouble ticket, submit a trouble ticket to track the problem. 122