use rye to test remotely

via ssh , no config yet
This commit is contained in:
Torsten Ruger 2015-11-16 23:23:08 +02:00
parent 9a81d4e6a6
commit bc3042a466
3 changed files with 64 additions and 7 deletions

View File

@ -4,6 +4,7 @@ gem "salama" , :path => "."
gem "ast" , :github => "whitequark/ast"
gem "rake"
gem "rye"
gem "salama-reader" , :github => "salama/salama-reader"
#gem "salama-reader" , :path => "../salama-reader"

View File

@ -34,11 +34,14 @@ PATH
GEM
remote: http://rubygems.org/
specs:
annoy (0.5.6)
highline (>= 1.5.0)
blankslate (3.1.3)
codeclimate-test-reporter (0.4.8)
simplecov (>= 0.7.1, < 1.0.0)
coderay (1.1.0)
docile (1.1.5)
drydock (0.6.9)
ffi (1.9.10)
ffi (1.9.10-x64-mingw32)
formatador (0.2.5)
@ -55,6 +58,7 @@ GEM
guard-minitest (2.4.4)
guard-compat (~> 1.2)
minitest (>= 3.0)
highline (1.7.8)
json (1.8.3)
listen (3.0.3)
rb-fsevent (>= 0.9.3)
@ -63,6 +67,9 @@ GEM
method_source (0.8.2)
minitest (5.8.1)
nenv (0.2.0)
net-scp (1.2.1)
net-ssh (>= 2.6.5)
net-ssh (3.0.1)
notiffany (0.0.8)
nenv (~> 0.1)
shellany (~> 0.0)
@ -81,6 +88,13 @@ GEM
rb-fsevent (0.9.6)
rb-inotify (0.9.5)
ffi (>= 0.5.0)
rye (0.9.13)
annoy
docile (>= 1.0.1)
highline (>= 1.5.1)
net-scp (>= 1.0.2)
net-ssh (>= 2.0.13)
sysinfo (>= 0.8.1)
shellany (0.0.1)
simplecov (0.10.0)
docile (~> 1.1.0)
@ -88,6 +102,10 @@ GEM
simplecov-html (~> 0.10.0)
simplecov-html (0.10.0)
slop (3.6.0)
storable (0.8.9)
sysinfo (0.8.1)
drydock
storable
thor (0.19.1)
win32console (1.3.2)
@ -102,6 +120,7 @@ DEPENDENCIES
guard-minitest
minitest
rake
rye
salama!
salama-arm!
salama-object-file!

View File

@ -1,5 +1,8 @@
require_relative '../helper'
require "interpreter/interpreter"
require "rye"
Rye::Cmd.add_command :ld, '/usr/bin/ld'
Rye::Cmd.add_command :aout, './a.out'
module RuntimeTests
@ -15,7 +18,7 @@ class Object
end
HERE
end
def check
def check ret = nil
machine = Register.machine.boot
Soml::Compiler.load_parfait
machine.parse_and_compile main.sub("PROGRAM" , @string_input )
@ -28,23 +31,57 @@ HERE
#puts interpreter.instruction
@interpreter.tick
end while( ! @interpreter.instruction.nil?)
assert_equal @stdout , @interpreter.stdout
write_file if true
assert_equal @stdout , @interpreter.stdout , "stdout wrong locally"
if ret
assert_equal Parfait::Message , @interpreter.get_register(:r0).class
assert_equal ret , @interpreter.get_register(:r0).return_value , "exit wrong #{@string_input}"
end
check_remote ret
end
def write_file
def connected
return @@conn if defined?(@@conn)
begin
box = Rye::Box.new("localhost" , :port => 2222 , :user => "pi")
box.pwd
puts "connected, testing also remotely"
@@conn = box
rescue Rye::Err
@@conn = false
end
return @@conn
end
def check_remote ret
return unless box = connected
file = write_object_file
r_file = file.sub("./" , "salama/")
box.file_upload file , r_file
box.ld "-N", r_file
begin #need to rescue here as rye throws if no return 0
ret = box.aout # and we use return to mean something
rescue Rye::Err => e # so it's basically never 0
ret = e.rap
end
assert_equal @stdout , ret.stdout.join , "remote std was #{ret.stdout}" if @stdout
assert_equal "" , ret.stderr.join , "remote had error"
if ret
should = @interpreter.get_register(:r0).return_value
assert_equal ret.exit_status.to_i ,should , "remote exit failed for #{@string_input}"
end
end
def write_object_file
file_name = caller(3).first.split("in ").last.chop.sub("`","")
return if file_name.include?("run")
file_name = "./tmp/" + file_name + ".o"
Register.machine.translate_arm
writer = Elf::ObjectWriter.new
writer.save file_name
file_name
end
def check_return val
check
assert_equal Parfait::Message , @interpreter.get_register(:r0).class
assert_equal val , @interpreter.get_register(:r0).return_value , @string_input
check val
end
def check_return_class val