00_Bootstrap.py 3.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. #!/usr/bin/python
  2. import os, sys, mmap
  3. from regression import Regression
  4. loader = '../src/pal'
  5. # Running Bootstrap
  6. regression = Regression(loader, "Bootstrap")
  7. regression.add_check(name="Basic Bootstrapping",
  8. check=lambda res: "User Program Started" in res[0].log)
  9. regression.add_check(name="Control Block: Executable Name",
  10. check=lambda res: "Loaded Executable: file:Bootstrap" in res[0].log)
  11. regression.add_check(name="Control Block: Default Manifest",
  12. check=lambda res: "Loaded Manifest: file:manifest" in res[0].log)
  13. regression.add_check(name="One Argument Given",
  14. check=lambda res: "# of Arguments: 1" in res[0].log and \
  15. "argv[0] = file:Bootstrap" in res[0].log)
  16. regression.add_check(name="Five Arguments Given",
  17. args = ['a', 'b', 'c', 'd'],
  18. check=lambda res: "# of Arguments: 5" in res[0].log and \
  19. "argv[0] = file:Bootstrap" in res[0].log and \
  20. "argv[1] = a" in res[0].log and "argv[2] = b" in res[0].log and \
  21. "argv[3] = c" in res[0].log and "argv[4] = d" in res[0].log)
  22. regression.add_check(name="Control Block: Debug Stream (Inline)",
  23. check=lambda res: "Written to Debug Stream" in res[0].out)
  24. regression.add_check(name="Control Block: Page Size",
  25. check=lambda res: ("Page Size: %d" % (mmap.PAGESIZE)) in res[0].log)
  26. regression.add_check(name="Control Block: Allocation Alignment",
  27. check=lambda res: ("Allocation Alignment: %d" % (mmap.ALLOCATIONGRANULARITY)) in res[0].log)
  28. regression.add_check(name="Control Block: Executable Range",
  29. check=lambda res: "Executable Range OK" in res[0].log)
  30. regression.run_checks()
  31. # Running Bootstrap2
  32. regression = Regression(loader, "Bootstrap2")
  33. regression.add_check(name="Control Block: Manifest as Executable Name",
  34. check=lambda res: "Loaded Manifest: file:Bootstrap2.manifest" in res[0].log)
  35. regression.run_checks()
  36. # Running Bootstrap3
  37. regression = Regression(loader, "Bootstrap3")
  38. regression.add_check(name="Preload Libraries",
  39. check=lambda res: "Binary 1 Preloaded" in res[0].log and
  40. "Binary 2 Preloaded" in res[0].log)
  41. regression.add_check(name="Preload Libraries Linking",
  42. check=lambda res: "Preloaded Function 1 Called" in res[0].log and
  43. "Preloaded Function 2 Called" in res[0].log)
  44. regression.run_checks()
  45. # Running Bootstrap4
  46. regression = Regression(loader, "Bootstrap4.manifest")
  47. regression.add_check(name="Control Block: Manifest as Argument",
  48. check=lambda res: "Loaded Manifest: file:Bootstrap4.manifest" in res[0].log)
  49. regression.add_check(name="Control Block: Executable as in Manifest",
  50. check=lambda res: "Loaded Executable: file:Bootstrap" in res[0].log)
  51. regression.run_checks()
  52. # Running Bootstrap4.manifest
  53. regression = Regression(executable = "./Bootstrap4.manifest")
  54. regression.add_check(name="Control Block: Manifest as Argument (Load by Shebang)",
  55. check=lambda res: "Loaded Manifest: file:./Bootstrap4.manifest" in res[0].log)
  56. regression.add_check(name="Control Block: Executable as in Manifest (Load by Shebang)",
  57. check=lambda res: "Loaded Executable: file:Bootstrap" in res[0].log)
  58. regression.add_check(name="Arguments: loader.execname in Manifest",
  59. check=lambda res: "argv[0] = Bootstrap" in res[0].log)
  60. regression.run_checks()
  61. # Running Bootstrap5.manifest
  62. regression = Regression(loader, "Bootstrap5.manifest")
  63. regression.add_check(name="Bootstrap without Executable but Preload Libraries",
  64. check=lambda res: "Binary 1 Preloaded" in res[0].log and
  65. "Binary 2 Preloaded" in res[0].log)
  66. regression.run_checks()