-
Notifications
You must be signed in to change notification settings - Fork 129
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Robert McLay
committed
Nov 6, 2023
1 parent
3374ef8
commit 217c9da
Showing
7 changed files
with
234 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,103 @@ | ||
#!/usr/bin/env lua | ||
-- -*- lua -*- | ||
|
||
local sys_lua_path = "@sys_lua_path@" | ||
if (sys_lua_path:sub(1,1) == "@") then | ||
sys_lua_path = package.path | ||
end | ||
|
||
local sys_lua_cpath = "@sys_lua_cpath@" | ||
if (sys_lua_cpath:sub(1,1) == "@") then | ||
sys_lua_cpath = package.cpath | ||
end | ||
|
||
package.path = sys_lua_path | ||
package.cpath = sys_lua_cpath | ||
|
||
local arg_0 = arg[0] | ||
_G._DEBUG = false | ||
local posix = require("posix") | ||
local readlink = posix.readlink | ||
local stat = posix.stat | ||
|
||
local st = stat(arg_0) | ||
while (st.type == "link") do | ||
local lnk = readlink(arg_0) | ||
if (arg_0:find("/") and (lnk:find("^/") == nil)) then | ||
local dir = arg_0:gsub("/[^/]*$","") | ||
lnk = dir .. "/" .. lnk | ||
end | ||
arg_0 = lnk | ||
st = stat(arg_0) | ||
end | ||
|
||
local ia,ja = arg_0:find(".*/") | ||
local LuaCommandName = false | ||
local LuaCommandName_dir = "./" | ||
if (ia) then | ||
LuaCommandName_dir = arg_0:sub(1,ja) | ||
LuaCommandName = arg_0:sub(ja+1) | ||
end | ||
|
||
package.path = LuaCommandName_dir .. "?.lua;" .. | ||
LuaCommandName_dir .. "../tools/?.lua;" .. | ||
LuaCommandName_dir .. "../tools/?/init.lua;" .. | ||
LuaCommandName_dir .. "../shells/?.lua;" .. | ||
LuaCommandName_dir .. "?/init.lua;" .. | ||
sys_lua_path | ||
package.cpath = LuaCommandName_dir .. "../lib/?.so;".. | ||
sys_lua_cpath | ||
|
||
require("strict") | ||
require("string_utils") | ||
require("serializeTbl") | ||
local dbg = require("Dbg"):dbg() | ||
if ( _VERSION ~= "Lua 5.1" ) then | ||
require("declare") | ||
declare("loadstring") | ||
loadstring = load | ||
end | ||
local json = require("json") | ||
local getenv = os.getenv | ||
local strfmt = string.format | ||
local concatTbl = table.concat | ||
local base64 = require("base64") | ||
local decode64 = base64.decode64 | ||
|
||
|
||
function main() | ||
-- dbg:activateDebug(1) | ||
local fn = arg[1] | ||
local f = io.open(fn) | ||
if (not f) then | ||
io.stderr:write("Error: ",fn,"not found!\n") | ||
exit(1) | ||
end | ||
|
||
local whole = f:read("*all") | ||
f:close() | ||
local tbl = json.decode(whole) | ||
local nblks = tonumber(tbl.env._ModuleTable_Sz_) | ||
local sA = {} | ||
local piece = "_ModuleTable%03d_" | ||
|
||
tbl.env._ModuleTable_Sz_ = nil | ||
for i = 1,nblks do | ||
local envNm = strfmt(piece,i) | ||
sA[#sA+1] = tbl.env[envNm] | ||
tbl.env[envNm] = nil | ||
end | ||
|
||
tbl.env.MT = decode64(concatTbl(sA)) | ||
|
||
|
||
local s = serializeTbl{ indent = true, name = "loadTbl", | ||
value = tbl} | ||
io.stdout:write(s) | ||
|
||
|
||
|
||
end | ||
|
||
|
||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
=========================== | ||
step 1 | ||
lua ProjectDIR/src/lmod.in.lua shell --regression_testing --version | ||
=========================== | ||
Modules based on Lua: Version 8.7.32 2023-08-28 12:42 -05:00 | ||
by Robert McLay [email protected] | ||
=========================== | ||
step 2 | ||
lua ProjectDIR/proj_mgmt/jsonLoadConversion load.json | ||
=========================== |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
-- -*- lua -*- | ||
local testName = "jsonShell" | ||
|
||
testdescript = { | ||
owner = "rtm", | ||
product = "modules", | ||
description = [[ | ||
Test initial module load | ||
]], | ||
keywords = {testName }, | ||
|
||
active = 1, | ||
testName = testName, | ||
job_submit_method = "INTERACTIVE", | ||
|
||
runScript = [[ | ||
. $(projectDir)/rt/common_funcs.sh | ||
unsetMT | ||
initStdEnvVars | ||
MODULEPATH=$(testDir)/mf/Core; export MODULEPATH | ||
rm -f _stderr.* _stdout.* err.* out.* | ||
rm -fr .lmod.d .lmodrc.lua load.json .cache .config | ||
runLmod --version # 1 | ||
LD_PRELOAD= $LUA_EXEC $projectDir/src/lmod.in.lua json load A > load.json | ||
runBase $LUA_EXEC $projectDir/proj_mgmt/jsonLoadConversion load.json | ||
HOME=$ORIG_HOME | ||
cat _stdout.[0-9][0-9][0-9] > _stdout.orig | ||
joinBase64Results -bash _stdout.orig _stdout.new | ||
cleanUp _stdout.new out.txt | ||
cat _stderr.[0-9][0-9][0-9] > _stderr.orig | ||
cleanUp _stderr.orig err.txt | ||
rm -f results.csv | ||
wrapperDiff --csv results.csv $(testDir)/out.txt out.txt | ||
wrapperDiff --csv results.csv $(testDir)/err.txt err.txt | ||
testFinish -r $(resultFn) -t $(runtimeFn) results.csv | ||
]], | ||
|
||
|
||
blessScript = [[ | ||
# perform what is needed | ||
]], | ||
|
||
tests = { | ||
{ id='t1'}, | ||
}, | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
setenv("A","A") | ||
prepend_path("MY_PATH","/path/to/nowhere") | ||
local bashStr = 'eval $($LMOD_DIR/ml_cmd "$@")' | ||
local cshStr = "eval `$LMOD_DIR/ml_cmd $*`" | ||
set_shell_function("ml",bashStr,cshStr) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
=========================== | ||
step 1 | ||
lua ProjectDIR/src/lmod.in.lua shell --regression_testing --version | ||
=========================== | ||
=========================== | ||
step 2 | ||
lua ProjectDIR/proj_mgmt/jsonLoadConversion load.json | ||
=========================== | ||
loadTbl = { | ||
_mlstatus = true, | ||
alias = {}, | ||
env = { | ||
A = "A", | ||
LOADEDMODULES = "A/1.0", | ||
MODULEPATH = "ProjectDIR/rt/jsonShell/mf/Core", | ||
MT = [[_ModuleTable_ = { | ||
MTversion = 3, | ||
c_rebuildTime = false, | ||
c_shortTime = false, | ||
depthT = {}, | ||
family = {}, | ||
mT = { | ||
A = { | ||
fn = "ProjectDIR/rt/jsonShell/mf/Core/A/1.0.lua", | ||
fullName = "A/1.0", | ||
loadOrder = 1, | ||
propT = {}, | ||
stackDepth = 0, | ||
status = "active", | ||
userName = "A", | ||
wV = "000000001.*zfinal", | ||
}, | ||
}, | ||
mpathA = { | ||
"ProjectDIR/rt/jsonShell/mf/Core", | ||
}, | ||
systemBaseMPATH = "ProjectDIR/rt/jsonShell/mf/Core", | ||
} | ||
]], | ||
MY_PATH = "/path/to/nowhere", | ||
_LMFILES_ = "ProjectDIR/rt/jsonShell/mf/Core/A/1.0.lua", | ||
}, | ||
shellFunc = { | ||
ml = { | ||
"eval $($LMOD_DIR/ml_cmd \"$@\")", "eval `$LMOD_DIR/ml_cmd $*`", | ||
}, | ||
}, | ||
unset = {}, | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters