From 1e293dd95ed983ee57c6786f36eb1ef7a7aef65a Mon Sep 17 00:00:00 2001 From: Xavier Delaruelle Date: Wed, 27 Sep 2023 15:45:14 +0200 Subject: [PATCH] ts: add new tests for sticky rules --- testsuite/modulefiles.4/.modulerc | 11 ++ testsuite/modulefiles.4/sticky0 | 1 + testsuite/modulefiles.4/sticky1/.modulerc | 24 +++ testsuite/modulefiles.4/sticky1/1.0 | 1 + testsuite/modulefiles.4/sticky1/2.0 | 1 + testsuite/modulefiles.4/sticky1/3.0 | 1 + testsuite/modulefiles.4/sticky2/1.0 | 14 ++ testsuite/modulefiles.4/sticky2/2.0 | 1 + testsuite/modulefiles.4/sticky3/1.0 | 25 +++ testsuite/modulefiles.4/sticky3/2.0 | 1 + testsuite/modulefiles.4/sticky4/.modulerc | 14 ++ testsuite/modulefiles.4/sticky4/sub/1.0 | 1 + testsuite/modulefiles.4/sticky4/sub/2.0 | 1 + testsuite/modulefiles.4/sticky4/sub/3.0 | 1 + testsuite/modulefiles.4/sticky4/sub2/1.0 | 1 + .../modules.50-cmds/462-sticky-corner.exp | 173 ++++++++++++++++++ 16 files changed, 271 insertions(+) create mode 100644 testsuite/modulefiles.4/sticky0 create mode 100644 testsuite/modulefiles.4/sticky1/.modulerc create mode 100644 testsuite/modulefiles.4/sticky1/1.0 create mode 100644 testsuite/modulefiles.4/sticky1/2.0 create mode 100644 testsuite/modulefiles.4/sticky1/3.0 create mode 100644 testsuite/modulefiles.4/sticky2/1.0 create mode 100644 testsuite/modulefiles.4/sticky2/2.0 create mode 100644 testsuite/modulefiles.4/sticky3/1.0 create mode 100644 testsuite/modulefiles.4/sticky3/2.0 create mode 100644 testsuite/modulefiles.4/sticky4/.modulerc create mode 100644 testsuite/modulefiles.4/sticky4/sub/1.0 create mode 100644 testsuite/modulefiles.4/sticky4/sub/2.0 create mode 100644 testsuite/modulefiles.4/sticky4/sub/3.0 create mode 100644 testsuite/modulefiles.4/sticky4/sub2/1.0 diff --git a/testsuite/modulefiles.4/.modulerc b/testsuite/modulefiles.4/.modulerc index 201640298..86a261ad9 100644 --- a/testsuite/modulefiles.4/.modulerc +++ b/testsuite/modulefiles.4/.modulerc @@ -48,3 +48,14 @@ if {[info exists env(TESTSUITE_MODULEPATH_LABEL)]} { } } } + +if {[info exists ::env(TESTSUITE_STICKY)]} { + switch -- $::env(TESTSUITE_STICKY) { + 6 - 7 { + module-alias alsticky1 sticky1/2.0 + } + 8 { + module-tag sticky sticky0 + } + } +} diff --git a/testsuite/modulefiles.4/sticky0 b/testsuite/modulefiles.4/sticky0 new file mode 100644 index 000000000..1c148cdd2 --- /dev/null +++ b/testsuite/modulefiles.4/sticky0 @@ -0,0 +1 @@ +#%Module diff --git a/testsuite/modulefiles.4/sticky1/.modulerc b/testsuite/modulefiles.4/sticky1/.modulerc new file mode 100644 index 000000000..bb2e4646f --- /dev/null +++ b/testsuite/modulefiles.4/sticky1/.modulerc @@ -0,0 +1,24 @@ +#%Module +if {[info exists ::env(TESTSUITE_STICKY)]} { + switch -- $::env(TESTSUITE_STICKY) { + 1 { + module-tag sticky sticky1@1.0,2.0 + } + 2 - 6 { + module-tag sticky sticky1@1:2 + } + 3 { + module-tag sticky sticky1@0: + } + 4 { + module-tag sticky [file dirname $ModulesCurrentModulefile]/1.0 + } + 5 { + module-alias sticky1/1.5 sticky/1.0 + module-tag sticky sticky1@1:2 + } + 7 { + module-tag sticky sticky1 + } + } +} diff --git a/testsuite/modulefiles.4/sticky1/1.0 b/testsuite/modulefiles.4/sticky1/1.0 new file mode 100644 index 000000000..1c148cdd2 --- /dev/null +++ b/testsuite/modulefiles.4/sticky1/1.0 @@ -0,0 +1 @@ +#%Module diff --git a/testsuite/modulefiles.4/sticky1/2.0 b/testsuite/modulefiles.4/sticky1/2.0 new file mode 100644 index 000000000..1c148cdd2 --- /dev/null +++ b/testsuite/modulefiles.4/sticky1/2.0 @@ -0,0 +1 @@ +#%Module diff --git a/testsuite/modulefiles.4/sticky1/3.0 b/testsuite/modulefiles.4/sticky1/3.0 new file mode 100644 index 000000000..1c148cdd2 --- /dev/null +++ b/testsuite/modulefiles.4/sticky1/3.0 @@ -0,0 +1 @@ +#%Module diff --git a/testsuite/modulefiles.4/sticky2/1.0 b/testsuite/modulefiles.4/sticky2/1.0 new file mode 100644 index 000000000..d82fc0fbd --- /dev/null +++ b/testsuite/modulefiles.4/sticky2/1.0 @@ -0,0 +1,14 @@ +#%Module +if {[info exists ::env(TESTSUITE_STICKY)]} { + switch -- $::env(TESTSUITE_STICKY) { + 8 { + prereq sticky0 + } + 9 - 10 - 11 { + prereq sticky4/sub/1.0 sticky4/sub/2.0 + } + default { + prereq sticky1/1.0 sticky1/2.0 + } + } +} diff --git a/testsuite/modulefiles.4/sticky2/2.0 b/testsuite/modulefiles.4/sticky2/2.0 new file mode 100644 index 000000000..1c148cdd2 --- /dev/null +++ b/testsuite/modulefiles.4/sticky2/2.0 @@ -0,0 +1 @@ +#%Module diff --git a/testsuite/modulefiles.4/sticky3/1.0 b/testsuite/modulefiles.4/sticky3/1.0 new file mode 100644 index 000000000..da21dd7fa --- /dev/null +++ b/testsuite/modulefiles.4/sticky3/1.0 @@ -0,0 +1,25 @@ +#%Module +if {[info exists ::env(TESTSUITE_STICKY)]} { + switch -- $::env(TESTSUITE_STICKY) { + 5 { + prereq sticky2/1.0 + module switch sticky1/1.5 + } + 6 - 7 { + prereq sticky2/1.0 + module switch sticky1 alsticky1 + } + 8 { + prereq sticky2/1.0 + module switch sticky0 sticky1 + } + 9 - 10 - 11 { + prereq sticky2/1.0 + module switch sticky4/sub/2.0 + } + default { + prereq sticky2/1.0 + module switch sticky1/2.0 + } + } +} diff --git a/testsuite/modulefiles.4/sticky3/2.0 b/testsuite/modulefiles.4/sticky3/2.0 new file mode 100644 index 000000000..1c148cdd2 --- /dev/null +++ b/testsuite/modulefiles.4/sticky3/2.0 @@ -0,0 +1 @@ +#%Module diff --git a/testsuite/modulefiles.4/sticky4/.modulerc b/testsuite/modulefiles.4/sticky4/.modulerc new file mode 100644 index 000000000..571c55850 --- /dev/null +++ b/testsuite/modulefiles.4/sticky4/.modulerc @@ -0,0 +1,14 @@ +#%Module +if {[info exists ::env(TESTSUITE_STICKY)]} { + switch -- $::env(TESTSUITE_STICKY) { + 9 { + module-tag sticky sticky4/sub@1.0: + } + 10 { + module-tag sticky sticky4/sub + } + 11 { + module-tag sticky sticky4/sub sticky4 + } + } +} diff --git a/testsuite/modulefiles.4/sticky4/sub/1.0 b/testsuite/modulefiles.4/sticky4/sub/1.0 new file mode 100644 index 000000000..1c148cdd2 --- /dev/null +++ b/testsuite/modulefiles.4/sticky4/sub/1.0 @@ -0,0 +1 @@ +#%Module diff --git a/testsuite/modulefiles.4/sticky4/sub/2.0 b/testsuite/modulefiles.4/sticky4/sub/2.0 new file mode 100644 index 000000000..1c148cdd2 --- /dev/null +++ b/testsuite/modulefiles.4/sticky4/sub/2.0 @@ -0,0 +1 @@ +#%Module diff --git a/testsuite/modulefiles.4/sticky4/sub/3.0 b/testsuite/modulefiles.4/sticky4/sub/3.0 new file mode 100644 index 000000000..1c148cdd2 --- /dev/null +++ b/testsuite/modulefiles.4/sticky4/sub/3.0 @@ -0,0 +1 @@ +#%Module diff --git a/testsuite/modulefiles.4/sticky4/sub2/1.0 b/testsuite/modulefiles.4/sticky4/sub2/1.0 new file mode 100644 index 000000000..1c148cdd2 --- /dev/null +++ b/testsuite/modulefiles.4/sticky4/sub2/1.0 @@ -0,0 +1 @@ +#%Module diff --git a/testsuite/modules.50-cmds/462-sticky-corner.exp b/testsuite/modules.50-cmds/462-sticky-corner.exp index 3b10dd4bf..c0d8ad4a6 100644 --- a/testsuite/modules.50-cmds/462-sticky-corner.exp +++ b/testsuite/modules.50-cmds/462-sticky-corner.exp @@ -418,6 +418,179 @@ set tserr [msg_load foo/2.0] testouterr_cmd_re sh {restore testsuite/home/coll-sticky-6} $ans $tserr +# +# is sticky reloading tests over loading module +# + +set mp $modpath.4 +set mpre $modpathre.4 +setenv_path_var MODULEPATH $mp + +setenv_var MODULES_ADVANCED_VERSION_SPEC 1 + +unsetenv_loaded_module +unsetenv_var __MODULES_LMTAG + +setenv_var TESTSUITE_STICKY 1 + +set ans [list] +lappend ans [list set LOADEDMODULES sticky1/1.0:sticky2/1.0:sticky3/1.0] +lappend ans [list set _LMFILES_ $mp/sticky1/1.0:$mp/sticky2/1.0:$mp/sticky3/1.0] +lappend ans [list set __MODULES_LMPREREQ sticky2/1.0&sticky1/1.0|sticky1/2.0:sticky3/1.0&sticky2/1.0] +lappend ans [list set __MODULES_LMTAG sticky1/1.0&sticky&auto-loaded:sticky2/1.0&auto-loaded] +lappend ans [list ERR] +set tserr [msg_top_load sticky3/1.0 {} {sticky1/1.0 sticky2/1.0} {} $err_stickyunload] +testouterr_cmd_re sh {load --auto sticky3/1.0} $ans $tserr + +setenv_var TESTSUITE_STICKY 2 +testouterr_cmd_re sh {load --auto sticky3/1.0} $ans $tserr +setenv_var TESTSUITE_STICKY 3 +testouterr_cmd_re sh {load --auto sticky3/1.0} $ans $tserr +setenv_var TESTSUITE_STICKY 4 +testouterr_cmd_re sh {load --auto sticky3/1.0} $ans $tserr + +setenv_var TESTSUITE_STICKY 5 +testouterr_cmd_re sh {load --auto sticky3/1.0} $ans $tserr +setenv_var TESTSUITE_STICKY 6 +testouterr_cmd_re sh {load --auto sticky3/1.0} $ans $tserr + +setenv_var TESTSUITE_STICKY 7 +set ans [list] +lappend ans [list set LOADEDMODULES sticky1/1.0:sticky2/1.0:sticky3/1.0] +lappend ans [list set _LMFILES_ $mp/sticky1/1.0:$mp/sticky2/1.0:$mp/sticky3/1.0] +lappend ans [list set __MODULES_LMSTICKYRULE sticky1/1.0&sticky|sticky1] +lappend ans [list set __MODULES_LMPREREQ sticky2/1.0&sticky1/1.0|sticky1/2.0:sticky3/1.0&sticky2/1.0] +lappend ans [list set __MODULES_LMTAG sticky1/1.0&sticky&auto-loaded:sticky2/1.0&auto-loaded] +lappend ans [list ERR] +#FIXME module switch may resolve switched-on module prior testing stickiness is preserved +testouterr_cmd_re sh {load --auto sticky3/1.0} $ans $tserr + +setenv_var TESTSUITE_STICKY 8 +set ans [list] +lappend ans [list set __MODULES_LMPREREQ sticky2/1.0&sticky0] +lappend ans [list set _LMFILES_ $mp/sticky0:$mp/sticky2/1.0] +lappend ans [list set LOADEDMODULES sticky0:sticky2/1.0] +lappend ans [list set __MODULES_LMTAG sticky0&sticky&auto-loaded] +set tserr [msg_top_load sticky2/1.0 {} {sticky0} {}] +testouterr_cmd_re sh {load --auto sticky2/1.0} $ans $tserr +set tserr [msg_load sticky3/1.0 $err_stickyunload [err_conun sticky0]] +testouterr_cmd_re sh {load --auto sticky3/1.0} ERR $tserr + +setenv_var TESTSUITE_STICKY 9 +set ans [list] +lappend ans [list set __MODULES_LMPREREQ sticky2/1.0&sticky4/sub/1.0|sticky4/sub/2.0] +lappend ans [list set _LMFILES_ $mp/sticky4/sub/1.0:$mp/sticky2/1.0] +lappend ans [list set LOADEDMODULES sticky4/sub/1.0:sticky2/1.0] +lappend ans [list set __MODULES_LMTAG sticky4/sub/1.0&sticky&auto-loaded] +set tserr [msg_top_load sticky2/1.0 {} {sticky4/sub/1.0} {}] +testouterr_cmd_re sh {load --auto sticky2/1.0} $ans $tserr + +set ans [list] +lappend ans [list set LOADEDMODULES sticky4/sub/1.0:sticky2/1.0:sticky3/1.0] +lappend ans [list set _LMFILES_ $mp/sticky4/sub/1.0:$mp/sticky2/1.0:$mp/sticky3/1.0] +lappend ans [list set __MODULES_LMPREREQ sticky2/1.0&sticky4/sub/1.0|sticky4/sub/2.0:sticky3/1.0&sticky2/1.0] +lappend ans [list set __MODULES_LMTAG sticky4/sub/1.0&sticky&auto-loaded:sticky2/1.0&auto-loaded] +lappend ans [list ERR] +set tserr [msg_top_load sticky3/1.0 {} {sticky4/sub/1.0 sticky2/1.0} {} $err_stickyunload] +testouterr_cmd_re sh {load --auto sticky3/1.0} $ans $tserr + +setenv_var TESTSUITE_STICKY 10 +set ans [list] +lappend ans [list set __MODULES_LMPREREQ sticky2/1.0&sticky4/sub/1.0|sticky4/sub/2.0] +lappend ans [list set __MODULES_LMSTICKYRULE sticky4/sub/1.0&sticky|sticky4/sub] +lappend ans [list set _LMFILES_ $mp/sticky4/sub/1.0:$mp/sticky2/1.0] +lappend ans [list set LOADEDMODULES sticky4/sub/1.0:sticky2/1.0] +lappend ans [list set __MODULES_LMTAG sticky4/sub/1.0&sticky&auto-loaded] +set tserr [msg_top_load sticky2/1.0 {} {sticky4/sub/1.0} {}] +testouterr_cmd_re sh {load --auto sticky2/1.0} $ans $tserr + +set ans [list] +lappend ans [list set __MODULES_LMPREREQ sticky2/1.0&sticky4/sub/1.0|sticky4/sub/2.0:sticky3/1.0&sticky2/1.0&sticky4/sub/2.0] +lappend ans [list set __MODULES_LMSTICKYRULE sticky4/sub/2.0&sticky|sticky4/sub] +lappend ans [list set _LMFILES_ $mp/sticky4/sub/2.0:$mp/sticky2/1.0:$mp/sticky3/1.0] +lappend ans [list set LOADEDMODULES sticky4/sub/2.0:sticky2/1.0:sticky3/1.0] +lappend ans [list set __MODULES_LMTAG sticky4/sub/2.0&sticky&auto-loaded:sticky2/1.0&auto-loaded] +set tserr [msg_top_load sticky3/1.0 {sticky4/sub/1.0} {} {sticky2/1.0} {Loading requirement: sticky4/sub/1.0 sticky2/1.0 sticky4/sub/2.0}] +testouterr_cmd_re sh {load --auto sticky3/1.0} $ans $tserr + + +# +# inconsistent environment +# + +setenv_var TESTSUITE_STICKY 10 + +# sticky rule set but not tag +setenv_loaded_module [list sticky4/sub/1.0] [list $mp/sticky4/sub/1.0] +setenv_var __MODULES_LMSTICKYRULE sticky4/sub/1.0&sticky|sticky4/sub +unsetenv_var __MODULES_LMTAG +set ans [list] +lappend ans [list unset __MODULES_LMSTICKYRULE] +lappend ans [list unset _LMFILES_] +lappend ans [list unset LOADEDMODULES] +testouterr_cmd_re sh {unload --auto sticky4} $ans {} + +# sticky rule inconsistent +setenv_loaded_module [list sticky4/sub/1.0] [list $mp/sticky4/sub/1.0] +setenv_var __MODULES_LMSTICKYRULE sticky4/sub/1.0&sticky +setenv_var __MODULES_LMTAG sticky4/sub/1.0&sticky +set tserr [msg_switch {sticky4/sub/1.0 } sticky4/sub/2.0 $err_stickyunload] +testouterr_cmd_re sh {switch sticky4/sub/2.0} ERR $tserr + +setenv_var __MODULES_LMSTICKYRULE sticky4/sub/1.0 +testouterr_cmd_re sh {switch sticky4/sub/2.0} ERR $tserr + +setenv_var __MODULES_LMSTICKYRULE sticky4/sub/1.0&foo +testouterr_cmd_re sh {switch sticky4/sub/2.0} ERR $tserr + +setenv_var __MODULES_LMSTICKYRULE sticky4/sub/1.0& +testouterr_cmd_re sh {switch sticky4/sub/2.0} ERR $tserr + +setenv_var __MODULES_LMSTICKYRULE sticky4/sub/1.0&foo|sticky4/sub +testouterr_cmd_re sh {switch sticky4/sub/2.0} ERR $tserr + +setenv_var __MODULES_LMSTICKYRULE sticky4/sub/1.0&sticky| +testouterr_cmd_re sh {switch sticky4/sub/2.0} ERR $tserr + +unsetenv_loaded_module +unsetenv_var __MODULES_LMSTICKYRULE +unsetenv_var __MODULES_LMTAG + + +# +# several generic definition +# + +setenv_var TESTSUITE_STICKY 11 + +set ans [list] +lappend ans [list set __MODULES_LMPREREQ sticky2/1.0&sticky4/sub/1.0|sticky4/sub/2.0] +lappend ans [list set __MODULES_LMSTICKYRULE sticky4/sub/1.0&sticky|sticky4/sub|sticky4] +lappend ans [list set _LMFILES_ $mp/sticky4/sub/1.0:$mp/sticky2/1.0] +lappend ans [list set LOADEDMODULES sticky4/sub/1.0:sticky2/1.0] +lappend ans [list set __MODULES_LMTAG sticky4/sub/1.0&sticky&auto-loaded] +set tserr [msg_top_load sticky2/1.0 {} {sticky4/sub/1.0} {}] +testouterr_cmd_re sh {load --auto sticky2/1.0} $ans $tserr + +setenv_loaded_module [list sticky4/sub/1.0] [list $mp/sticky4/sub/1.0] +setenv_var __MODULES_LMSTICKYRULE sticky4/sub/1.0&sticky|sticky4/sub|sticky4 +setenv_var __MODULES_LMTAG sticky4/sub/1.0&sticky + +set tserr [msg_switch {sticky4/sub/1.0 } sticky4/sub2/1.0 $err_stickyunload] +testouterr_cmd_re sh {switch sticky4/sub2/1.0} ERR $tserr + +set ans [list] +lappend ans [list set __MODULES_LMSTICKYRULE sticky4/sub/2.0&sticky|sticky4/sub|sticky4] +lappend ans [list set _LMFILES_ $mp/sticky4/sub/2.0] +lappend ans [list set LOADEDMODULES sticky4/sub/2.0] +lappend ans [list set __MODULES_LMTAG sticky4/sub/2.0&sticky] +testouterr_cmd_re sh {switch sticky4/sub/2.0} $ans {} + +unsetenv_loaded_module +unsetenv_var __MODULES_LMSTICKYRULE +unsetenv_var __MODULES_LMTAG + + # # Cleanup #