testbed-runner.lua 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. -- testbed-runner.lua — run the full balancerlite suite inside OpenWrt.
  2. package.path = "/testbed/src/?.lua;/testbed/src/?/init.lua;;"
  3. local files = {
  4. "tests/sha256.lua",
  5. "tests/state.lua",
  6. "tests/routing.lua",
  7. "tests/wg.lua",
  8. "tests/ctl.lua",
  9. "tests/smoke.lua",
  10. "tests/probes_config.lua",
  11. }
  12. local failures = 0
  13. for _, f in ipairs(files) do
  14. print(string.rep("=", 50))
  15. print("RUN " .. f)
  16. local ok, err = os.execute("lua " .. f .. " > /testbed/out-" .. f:match("tests/([%w_]+)%.lua") .. ".txt 2>&1")
  17. local rc = (ok and 0) or 1
  18. print(" exit=" .. rc .. (err and (" err=" .. tostring(err)) or ""))
  19. if rc ~= 0 then
  20. failures = failures + 1
  21. end
  22. end
  23. -- dump each output file
  24. local ofiles = {
  25. "out-sha256.txt",
  26. "out-state.txt",
  27. "out-routing.txt",
  28. "out-wg.txt",
  29. "out-ctl.txt",
  30. "out-smoke.txt",
  31. "out-probes_config.txt",
  32. }
  33. for _, f in ipairs(ofiles) do
  34. local fh = io.open("/testbed/" .. f, "r")
  35. if fh then
  36. local body = fh:read("*a")
  37. fh:close()
  38. print("----- " .. f .. " -----")
  39. print(body)
  40. end
  41. end
  42. print(string.rep("=", 50))
  43. if failures == 0 then
  44. print("TESTBED RESULT: ALL 7 SUITES PASS")
  45. else
  46. print("TESTBED RESULT: " .. failures .. " suite(s) FAILED")
  47. end
  48. os.exit(failures == 0 and 0 or 1)