Files
WoW-Hybrid-gateway/tests/private_account_switch_gate_test.py
praxisandClaude Fable 5.2 7f2139d8d0 Offline test fixtures
883 files, from working commit b1a079a.

Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
2026-11-19 01:32:48 +02:00

38 lines
1.8 KiB
Python

#!/usr/bin/env python3
"""Compile the actual disabled-by-default realm diagnostic gate."""
from pathlib import Path
import subprocess,tempfile
ROOT=Path(__file__).resolve().parents[1]
CODE=r'''
#include <stdint.h>
#include <assert.h>
static int32_t cas(volatile int32_t *p,int32_t n,int32_t o){int32_t v=*p;if(v==o)*p=n;return v;}
#define GW_PRIVATE_ACCOUNT_SWITCH_CAS cas
#include "private_account_switch_gate.h"
int main(void){
struct gw_private_account_switch_gate d={.abi=1,.size=32};
assert(gw_private_account_switch_realm_allowed(0,0,2,7));
assert(gw_private_account_switch_realm_allowed(0,1,1,7));
assert(!gw_private_account_switch_realm_allowed(&d,1,2,7));
d.owner=7;d.requested_generation=2;
assert(!gw_private_account_switch_realm_allowed(&d,1,2,7));
d.command=1;assert(!gw_private_account_switch_realm_allowed(&d,1,3,7));
assert(!gw_private_account_switch_realm_allowed(&d,1,2,8));
assert(d.command==1 && !d.admitted_generation);
assert(gw_private_account_switch_realm_allowed(&d,1,2,7));
assert(d.command==2 && d.admitted_generation==2);
assert(gw_private_account_switch_realm_allowed(&d,1,2,7));
assert(!gw_private_account_switch_realm_allowed(&d,1,3,7));
d.requested_generation=3;d.command=1;
assert(!gw_private_account_switch_realm_allowed(&d,1,3,7));
d.requested_generation=2;d.command=2;d.reserved=1;
assert(!gw_private_account_switch_realm_allowed(&d,1,2,7));
return 0;
}
'''
with tempfile.TemporaryDirectory(prefix='account-switch-gate-') as temp:
p=Path(temp);(p/'test.c').write_text(CODE)
subprocess.run(['cc','-std=c11','-Wall','-Wextra','-Werror','-I',str(ROOT/'native'),str(p/'test.c'),'-o',str(p/'test')],check=True)
subprocess.run([str(p/'test')],check=True)
print('Private realm gate: default, hold, stale identity and one-shot admission pass')