From 5230a9231e94835b9ed25a411346e4b363876599 Mon Sep 17 00:00:00 2001 From: root Date: Fri, 27 Mar 2026 04:05:44 -0400 Subject: [PATCH] add test_fmt test case --- docs/system_base/test_fmt/tc_fmt_fun001.yaml | 20 ++++++++++ tests/system_base/test_fmt/tc_fmt_fun001.py | 41 ++++++++++++++++++++ tests/system_base/test_fmt/test.c | 9 +++++ 3 files changed, 70 insertions(+) create mode 100644 docs/system_base/test_fmt/tc_fmt_fun001.yaml create mode 100644 tests/system_base/test_fmt/tc_fmt_fun001.py create mode 100644 tests/system_base/test_fmt/test.c diff --git a/docs/system_base/test_fmt/tc_fmt_fun001.yaml b/docs/system_base/test_fmt/tc_fmt_fun001.yaml new file mode 100644 index 00000000..449e8dc5 --- /dev/null +++ b/docs/system_base/test_fmt/tc_fmt_fun001.yaml @@ -0,0 +1,20 @@ ++作者: xufei ++优先级: P1 ++支持架构: noarch ++执行方式: 自动 ++测试类型: 功能测试 ++通用标签: local,fmt ++用例描述: fmt基本功能 ++修改人: xufei ++ ++前置条件: ++安装fmt fmt-devel gcc-c++软件包 ++测试步骤: ++- 使用gcc编译功能编译成可执行文件a.out ++-验证编译是否成功生成a.out可执行文件 ++-运行a.out程序检查其输出,验证fmt库能正确处理Unicode中文字符 + ++期望结果: ++-无编译错误 ++-正常生成可执行的编译文件 ++-运行a.out程序,程序功能符合预期 diff --git a/tests/system_base/test_fmt/tc_fmt_fun001.py b/tests/system_base/test_fmt/tc_fmt_fun001.py new file mode 100644 index 00000000..e436d175 --- /dev/null +++ b/tests/system_base/test_fmt/tc_fmt_fun001.py @@ -0,0 +1,41 @@ +""" +@File: tc_fmt_fun001.py +@Time: 2026/3/27 16:30:20 +@Author: xufei +@Version: 1.0 +@Contact: xufei@inspur.com +@License: Mulan PSL v2 +@Modify: xufei +""" +import subprocess +import time + +from common.basetest import LocalTest + +class Test(LocalTest): + """ + See tc_fmt_fun001.yaml for details + + :avocado: tags=P1,noarch,local,fmt + """ + PARAM_DIC = {"pkg_name": "fmt"} + + def setUp(self): + super().setUp(self.PARAM_DIC) + self.cmd('dnf install -y fmt-devel') + self.cmd('dnf install -y gcc-c++') + + + def test(self): + code, result = self.cmd('g++ ./tests/system_base/test_fmt/test.c -L/usr/lib64 -l fmt') + code, result = self.cmd('test -e a.out') + self.assertFalse(code, f"a.out not exist") + code, result = self.cmd('./a.out | grep "Hello, 世界"') + self.assertFalse(code, f"Failed") + + + def tearDown(self): + self.cmd('dnf remove -y fmt') + self.cmd('rm -rf a.out') + super().tearDown(self.PARAM_DIC) + diff --git a/tests/system_base/test_fmt/test.c b/tests/system_base/test_fmt/test.c new file mode 100644 index 00000000..470d8276 --- /dev/null +++ b/tests/system_base/test_fmt/test.c @@ -0,0 +1,9 @@ +#include +int main() { +fmt::print(fg(fmt::color::crimson) | fmt::emphasis::bold, +"Hello, {}!\n", "world"); +fmt::print(fg(fmt::color::floral_white) | bg(fmt::color::slate_gray) | +fmt::emphasis::underline, "Hello, {}!\n", "мир"); +fmt::print(fg(fmt::color::steel_blue) | fmt::emphasis::italic, +"Hello, {}!\n", "世界"); +} -- Gitee