from pathlib import Path ROOT = Path(__file__).resolve().parents[1] def read_text(path: str) -> str: return (ROOT / path).read_text(encoding="utf-8") def require(condition: bool, message: str) -> None: if not condition: raise SystemExit(message) def main() -> None: app = read_text("main/application.cc") mqtt_header = read_text("main/boards/sening-xiaozhi-s3/mqtt.h") require( "void BoardMqtt_StopPlaylistPlayback(void);" in mqtt_header, "MQTT header must expose a public playlist stop API", ) power_off_body = app.split("void Application::EnterPowerOffStandby()", 1)[1].split( "void Application::RestoreFromPowerOffStandby", 1 )[0] require( "BoardMqtt_StopPlaylistPlayback();" in power_off_body, "power-off standby must stop the whole playlist task, not only the current MP3", ) require( "StopSdCardMp3();" not in power_off_body, "power-off standby must not bypass the playlist stop API with direct MP3 stop", ) if __name__ == "__main__": main()