summaryrefslogtreecommitdiff
path: root/examples/utest/README.md
diff options
context:
space:
mode:
authorguozhanxin <[email protected]>2021-05-10 20:34:33 +0800
committerguozhanxin <[email protected]>2021-05-10 20:34:35 +0800
commit3906f3b948100bfafe03daecf9bc7b1d1ce9fb0b (patch)
treedb874dbd03922c73da70dd4f9664c5b23db1cff0 /examples/utest/README.md
parent5102c32b2697ed9d622276e3292dde8aa43cf5ec (diff)
[add] auto test ci.
Diffstat (limited to 'examples/utest/README.md')
-rw-r--r--examples/utest/README.md79
1 files changed, 79 insertions, 0 deletions
diff --git a/examples/utest/README.md b/examples/utest/README.md
new file mode 100644
index 0000000000..eb54ff170e
--- /dev/null
+++ b/examples/utest/README.md
@@ -0,0 +1,79 @@
+# RT-Thread 测试用例集合
+
+## 简介
+
+为了保证某一部分代码的质量,通常可以通过编写测试用例的方式,验证此代码的功能。为了保证 RT-Thread 的代码质量,我们搭建了一套简易的自动化测试环境。每当向 RT-Thread 提交代码时,都应该编写对应的测试用例,来保证提交的代码能够正常工作。
+
+## 目录结构
+
+| 目录 | 用途 |
+| --------- | ------------------------------------------------------------ |
+| configs | 配置文件集合(每一个目录代表一种功能集合,如:kernel,net等) |
+| testcases | 测试用例源代码 |
+
+## 如何贡献
+
+### 1. 编写测试用例
+
+参考已有的测试用例在 examples\utest\testcases 目录下添加自己的测试用例。测试用例的编写方法参考文档中心《utest 测试框架》章节。
+
+### 2. 本地测试
+
+1. 在 bsp\qemu-vexpress-a9 目录下打开 menuconfig,使能对应的测试用例,如下:
+
+```
+RT-Thread Utestcases --->
+ [*] RT-Thread Utestcases
+ Utest Self Testcase --->
+ [*] Pass test
+```
+
+2. 保存并退出,输入 scons 编译当前 bsp。
+
+3. 输入 .\qemu.bat 运行当前 bsp,在 msh 环境下执行 utest_run 命令,验证代码运行是否正常。
+
+```
+msh />utest_run
+[I/utest] [==========] [ utest ] loop 1/1
+[I/utest] [==========] [ utest ] started
+[I/utest] [----------] [ testcase ] (testcases.utest.pass_tc) started
+[D/utest] [ OK ] [ unit ] (test_assert_pass:16) is passed
+[D/utest] [ OK ] [ unit ] (test_assert_pass:17) is passed
+[D/utest] [ OK ] [ unit ] (test_assert_pass:19) is passed
+[D/utest] [ OK ] [ unit ] (test_assert_pass:20) is passed
+[D/utest] [ OK ] [ unit ] (test_assert_pass:22) is passed
+[D/utest] [ OK ] [ unit ] (test_assert_pass:23) is passed
+[D/utest] [ OK ] [ unit ] (test_assert_pass:25) is passed
+[D/utest] [ OK ] [ unit ] (test_assert_pass:26) is passed
+[D/utest] [ OK ] [ unit ] (test_assert_pass:28) is passed
+[D/utest] [ OK ] [ unit ] (test_assert_pass:29) is passed
+[I/utest] [ PASSED ] [ result ] testcase (testcases.utest.pass_tc)
+[I/utest] [----------] [ testcase ] (testcases.utest.pass_tc) finished
+[I/utest] [==========] [ utest ] finished
+```
+
+### 3. 提交
+
+1. 如果是对已有测试集合的完善,需要把添加的测试用例的配置项添加到对应测试集合的配置文件里,如:`examples\utest\configs\utest_self\config.h`。
+
+```
+/* RT-Thread Utestcases */
+
+#define RT_USING_UTESTCASES
+
+/* Utest Self Testcase */
+
+#define UTEST_SELF_PASS_TC
+
+/* xxx Testcase */
+#define UTEST_XXX_TC
+```
+
+2. 如果要添加新的测试集合,需要参考已有的测试集合,在 `examples\utest\configs` 目录下添加新的测试集合配置项。并更新 `.github\workflows\action_utest.yml` 内的测试集合。
+
+```
+- {UTEST: "kernel/ipc", RTT_BSP: "bsp/qemu-vexpress-a9", QEMU_ARCH: "vexpress-a9", CONFIG_FILE: "examples/utest/configs/utest_self/config.h"}
+- {UTEST: "components/utest", RTT_BSP: "bsp/qemu-vexpress-a9", QEMU_ARCH: "vexpress-a9", CONFIG_FILE: "examples/utest/configs/utest_self/config.h"}
+```
+
+3. 向 RT-Thread 主仓库提交合并请求。 \ No newline at end of file