forked from llvm-mos/llvm-mos-sdk
-
Notifications
You must be signed in to change notification settings - Fork 2
/
emutest.lua
59 lines (49 loc) · 1.44 KB
/
emutest.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
load_core(corepath)
load_game(rompath)
-- function to extract filename from path
function get_filename(path)
local result = path
-- iterate thru chars
for i=1,string.len(path) do
-- if char is a slash
if string.sub(path, i, i) == "/" then
-- return substring from next char to end
result = string.sub(path, i+1, string.len(path))
end
end
return result
end
romname = get_filename(rompath)
print("Running test on", romname)
print(get_logs())
for i=1,1000 do
run()
local ram = get_ram()
-- look for env var "EMUTEST_FB_CRC_PASS"
if os.getenv("EMUTEST_FB_CRC_PASS") then
-- if found, check for CRC match
if get_fb_crc() == tonumber(os.getenv("EMUTEST_FB_CRC_PASS")) then
print("Test passed via get_fb_crc.")
screenshot(romname .. "-pass.png")
os.exit(0)
end
end
-- look for RAM signature
if string.find(ram, 'TestPass') then
print("Test passed via RAM signature.")
run()
print("FB_CRC=", get_fb_crc())
screenshot(romname .. "-pass.png")
os.exit(0)
elseif string.find(ram, 'TestFail') then
print("Test failed via RAM signature.")
run()
print("FB_CRC=", get_fb_crc())
screenshot(romname .. "-fail.png")
os.exit(1)
end
end
print("Test indeterminate.")
print("FB_CRC=", get_fb_crc())
screenshot(romname .. "-unknown.png")
os.exit(2)