| 1 |
############################################################################## |
| 2 |
# Modules Revision 3.0 |
| 3 |
# Providing a flexible user environment |
| 4 |
# |
| 5 |
# File: modules.50-cmds/%M% |
| 6 |
# Revision: %I% |
| 7 |
# First Edition: 2020/06/05 |
| 8 |
# Last Mod.: %U%, %G% |
| 9 |
# |
| 10 |
# Authors: Xavier Delaruelle, [email protected] |
| 11 |
# |
| 12 |
# Description: Testuite testsequence |
| 13 |
# Command: |
| 14 |
# Modulefiles: module-info usergroups |
| 15 |
# Sub-Command: * |
| 16 |
# |
| 17 |
# Comment: %C{ |
| 18 |
# Check 'module-info usergroups' modulefile command |
| 19 |
# }C% |
| 20 |
# |
| 21 |
############################################################################## |
| 22 |
|
| 23 |
# ensure auto symbolic versions are not set for these tests |
| 24 |
setenv_var MODULES_ADVANCED_VERSION_SPEC 0 |
| 25 |
|
| 26 |
set mp $modpath.2 |
| 27 |
set mpre [regsub -all "\(\[.+?\]\)" $mp {\\\1}] |
| 28 |
|
| 29 |
# setup specific environment |
| 30 |
setenv_path_var MODULEPATH $mp |
| 31 |
|
| 32 |
# modulefile usage |
| 33 |
set ans [list] |
| 34 |
lappend ans [list set TS1 $usergroups] |
| 35 |
lappend ans [list set TS2 1] |
| 36 |
lappend ans [list set _LMFILES_ $mp/info/usergroups] |
| 37 |
lappend ans [list set LOADEDMODULES info/usergroups] |
| 38 |
lappend ans [list set TS3 0] |
| 39 |
testouterr_cmd sh {load info/usergroups} $ans {} |
| 40 |
|
| 41 |
skip_if_quick_mode |
| 42 |
|
| 43 |
set usergroups_disp [expr {[llength $usergroups] > 1 ? [regsub -all "\(\[{}\]\)" "{$usergroups}" {\\\1}] : $usergroups}] |
| 44 |
set tserr "$modlin |
| 45 |
$mpre/info/usergroups: |
| 46 |
|
| 47 |
setenv\t\tTS1 $usergroups_disp |
| 48 |
setenv\t\tTS2 1 |
| 49 |
setenv\t\tTS3 0 |
| 50 |
$modlin" |
| 51 |
testouterr_cmd_re sh {show info/usergroups} OK $tserr |
| 52 |
|
| 53 |
# modulerc usage |
| 54 |
testouterr_cmd sh "is-avail info/$userfgroup" ERR {} |
| 55 |
setenv_var TESTSUITE_INFO_GROUP_IN_RC 1 |
| 56 |
testouterr_cmd sh "is-avail info/$userfgroup" OK {} |
| 57 |
testouterr_cmd_re sh "show info/$userfgroup" OK $tserr |
| 58 |
unsetenv_var TESTSUITE_INFO_GROUP_IN_RC |
| 59 |
|
| 60 |
|
| 61 |
# make `id` command unavailable |
| 62 |
setenv_var PATH {} |
| 63 |
if {$install_libtclenvmodules eq {y}} { |
| 64 |
testouterr_cmd sh {load info/usergroups} $ans {} |
| 65 |
} else { |
| 66 |
# impact on modulefile |
| 67 |
set tserr [msg_load info/usergroups "$error_msgs: Command 'id' cannot be found"] |
| 68 |
testouterr_cmd sh {load info/usergroups} ERR $tserr |
| 69 |
|
| 70 |
# impact on modulerc |
| 71 |
setenv_var TESTSUITE_INFO_GROUP_IN_RC 1 |
| 72 |
testouterr_cmd sh "is-avail info/$userfgroup" ERR {} |
| 73 |
|
| 74 |
switch -- $tclsh_version { |
| 75 |
8.5 { |
| 76 |
set tserr [escre [msg_moderr {Command 'id' cannot be found} {module-info usergroups" |
| 77 |
invoked from within |
| 78 |
"if {[info exists env(TESTSUITE_INFO_GROUP_IN_RC)]} { |
| 79 |
foreach grp [module-info usergroups] { |
| 80 |
module-virtual info/$grp ./usergroups |
| 81 |
} |
| 82 |
}} $mp/info/.modulerc 6 { }]\n$err_path'info/$userfgroup'] |
| 83 |
} |
| 84 |
default { |
| 85 |
set tserr [escre [msg_moderr {Command 'id' cannot be found} {module-info usergroups} $mp/info/.modulerc 7 { }]\n$err_path'info/$userfgroup'] |
| 86 |
}} |
| 87 |
testouterr_cmd_re sh "show info/$userfgroup" ERR $tserr |
| 88 |
|
| 89 |
unsetenv_var TESTSUITE_INFO_GROUP_IN_RC |
| 90 |
} |
| 91 |
setenv_var PATH $ORIG_PATH |
| 92 |
|
| 93 |
|
| 94 |
# fake Windows platform if expected siteconfig file is installed |
| 95 |
if {[siteconfig_isStderrTty]} { |
| 96 |
# fake Windows platform with a cmd.exe tool to execute system commands |
| 97 |
setenv_var TESTSUITE_ENABLE_SITECONFIG_WINDOWS_PLATFORM 1 |
| 98 |
|
| 99 |
switch -- $tclsh_version { |
| 100 |
8.5 { |
| 101 |
set tserr [escre [msg_load info/usergroups [msg_moderr {module-info usergroups not supported on Windows platform} {module-info usergroups" |
| 102 |
invoked from within |
| 103 |
"lsort [module-info usergroups]" |
| 104 |
invoked from within |
| 105 |
"set grplist [lsort [module-info usergroups]]} $mp/info/usergroups 2 {}]]] |
| 106 |
} |
| 107 |
default { |
| 108 |
set tserr [escre [msg_load info/usergroups [msg_moderr {module-info usergroups not supported on Windows platform} {module-info usergroups} $mp/info/usergroups 2 {}]]] |
| 109 |
}} |
| 110 |
testouterr_cmd_re sh {load info/usergroups} ERR $tserr |
| 111 |
|
| 112 |
setenv_var TESTSUITE_INFO_GROUP_IN_RC 1 |
| 113 |
switch -- $tclsh_version { |
| 114 |
8.5 { |
| 115 |
set tserr [escre [msg_moderr {module-info usergroups not supported on Windows platform} {module-info usergroups" |
| 116 |
invoked from within |
| 117 |
"if {[info exists env(TESTSUITE_INFO_GROUP_IN_RC)]} { |
| 118 |
foreach grp [module-info usergroups] { |
| 119 |
module-virtual info/$grp ./usergroups |
| 120 |
} |
| 121 |
}} $mp/info/.modulerc 6 { }]\n$err_path'info/$userfgroup'] |
| 122 |
} |
| 123 |
default { |
| 124 |
set tserr [escre [msg_moderr {module-info usergroups not supported on Windows platform} {module-info usergroups} $mp/info/.modulerc 7 { }]\n$err_path'info/$userfgroup'] |
| 125 |
}} |
| 126 |
testouterr_cmd_re sh "load info/$userfgroup" ERR $tserr |
| 127 |
unsetenv_var TESTSUITE_INFO_GROUP_IN_RC |
| 128 |
|
| 129 |
unsetenv_var TESTSUITE_ENABLE_SITECONFIG_WINDOWS_PLATFORM |
| 130 |
} |
| 131 |
|
| 132 |
|
| 133 |
if {[llength $setpriv_call]} { |
| 134 |
|
| 135 |
set ans [list] |
| 136 |
lappend ans [list set TS1 [join [lsort [list $userfgroup 1234567]]]] |
| 137 |
lappend ans [list set TS2 1] |
| 138 |
lappend ans [list set _LMFILES_ $mp/info/usergroups] |
| 139 |
lappend ans [list set LOADEDMODULES info/usergroups] |
| 140 |
lappend ans [list set TS3 0] |
| 141 |
set launcher [list {*}$setpriv_call --ruid $username --regid $userfgroup --groups 1234567] |
| 142 |
testouterr_cmd sh {load info/usergroups} $ans {} fail $launcher |
| 143 |
|
| 144 |
} else { |
| 145 |
send_user "\tSkip setpriv tests as it is not supported in this environment\n" |
| 146 |
} |
| 147 |
|
| 148 |
# |
| 149 |
# Cleanup |
| 150 |
# |
| 151 |
|
| 152 |
reset_test_env |