Skip to content

Commit

Permalink
ts: fix testsuite run when id cmd cannot resolve group
Browse files Browse the repository at this point in the history
Update testsuite to cope with user group whose name cannot be resolved.

Fixes #476.
  • Loading branch information
xdelaruelle committed Oct 18, 2022
1 parent 39923ad commit d04eb75
Show file tree
Hide file tree
Showing 8 changed files with 77 additions and 2 deletions.
21 changes: 19 additions & 2 deletions testsuite/modules.00-init/005-init_ts.exp
Original file line number Diff line number Diff line change
Expand Up @@ -800,7 +800,8 @@ set domainname [auto_execok domainname]
set domainname_warn "$error_msgs: Command 'domainname' cannot be found"

# display result of id command
send_user "\tid output is '[exec id]'\n"
set idoutput [exec id]
send_user "\tid output is '$idoutput'\n"

# get current working directory
set ORIG_CWD [pwd]
Expand All @@ -809,12 +810,28 @@ set ORIG_CWD [pwd]
set username [exec id -u -n]
set userid [exec id -u]
send_user "\tCurrent username is '$username'\n"
set group_name_fetch_failed 0
if {[catch {
# correctly split groups in case some contain a space character (like on Cygwin/MSYS platforms)
set usergroups [lsort [split [string range [exec id -G -n -z] 0 end-1] \0]]
} errMsg]} {
# fallback to a more generic groups retrieval (in case '-z' option not supported on id)
set usergroups [lsort [exec id -G -n]]
if {[catch {
set usergroups [lsort [exec id -G -n]]
} errMsg]} {
set group_name_fetch_failed 1
# fallback in case all group names could not be resolved by 'id' command
# it happens especially when running testsuite through mockbuild
foreach grpinfo [split [string range [lindex [split $idoutput] 2] 7 end] ,] {
if {[set idx [string first ( $grpinfo]] != -1} {
set grp [string range $grpinfo $idx+1 end-1]
} else {
set grp $grpinfo
}
lappend usergroups $grp
}
set usergroups [lsort $usergroups]
}
}
# filter specific volatile groups
set usergroups [lsearch -all -inline -not -glob $usergroups com.apple.sharepoint.group.*]
Expand Down
6 changes: 6 additions & 0 deletions testsuite/modules.20-locate/112-hide-user-group.exp
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,10 @@ setenv_path_var MODULEPATH $mp

setenv_var MODULERCFILE $env(TESTSUITEDIR)/etc/modulerc.hide

if {$group_name_fetch_failed} {
send_user "\tSkip user group tests, as group name fetch failed\n"
} else {


set ans [list]
lappend ans [list set __MODULES_LMALTNAME hide1/5.0&as|hide1/latest]
Expand Down Expand Up @@ -247,6 +251,8 @@ testouterr_cmd sh {load hide1@5:} $ans $tserr4
testouterr_cmd sh {avail -t hide1@5:} OK $tserr1
unsetenv_var TESTSUITE_HIDE_ALLOW_USER_GROUP_ERR_SET3

}


#
# Cleanup
Expand Down
6 changes: 6 additions & 0 deletions testsuite/modules.20-locate/117-forbid-user-group.exp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ setenv_path_var MODULEPATH $mp

setenv_var MODULERCFILE $env(TESTSUITEDIR)/etc/modulerc.hide

if {$group_name_fetch_failed} {
send_user "\tSkip user group tests, as group name fetch failed\n"
} else {


set ans [list]
lappend ans [list set __MODULES_LMALTNAME hide1/5.0&as|hide1/latest]
Expand Down Expand Up @@ -132,6 +136,8 @@ testouterr_cmd sh {load hide1@5:} $ans $tserr3
testouterr_cmd sh {avail -t hide1@5:} OK $tserr1
unsetenv_var TESTSUITE_FORBID_ALLOW_USER_GROUP_ERR_SET2

}


#
# Cleanup
Expand Down
6 changes: 6 additions & 0 deletions testsuite/modules.20-locate/119-hide-cascading.exp
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ setenv_path_var MODULEPATH $mp
setenv_var MODULERCFILE $env(TESTSUITEDIR)/etc/modulerc.hide


if {$group_name_fetch_failed} {
send_user "\tSkip user group tests, as group name fetch failed\n"
} else {

setenv_var TESTSUITE_HIDE1_CASC_SET1 1
testouterr_cmd sh {avail -t hide1@4:} OK {}
testouterr_cmd sh {load hide1@4:} ERR $err_path'hide1@4:'
Expand Down Expand Up @@ -380,6 +384,8 @@ testouterr_cmd sh {whatis hide4} ERR $err_path'hide4'
testouterr_cmd_re sh {whatis hide4/.1.0} ERR [err_unablelocate hide4/.1.0]
unsetenv_var TESTSUITE_HIDE4_CASC3_SET1

}


#
# Cleanup
Expand Down
5 changes: 5 additions & 0 deletions testsuite/modules.50-cmds/287-info-usergroups.exp
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@ set mpre [regsub -all "\(\[.+?\]\)" $mp {\\\1}]
# setup specific environment
setenv_path_var MODULEPATH $mp

if {$group_name_fetch_failed} {
send_user "\tSkip user group tests, as group name fetch failed\n"
} else {

# modulefile usage
set ans [list]
Expand Down Expand Up @@ -130,6 +133,8 @@ unsetenv_var TESTSUITE_INFO_GROUP_IN_RC
unsetenv_var TESTSUITE_ENABLE_SITECONFIG_WINDOWS_PLATFORM
}

}


