-
Notifications
You must be signed in to change notification settings - Fork 374
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge remote-tracking branch 'remotes/origin/pr/1080'
# Conflicts: # BizHawk.Client.EmuHawk/BizHawk.Client.EmuHawk.csproj merges PR #1080 closes PR #1080 (let's see if either of these can do it)
- Loading branch information
Showing
8 changed files
with
906 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,149 @@ | ||
function round(num, numDecimalPlaces) | ||
local mult = 10^(numDecimalPlaces or 0) | ||
return math.floor(num * mult + 0.5) / mult | ||
end | ||
|
||
function get_baseline() | ||
i = 100 | ||
client.reboot_core() | ||
t = os.clock() | ||
|
||
while i > 0 do | ||
emu.frameadvance() | ||
i = i - 1 | ||
end | ||
baseline = os.clock() - t | ||
print('Baseline: ' .. round(baseline, 3) .. " secs") | ||
return baseline | ||
end | ||
|
||
function test_mmf() | ||
i = 100 | ||
client.reboot_core() | ||
t = os.clock() | ||
while i > 0 do | ||
emu.frameadvance() | ||
comm.mmfScreenshot() | ||
i = i - 1 | ||
end | ||
print('Memory mapped files: ' .. round((os.clock() - t - baseline), 3) .. " secs") | ||
end | ||
|
||
function test_http() | ||
print("Testing HTTP server") | ||
client.reboot_core() | ||
i = 100 | ||
t = os.clock() | ||
|
||
while i > 0 do | ||
emu.frameadvance() | ||
comm.httpTestGet() | ||
i = i - 1 | ||
end | ||
print('HTTP get: ' .. round((os.clock() - t - baseline), 3) .. " secs") | ||
|
||
client.reboot_core() | ||
i = 100 | ||
t = os.clock() | ||
|
||
while i > 0 do | ||
emu.frameadvance() | ||
comm.httpPostScreenshot() | ||
i = i - 1 | ||
end | ||
print('HTTP post: ' .. round((os.clock() - t - baseline), 3) .. " secs") | ||
|
||
end | ||
|
||
function test_socket() | ||
|
||
i = 100 | ||
client.reboot_core() | ||
t = os.clock() | ||
while i > 0 do | ||
emu.frameadvance() | ||
comm.socketServerScreenShot() | ||
i = i - 1 | ||
end | ||
print('Socket server: ' .. round((os.clock() - t - baseline), 3) .. " secs") | ||
end | ||
|
||
function test_socketresponse() | ||
best_time = -100 | ||
timeouts = {1, 2, 3, 4, 5, 10, 20, 25, 50, 100, 250, 500, 1000} | ||
comm.socketServerSetTimeout(1000) | ||
resp = comm.socketServerScreenShotResponse() | ||
for t, timeout in ipairs(timeouts) do | ||
comm.socketServerSetTimeout(timeout) | ||
client.reboot_core() | ||
print("Trying to find minimal timeout for Socket server") | ||
i = 100 | ||
t = os.clock() | ||
while i > 0 do | ||
emu.frameadvance() | ||
resp = comm.socketServerScreenShotResponse() | ||
if resp ~= 'ack' then | ||
i = -100 | ||
print(resp) | ||
print("Failed to a get a proper response") | ||
end | ||
i = i - 1 | ||
end | ||
if i > -100 then | ||
print("Best timeout: " .. timeout .. " msecs") | ||
print("Best time: " .. round((os.clock() - t - baseline), 3) .. " secs") | ||
break | ||
end | ||
end | ||
|
||
end | ||
|
||
function test_http_response() | ||
err = false | ||
print("Testing HTTP server response") | ||
client.reboot_core() | ||
i = 100 | ||
|
||
while i > 0 do | ||
emu.frameadvance() | ||
resp = comm.httpTestGet() | ||
if resp ~= "<html><body><h1>hi!</h1></body></html>" then | ||
print("Failed to get correct HTTP get response") | ||
print(resp) | ||
i = 0 | ||
err = true | ||
end | ||
i = i - 1 | ||
end | ||
if not err then | ||
print("HTTP GET looks fine: No errors occurred") | ||
end | ||
|
||
client.reboot_core() | ||
i = 100 | ||
err = false | ||
while i > 0 do | ||
emu.frameadvance() | ||
resp = comm.httpPostScreenshot() | ||
if resp ~= "<html><body>OK</body></html>" then | ||
print("Failed to get correct HTTP post response") | ||
print(resp) | ||
i = 0 | ||
err = true | ||
end | ||
i = i - 1 | ||
end | ||
if not err then | ||
print("HTTP POST looks fine: No errors occurred") | ||
end | ||
end | ||
|
||
baseline = get_baseline() | ||
test_socket() | ||
test_mmf() | ||
test_http() | ||
print("#####################") | ||
test_http_response() | ||
test_socketresponse() | ||
print() | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,91 @@ | ||
print("##########################################################") | ||
getUrl = comm.httpGetGetUrl() | ||
print("GET URL: " .. getUrl) | ||
|
||
postUrl = comm.httpGetPostUrl() | ||
print("POST URL: " .. postUrl) | ||
|
||
print("\nChecking GET URL change") | ||
error = false | ||
comm.httpSetGetUrl('a') | ||
if (getUrl ~= comm.httpGetGetUrl()) then | ||
comm.httpSetGetUrl(getUrl) | ||
error = (getUrl ~= comm.httpGetGetUrl()) | ||
else | ||
error = true | ||
end | ||
|
||
if error == false then | ||
print("Get URL was successfully changed") | ||
else | ||
print("Error while changing Get URL") | ||
end | ||
|
||
|
||
print("\nChecking POST URL change") | ||
error = false | ||
comm.httpSetPostUrl('a') | ||
if (postUrl ~= comm.httpGetPostUrl()) then | ||
comm.httpSetPostUrl(postUrl) | ||
error = (postUrl ~= comm.httpGetPostUrl()) | ||
else | ||
error = true | ||
end | ||
|
||
if error == false then | ||
print("Post URL was successfully changed") | ||
else | ||
print("Error while changing Post URL") | ||
end | ||
|
||
print("\nChecking GET request") | ||
getResponse = comm.httpGet("http://tasvideos.org/BizHawk.html") | ||
if string.find(getResponse, "Bizhawk") then | ||
print("GET seems to work") | ||
else | ||
print("Either the Bizhawk site is down or the GET does not work") | ||
end | ||
|
||
print("\nChecking memory mapped filed") | ||
|
||
size = comm.mmfScreenshot() | ||
if size > 0 then | ||
print("Memory mapped file was successfully written") | ||
else | ||
print("Failed to write memory mapped file") | ||
end | ||
|
||
mmf_filename = comm.mmfGetFilename() | ||
print("MMF filename: " .. mmf_filename) | ||
comm.mmfSetFilename("deleteme.tmp") | ||
error = false | ||
if (mmf_filename ~= comm.mmfGetFilename()) then | ||
comm.mmfSetFilename(mmf_filename) | ||
error = (mmf_filename ~= comm.mmfGetFilename()) | ||
else | ||
error = true | ||
end | ||
if error == false then | ||
print("MMF filename successfully changed") | ||
else | ||
print("MMF filename change failed") | ||
end | ||
|
||
print("Writing to MMF") | ||
|
||
message = "ABC" | ||
resp_n = tonumber(comm.mmfWrite(mmf_filename, message)) | ||
if (resp_n ~= string.len(message)) then | ||
print("Failed to write to MMF") | ||
else | ||
resp = comm.mmfRead(mmf_filename, string.len(message)) | ||
if (resp ~= message) then | ||
print("Failed to read from MMF") | ||
else | ||
print("MMF read and read OK") | ||
end | ||
end | ||
|
||
|
||
print("\nTests finished") | ||
print("Please run TestCommunication_All.lua with the supplied Python server for a more comprehensive test") |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.