feat(master : test_tool)添加阈值判断脚本

This commit is contained in:
leimingsheng 2025-06-27 14:29:53 +08:00
parent b17104dc2f
commit d480139f1d
2 changed files with 64 additions and 0 deletions

@ -0,0 +1,45 @@
#!/bin/sh
# 20250627
# A tool script to test a value greater or less than threhold
data=$1
direction=$2
threhold=$3
param_num=$#
print_usage(){
echo " Script Usage"
echo " ./check_threhold.sh <value> <direction> <threhold>"
echo " @Param direction : greater , >"
echo " less , <"
echo " equal , ="
echo ""
echo " E.G. ./check_threhold.sh 500 > 1000"
echo " +--> Result : 0"
echo ""
echo " About Result: 1 means true, 0 means fault"
echo ""
}
main(){
if [ ${param_num} -ne 3 ];then
print_usage
exit 0
fi
if [ "${direction}" = "great" ] || [ "${direction}" = ">" ];then
res= `echo " $data > $threhold" | bc -l`
elif [ "${direction}" = "less" ] || [ "${direction}" = "<" ];then
res= `echo " $data < $threhold" | bc -l`
elif [ "${direction}" = "equal" ] || [ "${direction}" = "=" ];then
res= `echo " $data = $threhold" | bc -l`
else
echo "Invalid direction"
print_usage
fi
echo $res
}
main

19
test_plugin/readme.md Normal file

@ -0,0 +1,19 @@
# 测试治具说明
> [!info]
> nicsensor提供了一部分测试治具脚本用于辅助编写测试脚本
## 阈值校验脚本-check_threhold.sh
阈值校验脚本提供了判断数值是否大于目标阈值的方法, 可进行整数和小数的比较。使用方法如下:
```shell
# 测试数据大于阈值
# 例如测试数据是否大于100有如下使用方法
res=`./check_threhold.sh ${data} > 100`
if [ $res -eq 1 ];then
echo "data is greater than threholds"
else
echo "data isn't greater than threholds"
fi
```