2018-06-06 09:19:18 +02:00
|
|
|
require_relative "helper"
|
|
|
|
|
|
|
|
module Risc
|
|
|
|
class TestMachinePositions < MiniTest::Test
|
2018-06-10 12:18:56 +02:00
|
|
|
def setup_for(platform)
|
2019-02-08 22:03:23 +01:00
|
|
|
Parfait.boot!(Parfait.default_test_options)
|
2019-08-12 23:13:29 +02:00
|
|
|
Mom.boot!
|
2018-07-02 08:35:57 +02:00
|
|
|
Risc.boot!
|
2019-08-12 23:13:29 +02:00
|
|
|
@linker = Mom::MomCollection.new.to_risc.translate(platform)
|
2018-07-02 08:35:57 +02:00
|
|
|
@linker.position_all
|
2018-06-06 09:19:18 +02:00
|
|
|
end
|
|
|
|
def test_cpu_init
|
2018-06-10 12:18:56 +02:00
|
|
|
setup_for(:interpreter)
|
2018-07-02 08:35:57 +02:00
|
|
|
#TODO assert Position.get @linker.cpu_init
|
2018-06-06 09:19:18 +02:00
|
|
|
end
|
|
|
|
def test_cpu_label
|
2018-06-10 12:18:56 +02:00
|
|
|
setup_for(:interpreter)
|
2018-07-02 08:35:57 +02:00
|
|
|
#TODO assert Position.get( @linker.cpu_init.label )
|
2018-06-06 09:19:18 +02:00
|
|
|
end
|
2018-06-10 12:18:56 +02:00
|
|
|
def test_label_positions_match
|
|
|
|
setup_for(:interpreter)
|
|
|
|
Position.positions.each do |object , position|
|
|
|
|
next unless object.is_a?(Label) and object.next
|
|
|
|
assert_equal position.at , Position.get(object.next).at
|
|
|
|
end
|
|
|
|
end
|
2018-06-06 09:19:18 +02:00
|
|
|
def test_cpu_first_arm
|
2018-06-10 12:18:56 +02:00
|
|
|
setup_for(:arm)
|
2018-07-02 08:35:57 +02:00
|
|
|
#TODO assert Position.get( @linker.cpu_init.first )
|
2018-06-06 09:19:18 +02:00
|
|
|
end
|
|
|
|
def test_has_arm_pos
|
|
|
|
has_positions(:arm)
|
|
|
|
end
|
|
|
|
def test_has_int_pos
|
|
|
|
has_positions(:interpreter)
|
|
|
|
end
|
|
|
|
def has_positions(platform)
|
2018-06-10 12:18:56 +02:00
|
|
|
setup_for(platform)
|
2018-07-02 08:35:57 +02:00
|
|
|
@linker.object_positions.each do |obj , pos|
|
2018-06-06 09:19:18 +02:00
|
|
|
assert Position.get(obj)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
def test_has_arm_meth
|
|
|
|
meth_positions(:arm)
|
|
|
|
end
|
|
|
|
def test_has_int_meth
|
|
|
|
meth_positions(:interpreter)
|
|
|
|
end
|
|
|
|
def meth_positions(platform)
|
2018-06-10 12:18:56 +02:00
|
|
|
setup_for(platform)
|
2018-06-06 09:19:18 +02:00
|
|
|
Parfait.object_space.each_type do |type|
|
|
|
|
type.each_method do |method|
|
|
|
|
assert Position.get(method.binary)
|
|
|
|
end
|
|
|
|
end
|
2018-07-02 08:35:57 +02:00
|
|
|
@linker.assemblers.each do |asm|
|
|
|
|
assert Position.get(asm.instructions)
|
|
|
|
end
|
2018-06-06 09:19:18 +02:00
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|