Merge branch 'pkg' of http://10.30.190.190:54866/redrsoe2100/os-autotest into pkg
This commit is contained in:
@@ -2,25 +2,9 @@
|
||||
"path": "$OET_PATH/testcases/function_test/pkg_test/google-noto-fonts/google-noto-sans-linear-b-fonts",
|
||||
"machine num": 1,
|
||||
"cases": [
|
||||
{
|
||||
"name": "test_google-noto-sans-linear-b-fonts_function_install",
|
||||
"desc": "测试软件包可以通过包管理器(如dnf, yum, apt)成功安装。"
|
||||
},
|
||||
{
|
||||
"name": "test_google-noto-sans-linear-b-fonts_function_verify",
|
||||
"desc": "测试软件包安装后,其提供的字体文件(如.ttf或.otf)存在于系统字体目录中。"
|
||||
},
|
||||
{
|
||||
"name": "test_google-noto-sans-linear-b-fonts_function_list",
|
||||
"desc": "测试可以通过系统命令(如fc-list)查询到已安装的Noto Sans Linear B字体。"
|
||||
},
|
||||
{
|
||||
"name": "test_google-noto-sans-linear-b-fonts_function_usage",
|
||||
"desc": "测试在支持字体选择的应用程序(如LibreOffice, GIMP)中可以使用Noto Sans Linear B字体。"
|
||||
},
|
||||
{
|
||||
"name": "test_google-noto-sans-linear-b-fonts_function_remove",
|
||||
"desc": "测试可以通过包管理器成功卸载软件包,且卸载后字体文件被移除。"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -13,34 +13,6 @@
|
||||
{
|
||||
"name": "test_jackson-annotations_function_check_version",
|
||||
"desc": "Test checking the installed version of jackson-annotations"
|
||||
},
|
||||
{
|
||||
"name": "test_jackson-annotations_function_usage_serialize",
|
||||
"desc": "Test serialization using Jackson annotations"
|
||||
},
|
||||
{
|
||||
"name": "test_jackson-annotations_function_usage_deserialize",
|
||||
"desc": "Test deserialization using Jackson annotations"
|
||||
},
|
||||
{
|
||||
"name": "test_jackson-annotations_function_usage_ignore",
|
||||
"desc": "Test @JsonIgnore annotation functionality"
|
||||
},
|
||||
{
|
||||
"name": "test_jackson-annotations_function_usage_rename",
|
||||
"desc": "Test @JsonProperty annotation for renaming fields"
|
||||
},
|
||||
{
|
||||
"name": "test_jackson-annotations_function_usage_date_format",
|
||||
"desc": "Test @JsonFormat annotation for date formatting"
|
||||
},
|
||||
{
|
||||
"name": "test_jackson-annotations_function_usage_include",
|
||||
"desc": "Test @JsonInclude annotation for conditional serialization"
|
||||
},
|
||||
{
|
||||
"name": "test_jackson-annotations_function_usage_constructor",
|
||||
"desc": "Test @JsonCreator annotation for custom constructors"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
{
|
||||
"path": "$OET_PATH/testcases/function_test/pkg_test/proftpd/proftpd-postgresql",
|
||||
"machine num": 1,
|
||||
"cases": [
|
||||
{
|
||||
"name": "test_proftpd-postgresql_function_dbconn",
|
||||
"desc": "Test PostgreSQL database connection"
|
||||
},
|
||||
{
|
||||
"name": "test_proftpd-postgresql_function_auth",
|
||||
"desc": "Test authentication functionality"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -5,30 +5,6 @@
|
||||
{
|
||||
"name": "test_python3-zope-proxy_function_install",
|
||||
"desc": "测试软件包python3-zope-proxy是否能通过系统包管理器正常安装。"
|
||||
},
|
||||
{
|
||||
"name": "test_python3-zope-proxy_function_import",
|
||||
"desc": "测试安装后能否成功导入zope.proxy模块,验证基本可用性。"
|
||||
},
|
||||
{
|
||||
"name": "test_python3-zope-proxy_function_proxy_basic",
|
||||
"desc": "测试创建基本代理对象,验证代理能正确转发属性访问和方法调用。"
|
||||
},
|
||||
{
|
||||
"name": "test_python3-zope-proxy_function_proxy_wrapping",
|
||||
"desc": "测试使用ProxyFactory包装对象,验证被包装对象的行为与原对象一致。"
|
||||
},
|
||||
{
|
||||
"name": "test_python3-zope-proxy_function_check_proxy",
|
||||
"desc": "测试使用isProxy和sameProxiedObjects函数,验证其能正确识别和比较代理对象。"
|
||||
},
|
||||
{
|
||||
"name": "test_python3-zope-proxy_function_remove_proxy",
|
||||
"desc": "测试使用pyramid和getProxiedObject函数,验证其能正确移除代理层,返回原始对象。"
|
||||
},
|
||||
{
|
||||
"name": "test_python3-zope-proxy_function_uninstall",
|
||||
"desc": "测试软件包python3-zope-proxy是否能通过系统包管理器正常卸载。"
|
||||
}
|
||||
]
|
||||
}
|
||||
@@ -1,108 +0,0 @@
|
||||
#!/usr/bin/bash
|
||||
|
||||
# Copyright (c) 2024 ISCAS .ALL rights reserved.
|
||||
# This program is licensed under Mulan PSL v2.
|
||||
# You can use it according to the terms and conditions of the Mulan PSL v2.
|
||||
# http://license.coscl.org.cn/MulanPSL2
|
||||
# THIS PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
||||
# EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||
# MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||
# See the Mulan PSL v2 for more details.
|
||||
|
||||
# #############################################
|
||||
# @Author : honghua
|
||||
# @Contact : honghua@iscas.ac.cn
|
||||
# @Date : 2026-04-02
|
||||
# @License : Mulan PSL v2
|
||||
# @Desc : Test @JsonIgnore annotation functionality
|
||||
# ############################################
|
||||
|
||||
source "$OET_PATH/libs/locallibs/common_lib.sh"
|
||||
|
||||
function run_test() {
|
||||
set -e
|
||||
|
||||
LOG_INFO "开始测试 @JsonIgnore 注解功能"
|
||||
|
||||
# 检查软件包是否存在
|
||||
LOG_INFO "检查 jackson-annotations 软件包是否在 yum 源中"
|
||||
if ! dnf list available jackson-annotations &>/dev/null; then
|
||||
LOG_ERROR "yum 源中未找到 jackson-annotations 软件包"
|
||||
exit 255
|
||||
fi
|
||||
|
||||
# 判断是否已安装
|
||||
LOG_INFO "检查环境是否已安装 jackson-annotations"
|
||||
if rpm -q jackson-annotations &>/dev/null; then
|
||||
already_installed=true
|
||||
LOG_INFO "环境已安装 jackson-annotations,测试结束后将保持安装状态"
|
||||
else
|
||||
already_installed=false
|
||||
LOG_INFO "环境未安装 jackson-annotations,将在测试前安装并在结束后卸载"
|
||||
fi
|
||||
|
||||
# 如果未安装,则安装软件包
|
||||
if [ "$already_installed" = false ]; then
|
||||
LOG_INFO "安装 jackson-annotations 软件包"
|
||||
dnf install -y jackson-annotations
|
||||
CHECK_RESULT $? 0 0 "安装 jackson-annotations 失败"
|
||||
fi
|
||||
|
||||
# 测试 @JsonIgnore 注解功能
|
||||
LOG_INFO "创建测试 Java 文件以验证 @JsonIgnore 注解功能"
|
||||
cat > TestJsonIgnore.java << "EOF"
|
||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
||||
public class TestJsonIgnore {
|
||||
public static class User {
|
||||
public String name = "Alice";
|
||||
@JsonIgnore
|
||||
public String password = "secret";
|
||||
public int age = 30;
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
User user = new User();
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
String json = mapper.writeValueAsString(user);
|
||||
System.out.println(json);
|
||||
// 验证 password 字段是否被忽略
|
||||
if (json.contains("password") || json.contains("secret")) {
|
||||
System.err.println("ERROR: @JsonIgnore annotation did not work, password field should be ignored.");
|
||||
System.exit(1);
|
||||
}
|
||||
if (!json.contains("\"name\":\"Alice\"") || !json.contains("\"age\":30")) {
|
||||
System.err.println("ERROR: Other fields should be present in JSON.");
|
||||
System.exit(1);
|
||||
}
|
||||
System.out.println("SUCCESS: @JsonIgnore annotation works correctly.");
|
||||
}
|
||||
}
|
||||
EOF
|
||||
|
||||
LOG_INFO "编译测试 Java 文件"
|
||||
javac -cp "/usr/share/java/jackson-annotations.jar:/usr/share/java/jackson-databind.jar:/usr/share/java/jackson-core.jar" TestJsonIgnore.java
|
||||
CHECK_RESULT $? 0 0 "编译 Java 文件失败"
|
||||
|
||||
LOG_INFO "运行测试程序验证 @JsonIgnore 注解功能"
|
||||
java -cp ".:/usr/share/java/jackson-annotations.jar:/usr/share/java/jackson-databind.jar:/usr/share/java/jackson-core.jar" TestJsonIgnore
|
||||
CHECK_RESULT $? 0 0 "@JsonIgnore 注解功能测试失败"
|
||||
|
||||
LOG_INFO "清理测试文件"
|
||||
rm -f TestJsonIgnore.java TestJsonIgnore.class
|
||||
|
||||
# 环境恢复
|
||||
LOG_INFO "开始环境恢复"
|
||||
if [ "$already_installed" = false ]; then
|
||||
LOG_INFO "卸载 jackson-annotations 软件包"
|
||||
dnf remove -y jackson-annotations
|
||||
CHECK_RESULT $? 0 0 "卸载 jackson-annotations 失败"
|
||||
else
|
||||
LOG_INFO "环境已安装 jackson-annotations,保持安装状态"
|
||||
fi
|
||||
|
||||
LOG_INFO "@JsonIgnore 注解功能测试完成"
|
||||
}
|
||||
|
||||
main "$@"
|
||||
@@ -1,112 +0,0 @@
|
||||
#!/usr/bin/bash
|
||||
|
||||
# Copyright (c) 2024 ISCAS .ALL rights reserved.
|
||||
# This program is licensed under Mulan PSL v2.
|
||||
# You can use it according to the terms and conditions of the Mulan PSL v2.
|
||||
# http://license.coscl.org.cn/MulanPSL2
|
||||
# THIS PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
||||
# EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||
# MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||
# See the Mulan PSL v2 for more details.
|
||||
|
||||
# #############################################
|
||||
# @Author : honghua
|
||||
# @Contact : honghua@iscas.ac.cn
|
||||
# @Date : 2026-04-02
|
||||
# @License : Mulan PSL v2
|
||||
# @Desc : Test @JsonInclude annotation for conditional serialization
|
||||
# ############################################
|
||||
|
||||
source "$OET_PATH/libs/locallibs/common_lib.sh"
|
||||
|
||||
function run_test() {
|
||||
LOG_INFO "开始测试:Test @JsonInclude annotation for conditional serialization"
|
||||
LOG_INFO "步骤1:检查系统中是否已安装jackson-annotations软件包"
|
||||
rpm -q jackson-annotations > /dev/null 2>&1
|
||||
if [ $? -eq 0 ]; then
|
||||
LOG_INFO "jackson-annotations软件包已安装,测试完成后将保持安装状态"
|
||||
INSTALLED_BEFORE_TEST=true
|
||||
else
|
||||
LOG_INFO "jackson-annotations软件包未安装,将在测试过程中安装并在测试完成后卸载"
|
||||
INSTALLED_BEFORE_TEST=false
|
||||
fi
|
||||
|
||||
LOG_INFO "步骤2:检查yum源中是否存在jackson-annotations软件包"
|
||||
dnf list available jackson-annotations > /dev/null 2>&1
|
||||
CHECK_RESULT $? 0 0 "yum源中未找到jackson-annotations软件包"
|
||||
if [ $? -ne 0 ]; then
|
||||
LOG_ERROR "yum源中未找到jackson-annotations软件包,退出测试"
|
||||
exit 255
|
||||
fi
|
||||
|
||||
if [ "$INSTALLED_BEFORE_TEST" = "false" ]; then
|
||||
LOG_INFO "步骤3:安装jackson-annotations软件包"
|
||||
dnf install -y jackson-annotations
|
||||
CHECK_RESULT $? 0 0 "安装jackson-annotations软件包失败"
|
||||
fi
|
||||
|
||||
LOG_INFO "步骤4:验证@JsonInclude注解的基本功能"
|
||||
cat > TestJsonInclude.java << "EOF"
|
||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
||||
public class TestJsonInclude {
|
||||
@JsonInclude(JsonInclude.Include.NON_NULL)
|
||||
static class User {
|
||||
public String name;
|
||||
public Integer age;
|
||||
|
||||
public User(String name, Integer age) {
|
||||
this.name = name;
|
||||
this.age = age;
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
|
||||
User user1 = new User("Alice", null);
|
||||
String json1 = mapper.writeValueAsString(user1);
|
||||
System.out.println("User with null age: " + json1);
|
||||
|
||||
if (!json1.contains("\"name\":\"Alice\"") || json1.contains("\"age\"")) {
|
||||
System.out.println("ERROR: @JsonInclude annotation not working properly");
|
||||
System.exit(1);
|
||||
}
|
||||
|
||||
User user2 = new User("Bob", 25);
|
||||
String json2 = mapper.writeValueAsString(user2);
|
||||
System.out.println("User with age 25: " + json2);
|
||||
|
||||
if (!json2.contains("\"name\":\"Bob\"") || !json2.contains("\"age\":25")) {
|
||||
System.out.println("ERROR: Normal serialization not working");
|
||||
System.exit(1);
|
||||
}
|
||||
|
||||
System.out.println("SUCCESS: @JsonInclude annotation test passed");
|
||||
}
|
||||
}
|
||||
EOF
|
||||
|
||||
javac -cp "/usr/share/java/jackson-annotations.jar:/usr/share/java/jackson-databind.jar:/usr/share/java/jackson-core.jar" TestJsonInclude.java
|
||||
CHECK_RESULT $? 0 0 "编译测试Java程序失败"
|
||||
|
||||
java -cp ".:/usr/share/java/jackson-annotations.jar:/usr/share/java/jackson-databind.jar:/usr/share/java/jackson-core.jar" TestJsonInclude
|
||||
CHECK_RESULT $? 0 0 "@JsonInclude注解功能测试失败"
|
||||
|
||||
LOG_INFO "步骤5:清理测试文件"
|
||||
rm -f TestJsonInclude.java TestJsonInclude.class
|
||||
|
||||
LOG_INFO "步骤6:恢复测试环境"
|
||||
if [ "$INSTALLED_BEFORE_TEST" = "false" ]; then
|
||||
LOG_INFO "卸载测试过程中安装的jackson-annotations软件包"
|
||||
dnf remove -y jackson-annotations
|
||||
CHECK_RESULT $? 0 0 "卸载jackson-annotations软件包失败"
|
||||
else
|
||||
LOG_INFO "保持jackson-annotations软件包安装状态"
|
||||
fi
|
||||
|
||||
LOG_INFO "测试完成:@JsonInclude注解条件序列化功能测试通过"
|
||||
}
|
||||
|
||||
main "$@"
|
||||
@@ -1,118 +0,0 @@
|
||||
#!/usr/bin/bash
|
||||
|
||||
# Copyright (c) 2024 ISCAS .ALL rights reserved.
|
||||
# This program is licensed under Mulan PSL v2.
|
||||
# You can use it according to the terms and conditions of the Mulan PSL v2.
|
||||
# http://license.coscl.org.cn/MulanPSL2
|
||||
# THIS PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
||||
# EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||
# MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||
# See the Mulan PSL v2 for more details.
|
||||
|
||||
# #############################################
|
||||
# @Author : honghua
|
||||
# @Contact : honghua@iscas.ac.cn
|
||||
# @Date : 2026-04-02
|
||||
# @License : Mulan PSL v2
|
||||
# @Desc : Test @JsonProperty annotation for renaming fields
|
||||
# ############################################
|
||||
|
||||
source "$OET_PATH/libs/locallibs/common_lib.sh"
|
||||
|
||||
function run_test() {
|
||||
LOG_INFO "开始测试 @JsonProperty 注解用于字段重命名功能"
|
||||
LOG_INFO "步骤1: 检查软件包是否在yum源中可用"
|
||||
dnf list available jackson-annotations 2>&1 | grep -q "jackson-annotations"
|
||||
if [ $? -ne 0 ]; then
|
||||
LOG_ERROR "yum源中未找到 jackson-annotations 软件包"
|
||||
exit 255
|
||||
fi
|
||||
|
||||
LOG_INFO "步骤2: 检查系统是否已安装 jackson-annotations"
|
||||
rpm -q jackson-annotations > /dev/null 2>&1
|
||||
if [ $? -eq 0 ]; then
|
||||
INSTALLED=1
|
||||
LOG_INFO "软件包已安装,测试完成后将保持安装状态"
|
||||
else
|
||||
INSTALLED=0
|
||||
LOG_INFO "软件包未安装,将在测试步骤中安装"
|
||||
fi
|
||||
|
||||
if [ $INSTALLED -eq 0 ]; then
|
||||
LOG_INFO "步骤3: 安装 jackson-annotations 软件包"
|
||||
dnf install -y jackson-annotations
|
||||
CHECK_RESULT $? 0 0 "安装 jackson-annotations 失败"
|
||||
fi
|
||||
|
||||
LOG_INFO "步骤4: 创建测试Java程序以验证 @JsonProperty 注解"
|
||||
cat > TestJsonPropertyRename.java << "EOF"
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
|
||||
public class TestJsonPropertyRename {
|
||||
static class TestObject {
|
||||
@JsonProperty("new_field_name")
|
||||
private String originalField;
|
||||
|
||||
public TestObject() {}
|
||||
|
||||
public String getOriginalField() {
|
||||
return originalField;
|
||||
}
|
||||
|
||||
public void setOriginalField(String originalField) {
|
||||
this.originalField = originalField;
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
|
||||
// 序列化测试
|
||||
TestObject obj = new TestObject();
|
||||
obj.setOriginalField("test_value");
|
||||
String json = mapper.writeValueAsString(obj);
|
||||
System.out.println("序列化结果: " + json);
|
||||
|
||||
// 验证字段名已重命名
|
||||
if (!json.contains("new_field_name")) {
|
||||
System.out.println("错误: 字段未按预期重命名");
|
||||
System.exit(1);
|
||||
}
|
||||
|
||||
// 反序列化测试
|
||||
String inputJson = "{\"new_field_name\":\"test_value2\"}";
|
||||
TestObject obj2 = mapper.readValue(inputJson, TestObject.class);
|
||||
if (!"test_value2".equals(obj2.getOriginalField())) {
|
||||
System.out.println("错误: 反序列化字段值不匹配");
|
||||
System.exit(1);
|
||||
}
|
||||
|
||||
System.out.println("测试通过: @JsonProperty 注解重名字段功能正常");
|
||||
}
|
||||
}
|
||||
EOF
|
||||
CHECK_RESULT $? 0 0 "创建测试Java程序失败"
|
||||
|
||||
LOG_INFO "步骤5: 编译测试程序"
|
||||
javac -cp "/usr/share/java/jackson-annotations.jar:/usr/share/java/jackson-databind.jar:/usr/share/java/jackson-core.jar" TestJsonPropertyRename.java
|
||||
CHECK_RESULT $? 0 0 "编译Java程序失败"
|
||||
|
||||
LOG_INFO "步骤6: 运行测试程序"
|
||||
java -cp ".:/usr/share/java/jackson-annotations.jar:/usr/share/java/jackson-databind.jar:/usr/share/java/jackson-core.jar" TestJsonPropertyRename
|
||||
CHECK_RESULT $? 0 0 "@JsonProperty 注解重名字段功能测试失败"
|
||||
|
||||
LOG_INFO "步骤7: 清理测试文件"
|
||||
rm -f TestJsonPropertyRename.java TestJsonPropertyRename.class
|
||||
CHECK_RESULT $? 0 0 "清理测试文件失败"
|
||||
|
||||
if [ $INSTALLED -eq 0 ]; then
|
||||
LOG_INFO "步骤8: 卸载测试安装的软件包"
|
||||
dnf remove -y jackson-annotations
|
||||
CHECK_RESULT $? 0 0 "卸载 jackson-annotations 失败"
|
||||
fi
|
||||
|
||||
LOG_INFO "测试完成: @JsonProperty 注解用于字段重命名功能验证通过"
|
||||
}
|
||||
|
||||
main "$@"
|
||||
@@ -1,91 +0,0 @@
|
||||
#!/usr/bin/bash
|
||||
|
||||
# Copyright (c) 2024 ISCAS .ALL rights reserved.
|
||||
# This program is licensed under Mulan PSL v2.
|
||||
# You can use it according to the terms and conditions of the Mulan PSL v2.
|
||||
# http://license.coscl.org.cn/MulanPSL2
|
||||
# THIS PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
||||
# EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||
# MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||
# See the Mulan PSL v2 for more details.
|
||||
|
||||
# #############################################
|
||||
# @Author : honghua
|
||||
# @Contact : honghua@iscas.ac.cn
|
||||
# @Date : 2026-04-02
|
||||
# @License : Mulan PSL v2
|
||||
# @Desc : Test serialization using Jackson annotations
|
||||
# ############################################
|
||||
|
||||
source "$OET_PATH/libs/locallibs/common_lib.sh"
|
||||
|
||||
function run_test() {
|
||||
LOG_INFO "开始测试:使用Jackson注解进行序列化测试"
|
||||
LOG_INFO "步骤1:检查系统中是否已安装jackson-annotations软件包"
|
||||
rpm -q jackson-annotations
|
||||
if [ $? -eq 0 ]; then
|
||||
LOG_INFO "jackson-annotations已安装,测试后将保持安装状态"
|
||||
INSTALLED=true
|
||||
else
|
||||
LOG_INFO "jackson-annotations未安装,将在测试过程中安装"
|
||||
INSTALLED=false
|
||||
fi
|
||||
LOG_INFO "步骤2:检查yum源中是否存在jackson-annotations软件包"
|
||||
dnf list available jackson-annotations
|
||||
if [ $? -ne 0 ]; then
|
||||
LOG_ERROR "yum源中未找到jackson-annotations软件包"
|
||||
exit 255
|
||||
fi
|
||||
if [ "$INSTALLED" = false ]; then
|
||||
LOG_INFO "步骤3:安装jackson-annotations软件包"
|
||||
dnf install -y jackson-annotations
|
||||
CHECK_RESULT $? 0 0 "安装jackson-annotations失败"
|
||||
fi
|
||||
LOG_INFO "步骤4:创建测试Java程序,使用Jackson注解进行序列化"
|
||||
cat > TestJacksonSerialize.java << "EOF"
|
||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
public class TestJacksonSerialize {
|
||||
static class TestData {
|
||||
@JsonProperty("user_name")
|
||||
private String userName;
|
||||
@JsonProperty("user_age")
|
||||
private int userAge;
|
||||
public TestData(String userName, int userAge) {
|
||||
this.userName = userName;
|
||||
this.userAge = userAge;
|
||||
}
|
||||
public String getUserName() { return userName; }
|
||||
public int getUserAge() { return userAge; }
|
||||
}
|
||||
public static void main(String[] args) throws Exception {
|
||||
TestData data = new TestData("testUser", 25);
|
||||
ObjectMapper mapper = new ObjectMapper();
|
||||
String json = mapper.writeValueAsString(data);
|
||||
System.out.println(json);
|
||||
if (json.contains("user_name") && json.contains("user_age")) {
|
||||
System.out.println("SUCCESS");
|
||||
} else {
|
||||
System.out.println("FAILURE");
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
||||
}
|
||||
EOF
|
||||
CHECK_RESULT $? 0 0 "创建测试Java程序失败"
|
||||
LOG_INFO "步骤5:编译并运行测试程序"
|
||||
javac -cp "/usr/share/java/jackson-annotations.jar:/usr/share/java/jackson-databind.jar:/usr/share/java/jackson-core.jar" TestJacksonSerialize.java
|
||||
CHECK_RESULT $? 0 0 "编译Java程序失败"
|
||||
java -cp ".:/usr/share/java/jackson-annotations.jar:/usr/share/java/jackson-databind.jar:/usr/share/java/jackson-core.jar" TestJacksonSerialize
|
||||
CHECK_RESULT $? 0 0 "运行Java程序失败"
|
||||
LOG_INFO "步骤6:清理临时文件"
|
||||
rm -f TestJacksonSerialize.java TestJacksonSerialize.class
|
||||
if [ "$INSTALLED" = false ]; then
|
||||
LOG_INFO "步骤7:卸载测试过程中安装的jackson-annotations软件包"
|
||||
dnf remove -y jackson-annotations
|
||||
CHECK_RESULT $? 0 0 "卸载jackson-annotations失败"
|
||||
fi
|
||||
LOG_INFO "测试完成:使用Jackson注解进行序列化测试通过"
|
||||
}
|
||||
|
||||
main "$@"
|
||||
@@ -1,70 +0,0 @@
|
||||
#!/usr/bin/bash
|
||||
|
||||
# Copyright (c) 2024 ISCAS .ALL rights reserved.
|
||||
# This program is licensed under Mulan PSL v2.
|
||||
# You can use it according to the terms and conditions of the Mulan PSL v2.
|
||||
# http://license.coscl.org.cn/MulanPSL2
|
||||
# THIS PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
||||
# EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||
# MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||
# See the Mulan PSL v2 for more details.
|
||||
|
||||
# #############################################
|
||||
# @Author : honghua
|
||||
# @Contact : honghua@iscas.ac.cn
|
||||
# @Date : 2025-12-12
|
||||
# @License : Mulan PSL v2
|
||||
# @Desc : Test authentication functionality
|
||||
# ############################################
|
||||
|
||||
source "$OET_PATH/libs/locallibs/common_lib.sh"
|
||||
|
||||
function run_test() {
|
||||
|
||||
# 检查yum源中是否存在proftpd-postgresql软件包
|
||||
LOG_INFO "检查yum源中是否存在proftpd-postgresql软件包"
|
||||
dnf list available proftpd-postgresql > /dev/null 2>&1
|
||||
if [ $? -ne 0 ]; then
|
||||
LOG_ERROR "yum源中不存在proftpd-postgresql软件包"
|
||||
exit 255
|
||||
fi
|
||||
|
||||
# 检查是否已安装proftpd-postgresql
|
||||
LOG_INFO "检查是否已安装proftpd-postgresql"
|
||||
rpm -q proftpd-postgresql > /dev/null 2>&1
|
||||
if [ $? -eq 0 ]; then
|
||||
LOG_INFO "proftpd-postgresql已安装,脚本结束时保持安装状态"
|
||||
installed=true
|
||||
else
|
||||
installed=false
|
||||
fi
|
||||
|
||||
# 如果未安装,则安装proftpd-postgresql
|
||||
if [ "$installed" = false ]; then
|
||||
LOG_INFO "安装proftpd-postgresql"
|
||||
dnf install -y proftpd-postgresql
|
||||
CHECK_RESULT $? 0 0 "安装proftpd-postgresql失败"
|
||||
fi
|
||||
|
||||
# 测试认证功能
|
||||
LOG_INFO "测试认证功能"
|
||||
# 这里假设测试认证功能的命令是test_auth,实际应根据实际情况替换为真实命令
|
||||
test_auth
|
||||
CHECK_RESULT $? 0 0 "测试认证功能失败"
|
||||
|
||||
# 如果脚本开始时未安装proftpd-postgresql,则在脚本结束前卸载它
|
||||
if [ "$installed" = false ]; then
|
||||
LOG_INFO "卸载proftpd-postgresql"
|
||||
dnf remove -y proftpd-postgresql
|
||||
CHECK_RESULT $? 0 0 "卸载proftpd-postgresql失败"
|
||||
|
||||
# 清理可能残留的配置文件
|
||||
LOG_INFO "清理残留的配置文件"
|
||||
rm -rf /etc/proftpd
|
||||
fi
|
||||
|
||||
LOG_INFO "测试脚本执行完成"
|
||||
|
||||
}
|
||||
|
||||
main "$@"
|
||||
@@ -1,65 +0,0 @@
|
||||
#!/usr/bin/bash
|
||||
|
||||
# Copyright (c) 2024 ISCAS .ALL rights reserved.
|
||||
# This program is licensed under Mulan PSL v2.
|
||||
# You can use it according to the terms and conditions of the Mulan PSL v2.
|
||||
# http://license.coscl.org.cn/MulanPSL2
|
||||
# THIS PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
||||
# EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||
# MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||
# See the Mulan PSL v2 for more details.
|
||||
|
||||
# #############################################
|
||||
# @Author : honghua
|
||||
# @Contact : honghua@iscas.ac.cn
|
||||
# @Date : 2025-11-30
|
||||
# @License : Mulan PSL v2
|
||||
# @Desc : Test PostgreSQL database connection
|
||||
# ############################################
|
||||
|
||||
source "$OET_PATH/libs/locallibs/common_lib.sh"
|
||||
|
||||
function run_test() {
|
||||
LOG_INFO "开始测试PostgreSQL数据库连接功能"
|
||||
|
||||
# 检查是否已安装proftpd-postgresql软件包
|
||||
LOG_INFO "检查proftpd-postgresql软件包是否已安装"
|
||||
if rpm -q proftpd-postgresql > /dev/null; then
|
||||
LOG_INFO "proftpd-postgresql已安装,跳过安装步骤"
|
||||
INSTALLED=true
|
||||
else
|
||||
LOG_INFO "proftpd-postgresql未安装,准备安装"
|
||||
INSTALLED=false
|
||||
fi
|
||||
|
||||
# 检查yum源中是否有proftpd-postgresql软件包
|
||||
LOG_INFO "检查yum源中是否有proftpd-postgresql软件包"
|
||||
if ! dnf list available proftpd-postgresql > /dev/null 2>&1; then
|
||||
LOG_ERROR "yum源中没有找到proftpd-postgresql软件包"
|
||||
exit 255
|
||||
fi
|
||||
|
||||
# 如果未安装,则安装软件包
|
||||
if [ "$INSTALLED" = false ]; then
|
||||
LOG_INFO "正在安装proftpd-postgresql软件包"
|
||||
dnf install -y proftpd-postgresql
|
||||
CHECK_RESULT $? 0 0 "安装proftpd-postgresql失败"
|
||||
fi
|
||||
|
||||
# 测试PostgreSQL数据库连接功能
|
||||
LOG_INFO "测试PostgreSQL数据库连接功能"
|
||||
# 假设使用pg_isready命令测试连接,这里仅为示例
|
||||
pg_isready -h localhost -p 5432 -U postgres
|
||||
CHECK_RESULT $? 0 0 "PostgreSQL数据库连接失败"
|
||||
|
||||
# 清理环境:如果脚本开始时未安装,则卸载软件包
|
||||
if [ "$INSTALLED" = false ]; then
|
||||
LOG_INFO "卸载proftpd-postgresql软件包"
|
||||
dnf remove -y proftpd-postgresql
|
||||
CHECK_RESULT $? 0 0 "卸载proftpd-postgresql失败"
|
||||
fi
|
||||
|
||||
LOG_INFO "PostgreSQL数据库连接测试完成"
|
||||
}
|
||||
|
||||
main "$@"
|
||||
@@ -1,133 +0,0 @@
|
||||
#!/usr/bin/bash
|
||||
|
||||
# Copyright (c) 2024 ISCAS .ALL rights reserved.
|
||||
# This program is licensed under Mulan PSL v2.
|
||||
# You can use it according to the terms and conditions of the Mulan PSL v2.
|
||||
# http://license.coscl.org.cn/MulanPSL2
|
||||
# THIS PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
||||
# EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||
# MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||
# See the Mulan PSL v2 for more details.
|
||||
|
||||
# #############################################
|
||||
# @Author : honghua
|
||||
# @Contact : honghua@iscas.ac.cn
|
||||
# @Date : 2026-02-23
|
||||
# @License : Mulan PSL v2
|
||||
# @Desc : 测试使用isProxy和sameProxiedObjects函数,验证其能正确识别和比较代理对象。
|
||||
# ############################################
|
||||
|
||||
source "$OET_PATH/libs/locallibs/common_lib.sh"
|
||||
|
||||
function run_test() {
|
||||
# 定义颜色输出
|
||||
LOG_INFO() {
|
||||
echo -e "\033[32m[INFO]\033[0m $1"
|
||||
}
|
||||
LOG_ERROR() {
|
||||
echo -e "\033[31m[ERROR]\033[0m $1"
|
||||
}
|
||||
|
||||
# 定义软件包名称
|
||||
PACKAGE_NAME="python3-zope-proxy"
|
||||
|
||||
# 步骤1:检查yum源中是否存在python3-zope-proxy软件包
|
||||
LOG_INFO "步骤1:检查yum源中是否存在${PACKAGE_NAME}软件包"
|
||||
if ! dnf list available ${PACKAGE_NAME} &>/dev/null; then
|
||||
LOG_ERROR "yum源中未找到${PACKAGE_NAME}软件包"
|
||||
exit 255
|
||||
fi
|
||||
|
||||
# 步骤2:检查系统是否已安装python3-zope-proxy
|
||||
LOG_INFO "步骤2:检查系统是否已安装${PACKAGE_NAME}"
|
||||
if rpm -q ${PACKAGE_NAME} &>/dev/null; then
|
||||
LOG_INFO "${PACKAGE_NAME}已安装,标记为已安装状态"
|
||||
INSTALLED="true"
|
||||
else
|
||||
LOG_INFO "${PACKAGE_NAME}未安装,标记为未安装状态"
|
||||
INSTALLED="false"
|
||||
fi
|
||||
|
||||
# 步骤3:如果未安装,则安装python3-zope-proxy
|
||||
if [ "${INSTALLED}" = "false" ]; then
|
||||
LOG_INFO "步骤3:安装${PACKAGE_NAME}"
|
||||
dnf install -y ${PACKAGE_NAME} &>/dev/null
|
||||
CHECK_RESULT $? 0 0 "安装${PACKAGE_NAME}失败"
|
||||
LOG_INFO "${PACKAGE_NAME}安装成功"
|
||||
fi
|
||||
|
||||
# 步骤4:验证isProxy函数能正确识别代理对象
|
||||
LOG_INFO "步骤4:验证isProxy函数能正确识别代理对象"
|
||||
python3 -c "
|
||||
from zope.proxy import ProxyBase, isProxy
|
||||
|
||||
class Target:
|
||||
def __init__(self, value):
|
||||
self.value = value
|
||||
|
||||
target = Target(42)
|
||||
proxy = ProxyBase(target)
|
||||
|
||||
print("Target is proxy:", isProxy(target))
|
||||
print("Proxy is proxy:", isProxy(proxy))
|
||||
" > /tmp/proxy_test.log 2>&1
|
||||
CHECK_RESULT $? 0 0 "执行Python验证isProxy函数失败"
|
||||
# 检查输出是否符合预期
|
||||
if grep -q "Target is proxy: False" /tmp/proxy_test.log && grep -q "Proxy is proxy: True" /tmp/proxy_test.log; then
|
||||
LOG_INFO "isProxy函数验证成功:能正确识别代理对象"
|
||||
else
|
||||
LOG_ERROR "isProxy函数验证失败:未能正确识别代理对象"
|
||||
cat /tmp/proxy_test.log
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# 步骤5:验证sameProxiedObjects函数能正确比较代理对象
|
||||
LOG_INFO "步骤5:验证sameProxiedObjects函数能正确比较代理对象"
|
||||
python3 -c "
|
||||
from zope.proxy import ProxyBase, sameProxiedObjects
|
||||
|
||||
class Target:
|
||||
def __init__(self, value):
|
||||
self.value = value
|
||||
|
||||
target1 = Target(42)
|
||||
target2 = Target(42)
|
||||
proxy1 = ProxyBase(target1)
|
||||
proxy2 = ProxyBase(target1)
|
||||
proxy3 = ProxyBase(target2)
|
||||
|
||||
print("proxy1 and proxy2 same:", sameProxiedObjects(proxy1, proxy2))
|
||||
print("proxy1 and proxy3 same:", sameProxiedObjects(proxy1, proxy3))
|
||||
print("proxy1 and target1 same:", sameProxiedObjects(proxy1, target1))
|
||||
" > /tmp/proxy_test2.log 2>&1
|
||||
CHECK_RESULT $? 0 0 "执行Python验证sameProxiedObjects函数失败"
|
||||
# 检查输出是否符合预期
|
||||
if grep -q "proxy1 and proxy2 same: True" /tmp/proxy_test2.log && \
|
||||
grep -q "proxy1 and proxy3 same: False" /tmp/proxy_test2.log && \
|
||||
grep -q "proxy1 and target1 same: True" /tmp/proxy_test2.log; then
|
||||
LOG_INFO "sameProxiedObjects函数验证成功:能正确比较代理对象"
|
||||
else
|
||||
LOG_ERROR "sameProxiedObjects函数验证失败:未能正确比较代理对象"
|
||||
cat /tmp/proxy_test2.log
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# 步骤6:清理临时文件
|
||||
LOG_INFO "步骤6:清理临时文件"
|
||||
rm -f /tmp/proxy_test.log /tmp/proxy_test2.log
|
||||
CHECK_RESULT $? 0 0 "清理临时文件失败"
|
||||
|
||||
# 步骤7:如果测试前未安装,则卸载python3-zope-proxy
|
||||
if [ "${INSTALLED}" = "false" ]; then
|
||||
LOG_INFO "步骤7:卸载${PACKAGE_NAME}"
|
||||
dnf remove -y ${PACKAGE_NAME} &>/dev/null
|
||||
CHECK_RESULT $? 0 0 "卸载${PACKAGE_NAME}失败"
|
||||
LOG_INFO "${PACKAGE_NAME}卸载成功,环境已恢复"
|
||||
else
|
||||
LOG_INFO "步骤7:测试前已安装${PACKAGE_NAME},保持安装状态"
|
||||
fi
|
||||
|
||||
LOG_INFO "测试脚本执行完成"
|
||||
}
|
||||
|
||||
main "$@"
|
||||
@@ -1,61 +0,0 @@
|
||||
#!/usr/bin/bash
|
||||
|
||||
# Copyright (c) 2024 ISCAS .ALL rights reserved.
|
||||
# This program is licensed under Mulan PSL v2.
|
||||
# You can use it according to the terms and conditions of the Mulan PSL v2.
|
||||
# http://license.coscl.org.cn/MulanPSL2
|
||||
# THIS PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
||||
# EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||
# MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||
# See the Mulan PSL v2 for more details.
|
||||
|
||||
# #############################################
|
||||
# @Author : honghua
|
||||
# @Contact : honghua@iscas.ac.cn
|
||||
# @Date : 2026-02-23
|
||||
# @License : Mulan PSL v2
|
||||
# @Desc : 测试安装后能否成功导入zope.proxy模块,验证基本可用性。
|
||||
# ############################################
|
||||
|
||||
source "$OET_PATH/libs/locallibs/common_lib.sh"
|
||||
|
||||
function run_test() {
|
||||
LOG_INFO "开始测试python3-zope-proxy模块导入功能"
|
||||
LOG_INFO "步骤1:检查yum源中是否存在python3-zope-proxy软件包"
|
||||
if ! dnf list available python3-zope-proxy &>/dev/null; then
|
||||
LOG_ERROR "yum源中未找到python3-zope-proxy软件包"
|
||||
exit 255
|
||||
fi
|
||||
|
||||
LOG_INFO "步骤2:检查当前环境是否已安装python3-zope-proxy"
|
||||
if rpm -q python3-zope-proxy &>/dev/null; then
|
||||
LOG_INFO "python3-zope-proxy已安装,标记为保持安装状态"
|
||||
INSTALLED_BEFORE="true"
|
||||
else
|
||||
LOG_INFO "python3-zope-proxy未安装,标记为需要测试安装"
|
||||
INSTALLED_BEFORE="false"
|
||||
fi
|
||||
|
||||
if [ "$INSTALLED_BEFORE" = "false" ]; then
|
||||
LOG_INFO "步骤3:安装python3-zope-proxy软件包"
|
||||
dnf install -y python3-zope-proxy
|
||||
CHECK_RESULT $? 0 0 "安装python3-zope-proxy失败"
|
||||
fi
|
||||
|
||||
LOG_INFO "步骤4:验证python3-zope-proxy模块能否成功导入"
|
||||
python3 -c "import zope.proxy; print("zope.proxy模块导入成功")"
|
||||
CHECK_RESULT $? 0 0 "导入zope.proxy模块失败"
|
||||
|
||||
LOG_INFO "步骤5:清理环境,恢复到之前的状态"
|
||||
if [ "$INSTALLED_BEFORE" = "false" ]; then
|
||||
LOG_INFO "卸载测试安装的python3-zope-proxy软件包"
|
||||
dnf remove -y python3-zope-proxy
|
||||
CHECK_RESULT $? 0 0 "卸载python3-zope-proxy失败"
|
||||
else
|
||||
LOG_INFO "环境已安装python3-zope-proxy,保持安装状态"
|
||||
fi
|
||||
|
||||
LOG_INFO "测试完成"
|
||||
}
|
||||
|
||||
main "$@"
|
||||
@@ -1,142 +0,0 @@
|
||||
#!/usr/bin/bash
|
||||
|
||||
# Copyright (c) 2024 ISCAS .ALL rights reserved.
|
||||
# This program is licensed under Mulan PSL v2.
|
||||
# You can use it according to the terms and conditions of the Mulan PSL v2.
|
||||
# http://license.coscl.org.cn/MulanPSL2
|
||||
# THIS PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
||||
# EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||
# MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||
# See the Mulan PSL v2 for more details.
|
||||
|
||||
# #############################################
|
||||
# @Author : honghua
|
||||
# @Contact : honghua@iscas.ac.cn
|
||||
# @Date : 2026-02-23
|
||||
# @License : Mulan PSL v2
|
||||
# @Desc : 测试创建基本代理对象,验证代理能正确转发属性访问和方法调用。
|
||||
# ############################################
|
||||
|
||||
source "$OET_PATH/libs/locallibs/common_lib.sh"
|
||||
|
||||
function run_test() {
|
||||
# 判断是否已安装python3-zope-proxy
|
||||
LOG_INFO "检查是否已安装python3-zope-proxy"
|
||||
if dnf list installed python3-zope-proxy &> /dev/null; then
|
||||
LOG_INFO "python3-zope-proxy已安装,脚本结束后将保持安装状态"
|
||||
already_installed=1
|
||||
else
|
||||
LOG_INFO "python3-zope-proxy未安装,将在测试过程中安装"
|
||||
already_installed=0
|
||||
fi
|
||||
|
||||
# 检查yum源中是否有该软件包
|
||||
LOG_INFO "检查yum源中是否有python3-zope-proxy软件包"
|
||||
if ! dnf list available python3-zope-proxy &> /dev/null; then
|
||||
LOG_ERROR "yum源中未找到python3-zope-proxy软件包"
|
||||
exit 255
|
||||
fi
|
||||
|
||||
# 如果未安装,则安装软件包
|
||||
if [ $already_installed -eq 0 ]; then
|
||||
LOG_INFO "开始安装python3-zope-proxy"
|
||||
dnf install -y python3-zope-proxy
|
||||
CHECK_RESULT $? 0 0 "安装python3-zope-proxy失败"
|
||||
fi
|
||||
|
||||
# 测试创建基本代理对象,验证代理能正确转发属性访问和方法调用
|
||||
LOG_INFO "开始测试创建基本代理对象"
|
||||
|
||||
# 创建测试Python脚本
|
||||
cat > /tmp/test_proxy.py << "EOF"
|
||||
from zope.proxy import ProxyBase
|
||||
from zope.proxy.decorator import DecoratorSpecificationDescriptor
|
||||
|
||||
# 定义目标对象
|
||||
class TargetObject:
|
||||
def __init__(self):
|
||||
self.value = 42
|
||||
|
||||
def get_value(self):
|
||||
return self.value
|
||||
|
||||
def multiply(self, x):
|
||||
return self.value * x
|
||||
|
||||
# 创建代理类
|
||||
class BasicProxy(ProxyBase):
|
||||
pass
|
||||
|
||||
# 测试代理功能
|
||||
def test_basic_proxy():
|
||||
# 创建目标对象
|
||||
target = TargetObject()
|
||||
|
||||
# 创建代理对象
|
||||
proxy = BasicProxy(target)
|
||||
|
||||
# 验证属性访问转发
|
||||
LOG_INFO "测试属性访问转发"
|
||||
if proxy.value != 42:
|
||||
LOG_ERROR "属性访问转发失败: proxy.value = " + str(proxy.value)
|
||||
return False
|
||||
|
||||
# 验证方法调用转发
|
||||
LOG_INFO "测试方法调用转发"
|
||||
if proxy.get_value() != 42:
|
||||
LOG_ERROR "get_value()方法转发失败: " + str(proxy.get_value())
|
||||
return False
|
||||
|
||||
# 验证带参数的方法调用转发
|
||||
LOG_INFO "测试带参数的方法调用转发"
|
||||
if proxy.multiply(2) != 84:
|
||||
LOG_ERROR "multiply()方法转发失败: " + str(proxy.multiply(2))
|
||||
return False
|
||||
|
||||
# 验证修改属性
|
||||
LOG_INFO "测试修改属性"
|
||||
proxy.value = 100
|
||||
if target.value != 100:
|
||||
LOG_ERROR "属性修改转发失败: target.value = " + str(target.value)
|
||||
return False
|
||||
|
||||
# 验证通过代理访问修改后的属性
|
||||
if proxy.value != 100:
|
||||
LOG_ERROR "修改后属性访问转发失败: proxy.value = " + str(proxy.value)
|
||||
return False
|
||||
|
||||
LOG_INFO "所有代理功能测试通过"
|
||||
return True
|
||||
|
||||
# 执行测试
|
||||
if __name__ == "__main__":
|
||||
import sys
|
||||
if test_basic_proxy():
|
||||
sys.exit(0)
|
||||
else:
|
||||
sys.exit(1)
|
||||
EOF
|
||||
|
||||
# 执行测试脚本
|
||||
LOG_INFO "执行代理功能测试脚本"
|
||||
python3 /tmp/test_proxy.py
|
||||
CHECK_RESULT $? 0 0 "代理功能测试失败"
|
||||
|
||||
# 清理临时文件
|
||||
LOG_INFO "清理临时测试文件"
|
||||
rm -f /tmp/test_proxy.py
|
||||
|
||||
# 环境恢复
|
||||
LOG_INFO "开始环境恢复"
|
||||
if [ $already_installed -eq 0 ]; then
|
||||
LOG_INFO "卸载测试安装的python3-zope-proxy软件包"
|
||||
dnf remove -y python3-zope-proxy
|
||||
CHECK_RESULT $? 0 0 "卸载python3-zope-proxy失败"
|
||||
else
|
||||
LOG_INFO "保持python3-zope-proxy安装状态"
|
||||
fi
|
||||
|
||||
LOG_INFO "测试脚本执行完成"
|
||||
}
|
||||
|
||||
main "$@"
|
||||
@@ -1,99 +0,0 @@
|
||||
#!/usr/bin/bash
|
||||
|
||||
# Copyright (c) 2024 ISCAS .ALL rights reserved.
|
||||
# This program is licensed under Mulan PSL v2.
|
||||
# You can use it according to the terms and conditions of the Mulan PSL v2.
|
||||
# http://license.coscl.org.cn/MulanPSL2
|
||||
# THIS PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
||||
# EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||
# MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||
# See the Mulan PSL v2 for more details.
|
||||
|
||||
# #############################################
|
||||
# @Author : honghua
|
||||
# @Contact : honghua@iscas.ac.cn
|
||||
# @Date : 2026-02-23
|
||||
# @License : Mulan PSL v2
|
||||
# @Desc : 测试使用ProxyFactory包装对象,验证被包装对象的行为与原对象一致。
|
||||
# ############################################
|
||||
|
||||
source "$OET_PATH/libs/locallibs/common_lib.sh"
|
||||
|
||||
function run_test() {
|
||||
LOG_INFO "开始测试:测试使用ProxyFactory包装对象,验证被包装对象的行为与原对象一致。"
|
||||
|
||||
# 检查yum源中是否有python3-zope-proxy软件包
|
||||
LOG_INFO "步骤1:检查yum源中是否有python3-zope-proxy软件包"
|
||||
if ! dnf list available python3-zope-proxy 2>/dev/null | grep -q python3-zope-proxy; then
|
||||
LOG_ERROR "yum源中未找到python3-zope-proxy软件包"
|
||||
exit 255
|
||||
fi
|
||||
|
||||
# 检查是否已安装python3-zope-proxy
|
||||
LOG_INFO "步骤2:检查是否已安装python3-zope-proxy"
|
||||
if rpm -q python3-zope-proxy &>/dev/null; then
|
||||
LOG_INFO "python3-zope-proxy已安装,测试结束后将保持安装状态"
|
||||
INSTALLED_BEFORE_TEST=1
|
||||
else
|
||||
LOG_INFO "python3-zope-proxy未安装,将在测试过程中安装"
|
||||
INSTALLED_BEFORE_TEST=0
|
||||
fi
|
||||
|
||||
# 如果未安装,则安装python3-zope-proxy
|
||||
if [ $INSTALLED_BEFORE_TEST -eq 0 ]; then
|
||||
LOG_INFO "步骤3:安装python3-zope-proxy"
|
||||
dnf install -y python3-zope-proxy
|
||||
CHECK_RESULT $? 0 0 "安装python3-zope-proxy失败"
|
||||
fi
|
||||
|
||||
# 测试使用ProxyFactory包装对象
|
||||
LOG_INFO "步骤4:测试使用ProxyFactory包装对象"
|
||||
cat > /tmp/test_proxy_wrapping.py << "EOF"
|
||||
from zope.proxy import ProxyFactory
|
||||
from zope.proxy.decorator import DecoratorSpecificationDescriptor
|
||||
|
||||
class OriginalClass:
|
||||
def method(self):
|
||||
return "original method"
|
||||
|
||||
@property
|
||||
def prop(self):
|
||||
return "original property"
|
||||
|
||||
original = OriginalClass()
|
||||
proxy = ProxyFactory(original)
|
||||
|
||||
# 验证方法调用
|
||||
result_method = proxy.method()
|
||||
assert result_method == "original method", f"方法调用不一致: {result_method}"
|
||||
|
||||
# 验证属性访问
|
||||
result_prop = proxy.prop
|
||||
assert result_prop == "original property", f"属性访问不一致: {result_prop}"
|
||||
|
||||
# 验证类型
|
||||
assert type(proxy).__name__ == "Proxy", f"代理类型不正确: {type(proxy)}"
|
||||
|
||||
print("测试通过:代理对象行为与原对象一致")
|
||||
EOF
|
||||
|
||||
python3 /tmp/test_proxy_wrapping.py
|
||||
CHECK_RESULT $? 0 0 "ProxyFactory包装对象测试失败"
|
||||
|
||||
# 清理临时文件
|
||||
LOG_INFO "步骤5:清理临时文件"
|
||||
rm -f /tmp/test_proxy_wrapping.py
|
||||
|
||||
# 如果测试前未安装,则在测试后卸载python3-zope-proxy
|
||||
if [ $INSTALLED_BEFORE_TEST -eq 0 ]; then
|
||||
LOG_INFO "步骤6:卸载python3-zope-proxy"
|
||||
dnf remove -y python3-zope-proxy
|
||||
CHECK_RESULT $? 0 0 "卸载python3-zope-proxy失败"
|
||||
else
|
||||
LOG_INFO "步骤6:保持python3-zope-proxy安装状态"
|
||||
fi
|
||||
|
||||
LOG_INFO "测试完成:ProxyFactory包装对象测试通过"
|
||||
}
|
||||
|
||||
main "$@"
|
||||
@@ -1,106 +0,0 @@
|
||||
#!/usr/bin/bash
|
||||
|
||||
# Copyright (c) 2024 ISCAS .ALL rights reserved.
|
||||
# This program is licensed under Mulan PSL v2.
|
||||
# You can use it according to the terms and conditions of the Mulan PSL v2.
|
||||
# http://license.coscl.org.cn/MulanPSL2
|
||||
# THIS PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
||||
# EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||
# MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||
# See the Mulan PSL v2 for more details.
|
||||
|
||||
# #############################################
|
||||
# @Author : honghua
|
||||
# @Contact : honghua@iscas.ac.cn
|
||||
# @Date : 2026-02-23
|
||||
# @License : Mulan PSL v2
|
||||
# @Desc : 测试使用pyramid和getProxiedObject函数,验证其能正确移除代理层,返回原始对象。
|
||||
# ############################################
|
||||
|
||||
source "$OET_PATH/libs/locallibs/common_lib.sh"
|
||||
|
||||
function run_test() {
|
||||
# 判断是否已安装python3-zope-proxy
|
||||
LOG_INFO "检查是否已安装python3-zope-proxy"
|
||||
rpm -q python3-zope-proxy > /dev/null 2>&1
|
||||
if [ $? -eq 0 ]; then
|
||||
LOG_INFO "python3-zope-proxy已安装,测试结束后保持安装状态"
|
||||
INSTALLED_BEFORE=1
|
||||
else
|
||||
LOG_INFO "python3-zope-proxy未安装,将在测试前安装,测试后卸载"
|
||||
INSTALLED_BEFORE=0
|
||||
fi
|
||||
|
||||
# 检查yum源中是否有python3-zope-proxy
|
||||
LOG_INFO "检查yum源中是否有python3-zope-proxy"
|
||||
dnf list available python3-zope-proxy > /dev/null 2>&1
|
||||
if [ $? -ne 0 ]; then
|
||||
LOG_ERROR "yum源中没有python3-zope-proxy软件包"
|
||||
exit 255
|
||||
fi
|
||||
|
||||
# 如果未安装,则安装python3-zope-proxy
|
||||
if [ $INSTALLED_BEFORE -eq 0 ]; then
|
||||
LOG_INFO "安装python3-zope-proxy"
|
||||
dnf install -y python3-zope-proxy
|
||||
CHECK_RESULT $? 0 0 "安装python3-zope-proxy失败"
|
||||
fi
|
||||
|
||||
# 创建测试Python脚本
|
||||
LOG_INFO "创建测试Python脚本"
|
||||
cat > test_remove_proxy.py << "EOF"
|
||||
from zope.proxy import ProxyBase, getProxiedObject
|
||||
|
||||
class OriginalObject:
|
||||
def test_method(self):
|
||||
return "original_method"
|
||||
|
||||
class TestProxy(ProxyBase):
|
||||
pass
|
||||
|
||||
def test_remove_proxy():
|
||||
# 创建原始对象
|
||||
original = OriginalObject()
|
||||
|
||||
# 创建代理对象
|
||||
proxy = TestProxy(original)
|
||||
|
||||
# 验证代理对象包装了原始对象
|
||||
assert proxy.__subject__ is original
|
||||
|
||||
# 使用getProxiedObject移除代理层
|
||||
unproxied = getProxiedObject(proxy)
|
||||
|
||||
# 验证返回的是原始对象
|
||||
assert unproxied is original
|
||||
|
||||
# 验证原始对象的方法正常工作
|
||||
result = unproxied.test_method()
|
||||
assert result == "original_method"
|
||||
|
||||
print("测试通过:成功移除代理层,返回原始对象")
|
||||
|
||||
if __name__ == "__main__":
|
||||
test_remove_proxy()
|
||||
EOF
|
||||
|
||||
# 执行测试脚本
|
||||
LOG_INFO "执行测试脚本验证pyramid和getProxiedObject函数"
|
||||
python3 test_remove_proxy.py
|
||||
CHECK_RESULT $? 0 0 "测试失败:无法正确移除代理层返回原始对象"
|
||||
|
||||
# 清理临时文件
|
||||
LOG_INFO "清理临时文件"
|
||||
rm -f test_remove_proxy.py
|
||||
|
||||
# 如果测试前未安装,则卸载python3-zope-proxy
|
||||
if [ $INSTALLED_BEFORE -eq 0 ]; then
|
||||
LOG_INFO "卸载python3-zope-proxy"
|
||||
dnf remove -y python3-zope-proxy
|
||||
CHECK_RESULT $? 0 0 "卸载python3-zope-proxy失败"
|
||||
fi
|
||||
|
||||
LOG_INFO "测试完成"
|
||||
}
|
||||
|
||||
main "$@"
|
||||
@@ -1,80 +0,0 @@
|
||||
#!/usr/bin/bash
|
||||
|
||||
# Copyright (c) 2024 ISCAS .ALL rights reserved.
|
||||
# This program is licensed under Mulan PSL v2.
|
||||
# You can use it according to the terms and conditions of the Mulan PSL v2.
|
||||
# http://license.coscl.org.cn/MulanPSL2
|
||||
# THIS PROGRAM IS PROVIDED ON AN "AS IS" BASIS, WITHOUT WARRANTIES OF ANY KIND,
|
||||
# EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO NON-INFRINGEMENT,
|
||||
# MERCHANTABILITY OR FIT FOR A PARTICULAR PURPOSE.
|
||||
# See the Mulan PSL v2 for more details.
|
||||
|
||||
# #############################################
|
||||
# @Author : honghua
|
||||
# @Contact : honghua@iscas.ac.cn
|
||||
# @Date : 2026-02-23
|
||||
# @License : Mulan PSL v2
|
||||
# @Desc : 测试软件包python3-zope-proxy是否能通过系统包管理器正常卸载。
|
||||
# ############################################
|
||||
|
||||
source "$OET_PATH/libs/locallibs/common_lib.sh"
|
||||
|
||||
function run_test() {
|
||||
# 定义软件包名称
|
||||
PACKAGE_NAME="python3-zope-proxy"
|
||||
|
||||
# 步骤1:检查软件包是否在yum源中
|
||||
LOG_INFO "步骤1:检查软件包是否在yum源中"
|
||||
dnf list available $PACKAGE_NAME &>/dev/null
|
||||
if [ $? -ne 0 ]; then
|
||||
LOG_ERROR "软件包 $PACKAGE_NAME 不在yum源中"
|
||||
exit 255
|
||||
fi
|
||||
|
||||
# 步骤2:检查当前环境是否已安装软件包
|
||||
LOG_INFO "步骤2:检查当前环境是否已安装软件包"
|
||||
INSTALLED=0
|
||||
rpm -q $PACKAGE_NAME &>/dev/null
|
||||
if [ $? -eq 0 ]; then
|
||||
LOG_INFO "软件包 $PACKAGE_NAME 已安装"
|
||||
INSTALLED=1
|
||||
else
|
||||
LOG_INFO "软件包 $PACKAGE_NAME 未安装"
|
||||
fi
|
||||
|
||||
# 步骤3:如果未安装,则安装软件包
|
||||
if [ $INSTALLED -eq 0 ]; then
|
||||
LOG_INFO "步骤3:安装软件包 $PACKAGE_NAME"
|
||||
dnf install -y $PACKAGE_NAME
|
||||
CHECK_RESULT $? 0 0 "安装软件包 $PACKAGE_NAME 失败"
|
||||
fi
|
||||
|
||||
# 步骤4:测试卸载软件包
|
||||
LOG_INFO "步骤4:测试卸载软件包 $PACKAGE_NAME"
|
||||
dnf remove -y $PACKAGE_NAME
|
||||
CHECK_RESULT $? 0 0 "卸载软件包 $PACKAGE_NAME 失败"
|
||||
|
||||
# 步骤5:验证软件包是否已卸载
|
||||
LOG_INFO "步骤5:验证软件包是否已卸载"
|
||||
rpm -q $PACKAGE_NAME &>/dev/null
|
||||
if [ $? -eq 0 ]; then
|
||||
LOG_ERROR "软件包 $PACKAGE_NAME 卸载失败"
|
||||
exit 1
|
||||
else
|
||||
LOG_INFO "软件包 $PACKAGE_NAME 卸载成功"
|
||||
fi
|
||||
|
||||
# 步骤6:环境恢复
|
||||
LOG_INFO "步骤6:环境恢复"
|
||||
if [ $INSTALLED -eq 1 ]; then
|
||||
LOG_INFO "重新安装软件包 $PACKAGE_NAME 以恢复环境"
|
||||
dnf install -y $PACKAGE_NAME
|
||||
CHECK_RESULT $? 0 0 "重新安装软件包 $PACKAGE_NAME 失败"
|
||||
else
|
||||
LOG_INFO "环境未安装软件包,无需恢复"
|
||||
fi
|
||||
|
||||
LOG_INFO "测试完成:软件包 $PACKAGE_NAME 能通过系统包管理器正常卸载"
|
||||
}
|
||||
|
||||
main "$@"
|
||||
Reference in New Issue
Block a user