From 18dfae8919f9e244f36012afdcb86da3e955a55a Mon Sep 17 00:00:00 2001 From: propelluo Date: Fri, 13 Mar 2026 16:29:41 +0800 Subject: [PATCH 1/2] init tsuite project Signed-off-by: propelluo --- .gitignore | 17 +++++++++++++++++ .gitmodules | 3 +++ Makefile | 27 +++++++++++++++++++++++++++ Makefile.common | 3 +++ cmd/Makefile | 20 ++++++++++++++++++++ cmd/hello.c | 6 ++++++ common | 1 + kmod/Makefile | 33 +++++++++++++++++++++++++++++++++ lib/Makefile | 20 ++++++++++++++++++++ lib/ts_common.c | 14 ++++++++++++++ lib/ts_common.h | 6 ++++++ lib/ts_common.py | 35 +++++++++++++++++++++++++++++++++++ lib/ts_common.sh | 16 ++++++++++++++++ lib/ts_setup | 13 +++++++++++++ lib/ts_teardown | 13 +++++++++++++ testcase/Makefile | 21 +++++++++++++++++++++ tsuite | 21 +++++++++++++++++++++ 17 files changed, 269 insertions(+) create mode 100644 .gitmodules create mode 100644 Makefile create mode 100644 Makefile.common create mode 100644 cmd/Makefile create mode 100644 cmd/hello.c create mode 160000 common create mode 100644 kmod/Makefile create mode 100644 lib/Makefile create mode 100644 lib/ts_common.c create mode 100644 lib/ts_common.h create mode 100644 lib/ts_common.py create mode 100644 lib/ts_common.sh create mode 100755 lib/ts_setup create mode 100755 lib/ts_teardown create mode 100644 testcase/Makefile create mode 100755 tsuite diff --git a/.gitignore b/.gitignore index 5d947ca..1c7a07a 100644 --- a/.gitignore +++ b/.gitignore @@ -16,3 +16,20 @@ bin-release/ # Project files, i.e. `.project`, `.actionScriptProperties` and `.flexProperties` # should NOT be excluded as they contain compiler settings and other important # information for Eclipse / Flash Builder. +.idea/ +logs/ +__pycache__/ +*.o +*.a +*.d +*.cmd +*.test +*.ko +*.mod +*.mod.c +Module.symvers +modules.order +compile_commands.json +/*.json +/*.xlsx + diff --git a/.gitmodules b/.gitmodules new file mode 100644 index 0000000..dbfb31c --- /dev/null +++ b/.gitmodules @@ -0,0 +1,3 @@ +[submodule "common"] + path = common + url = https://gitee.com/opencloudos-testing/tsuite.git diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..2606fa9 --- /dev/null +++ b/Makefile @@ -0,0 +1,27 @@ +export TST_TS_TOPDIR := $(shell pwd) +DIRS := cmd kmod testcase +LIBS := common lib + +all: libs + @for d in $(DIRS); do \ + echo try make $$d; \ + make -C $$d all; \ + done + +libs: + @for d in $(LIBS); do \ + echo try make $$d; \ + make -C $$d all; \ + done + +clean: + @for d in $(DIRS) $(LIBS); do \ + echo try clean $$d; \ + make -C $$d clean; \ + done + +cleanall: + @for d in $(DIRS) $(LIBS); do \ + echo try cleanall $$d; \ + make -C $$d cleanall; \ + done diff --git a/Makefile.common b/Makefile.common new file mode 100644 index 0000000..812f9dc --- /dev/null +++ b/Makefile.common @@ -0,0 +1,3 @@ +CFLAGS += -Wall -g -I$(TST_TS_TOPDIR)/common/lib -I$(TST_TS_TOPDIR)/lib +LDFLAGS += -L$(TST_TS_TOPDIR)/common/lib -L$(TST_TS_TOPDIR)/lib +LDFLAGS += -lm -lrt -lpthread -Wl,--whole-archive -lcommon -ltscommon -Wl,--no-whole-archive diff --git a/cmd/Makefile b/cmd/Makefile new file mode 100644 index 0000000..133158c --- /dev/null +++ b/cmd/Makefile @@ -0,0 +1,20 @@ +export TST_TS_TOPDIR ?= $(shell pwd)/.. +include $(TST_TS_TOPDIR)/Makefile.common +ALL_SRC := $(wildcard *.c) +ALL_OBJ := $(patsubst %.c,%.o,$(ALL_SRC)) +ALL_BIN := $(patsubst %.o,%.cmd,$(ALL_OBJ)) +CFLAGS += +LDFLAGS += + +all: $(ALL_BIN) + +$(ALL_BIN):%.cmd:%.o + $(CC) $^ -o $@ $(LDFLAGS) + +$(ALL_OBJ):%.o:%.c + $(CC) $(CFLAGS) -c $^ -o $@ + +clean: + rm -rfv $(ALL_OBJ) $(ALL_BIN) + +cleanall: clean diff --git a/cmd/hello.c b/cmd/hello.c new file mode 100644 index 0000000..c70b442 --- /dev/null +++ b/cmd/hello.c @@ -0,0 +1,6 @@ +#include + +int main(void) { + printf("hello world\n"); + return 0; +} diff --git a/common b/common new file mode 160000 index 0000000..bdae120 --- /dev/null +++ b/common @@ -0,0 +1 @@ +Subproject commit bdae12032f6c28061e0da6adfd9b5b1361dda221 diff --git a/kmod/Makefile b/kmod/Makefile new file mode 100644 index 0000000..5f4ff1a --- /dev/null +++ b/kmod/Makefile @@ -0,0 +1,33 @@ +# General Purpose Makefile for Linux Kernel module +# 以下编译适合于在内核代码树之外编译内核模块。 +# 整个过程会导致本Makefile文件被加载执行两遍。 +# 第一遍执行时,由于`KERNELRELEASE`没有被定义,所以先执行`else`下的逻辑。 +# `-C $(KERNEL_DIR)`指明跳转到内核源码目录下读取那里的Makefile; +# `M=$(CURDIR)`表明然后返回到当前目录继续读入当前的Makefile并执行之。此为第二遍执行。 +# 第二遍执行时,此时从内核源码目录返回时,KERNELRELEASE已被被定义, +# kbuild也被启动去解析kbuild语法的语句,make将继续读取else之前的内容。 +# else之前的内容为kbuild语法的语句, 指明模块源码中各文件的依赖关系,以及要生成的目标模块名。 + +CURDIR ?= $(shell pwd) +KERNEL_VER := $(shell uname -r) +KERNEL_DIR ?= /usr/src/kernels/$(KERNEL_VER) +export ALL_SRC ?= $(filter-out %.mod.c, $(wildcard *.c)) +export ALL_OBJ ?= $(patsubst %.c,%.o,$(ALL_SRC)) +export ALL_MOD ?= $(patsubst %.o,%.ko,$(ALL_OBJ)) + +ifneq ($(KERNELRELEASE),) + obj-m += $(ALL_OBJ) +else +all: +ifneq ($(ALL_OBJ),) + $(MAKE) -C $(KERNEL_DIR) M=$(CURDIR) modules + ../tsuite sign $(ALL_MOD) +endif +endif + +clean: +ifneq ($(ALL_OBJ),) + $(MAKE) -C $(KERNEL_DIR) M=$(CURDIR) clean +endif + +cleanall: clean diff --git a/lib/Makefile b/lib/Makefile new file mode 100644 index 0000000..171b10b --- /dev/null +++ b/lib/Makefile @@ -0,0 +1,20 @@ +export TST_TS_TOPDIR ?= $(shell pwd)/.. +include $(TST_TS_TOPDIR)/Makefile.common +ALL_SRC := $(wildcard *.c) +ALL_OBJ := $(patsubst %.c,%.o,$(ALL_SRC)) +LIB_STATIC := libtscommon.a +CFLAGS += + +all: $(LIB_STATIC) + +$(LIB_STATIC): $(ALL_OBJ) + ar -rc $(LIB_STATIC) $(ALL_OBJ) + +$(ALL_OBJ):%.o:%.c + $(CC) $(CFLAGS) -c $^ -o $@ + +clean: + rm -rfv $(LIB_STATIC) $(ALL_OBJ) + +cleanall: clean + rm -rfv __pycache__ diff --git a/lib/ts_common.c b/lib/ts_common.c new file mode 100644 index 0000000..b449430 --- /dev/null +++ b/lib/ts_common.c @@ -0,0 +1,14 @@ +// 测试套自定义公共函数库 +#include "common.h" +#include "ts_common.h" + +int tc_setup_common(int argc, char **argv) { + msg("this is tc_setup_common"); + return 0; +} + +int tc_teardown_common(int argc, char **argv) { + msg("this is tc_teardown_common"); + return 0; +} + diff --git a/lib/ts_common.h b/lib/ts_common.h new file mode 100644 index 0000000..9ed2c5f --- /dev/null +++ b/lib/ts_common.h @@ -0,0 +1,6 @@ +#ifndef __TS_COMMON_H__ +#define __TS_COMMON_H__ + +// 测试套自定义头文件内容 + +#endif // __TS_COMMON_H__ diff --git a/lib/ts_common.py b/lib/ts_common.py new file mode 100644 index 0000000..51ca901 --- /dev/null +++ b/lib/ts_common.py @@ -0,0 +1,35 @@ +#!/usr/bin/env python3 +# coding: utf-8 +# Desc: 测试套公共模块 +import abc +import os.path +import sys + +sys.path.append(os.path.join(os.path.dirname(os.path.abspath(__file__)), '..')) +from common.lib.common import TestCase + + +class MyTestCase(TestCase): + """ + 本测试套内的Python用例需要继承此类 + """ + + def tc_setup_common(self, *args): + """ + 所有Python用例执行tc_setup函数前会先执行本函数 + :param args: + :return: + """ + self.msg("this is tc_setup_common") + + @abc.abstractmethod + def do_test(self, *args): + pass + + def tc_teardown_common(self, *args): + """ + 所有Python用例执行tc_teardown函数后会执行本函数 + :param args: + :return: + """ + self.msg("this is tc_teardown_common") diff --git a/lib/ts_common.sh b/lib/ts_common.sh new file mode 100644 index 0000000..6ef4aa8 --- /dev/null +++ b/lib/ts_common.sh @@ -0,0 +1,16 @@ +#!/bin/bash +# 测试套公共函数 +# 约定: +# 1、以下划线"_"开头的函数和变量用例不能直接调用 +# 2、环境变量全大写,全局变量加上"g_"前置,局部变量统一加"local"修饰 + +tc_setup_common() { + msg "this is tc_setup_common" + return 0 +} + +tc_teardown_common() { + msg "this is tc_teardown_common" + return 0 +} + diff --git a/lib/ts_setup b/lib/ts_setup new file mode 100755 index 0000000..3aaab92 --- /dev/null +++ b/lib/ts_setup @@ -0,0 +1,13 @@ +#!/bin/bash +# Time: 2022-04-19 22:44:25 +# Desc: ts_setup +[ -z "$TST_TS_TOPDIR" ] && export TST_TS_TOPDIR="$(realpath "$(dirname "$0")/..")" +source "${TST_TS_TOPDIR}/common/lib/common.sh" + +ts_setup() { + # 测试套setup脚本,在这里增加setup操作 + msg "this is ts_setup" + return 0 +} + +ts_setup diff --git a/lib/ts_teardown b/lib/ts_teardown new file mode 100755 index 0000000..8616195 --- /dev/null +++ b/lib/ts_teardown @@ -0,0 +1,13 @@ +#!/bin/bash +# Time: 2022-04-19 22:44:25 +# Desc: ts_teardown +[ -z "$TST_TS_TOPDIR" ] && export TST_TS_TOPDIR="$(realpath "$(dirname "$0")/..")" +source "${TST_TS_TOPDIR}/common/lib/common.sh" + +ts_teardown() { + # 测试套teardown脚本,在这里增加teardown操作 + msg "this is ts_teardown" + return 0 +} + +ts_teardown diff --git a/testcase/Makefile b/testcase/Makefile new file mode 100644 index 0000000..1b4db5b --- /dev/null +++ b/testcase/Makefile @@ -0,0 +1,21 @@ +export TST_TS_TOPDIR ?= $(shell pwd)/.. +include $(TST_TS_TOPDIR)/Makefile.common +ALL_SRC := $(filter-out %.mod.c, $(wildcard *.c)) +ALL_OBJ := $(patsubst %.c,%.o,$(ALL_SRC)) +ALL_BIN := $(patsubst %.o,%.test,$(ALL_OBJ)) +CFLAGS += +LDFLAGS += +LDFLAGS += + +all: $(ALL_BIN) + +$(ALL_BIN):%.test:%.o + $(CC) $^ -o $@ $(LDFLAGS) + +$(ALL_OBJ):%.o:%.c + $(CC) $(CFLAGS) -c $^ -o $@ + +clean: + rm -rfv $(ALL_OBJ) $(ALL_BIN) + +cleanall: clean diff --git a/tsuite b/tsuite new file mode 100755 index 0000000..5fa0542 --- /dev/null +++ b/tsuite @@ -0,0 +1,21 @@ +#!/bin/bash + +TST_TS_TOPDIR=$(realpath "$(dirname "$0")") +export TST_TS_TOPDIR +TST_TS_SYSDIR="$TST_TS_TOPDIR/logs/.ts.sysdir" +export TST_TS_SYSDIR +TST_RUN_DATATIME=$(date '+%Y%m%d%H%M%S') +export TST_RUN_DATATIME +TST_TS_ORI_CWD="$(pwd)" +export TST_TS_ORI_CWD + +_tsuite_main() { + if [ ! -x "${TST_TS_TOPDIR}/common/tsuite" ]; then + echo "tsuite common in submodule not checkout, please run command:" + echo " git submodule init && git submodule update" + return 1 + fi + "${TST_TS_TOPDIR}/common/tsuite" "$@" +} + +_tsuite_main "$@" -- Gitee From 94adedfd6f306f45bf663541868fe212ca5b2bd9 Mon Sep 17 00:00:00 2001 From: propelluo Date: Fri, 13 Mar 2026 16:35:34 +0800 Subject: [PATCH 2/2] add tst-open-ffmpeg Signed-off-by: propelluo --- .gitmodules | 3 +++ tst-open-ffmpeg | 1 + 2 files changed, 4 insertions(+) create mode 160000 tst-open-ffmpeg diff --git a/.gitmodules b/.gitmodules index dbfb31c..7f7587d 100644 --- a/.gitmodules +++ b/.gitmodules @@ -1,3 +1,6 @@ [submodule "common"] path = common url = https://gitee.com/opencloudos-testing/tsuite.git +[submodule "tst-open-ffmpeg"] + path = tst-open-ffmpeg + url = https://gitee.com/opencloudos-testing/tst-open-ffmpeg.git diff --git a/tst-open-ffmpeg b/tst-open-ffmpeg new file mode 160000 index 0000000..e5c950f --- /dev/null +++ b/tst-open-ffmpeg @@ -0,0 +1 @@ +Subproject commit e5c950fc6b1b1e8a824594dfe6ef032c7da5dde4 -- Gitee