883 files, from working commit b1a079a. Co-Authored-By: Claude Fable 5.2 <noreply@anthropic.com>
75 lines
6.6 KiB
Python
75 lines
6.6 KiB
Python
#!/usr/bin/env python3
|
|
"""Observe actual op45 result/initial-bundle validators with bounded mock data."""
|
|
import os
|
|
from pathlib import Path
|
|
import subprocess
|
|
import unittest
|
|
|
|
ROOT = Path(__file__).resolve().parents[1]
|
|
|
|
|
|
class InitialSpellCallDiagnosticsTest(unittest.TestCase):
|
|
def test_actual_result_and_bundle_failure_steps(self):
|
|
source = (ROOT / "native/wine_pipe_host.c").read_text()
|
|
functions = source[source.index("static int spell_barrier_initial_ids_result("):source.index("static int spell_barrier_begin(")]
|
|
output = Path(os.environ.get("GW_TEST_OUTPUT_DIR", ROOT / "build/test-initial-spell-call-diagnostics")).resolve()
|
|
output.mkdir(parents=True, exist_ok=True)
|
|
unit = output / "initial-spell-call.c"
|
|
unit.write_text(r'''
|
|
#include <assert.h>
|
|
#include <stdint.h>
|
|
#include <string.h>
|
|
#include "wine_pipe_host.h"
|
|
#include "world_locator_fifo.h"
|
|
typedef int32_t NTSTATUS;
|
|
struct gw_wire_call {int32_t result;uint32_t input_bytes,required,capacity,consumed;const uint8_t* input;};
|
|
static struct gw_pipe_initial_spell_ids_call gw_wire_initial_spell_ids_call;
|
|
static unsigned char spell_barrier_ids[12+4096*4],converted[64];
|
|
static uint32_t u32(const unsigned char* p){return gw_world_locator_u32(p);}
|
|
''' + functions + r'''
|
|
static void put(unsigned char* p,uint32_t value){for(unsigned i=0;i<4;++i)p[i]=(unsigned char)(value>>(8*i));}
|
|
static void reset(struct gw_wire_call* c,uint32_t* count){
|
|
gw_wire_initial_spell_ids_call=(struct gw_pipe_initial_spell_ids_call){.abi=1,.size=sizeof(struct gw_pipe_initial_spell_ids_call)};
|
|
memset(spell_barrier_ids,0,sizeof(spell_barrier_ids));memset(converted,0,sizeof(converted));
|
|
*c=(struct gw_wire_call){.required=24,.capacity=sizeof(spell_barrier_ids)};*count=0;
|
|
put(spell_barrier_ids,4509);put(spell_barrier_ids+8,3);put(spell_barrier_ids+12,1);put(spell_barrier_ids+16,7);put(spell_barrier_ids+20,9);
|
|
}
|
|
int main(void){
|
|
struct gw_wire_call c;uint32_t known[4096],count;unsigned char input=0;
|
|
assert(sizeof(struct gw_pipe_initial_spell_ids_call)==88&&sizeof(struct gw_pipe_spell_locator_barrier)==88&&sizeof(struct gw_pipe_spell_locator_guard)==144);
|
|
reset(&c,&count);assert(!spell_barrier_initial_ids_result((NTSTATUS)0xc0000001u,&c,4509,known,&count));
|
|
assert(gw_wire_initial_spell_ids_call.bound_step==4&&gw_wire_initial_spell_ids_call.transport_status==(NTSTATUS)0xc0000001u&&!gw_wire_initial_spell_ids_call.contract_written_known&&!gw_wire_initial_spell_ids_call.header_bounds_valid&&!count);
|
|
reset(&c,&count);c.result=-1;c.required=0;c.input=&input;c.input_bytes=1;
|
|
assert(!spell_barrier_initial_ids_result(0,&c,4509,known,&count)&&gw_wire_initial_spell_ids_call.bound_step==5);
|
|
assert(gw_wire_initial_spell_ids_call.call_result==-1&&gw_wire_initial_spell_ids_call.contract_written_known&&!gw_wire_initial_spell_ids_call.contract_written_bytes&&!gw_wire_initial_spell_ids_call.input_is_null&&gw_wire_initial_spell_ids_call.input_bytes==1);
|
|
reset(&c,&count);c.result=-3;c.capacity=8;
|
|
assert(!spell_barrier_initial_ids_result(0,&c,4509,known,&count)&&gw_wire_initial_spell_ids_call.bound_step==5);
|
|
assert(gw_wire_initial_spell_ids_call.required==24&&gw_wire_initial_spell_ids_call.capacity==8&&gw_wire_initial_spell_ids_call.contract_written_known&&!gw_wire_initial_spell_ids_call.contract_written_bytes);
|
|
reset(&c,&count);c.result=-6;assert(!spell_barrier_initial_ids_result(0,&c,4509,known,&count)&&!gw_wire_initial_spell_ids_call.contract_written_known);
|
|
reset(&c,&count);c.required=11;assert(!spell_barrier_initial_ids_result(0,&c,4509,known,&count)&&gw_wire_initial_spell_ids_call.bound_step==6&&!gw_wire_initial_spell_ids_call.header_bounds_valid);
|
|
reset(&c,&count);c.required=sizeof(spell_barrier_ids)+1;assert(!spell_barrier_initial_ids_result(0,&c,4509,known,&count)&&gw_wire_initial_spell_ids_call.bound_step==6);
|
|
reset(&c,&count);put(spell_barrier_ids,0);assert(!spell_barrier_initial_ids_result(0,&c,4509,known,&count)&&gw_wire_initial_spell_ids_call.bound_step==7&&!gw_wire_initial_spell_ids_call.header_shape_valid&&!gw_wire_initial_spell_ids_call.source_guid&&!count);
|
|
reset(&c,&count);put(spell_barrier_ids+8,4097);assert(!spell_barrier_initial_ids_result(0,&c,4509,known,&count)&&gw_wire_initial_spell_ids_call.bound_step==8&&!gw_wire_initial_spell_ids_call.decoded_count);
|
|
reset(&c,&count);c.required=20;assert(!spell_barrier_initial_ids_result(0,&c,4509,known,&count)&&gw_wire_initial_spell_ids_call.bound_step==9&&!gw_wire_initial_spell_ids_call.header_shape_valid);
|
|
reset(&c,&count);put(spell_barrier_ids,4526);assert(!spell_barrier_initial_ids_result(0,&c,4509,known,&count)&&gw_wire_initial_spell_ids_call.bound_step==10);
|
|
assert(gw_wire_initial_spell_ids_call.header_shape_valid&&gw_wire_initial_spell_ids_call.source_guid==4526&&gw_wire_initial_spell_ids_call.decoded_count==3&&!gw_wire_initial_spell_ids_call.expected_guid_matches&&!count);
|
|
reset(&c,&count);put(spell_barrier_ids+20,7);assert(!spell_barrier_initial_ids_result(0,&c,4509,known,&count)&&gw_wire_initial_spell_ids_call.bound_step==11&&!count);
|
|
reset(&c,&count);assert(spell_barrier_initial_ids_result(0,&c,4509,known,&count)&&gw_wire_initial_spell_ids_call.bound_step==12&&count==3&&known[2]==9);
|
|
assert(gw_wire_initial_spell_ids_call.input_is_null&&gw_wire_initial_spell_ids_call.contract_written_known&&gw_wire_initial_spell_ids_call.contract_written_bytes==24&&gw_wire_initial_spell_ids_call.expected_guid_matches);
|
|
assert(!spell_barrier_initial_bundle(3)&&gw_wire_initial_spell_ids_call.bound_step==13&&!gw_wire_initial_spell_ids_call.first_bundle_valid);
|
|
put(converted,1);put(converted+4,0x5e0000);put(converted+8,0);
|
|
assert(!spell_barrier_initial_bundle(12)&&gw_wire_initial_spell_ids_call.bound_step==14);
|
|
put(converted+4,0x690019);assert(spell_barrier_initial_bundle(12)&&gw_wire_initial_spell_ids_call.bound_step==15&&gw_wire_initial_spell_ids_call.first_bundle_valid);
|
|
reset(&c,&count);c.required=12;put(spell_barrier_ids+8,0);assert(spell_barrier_initial_ids_result(0,&c,4509,known,&count)&&!count&&gw_wire_initial_spell_ids_call.header_shape_valid);
|
|
return 0;
|
|
}
|
|
''')
|
|
command = ["gcc", "-std=c11", "-Wall", "-Wextra", "-Werror", "-fsanitize=address,undefined", "-fno-omit-frame-pointer", "-I", str(ROOT / "native"), str(unit), "-o", str(output / "initial-spell-call")]
|
|
with (output / "compile-and-run.private.log").open("w") as log:
|
|
subprocess.run(command, check=True, stdout=log, stderr=subprocess.STDOUT)
|
|
subprocess.run([str(output / "initial-spell-call")], check=True, stdout=log, stderr=subprocess.STDOUT)
|
|
|
|
|
|
if __name__ == "__main__":
|
|
unittest.main()
|