-
Notifications
You must be signed in to change notification settings - Fork 227
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #20 from charliesome/ci
Get Travis CI going
- Loading branch information
Showing
3 changed files
with
107 additions
and
2 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,95 @@ | ||
#!/usr/bin/env ruby | ||
# coding: BINARY | ||
require "socket" | ||
require "timeout" | ||
require "json" | ||
|
||
QEMU = ENV["QEMU"] || "qemu-system-i386" | ||
IMG = ENV["IMG"] || "floppy.img" | ||
|
||
File.delete("x.ppm") if File.exist?("x.ppm") | ||
|
||
Timeout.timeout(20) do | ||
server = TCPServer.new(4444) | ||
qemu = IO.popen([ | ||
QEMU, | ||
"-monitor", "tcp:127.0.0.1:4444", | ||
"-net", "none", | ||
"-nographic", | ||
"-fda", IMG, | ||
], "r+") | ||
monitor = server.accept | ||
|
||
puts monitor.gets | ||
|
||
eip = nil | ||
loop do | ||
monitor.puts "print $eip" | ||
monitor.gets | ||
current_eip = monitor.gets | ||
puts "EIP is at #{current_eip}" | ||
if current_eip == eip | ||
puts "Detected halt, screenshotting." | ||
break | ||
else | ||
eip = current_eip | ||
sleep 0.1 | ||
end | ||
end | ||
|
||
monitor.puts "screendump screen.ppm" | ||
monitor.gets | ||
|
||
monitor.puts "quit" | ||
monitor.gets | ||
|
||
Process.kill(:KILL, qemu.pid) | ||
end | ||
|
||
unless File.exist?("screen.ppm") | ||
abort "screen.ppm does not exist!" | ||
end | ||
|
||
if system "convert screen.ppm screen.png" | ||
begin | ||
Timeout.timeout(5) do | ||
response = `curl -X POST -F name=screen.png -F 'fileinput[0][email protected]' http://cubeupload.com/upload_json.php` | ||
filename = JSON.parse(response)["file_name"] | ||
$stderr.puts "Screenshot available at: http://i.cubeupload.com/#{filename}" | ||
end | ||
rescue Timeout::Error | ||
$stderr.puts "could not upload screenshot to cubeupload" | ||
end | ||
end | ||
|
||
magic, coords, channel_depth, data = File.read("screen.ppm").force_encoding("BINARY").split("\n", 4) | ||
|
||
unless magic == "P6" | ||
abort "screen.ppm is not a 24-bit binary portable pixmap" | ||
end | ||
|
||
unless coords == "720 400" | ||
abort "screen.ppm is not 720x400 (is: #{coords.inspect})" | ||
end | ||
|
||
unless channel_depth == "255" | ||
abort "channel depth is not 255" | ||
end | ||
|
||
data.bytes.each_slice(720 * 3).each_with_index do |row, y| | ||
row.each_slice(3).each_with_index do |pix, x| | ||
expected_colour = | ||
if (0..8).include?(x) && (62..63).include?(y) # cursor | ||
[0, 0, 0] | ||
else | ||
[0xff, 0x57, 0x57] | ||
end | ||
|
||
unless pix == expected_colour | ||
abort "pixel at (#{x}, #{y}) is not #%02x%02x%02x, is: #%02x%02x%02x" % (expected_colour + pix) | ||
end | ||
end | ||
end | ||
|
||
$stderr.puts "Tests passed." | ||
exit true |
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,9 @@ | ||
before_install: | ||
- yes | sudo add-apt-repository ppa:hansjorg/rust | ||
- sudo apt-get update | ||
install: | ||
- sudo apt-get install rust-nightly nasm qemu imagemagick | ||
script: | ||
- sed -i 's/i386-elf-ld/ld/' Makefile | ||
- make | ||
- ruby .travis.rb |
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