mirror of
https://github.com/rust-embedded/rust-raspberrypi-OS-tutorials.git
synced 2024-11-03 15:40:21 +00:00
8c661977b8
This is finally possible since the new feature resolver. For reference: https://github.com/rust-lang/rust-analyzer/issues/6197#issuecomment-827564835
42 lines
1.2 KiB
Ruby
Executable File
42 lines
1.2 KiB
Ruby
Executable File
#!/usr/bin/env ruby
|
|
# frozen_string_literal: true
|
|
|
|
# SPDX-License-Identifier: MIT OR Apache-2.0
|
|
#
|
|
# Copyright (c) 2019-2022 Andre Richter <andre.o.richter@gmail.com>
|
|
|
|
file_dir = File.dirname(__FILE__)
|
|
$LOAD_PATH.unshift(file_dir) unless $LOAD_PATH.include?(file_dir)
|
|
|
|
require 'boot_test'
|
|
require 'console_io_test'
|
|
require 'exit_code_test'
|
|
|
|
qemu_cmd = ARGV.join(' ')
|
|
binary = ARGV.last
|
|
test_name = binary.gsub(%r{.*deps/}, '').split('-')[0]
|
|
|
|
# Check if virtual manifest (tutorial 12 or later) or not
|
|
path_prefix = File.exist?('kernel/Cargo.toml') ? 'kernel/' : ''
|
|
|
|
case test_name
|
|
when 'kernel8.img'
|
|
load "#{path_prefix}tests/boot_test_string.rb" # provides 'EXPECTED_PRINT'
|
|
BootTest.new(qemu_cmd, EXPECTED_PRINT).run # Doesn't return
|
|
|
|
when 'libkernel'
|
|
ExitCodeTest.new(qemu_cmd, 'Kernel library unit tests').run # Doesn't return
|
|
|
|
else
|
|
console_test_file = "#{path_prefix}tests/#{test_name}.rb"
|
|
test_name.concat('.rs')
|
|
test = if File.exist?(console_test_file)
|
|
load console_test_file # provides 'subtest_collection'
|
|
ConsoleIOTest.new(qemu_cmd, test_name, subtest_collection)
|
|
else
|
|
ExitCodeTest.new(qemu_cmd, test_name)
|
|
end
|
|
|
|
test.run # Doesn't return
|
|
end
|