Adding more tests and excludes to be able to traverse through /**/* wihtout error
Added test summary to stdout
This commit is contained in:
@@ -40,8 +40,9 @@ tocompete_init() {
|
||||
# compete_no_permission
|
||||
mkdir -p "${_tc_tmp}/noperm"
|
||||
chmod 400 "${_tc_tmp}/noperm"
|
||||
ln -s "noperm" "${_tc_tmp}/lnoperm"
|
||||
ln -s "noperm" "${_tc_tmp}/noperml"
|
||||
ln -s "/" "${_tc_tmp}/lroot"
|
||||
ln -s "/root" "${_tc_tmp}/lroothome"
|
||||
|
||||
#echo "rl: " && readlink "${_tc_tmp}/lnoperm"
|
||||
#ls -l "${_tc_tmp}"
|
||||
@@ -53,6 +54,12 @@ tocompete_init() {
|
||||
# Compete test arrays with "dynamic" cases need to be inside the init function
|
||||
# e.g. "$(cd ../test && pwd)/file" - base directory must be set first
|
||||
# e.g. "${_tc_tmp}/"* - _tc_tmp must be populated first
|
||||
compete_invalid=( "Invalid files with and without valid path"
|
||||
"${_tc_tmp}/invalid_file"
|
||||
"/invalid_file"
|
||||
"/invalid_direcotry/invalidfile"
|
||||
)
|
||||
|
||||
compete_links=( "Test - Valid links"
|
||||
"${_tc_tmp}/a 3" # slink chain a3 -> a2 -> a
|
||||
"${_tc_tmp}/a"*
|
||||
@@ -62,18 +69,21 @@ tocompete_init() {
|
||||
"/dev/stdout" # skip - different output
|
||||
"/etc/mtab" # skip - Always different
|
||||
"/proc/mounts" # skip - Always different
|
||||
"/proc/net/"* # skip - Always different
|
||||
)
|
||||
|
||||
compete_no_permission=( "No permission to enter directory (direct and link)"
|
||||
"lnoperm"
|
||||
"noperm"
|
||||
"lroot"
|
||||
"/proc/"**/cwd # special - no permission for links
|
||||
"noperm"*
|
||||
"lroot"*
|
||||
"/"
|
||||
)
|
||||
|
||||
# Add tests to global test array from test_rdlink
|
||||
tocompete+=(
|
||||
compete_no_permission
|
||||
compete_invalid
|
||||
compete_links
|
||||
compete_no_permission
|
||||
compete_canonicalize
|
||||
compete_all
|
||||
)
|
||||
@@ -109,7 +119,7 @@ toassert_init() {
|
||||
# e.g. "${_tc_tmp}/"* - _tc_tmp must be populated first
|
||||
assert_invalid_files=( "Assert - invalid files"
|
||||
"${_ta_tmp}/missing_file" "${_ta_tmp}/missing_file"
|
||||
"${_ta_tmp}/missd/missf" "${_ta_tmp}/missd/missf"
|
||||
"${_ta_tmp}/missd/missf" ""
|
||||
"${_ta_tmp}/miss c" "${_ta_tmp}/miss c"
|
||||
"rel_a" "${_ta_tmp}/rel_a"
|
||||
"../rel_b" "$(cd ".." && pwd)/rel_b"
|
||||
@@ -127,13 +137,19 @@ toassert_clean() {
|
||||
|
||||
########## Common data and functions ##########
|
||||
#
|
||||
# [0] path to exclude [1] Reason for exclution
|
||||
# [2] path to exclude [3] Reason for exclution
|
||||
# [0] exclude regex [1] Reason for exclution
|
||||
# [2] exclude regex [3] Reason for exclution
|
||||
exclude_path=(
|
||||
"/dev/fd" "Always different"
|
||||
"/dev/stdout" "Always different in pipes"
|
||||
"/etc/mtab" "Always different"
|
||||
"/proc/mounts" "Always different"
|
||||
"/dev/fd$" "Different on every call"
|
||||
"/dev/stdout$" "Always different in pipes"
|
||||
"/etc/mtab$" "Different on every call"
|
||||
"/proc/mounts$" "Different on every call"
|
||||
"/proc/net$" "Different on every call"
|
||||
"/proc/net/.*" "Different on every call"
|
||||
"/proc/self/fd/(1|3|255)" "Different on every call"
|
||||
"/proc/self$" "Different on every call"
|
||||
"/proc/self/(attr|fdinfo|map_files|net|ns|task)/.*" "Different on every call"
|
||||
"/proc/thread-self$" "Different on every call"
|
||||
)
|
||||
|
||||
toexclude() {
|
||||
@@ -144,7 +160,7 @@ toexclude() {
|
||||
exclude="${path}"
|
||||
else
|
||||
# return reason for exclution
|
||||
if [[ "${exclude}" == "${1:-}" ]] ; then
|
||||
if [[ "${1:-}" =~ ${exclude} ]] ; then
|
||||
printf "${path}"
|
||||
return 0
|
||||
fi
|
||||
|
Reference in New Issue
Block a user