Commit cb90b267 authored by Vitaly Lipatov's avatar Vitaly Lipatov

tests: add test_startwith.sh test_status.sh

parent 1eb50248
#!/bin/sh
startwith()
{
# rhas "$1" "^$2"
#echo "${#2}"
#echo "${1:0:${#2}}"
[ "${1:0:${#2}}" = "$2" ]
#[[ "$1" = ${2}* ]]
}
check_ok()
{
startwith "$1" "$2" && echo "OK for '$1' with '$2'" || echo "FATAL with '$1': result FALSE do not match with '$2'"
}
check_notok()
{
startwith "$1" "$2" && echo "FATAL with '$1': result TRUE do not match with '$2'" || echo "OK for '$1' with '$2'"
}
check_ok "/abs" "/"
check_notok "../abs" "/"
check_ok "../abs" ".."
check_ok "common-file.abs" "common"
startwith_inlist()
{
local str="$1"
local i
for i in "$@" ; do
startwith "$str" "$i" && return
done
return 1
}
startwith_inlist "file-1.2.3.rpm" "base" "name" "filer" "file" && echo OK
startwith_inlist "files-1.2.3.rpm" "base" "name" "filer" "file" || echo OK
__status_repacked()
{
local repacked="$(epm print field Description for "$1" | grep -qi "alien" 2>/dev/null)"
local packager="$(epm print field Packager for "$1" 2>/dev/null)"
local rpmversion="$(epm print field Version for "$1" 2>/dev/null)"
[ -n "$rpmversion" ] || return
[ "$packager" = "EPM <support@etersoft.ru>" ] && return 0
[ "$packager" = "EPM <support@eepm.ru>" ] && return 0
return 1
}
LIST="hiddify mc"
#__status_repacked $LIST
#echo $?
FORMAT="%{Name} %{Version} %{Packager}\n"
a= rpmquery --queryformat "$FORMAT" -a | grep "EPM <support@e"
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment