fix remote test framework
was resting machine objects and causing bugs reboot now and really start from scratch for remote
This commit is contained in:
parent
791cc96a0d
commit
bca0ae1b3b
@ -18,25 +18,29 @@ module RuntimeTests
|
|||||||
|
|
||||||
def setup
|
def setup
|
||||||
@stdout = ""
|
@stdout = ""
|
||||||
|
end
|
||||||
|
|
||||||
|
def load_program
|
||||||
@machine = Register.machine.boot
|
@machine = Register.machine.boot
|
||||||
Soml::Compiler.load_parfait
|
Soml::Compiler.load_parfait
|
||||||
|
@machine.parse_and_compile main()
|
||||||
|
@machine.collect
|
||||||
end
|
end
|
||||||
|
|
||||||
def check ret = nil
|
def check ret = nil
|
||||||
@machine.parse_and_compile main()
|
load_program
|
||||||
@machine.collect
|
interpreter = Register::Interpreter.new
|
||||||
@interpreter = Register::Interpreter.new
|
interpreter.start @machine.init
|
||||||
@interpreter.start @machine.init
|
|
||||||
count = 0
|
count = 0
|
||||||
begin
|
begin
|
||||||
count += 1
|
count += 1
|
||||||
#puts interpreter.instruction
|
#puts interpreter.instruction
|
||||||
@interpreter.tick
|
interpreter.tick
|
||||||
end while( ! @interpreter.instruction.nil?)
|
end while( ! interpreter.instruction.nil?)
|
||||||
assert_equal @stdout , @interpreter.stdout , "stdout wrong locally"
|
assert_equal @stdout , interpreter.stdout , "stdout wrong locally"
|
||||||
if ret
|
if ret
|
||||||
assert_equal Parfait::Message , @interpreter.get_register(:r0).class
|
assert_equal Parfait::Message , interpreter.get_register(:r0).class
|
||||||
assert_equal ret , @interpreter.get_register(:r0).return_value , "exit wrong #{@string_input}"
|
assert_equal ret , interpreter.get_register(:r0).return_value , "exit wrong #{@string_input}"
|
||||||
end
|
end
|
||||||
check_remote ret
|
check_remote ret
|
||||||
end
|
end
|
||||||
@ -50,9 +54,11 @@ module RuntimeTests
|
|||||||
@@conn = Rye::Box.new(machine || "localhost" , :port => (port || 2222) , :user => (user || "pi"))
|
@@conn = Rye::Box.new(machine || "localhost" , :port => (port || 2222) , :user => (user || "pi"))
|
||||||
end
|
end
|
||||||
|
|
||||||
def check_remote ret
|
def check_remote ret_val
|
||||||
return unless box = connected
|
return unless box = connected
|
||||||
|
load_program
|
||||||
file = write_object_file
|
file = write_object_file
|
||||||
|
print "\nfile #{file} "
|
||||||
r_file = file.sub("./" , "salama/")
|
r_file = file.sub("./" , "salama/")
|
||||||
box.file_upload file , r_file
|
box.file_upload file , r_file
|
||||||
box.ld "-N", r_file
|
box.ld "-N", r_file
|
||||||
@ -63,15 +69,14 @@ module RuntimeTests
|
|||||||
end
|
end
|
||||||
assert_equal @stdout , ret.stdout.join , "remote std was #{ret.stdout}" if @stdout
|
assert_equal @stdout , ret.stdout.join , "remote std was #{ret.stdout}" if @stdout
|
||||||
assert_equal "" , ret.stderr.join , "remote had error"
|
assert_equal "" , ret.stderr.join , "remote had error"
|
||||||
if ret and ret.is_a?(Numeric)
|
if ret_val
|
||||||
should = @interpreter.get_register(:r0).return_value
|
ret_val &= 0xFF # don't knwo why exit codes are restricted but there you are
|
||||||
should &= 0xFF # don't knwo why exit codes are restricted but there you are
|
assert_equal ret_val , ret.exit_status.to_i , "remote exit failed for #{@string_input}"
|
||||||
assert_equal should , ret.exit_status.to_i , "remote exit failed for #{@string_input}"
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def write_object_file
|
def write_object_file
|
||||||
file_name = caller(4).first.split("in ").last.chop.sub("`","")
|
file_name = caller(3).first.split("in ").last.chop.sub("`","")
|
||||||
return if file_name.include?("run")
|
return if file_name.include?("run")
|
||||||
file_name = "./tmp/" + file_name + ".o"
|
file_name = "./tmp/" + file_name + ".o"
|
||||||
Register.machine.translate_arm
|
Register.machine.translate_arm
|
||||||
@ -80,12 +85,4 @@ module RuntimeTests
|
|||||||
file_name
|
file_name
|
||||||
end
|
end
|
||||||
|
|
||||||
def check_return val
|
|
||||||
check val
|
|
||||||
end
|
|
||||||
|
|
||||||
def check_return_class val
|
|
||||||
check
|
|
||||||
assert_equal val , @interpreter.get_register(:r0).return_value.class
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
Loading…
x
Reference in New Issue
Block a user