Release 0.9.1-3 with RetroBrowser, PPC audio, XP diagnostics and LP64 repair
This commit is contained in:
28
tests/test_mac_audio.py
Normal file
28
tests/test_mac_audio.py
Normal file
@@ -0,0 +1,28 @@
|
||||
#!/usr/bin/env python3
|
||||
"""Run the supplied mock scenarios against actual production audio functions."""
|
||||
from pathlib import Path
|
||||
import subprocess,tempfile
|
||||
root=Path(__file__).resolve().parents[1]
|
||||
production=(root/'clients/retro-browser/sdl12/main.c').read_text()
|
||||
mock=(root/'tests/test_mac_audio_mock.c').read_text()
|
||||
prefix=mock[:mock.index('static short ring')]
|
||||
state=production[production.index('static short ring'):production.index('static int ready')]
|
||||
functions=production[production.index('static void sound_message'):production.index('static void rect')]
|
||||
scenarios=mock[mock.index('int main('):]
|
||||
# Also exercise full stereo queue, overflow, wraparound and odd-byte silence.
|
||||
scenarios=scenarios.replace('puts("PASS mocked', '''{
|
||||
short frame[2]={123,-456}, sink[8]; unsigned j;
|
||||
sound_close();assert(sound_open(22050,2));
|
||||
for(j=0;j<8191;j++)assert(sound_queue(frame,2,2)==2);
|
||||
assert(sound_queue(frame,2,2)==0);
|
||||
sound_callback(0,(Uint8*)sink,4);assert(sink[0]==123&&sink[1]==-456);
|
||||
assert(sound_queue(frame,2,2)==2);assert(head==0);
|
||||
sound_close();memset(sink,0x55,sizeof sink);
|
||||
sound_callback(0,(Uint8*)sink,3);assert(((Uint8*)sink)[2]==0);
|
||||
}
|
||||
puts("PASS production audio + stereo full/wrap/odd callback; mocked''')
|
||||
with tempfile.TemporaryDirectory(prefix='mars-audio-test-') as t:
|
||||
c=Path(t)/'test.c';exe=Path(t)/'test'
|
||||
c.write_text(prefix+state+functions+scenarios)
|
||||
subprocess.run(['cc','-std=c89','-Wall','-Wextra','-fsanitize=address,undefined','-g','-I',str(root/'clients/retro-browser/common'),str(c),str(root/'clients/retro-browser/common/rbp.c'),'-o',str(exe)],check=True)
|
||||
subprocess.run([str(exe)],check=True)
|
||||
Reference in New Issue
Block a user