Add cycle limit to CI emulator test

This commit is contained in:
s3lph 2022-02-10 10:12:29 +01:00
parent 8647f77cc9
commit ac284974d3
2 changed files with 8 additions and 2 deletions

View file

@ -25,5 +25,6 @@ emu6502: memtest6502
gcc -D_END=$$(cat tmp/memtest4k-f000-ascii.map | grep ^done, | cut -d, -f2 | tr -d ' ,') -o out/emu6502 src/emu6502.c src/fake6502.c
test: memtest6502
gcc -DNOLIMIT -D_END=$$(cat tmp/memtest4k-f000-ascii.map | grep ^done, | cut -d, -f2 | tr -d ' ,') -o out/emu6502 src/emu6502.c src/fake6502.c
# Run the emulator, but terminate after 10M instructions
gcc -D_LIMIT=10000000 -D_END=$$(cat tmp/memtest4k-f000-ascii.map | grep ^done, | cut -d, -f2 | tr -d ' ,') -o out/emu6502 src/emu6502.c src/fake6502.c
out/emu6502 | tail -30

View file

@ -84,7 +84,12 @@ int main() {
reset6502();
signal(SIGINT, intv);
while (1) {
#ifndef NOLIMIT
#ifdef _LIMIT
if (instructions >= _LIMIT) {
dprintf(2, "Prematurely terminated after %d instructions (limit exceeded)", instructions);
exit(2);
}
#else
usleep(1);
#endif
step6502();