"""Imported live/offline scientific predicates, not a parallel test model.""" import re from geometry import need,exact,crossing,expected_outputs from predicates import protocol def client_exit(log,code,scenario='observed'): # WHY: root OOM creates A, never B. CONTRACT: hierarchy-sensitive close; # no normal error0 close is substituted for a wire-proven no_memory path. # INVARIANT: every created role is destroyed exactly once, child first. need(scenario in ('observed','root_failure','nested_failure','nested','toplevel'),'unknown closure scenario') if 'TOPLEVEL CREATE ' in log: created=re.findall(r'^(POPUP_[AB]|TOPLEVEL) CREATE ',log,re.M) need(len(created)==len(set(created)) and created and created[0]=='TOPLEVEL','ambiguous created hierarchy') expected={'root_failure':['TOPLEVEL','POPUP_A'],'nested_failure':['TOPLEVEL','POPUP_A','POPUP_B'],'nested':['TOPLEVEL','POPUP_A','POPUP_B'],'toplevel':['TOPLEVEL']}.get(scenario,created) need(created==expected,'scenario created hierarchy differs') order=re.findall(r'^(POPUP_[AB]|TOPLEVEL) DESTROY',log,re.M) need(order==list(reversed(created)),'actual created hierarchy child-first destruction') failed={'root_failure':'POPUP_A','nested_failure':'POPUP_B'}.get(scenario) if failed:need(failed+' MAP ' not in log,'failed popup mapped despite NULL') if scenario=='nested_failure':need('POPUP_A MAP ' in log,'nested failure without mapped root') need('CLOSE_RECEIVED' in log and log.index('CLOSE_RECEIVED')0 and releases[0][0]==releases[0][1],'client SHM release incomplete/unobserved') errors=re.findall(r'EXIT[^\n]*error=(\d+)',log) need(code==0 and len(errors)==1 and errors==['0'],'normal client exit/error differs') need(not re.search(r'protocol error|wl_display[^\n]*\.error\(',log,re.I),'wire error cannot be ordinary close') return dict(status='PASS',scenario=scenario,exit=code,wire_error=False) def window(start,end,events): need(start