4 Star 4 Fork 106

OpenCloudOS/packages-testing

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
该仓库未声明开源许可证文件(LICENSE),使用请关注具体项目描述及其代码上游依赖。
克隆/下载
glibc_test.sh 1.68 KB
一键复制 编辑 原始数据 按行查看 历史
#!/bin/bash
###############################################################################
# @用例ID: 20230525-154056-556766015
# @用例名称: glibc-test
# @用例级别: 3
# @用例标签:
# @用例类型: 功能
###############################################################################
[ -z "$TST_TS_TOPDIR" ] && {
TST_TS_TOPDIR="$(realpath "$(dirname "$0")/..")"
export TST_TS_TOPDIR
}
source "${TST_TS_TOPDIR}/tst_common/lib/common.sh" || exit 1
###############################################################################
g_tmpdir="$(mktemp -d)"
tc_setup() {
msg "this is tc_setup"
# @预置条件:glibc已提前安装
assert_true command -v gcc
return 0
}
do_test() {
msg "this is do_test"
# @测试步骤:1: 编写测试程序文件
cat >test.c <<EOF
#include <stdio.h>
#include <stdlib.h>
int main() {
// 使用 printf 打印 Hello, World!
printf("Hello, World!\\n");
// 使用 malloc 分配内存
int* arr = malloc(5 * sizeof(int));
if (arr == NULL) {
printf("Failed to allocate memory\\n");
return 1;
}
// 释放内存
free(arr);
return 0;
}
EOF
# @测试步骤:2: 编译测试程序
assert_true gcc -o test test.c
# @测试步骤:3: 执行测试程序
# @预期结果:3: 执行成功
assert_true ./test
return 0
}
tc_teardown() {
msg "this is tc_teardown"
# 删除 test.c 文件
rm -f test.c
# 删除 test 文件
rm -f test
rm -rfv "$g_tmpdir" || return 1
return 0
}
###############################################################################
tst_main "$@"
###############################################################################
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
1
https://gitee.com/OpenCloudOS/packages-testing.git
git@gitee.com:OpenCloudOS/packages-testing.git
OpenCloudOS
packages-testing
packages-testing
master

搜索帮助