Initial commit: Geminux 0.1.0 (helio) for Planet Computers Gemini PDA (MT6797X)
This commit is contained in:
commit
034c1f61b1
816 files changed
+223435
No files matched your search
Executable
+112
@@ -0,0 +1,112 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Verify zero-poll daemon design and Geminux power/lid-suspend policy logic."""
|
||||
|
||||
import os
|
||||
import re
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
|
||||
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
|
||||
DAEMON_DIR = os.path.join(BASE_DIR, "src", "geminux-daemons")
|
||||
POLICY_C = os.path.join(DAEMON_DIR, "geminux-power-policy.c")
|
||||
|
||||
DAEMON_FILES = {
|
||||
"geminux-powerd.c": "epoll_wait",
|
||||
"geminux-statusd.c": "epoll_wait",
|
||||
"geminux-ccci-daemon.c": "epoll_wait",
|
||||
"geminux-modem-ctl.c": "epoll_wait",
|
||||
"geminux-bt-obex.c": "g_main_loop_run",
|
||||
"geminux-leds.c": "epoll_wait",
|
||||
}
|
||||
|
||||
C_TEST = r"""
|
||||
#include <assert.h>
|
||||
#include <string.h>
|
||||
#include "geminux-power-policy.h"
|
||||
|
||||
int main(void) {
|
||||
geminux_power_policy_t pol;
|
||||
geminux_policy_init(&pol);
|
||||
assert(pol.profile == POWER_PROFILE_BALANCED);
|
||||
assert(pol.lid_suspend_enabled);
|
||||
assert(!geminux_should_suspend_on_lid(&pol));
|
||||
|
||||
/* Closing lid on battery should trigger S3 suspend */
|
||||
pol.lid_closed = true;
|
||||
assert(geminux_should_suspend_on_lid(&pol));
|
||||
|
||||
/* Active voice call inhibitor blocks lid suspend */
|
||||
assert(geminux_policy_add_inhibit(&pol, "call"));
|
||||
assert(!geminux_should_suspend_on_lid(&pol));
|
||||
assert(geminux_policy_del_inhibit(&pol, "call"));
|
||||
assert(geminux_should_suspend_on_lid(&pol));
|
||||
|
||||
/* Connected external HDMI display blocks lid suspend */
|
||||
pol.hdmi_connected = true;
|
||||
assert(!geminux_should_suspend_on_lid(&pol));
|
||||
pol.hdmi_connected = false;
|
||||
assert(geminux_should_suspend_on_lid(&pol));
|
||||
|
||||
/* Profile parameters: eco disables A72 big cluster, balanced/perf enable A72 */
|
||||
geminux_profile_params_t eco = geminux_policy_params(POWER_PROFILE_ECO, false);
|
||||
assert(strcmp(eco.governor, "schedutil") == 0);
|
||||
assert(!eco.a72_online);
|
||||
assert(eco.suspend_timeout_s > 0);
|
||||
|
||||
geminux_profile_params_t bal = geminux_policy_params(POWER_PROFILE_BALANCED, false);
|
||||
assert(strcmp(bal.governor, "schedutil") == 0);
|
||||
assert(bal.a72_online);
|
||||
|
||||
geminux_profile_params_t perf = geminux_policy_params(POWER_PROFILE_PERFORMANCE, true);
|
||||
assert(strcmp(perf.governor, "schedutil") == 0);
|
||||
assert(perf.a72_online);
|
||||
assert(perf.suspend_timeout_s == 0);
|
||||
return 0;
|
||||
}
|
||||
"""
|
||||
|
||||
|
||||
def main():
|
||||
for fname, required_loop in DAEMON_FILES.items():
|
||||
path = os.path.join(DAEMON_DIR, fname)
|
||||
with open(path, "r", encoding="utf-8") as handle:
|
||||
src = handle.read()
|
||||
for bad in (r"\bsleep\s*\(", r"\busleep\s*\(", r"\bnanosleep\s*\("):
|
||||
if re.search(bad, src):
|
||||
raise AssertionError(f"Busy-wait sleep call ({bad}) detected in {fname}")
|
||||
if required_loop not in src:
|
||||
raise AssertionError(f"Expected event loop primitive {required_loop} missing in {fname}")
|
||||
|
||||
with tempfile.TemporaryDirectory(prefix="geminux-power-test-") as tmp:
|
||||
src = os.path.join(tmp, "test_power.c")
|
||||
bin_path = os.path.join(tmp, "test_power")
|
||||
with open(src, "w", encoding="utf-8") as handle:
|
||||
handle.write(C_TEST)
|
||||
|
||||
gcc = shutil.which("gcc")
|
||||
if gcc:
|
||||
subprocess.run(
|
||||
[gcc, "-std=c11", "-Wall", "-Wextra", "-Werror",
|
||||
"-I", DAEMON_DIR, src, POLICY_C, "-o", bin_path],
|
||||
check=True,
|
||||
)
|
||||
subprocess.run([bin_path], check=True)
|
||||
else:
|
||||
subprocess.run(
|
||||
["docker", "run", "--rm", "-v", f"{BASE_DIR}:/geminux:ro",
|
||||
"-v", f"{tmp}:/work", "alpine:3.24", "sh", "-eu", "-c",
|
||||
"apk add --no-cache build-base >/dev/null && "
|
||||
"gcc -std=c11 -Wall -Wextra -Werror -I/geminux/src/geminux-daemons "
|
||||
"/work/test_power.c /geminux/src/geminux-daemons/geminux-power-policy.c "
|
||||
"-o /work/test_power && /work/test_power"],
|
||||
check=True,
|
||||
)
|
||||
|
||||
print("[PASS] Zero-poll daemon loops and power/lid policy verified")
|
||||
return 0
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
sys.exit(main())
|
||||
Reference in new issue
Block a user