#
# Cleanup
Expand Down
6 changes: 6 additions & 0 deletions testsuite/modules.50-cmds/440-module-tag.exp
Original file line number Diff line number Diff line change
Expand Up @@ -310,6 +310,10 @@ lappend ans [list set __MODULES_LMTAG tag/5.0&foo]
testouterr_cmd sh {load tag/5.0} $ans {}
unsetenv_var TESTSUITE_MODULE_TAG_SET6

if {$group_name_fetch_failed} {
send_user "\tSkip user group tests, as group name fetch failed\n"
} else {

setenv_var TESTSUITE_MODULE_TAG_SET7 1
set tserr "$mp:
tag/5.0
Expand All @@ -335,6 +339,8 @@ lappend ans [list set __MODULES_LMTAG tag/5.0&foo]
testouterr_cmd sh {load tag/5.0} $ans {}
unsetenv_var TESTSUITE_MODULE_TAG_SET8

}

unsetenv_var MODULES_ADVANCED_VERSION_SPEC

# use module-tag in modulefile
Expand Down
22 changes: 22 additions & 0 deletions testsuite/modules.70-maint/220-config.exp
Original file line number Diff line number Diff line change
Expand Up @@ -392,6 +392,13 @@ append tserr "\n\n$state_header"
if {[auto_execok uname] eq {} || [auto_execok domainname] eq {}} {
append tserr "(\nWARNING: Command '\\S+' cannot be found)+"
}
if {$group_name_fetch_failed} {
if {$install_libtclenvmodules eq {y}} {
append tserr "(\nWARNING: couldn't find name for group id \"\\S+\": Success)+"
} else {
append tserr "(\nWARNING: .*\n .*/id: cannot find name for group ID \\S+)+"
}
}
foreach param $statelist {
append tserr "\n$param\\s+.*"
}
Expand Down Expand Up @@ -420,6 +427,14 @@ foreach param [lsort [array names configset]] {
}
append tserr "\n\n$state_header"
append tserr "(\nWARNING: Command '\\S+' cannot be found)+"
if {$group_name_fetch_failed} {
if {$install_libtclenvmodules eq {y}} {
append tserr "(\nWARNING: couldn't find name for group id \"\\S+\": Success)+"
} else {
append tserr "(\nWARNING: Command '\\S+' cannot be found)*"
}
}
append tserr "(\nWARNING: Command '\\S+' cannot be found)*"
foreach param $statelist {
append tserr "\n$param\\s+.*"
}
Expand Down Expand Up @@ -452,6 +467,13 @@ append tserr "\n\n$state_header"
if {[auto_execok uname] eq {} || [auto_execok domainname] eq {}} {
append tserr "(\nWARNING: Command '\\S+' cannot be found)+"
}
if {$group_name_fetch_failed} {
if {$install_libtclenvmodules eq {y}} {
append tserr "(\nWARNING: couldn't find name for group id \"\\S+\": Success)+"
} else {
append tserr "(\nWARNING: .*\n .*/id: cannot find name for group ID \\S+)+"
}
}
foreach param $statelist {
append tserr "\n$param\\s+.*"
}
Expand Down
7 changes: 7 additions & 0 deletions testsuite/modules.70-maint/390-state.exp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,13 @@ set tserr "$vers_reportre\n\n$state_header"
if {[auto_execok uname] eq {} || [auto_execok domainname] eq {}} {
append tserr "(\nWARNING: Command '\\S+' cannot be found)+"
}
if {$group_name_fetch_failed} {
if {$install_libtclenvmodules eq {y}} {
append tserr "(\nWARNING: couldn't find name for group id \"\\S+\": Success)+"
} else {
append tserr "(\nWARNING: .*\n .*/id: cannot find name for group ID \\S+)+"
}
}
foreach param $statelist {
append tserr "\n$param\\s+.*"
}
Expand Down

0 comments on commit d04eb75

Please sign in to comment.