首页龙虾技能列表 › Server Test Converter

Server Test Converter

v1.0.1

将服务器测试命令 txt 文件转换为 pytest 测试用例。每个 txt 文件对应生成一个独立的 pytest 文件,命令合并到一个函数中执行。包含通用框架 test_framework.py,适配各种测试环境。

0· 146·0 当前·0 累计
by @liuyun2025·MIT-0
下载技能包
License
MIT-0
最后更新
2026/4/14
安全扫描
VirusTotal
可疑
查看报告
OpenClaw
安全
high confidence
The skill is internally consistent: it converts txt command files into pytest files and only reads/writes local paths; it does not request credentials, install code, or contact external endpoints.
评估建议
This skill appears to do what it says, but take these precautions before installing/using it: 1) Inspect your txt input files for sensitive data (passwords, tokens, IPs) because the generated pytest files will contain the command strings in cleartext. 2) Review and control the test_framework.py you use — the converter assumes you will implement send_a_cmd(); avoid hard-coding credentials in that implementation and prefer SSH keys or a secure credential store. 3) Run the converter and the produce...
详细分析 ▾
用途与能力
Name/description match the implementation: the script reads txt files, parses commands, groups them by executor type, and emits pytest files and a reference test_framework. No unrelated binaries, services, or credentials are required.
指令范围
SKILL.md and the script tightly bound to local paths under /home/admin/.openclaw and instruct the user to implement send_a_cmd() (SSH/subprocess/other). That is within scope, but the docs show examples with hard-coded credentials and the generated tests will contain the original command text verbatim — review inputs for sensitive data before generating or sharing outputs.
安装机制
No install spec; this is instruction-only plus a Python script. Nothing is downloaded or written outside the declared output directory by the script itself.
凭证需求
The skill declares no required environment variables or credentials. The examples in SKILL.md mention using paramiko or subprocess, but those are implementation suggestions the user must provide and do not create hidden credential requests.
持久化与权限
always is false and the skill does not request persistent/autonomous privileges or modify other skills or global config.
安全有层次,运行前请审查代码。

License

MIT-0

可自由使用、修改和再分发,无需署名。

运行时依赖

无特殊依赖

版本

latestv1.0.12026/3/18

- 新增通用测试框架 test_framework.py,支持自定义命令执行逻辑,适配多种测试环境 - 生成的 pytest 文件现在依赖 test_framework.py,简化了环境集成和命令适配 - SKILL.md 文档优化,详细说明框架用法、配置步骤和 send_a_cmd() 实现方法 - 保持每个 txt 文件生成一个独立的 pytest 文件机制,并支持自动命令去重

● 可疑

安装命令 点击复制

官方npx clawhub@latest install server-test-converter
镜像加速npx clawhub@latest install server-test-converter --registry https://cn.clawhub-mirror.com

技能文档

将服务器/网卡测试命令文件转换为 pytest 测试用例。每个 txt 文件生成一个对应的 pytest 文件

功能概述

  • 输入: 包含测试命令的 txt 文件(支持批量处理)
  • 输出: 每个 txt 文件对应一个 pytest 测试文件
  • 执行方式: 支持 send_r5 (R5卡) 和 send_host (主机Shell) 两种方式
  • 通用框架: 提供 test_framework.py,可适配各种测试环境

使用方法

1. 准备输入文件

将待转换的 txt 命令文件放到目录:

/home/admin/.openclaw/tytest/txt_contents/txt/.txt

2. 运行转换脚本

python3 /home/admin/.openclaw/workspace/skills/server-test-converter/convert_commands.py

3. 获取输出

转换后的文件:

/home/admin/.openclaw/tytest/
├── test_framework.py    # 通用框架(需要配置)
├── test_xxx.py         # 生成的测试用例
└── txt_contents/       # 原始命令文件

通用框架说明

test_framework.py

生成的测试代码依赖 test_framework.py,使用方式:

from test_framework import send_r5, send_host, send_r5_wait, send_host_wait, tl_log, TARGET, TARGET_R5

配置步骤

  • 复制到测试服务器: 将 test_framework.pytest_xxx.py 复制到测试服务器
  • 实现 send_a_cmd(): 根据你的测试环境实现命令执行逻辑
# 方式一: SSH
import paramiko
def send_a_cmd(cmd, target):
    ssh = paramiko.SSHClient()
    ssh.connect(hostname='192.168.1.100', username='admin', password='xxx')
    stdin, stdout, stderr = ssh.exec_command(cmd)
    return stdout.read()

# 方式二: 调用已有框架 from your_framework import execute_cmd def send_a_cmd(cmd, target): return execute_cmd(cmd, target)

# 方式三: 本地执行 import subprocess def send_a_cmd(cmd, target): result = subprocess.run(cmd, shell=True, capture_output=True) return result.stdout

  • 配置目标设备: 修改 TARGETTARGET_R5 的值
  • 运行测试:
pip install pytest
pytest test_xxx.py -v

命令执行方式判断

命令类型示例执行方式
内存操作md, mwsend_r5_wait
调度器txsch_test_, dmif_txsch_send_r5_wait
DFX诊断dmif_eoc_, _show_dfxsend_r5_wait
网卡命令ice_, test_, nicif_send_r5_wait
其他Shell 命令等send_host_wait

输出格式

#!/usr/bin/env python3
"""
自动生成的测试用例: xxx.txt
"""

import pytest import sys import os

sys.path.insert(0, os.path.dirname(os.path.abspath(__file__))) from test_framework import send_r5, send_host, send_r5_wait, send_host_wait, tl_log, TARGET, TARGET_R5

class TestXxx: def test_all_commands(self, env): """执行所有命令""" commands = ['命令1', '命令2'] for cmd in commands: send_r5_wait(TARGET_R5, cmd)

注意事项

  • 通用框架: 不依赖特定测试框架,适配各种环境
  • 需要实现: 用户需要实现 send_a_cmd() 函数
  • 配置目标: 根据实际修改 TARGETTARGET_R5
  • 自动去重: 相同的命令只保留一条
数据来源:ClawHub ↗ · 中文优化:龙虾技能库
OpenClaw 技能定制 / 插件定制 / 私有工作流定制

免费技能或插件可能存在安全风险,如需更匹配、更安全的方案,建议联系付费定制

了解定制服务