File: 287-info-usergroups.exp

package info (click to toggle)
modules 5.2.0-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 20,572 kB
  • sloc: exp: 46,525; sh: 5,261; tcl: 3,182; makefile: 1,355; ansic: 466; python: 251; csh: 201; perl: 47; ruby: 44
file content (143 lines) | stat: -rw-r--r-- 4,562 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
##############################################################################
#   Modules Revision 3.0
#   Providing a flexible user environment
#
#   File:		modules.50-cmds/%M%
#   Revision:		%I%
#   First Edition:	2020/06/05
#   Last Mod.:		%U%, %G%
#
#   Authors:		Xavier Delaruelle, xavier.delaruelle@cea.fr
#
#   Description:	Testuite testsequence
#   Command:
#   Modulefiles:    module-info usergroups
#   Sub-Command:    *
#
#   Comment:	%C{
#           Check 'module-info usergroups' modulefile command
#		}C%
#
##############################################################################

# ensure auto symbolic versions are not set for these tests
setenv_var MODULES_ADVANCED_VERSION_SPEC 0

set mp $modpath.2
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]
lappend ans [list set TS1 $usergroups]
lappend ans [list set TS2 1]
lappend ans [list set _LMFILES_ $mp/info/usergroups]
lappend ans [list set LOADEDMODULES info/usergroups]
lappend ans [list set TS3 0]
testouterr_cmd sh {load info/usergroups} $ans {}

skip_if_quick_mode

set usergroups_disp [expr {[llength $usergroups] > 1 ? [regsub -all "\(\[{}\]\)" "{$usergroups}" {\\\1}] : $usergroups}]
set tserr "$modlin
$mpre/info/usergroups:

setenv\t\tTS1 $usergroups_disp
setenv\t\tTS2 1
setenv\t\tTS3 0
$modlin"
testouterr_cmd_re sh {show info/usergroups} OK $tserr

# modulerc usage
testouterr_cmd sh "is-avail info/$userfgroup" ERR {}
setenv_var TESTSUITE_INFO_GROUP_IN_RC 1
testouterr_cmd sh "is-avail info/$userfgroup" OK {}
testouterr_cmd_re sh "show info/$userfgroup" OK $tserr
unsetenv_var TESTSUITE_INFO_GROUP_IN_RC


# make `id` command unavailable
setenv_var PATH {}
if {$install_libtclenvmodules eq {y}} {
    testouterr_cmd sh {load info/usergroups} $ans {}
} else {
    # impact on modulefile
    set tserr [msg_load info/usergroups "$error_msgs: Command 'id' cannot be found"]
    testouterr_cmd sh {load info/usergroups} ERR $tserr

    # impact on modulerc
    setenv_var TESTSUITE_INFO_GROUP_IN_RC 1
    testouterr_cmd sh "is-avail info/$userfgroup" ERR {}

    switch -- $tclsh_version {
    8.5 {
        set tserr [escre [msg_moderr {Command 'id' cannot be found} {module-info usergroups"
      invoked from within
  "if {[info exists env(TESTSUITE_INFO_GROUP_IN_RC)]} {
      foreach grp [module-info usergroups] {
          module-virtual info/$grp ./usergroups
      }
  }} $mp/info/.modulerc 6 {  }]\n$err_path'info/$userfgroup']
    }
    default {
        set tserr [escre [msg_moderr {Command 'id' cannot be found} {module-info usergroups} $mp/info/.modulerc 7 {  }]\n$err_path'info/$userfgroup']
    }}
    testouterr_cmd_re sh "show info/$userfgroup" ERR $tserr

    unsetenv_var TESTSUITE_INFO_GROUP_IN_RC
}
setenv_var PATH $ORIG_PATH


# fake Windows platform if expected siteconfig file is installed
if {[siteconfig_isStderrTty]} {
# fake Windows platform with a cmd.exe tool to execute system commands
setenv_var TESTSUITE_ENABLE_SITECONFIG_WINDOWS_PLATFORM 1

switch -- $tclsh_version {
8.5 {
    set tserr [escre [msg_load info/usergroups [msg_moderr {module-info usergroups not supported on Windows platform} {module-info usergroups"
    invoked from within
"lsort [module-info usergroups]"
    invoked from within
"set grplist [lsort [module-info usergroups]]} $mp/info/usergroups 2 {}]]]
}
default {
    set tserr [escre [msg_load info/usergroups [msg_moderr {module-info usergroups not supported on Windows platform} {module-info usergroups} $mp/info/usergroups 2 {}]]]
}}
testouterr_cmd_re sh {load info/usergroups} ERR $tserr

setenv_var TESTSUITE_INFO_GROUP_IN_RC 1
switch -- $tclsh_version {
8.5 {
    set tserr [escre [msg_moderr {module-info usergroups not supported on Windows platform} {module-info usergroups"
      invoked from within
  "if {[info exists env(TESTSUITE_INFO_GROUP_IN_RC)]} {
      foreach grp [module-info usergroups] {
          module-virtual info/$grp ./usergroups
      }
  }} $mp/info/.modulerc 6 {  }]\n$err_path'info/$userfgroup']
}
default {
    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']
}}
testouterr_cmd_re sh "load info/$userfgroup" ERR $tserr
unsetenv_var TESTSUITE_INFO_GROUP_IN_RC

unsetenv_var TESTSUITE_ENABLE_SITECONFIG_WINDOWS_PLATFORM
}

}


#
#  Cleanup
#

reset_test_env