From ada184c093313cd90bc5849fae857de2b9bcffe4 Mon Sep 17 00:00:00 2001 From: root Date: Tue, 23 Dec 2025 17:19:31 +0800 Subject: [PATCH] add rpcsvc-proto test case --- .../rpcsvc-proto/tc_rpcsvc-proto_fun001.yaml | 36 ++++++++++ .../rpcsvc-proto/tc_rpcsvc-proto_fun001.py | 66 +++++++++++++++++++ tests/system_base/rpcsvc-proto/text.x | 22 +++++++ 3 files changed, 124 insertions(+) create mode 100644 docs/system_base/rpcsvc-proto/tc_rpcsvc-proto_fun001.yaml create mode 100644 tests/system_base/rpcsvc-proto/tc_rpcsvc-proto_fun001.py create mode 100644 tests/system_base/rpcsvc-proto/text.x diff --git a/docs/system_base/rpcsvc-proto/tc_rpcsvc-proto_fun001.yaml b/docs/system_base/rpcsvc-proto/tc_rpcsvc-proto_fun001.yaml new file mode 100644 index 0000000000..45c49c71cc --- /dev/null +++ b/docs/system_base/rpcsvc-proto/tc_rpcsvc-proto_fun001.yaml @@ -0,0 +1,36 @@ +作者: douzhichong +优先级: P1 +支持架构: noarch +执行方式: 自动 +测试类型: 功能测试 +通用标签: local,rpcgen +用例描述: rpcgen工具基本功能测试 +修改人: douzhichong + +前置条件: +- 系统已安装rpcgen和gcc-c++软件包 +- 已准备test.x测试文件 + +测试步骤: +- 测试rpcgen -C text.x -T命令能够生成头文件 +- 验证rpcgen -C -a -b text.x -I -K 2 -L -M -N -5命令能够生成Makefile文件 +- 检查rpcgen -C text.x -h -i 100命令能够生成包含指定结构体的头文件 +- 检查rpcgen -C text.x -l命令能够生成包含指定函数声明的客户端代码 +- 验证rpcgen -C text.x -m命令能够生成包含XDR过程的服务器端代码 +- 测试rpcgen -C text.x -c -o demo1命令能够生成客户端代码并输出到指定文件 +- 验证rpcgen -C text.x -Sc命令能够显示编译错误信息 +- 测试rpcgen -C text.x -t命令能够生成包含指定结构的代码 +- 检查rpcgen --version命令能够正确显示版本信息 +- 检查rpcgen --help命令能够正确显示帮助信息 + +期望结果: +- rpcgen -C text.x -T命令执行成功并生成text.h文件 +- rpcgen -C -a -b text.x -I -K 2 -L -M -N -5命令执行成功并生成Makefile.text文件 +- rpcgen -C text.x -h -i 100命令输出中包含"extern struct TEST"文本 +- rpcgen -C text.x -l命令输出中包含"test_proc_2(struct"文本 +- rpcgen -C text.x -m命令输出中包含"xdrproc_t _xdr_argument"文本 +- rpcgen -C text.x -c -o demo1命令执行成功并生成demo1文件 +- rpcgen -C text.x -Sc命令输出中包含"usage: %s"文本 +- rpcgen -C text.x -t命令输出中包含"struct rpcgen_table"文本 +- rpcgen --version命令输出中包含版本数字信息 +- rpcgen --help命令输出中包含"usage: rpcgen infile"文本 diff --git a/tests/system_base/rpcsvc-proto/tc_rpcsvc-proto_fun001.py b/tests/system_base/rpcsvc-proto/tc_rpcsvc-proto_fun001.py new file mode 100644 index 0000000000..f106b833bb --- /dev/null +++ b/tests/system_base/rpcsvc-proto/tc_rpcsvc-proto_fun001.py @@ -0,0 +1,66 @@ +""" +@File: tc_rpcsvc-proto_fun001.py +@Time: 2025/12/23 16:30:20 +@Author: douzhichong +@Version: 1.0 +@Contact: douzhichong@inspur.com +@License: Mulan PSL v2 +@Modify: douzhichong +""" +import subprocess + +from common.basetest import LocalTest + + +class Test(LocalTest): + """ + See tc_rpcsvc-proto_fun001.yaml for details + + :avocado: tags=P1,noarch,local,rpcgen + """ + PARAM_DIC = {"pkg_name": "rpcgen gcc-c++"} + + def setUp(self): + super().setUp(self.PARAM_DIC) + self.cmd('mkdir rpscvc') + self.cmd("cp ./tests/system_base/rpcsvc-proto/text.x ./rpscvc/") + + def test(self): + code, result = self.cmd("cd rpscvc && rpcgen -C text.x -T") + self.assertFalse(code, "rpcgen -C text.x -T command failed") + code, result = self.cmd("cd rpscvc && test -f text.h") + self.assertFalse(code, "text.h file not created") + + code, result = self.cmd("cd rpscvc && rpcgen -C -a -b text.x -I -K 2 -L -M -N -5") + self.assertFalse(code, "rpcgen -C -a -b text.x -I -K 2 -L -M -N -5 command failed") + code, result = self.cmd("cd rpscvc && test -f Makefile.text") + self.assertFalse(code, "Makefile.text file not created") + + code, result = self.cmd("cd rpscvc && rpcgen -C text.x -h -i 100 | grep 'extern struct TEST'") + self.assertFalse(code, "Check rpcgen -C text.x -h -i 100 failed") + + code, result = self.cmd("cd rpscvc && rpcgen -C text.x -l | grep 'test_proc_2(struct'") + self.assertFalse(code, "Check rpcgen -C text.x -l failed") + + code, result = self.cmd("cd rpscvc && rpcgen -C text.x -m | grep 'xdrproc_t _xdr_argument'") + self.assertFalse(code, "Check rpcgen -C text.x -m failed") + + code, result = self.cmd("cd rpscvc && rpcgen -C text.x -c -o demo1") + self.assertFalse(code, "rpcgen -C text.x -c -o demo1 command failed") + code, result = self.cmd("cd rpscvc && test -f demo1") + self.assertFalse(code, "demo1 file not created") + + code, result = self.cmd("cd rpscvc && rpcgen -C text.x -Sc | grep 'usage: %s'") + self.assertFalse(code, "Check rpcgen -C text.x -Sc failed") + + code, result = self.cmd("cd rpscvc && rpcgen -C text.x -t | grep 'struct rpcgen_table'") + self.assertFalse(code, "Check rpcgen -C text.x -t failed") + + code, result = self.cmd("cd rpscvc && rpcgen --version | grep 'rpcgen (rpcsvc-proto) [[:digit:]]'") + self.assertFalse(code, "Check rpcgen --version failed") + + code, result = self.cmd("cd rpscvc && rpcgen --help | grep 'usage: rpcgen infile'") + self.assertFalse(code, "Check rpcgen --help failed") + def tearDown(self): + self.cmd('rm -rf rpscvc') + super().tearDown(self.PARAM_DIC) diff --git a/tests/system_base/rpcsvc-proto/text.x b/tests/system_base/rpcsvc-proto/text.x new file mode 100644 index 0000000000..7221226918 --- /dev/null +++ b/tests/system_base/rpcsvc-proto/text.x @@ -0,0 +1,22 @@ +/* filename: test.x */ + +const ADD = 0; +const SUB = 1; +const MUL = 2; +const DIV = 3; + +struct TEST +{ + int op; /* 0-ADD, 1-SUB, 2-MUL, 3-DIV */ + float arg1; + float arg2; + float result; +}; + +program TEST_PROG +{ + version TEST_VER + { + struct TEST TEST_PROC(struct TEST) = 1; + } = 2; +} = 0x20000001; -- Gitee