Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change the meaning of manual mode #359

Merged
merged 8 commits into from
May 11, 2024
Merged
22 changes: 15 additions & 7 deletions lib/cli.rb
Original file line number Diff line number Diff line change
Expand Up @@ -93,10 +93,10 @@ def version_option(parser)

# class TestOptions
class TestOptions
attr_accessor :platform, :drivers, :driver_path, :commit, :diff_file, :svvp, :manual,
attr_accessor :platform, :drivers, :driver_path, :commit, :diff_file, :svvp, :dump,
:gthb_context_prefix, :gthb_context_suffix, :playlist, :select_test_names,
:reject_test_names, :triggers_file, :reject_report_sections, :boot_device,
:allow_test_duplication
:allow_test_duplication, :manual

def create_parser
OptionParser.new do |parser|
Expand All @@ -117,7 +117,7 @@ def define_options(parser)
commit_option(parser)
diff_file_option(parser)
svvp_option(parser)
manual_option(parser)
dump_option(parser)
gthb_context_prefix_option(parser)
gthb_context_suffix_option(parser)
playlist_option(parser)
Expand All @@ -127,6 +127,7 @@ def define_options(parser)
reject_report_sections_option(parser)
boot_device_option(parser)
allow_test_duplication_option(parser)
manual_option(parser)
end

def platform_option(parser)
Expand Down Expand Up @@ -171,10 +172,10 @@ def svvp_option(parser)
end
end

def manual_option(parser)
parser.on('--manual', TrueClass,
'Run and prepare the machine for tests, but do not run the tests themselves') do |manual|
@manual = manual
def dump_option(parser)
parser.on('--dump', TrueClass,
'Create machines snapshots and generate scripts for run it manualy') do |dump|
@dump = dump
end
end

Expand Down Expand Up @@ -254,6 +255,13 @@ def allow_test_duplication_option(parser)
@allow_test_duplication = allow_test_duplication
end
end

def manual_option(parser)
parser.on('--manual', TrueClass,
'Run AutoHCK in manual mode') do |manual|
@manual = manual
end
end
end

# class InstallOptions
Expand Down
47 changes: 37 additions & 10 deletions lib/engines/hcktest/hcktest.rb
Original file line number Diff line number Diff line change
Expand Up @@ -183,9 +183,6 @@ def configure_setup_and_synchronize
@studio.configure(@platform['clients'])
configure_clients
@clients.each_value(&:synchronize)
@client1 = @clients.values[0]
@client2 = @clients.values[1]
@client1.support = @client2
@studio.keep_snapshot
@clients.each_value(&:keep_snapshot)
end
Expand Down Expand Up @@ -226,29 +223,59 @@ def tag
end
end

def manual_run
def dump_run
ResourceScope.open do |scope|
run_studio(scope, { dump_only: true })
run_clients(scope, { dump_only: true })
end
end

def pause_run
@project.logger.info('AutoHCK switched in manual mode. Waiting for manual exit.')
@project.logger.info("Type 'exit' and press ENTER to exit manul mode")

# rubocop:disable Lint/Debugger
binding.irb
# rubocop:enable Lint/Debugger

@project.logger.info('Manual exit. AutoHCK will continue.')
end

def prepare_tests
client, support = @clients.values

@tests = Tests.new(client, support, @project, client.target, @studio.tools)

if client.target.nil?
raise EngineError, 'HLK test target is not defined' unless @project.options.test.manual

@project.logger.info('HLK test target is not defined, skipping tests loading in manual mode')
return
end

@tests.list_tests(log: true)
end

def auto_run
ResourceScope.open do |scope|
run_and_configure_setup scope
client = @client1
client.run_tests
client.create_package
prepare_tests

@tests.run

pause_run if @project.options.test.manual

@tests.create_project_package
end
end

def run
upload_driver_package unless @driver_path.nil?

if @project.options.test.manual
@project.logger.info('AutoHCK started in manual mode')
if @project.options.test.dump
@project.logger.info('AutoHCK started in dump only mode')

manual_run
dump_run

@project.logger.info("Find all scripts in folder: #{@project.workspace_path}")
else
Expand Down
4 changes: 4 additions & 0 deletions lib/engines/hcktest/playlist.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,8 @@ def initialize(client, project, target, tools, kit)
else
custom_playlist
end

@rejected_test = []
end

# A custom ListTests error exception
Expand All @@ -34,6 +36,8 @@ def info_page_url(test)
end

def list_tests(log)
return @tests = [] if @target.nil?

@tests = @tools.list_tests(@target['key'], @machine, @project.engine.tag,
@playlist)
raise ListTestsError, 'Failed to list tests' unless @tests
Expand Down
1 change: 1 addition & 0 deletions lib/engines/hcktest/tests.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ def initialize(client, support, project, target, tools)
@support = support
@logger = project.logger
@playlist = Playlist.new(client, project, target, tools, @client.kit)
@tests = []
@tests_extra = {}

@results_template = ERB.new(File.read('lib/templates/report.html.erb'))
Expand Down
19 changes: 6 additions & 13 deletions lib/setupmanagers/hckclient.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,7 @@ class HCKClient
# Client cooldown sleep after thread is joined in seconds
CLIENT_COOLDOWN_SLEEP = 60

attr_reader :name, :kit
attr_writer :support
attr_reader :name, :kit, :target

def initialize(setup_manager, scope, studio, name, run_opts)
@project = setup_manager.project
Expand All @@ -37,16 +36,6 @@ def add_target_to_project
@target = Targets.new(self, @project, @tools, @pool).add_target_to_project
end

def run_tests
@tests = Tests.new(self, @support, @project, @target, @tools)
@tests.list_tests(log: true)
@tests.run
end

def create_package
@tests.create_project_package
end

def configure_machine
move_machine_to_pool
set_machine_ready
Expand Down Expand Up @@ -157,7 +146,11 @@ def configure(run_only: false)
@tools = @studio.tools
@cooldown_thread = Thread.new do
return_when_client_up
Thread.exit if run_only
if run_only
@logger.info("Preparing client skipped #{@name}...")

Thread.exit
end

@logger.info("Preparing client #{@name}...")
@project.extra_sw_manager.install_software_before_driver(@tools, @name)
Expand Down
8 changes: 8 additions & 0 deletions sorbet/rbi/binding.rbi
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# typed: true
# frozen_string_literal: true

# Binding class extention
class Binding
sig { void }
def irb; end
end
Loading