Lua4z
A binary distribution of Lua for z/OS, with batteries
-- Installation verification procedure (IVP)

-- Verify that Lua4z is installed and configured correctly

-- Check that LUA_PATH has been set correctly
local function check_path()
  local modules = { "say", "pl", "pl.stringx" }
  for _, module in ipairs(modules) do
    if not pcall(require, module) then return false end
  end
  return true
end

-- Check that LUA_CPATH has been set correctly
local function check_cpath()
  local modules = { "cjson", "socket" }
  for _, module in ipairs(modules) do
    if not pcall(require, module) then return false end
  end
  return true
end

-- Define a table that identifies and describes the verification functions
local tests = {
  { check_path,  "Checking LUA_PATH configuration" },
  { check_cpath, "Checking LUA_CPATH configuration" }
}

-- Display banner
print("Lua4z installation verification procedure (IVP)\n")

-- Call the verification functions
local passed = 0
for _, test in ipairs(tests) do
  local pass = test[1]()
  if pass then passed = passed + 1  end
  print(test[2] .. ": " .. (pass and "passed" or "failed"))
end

local failed = #tests - passed

print([[

Test results:
  ]]..passed..[[ passed
  ]]..failed..[[ failed
]])

if failed == 0 then
  print "Success: all tests passed.\n"
end

return failed