from pathlib import Path
import subprocess
p=Path(__file__).resolve().parent
mut=p/'build/negative';mut.mkdir(parents=True,exist_ok=True)
for name in ['pca9956b_fault_monitor.c','pca9956b_bank_monitor.c']:
    (mut/name).write_text((p/'src'/name).read_text().replace('20u','30u'))
subprocess.run(['cc','-std=c11','-Wall','-Wextra','-Werror','-I'+str(p/'src'),str(mut/'pca9956b_fault_monitor.c'),str(mut/'pca9956b_bank_monitor.c'),str(p/'tests/test_bank.c'),'-o',str(mut/'wrong_age')],check=True)
r=subprocess.run([str(mut/'wrong_age')],capture_output=True,text=True)
assert r.returncode!=0,'Weakened freshness mutant unexpectedly passed'
print('PASS 30ms freshness mutant rejected by unchanged tests')
