Rendering Engine 0.2.17
Modular Graphics Rendering Engine | v0.2.17
Loading...
Searching...
No Matches
application_smoke_tests Namespace Reference

Functions

 run_build (command, cwd)
 
 discover_applications ()
 
 run_application (executable, seconds, shutdown_timeout)
 
 main ()
 

Variables

 ROOT = Path(__file__).resolve().parents[2]
 
tuple APPLICATION_FOLDERS = ("ContentExamples", "TestApplications")
 
dict EXCLUDED_APPLICATIONS = {"TextureBenchmark"}
 
 file
 

Detailed Description

Build and launch existing Rendering Engine example/test applications.

Runs on Linux and FreeBSD. Verifies successful compilation and that
applications remain running during a short observation period.
Requires a graphical environment; not intended for headless CI.

Function Documentation

◆ discover_applications()

application_smoke_tests.discover_applications ( )

Definition at line 32 of file application_smoke_tests.py.

32def discover_applications():
33 apps = []
34 for folder in APPLICATION_FOLDERS:
35 parent = ROOT / folder
36 if not parent.is_dir():
37 raise RuntimeError(f"Missing directory: {parent}")
38 for project in sorted(parent.iterdir()):
39 if project.name in EXCLUDED_APPLICATIONS:
40 continue
41 if project.is_dir() and (project / "build_project.sh").is_file():
42 apps.append(project)
43 if not apps:
44 raise RuntimeError("No application build scripts found")
45 return apps
46
47

◆ main()

application_smoke_tests.main ( )

Definition at line 86 of file application_smoke_tests.py.

86def main():
87 parser = argparse.ArgumentParser(description=__doc__)
88 parser.add_argument("--release", action="store_true", help="Build Release rather than Debug")
89 parser.add_argument("--seconds", type=float, default=3.0, help="GUI observation time (default 3)")
90 parser.add_argument("--shutdown-timeout", type=float, default=3.0)
91 parser.add_argument("--skip-engine-build", action="store_true", help="Reuse existing engine build")
92 args = parser.parse_args()
93 if os.name != "posix" or not (
94 sys.platform == "linux" or sys.platform.startswith("freebsd")
95 ):
96 parser.error("This smoke test supports Linux and FreeBSD only")
97 if args.seconds <= 0 or args.shutdown_timeout <= 0:
98 parser.error("Timeouts must be positive")
99
100 build_type = "Release" if args.release else "Debug"
101 build_flag = "--release" if args.release else "--debug"
102 apps = discover_applications()
103 print(f"Rendering Engine root: {ROOT}")
104 print(f"Build configuration: {build_type}")
105 print(f"Applications found: {len(apps)}", flush=True)
106
107 if not args.skip_engine_build:
108 run_build(["sh", str(ROOT / "build_engine.sh"), "--engine-only", build_flag], ROOT)
109
110 results = []
111 for app in apps:
112 print(f"\n=== {app.name} ===", flush=True)
113 try:
114 run_build(["sh", str(app / "build_project.sh"), build_flag], app)
115 executable = ROOT / "Build" / "UserApplications" / app.name / build_type / app.name
116 if not executable.is_file():
117 raise RuntimeError(f"Executable not found: {executable}")
118 if not os.access(executable, os.X_OK):
119 raise RuntimeError(f"Executable not executable: {executable}")
120 status, reason = run_application(executable, args.seconds, args.shutdown_timeout)
121 except (OSError, RuntimeError) as exc:
122 status, reason = "FAIL", str(exc)
123 results.append((app.name, status, reason))
124 print(f"{status}: {app.name}: {reason}", flush=True)
125
126 print("\n=== Summary ===")
127 for name, status, reason in results:
128 print(f"{status:4} {name}: {reason}")
129 passed = sum(status == "PASS" for _, status, _ in results)
130 print(f"Passed {passed}/{len(results)}")
131 return 0 if passed == len(results) else 1
132
133
int main(int argc, char *argv[])

◆ run_application()

application_smoke_tests.run_application (   executable,
  seconds,
  shutdown_timeout 
)

Definition at line 48 of file application_smoke_tests.py.

48def run_application(executable, seconds, shutdown_timeout):
49 # Child uses its own process group so cleanup also handles descendants.
50 with open(os.devnull, "rb") as devnull:
51 process = subprocess.Popen(
52 [str(executable)], cwd=executable.parent, stdin=devnull,
53 start_new_session=True,
54 )
55 try:
56 try:
57 code = process.wait(timeout=seconds)
58 except subprocess.TimeoutExpired:
59 code = None
60
61 if code is not None:
62 if code == 0:
63 return "PASS", "Exited normally (code 0)"
64 return "FAIL", f"Exited unexpectedly (code {code})"
65
66 # The GUI is still alive after the observation window.
67 os.killpg(process.pid, signal.SIGTERM)
68 try:
69 code = process.wait(timeout=shutdown_timeout)
70 except subprocess.TimeoutExpired:
71 os.killpg(process.pid, signal.SIGKILL)
72 process.wait()
73 return "FAIL", "Did not stop after SIGTERM; SIGKILL required"
74
75 if code in (-signal.SIGTERM, 128 + signal.SIGTERM):
76 return "PASS", f"Stayed alive {seconds:g}s; terminated by test runner (code {code})"
77 if code == 0:
78 return "PASS", "Stayed alive; shutdown returned code 0"
79 return "FAIL", f"Unexpected exit code during shutdown: {code}"
80 finally:
81 if process.poll() is None:
82 os.killpg(process.pid, signal.SIGKILL)
83 process.wait()
84
85

◆ run_build()

application_smoke_tests.run_build (   command,
  cwd 
)

Definition at line 25 of file application_smoke_tests.py.

25def run_build(command, cwd):
26 print(f"\n$ {' '.join(map(str, command))}", flush=True)
27 result = subprocess.run(command, cwd=cwd, check=False)
28 if result.returncode != 0:
29 raise RuntimeError(f"Build failed (exit code {result.returncode}): {command}")
30
31

Variable Documentation

◆ APPLICATION_FOLDERS

tuple application_smoke_tests.APPLICATION_FOLDERS = ("ContentExamples", "TestApplications")

Definition at line 21 of file application_smoke_tests.py.

◆ EXCLUDED_APPLICATIONS

dict application_smoke_tests.EXCLUDED_APPLICATIONS = {"TextureBenchmark"}

Definition at line 22 of file application_smoke_tests.py.

◆ file

application_smoke_tests.file

Definition at line 138 of file application_smoke_tests.py.

◆ ROOT

application_smoke_tests.ROOT = Path(__file__).resolve().parents[2]

Definition at line 20 of file application_smoke_tests.py.