Added flight recorder and more boot messages.
All checks were successful
Run test asserts / Test-Asserts (push) Successful in -8s

This commit is contained in:
Willem Cazander 2024-06-29 15:47:52 +02:00
parent 97088650d4
commit c1a52773ac
16 changed files with 176 additions and 94 deletions

View file

@ -0,0 +1,33 @@
# boot_exec -- Helper command to autoexec.bat boot scripts.
#
# Adds the following command to openMSX;
#
# 'boot_exec_exit'
# Requested delayed shutdown of openMSX.
# (as workaround for segfault when screenshot is not ready yet)
#
# 'boot_exec_color_dark'
# Sets the VDP colors to dark color tones.
#
# 'boot_exec_config_info'
# Displays machine and openMSX version on one line.
#
proc boot_exec_exit {} {
after time 1 "exit 0"
return "Shutdown openMSX"
}
proc boot_exec_color_dark {} {
setcolor 4 000
setcolor 15 777
return "Boot color dark"
}
proc boot_exec_config_info {} {
set result "Run machine "
append result [machine_info config_name]
append result " on "
append result [openmsx_info version]
return $result
}

View file

@ -35,7 +35,6 @@
# The number of partitions created in the disk image, defaults to 1.
#
# per default create msxdos1 compatible partition size.
set boot_hdd_size 15m
set boot_hdd_image hdd.dsk
set boot_hdd_path_import 0
@ -44,7 +43,6 @@ set boot_hdd_export_partition 0
set boot_hdd_export_dir \\
set boot_hdd_partitions 1
# Parse env settings
if {[info exists ::env(BOOT_HDD_SIZE)] && ([string trim $::env(BOOT_HDD_SIZE)] != "")} {
set boot_hdd_size [string trim $::env(BOOT_HDD_SIZE)]
}

View file

@ -1,10 +1,10 @@
# boot_env -- Sets various openMSX settings based from environment variables.
# boot_mode -- Controls the boot mode config of openMSX from environment variables.
#
# Typically used in automation tools which run openMSX without human interaction.
#
# Adds the following command to openMSX;
#
# 'boot_gui_mode'
# 'boot_mode_show_gui'
# Enables the renderer and throttle from the inside.
#
# Supported environment variables by this script;
@ -13,38 +13,34 @@
# Override video output from command line.
#
# RENDERER=SDL
# Select video renderer type for gui mode or in none headless mode.
# Select video renderer type for GUI mode or in none headless mode.
#
# SCALE_FACTOR=3
# Override video scale factor for SDL renderer.
# Override video scale factor for the renderer.
#
# THROTTLE=off
# Disables msx speed emulation.
# Disables MSX speed emulation.
#
# SPEED=400
# Sets msx speed to 4x of original but only when throttle is on.
#
# RECORDER=bin/output.avi
# Enables the the video recorder.
# SPEED=333
# Sets CPU speed to relative from normal but only when throttle is on.
#
# Enabled openMSX gui from inside
proc boot_gui_mode {} {
set boot_env_renderer_type 0
proc boot_mode_show_gui {} {
global renderer
global throttle
global boot_env_renderer_type
if {$boot_env_renderer_type != 0} {
set renderer $boot_env_renderer_type
after time 1 "set renderer $boot_env_renderer_type"
set throttle on
} else {
puts stderr "error: Requested boot_gui_mode but env.RENDERER is missing."
exit 1
}
return "Requested GUI with $boot_env_renderer_type"
}
# Globals
set boot_env_renderer_type 0
if {[info exists ::env(RENDERER)] && ([string trim $::env(RENDERER)] != "")} {
set boot_env_renderer_type [string trim $::env(RENDERER)]
}
@ -76,13 +72,3 @@ if {[info exists ::env(SPEED)] && ([string trim $::env(SPEED)] != "")} {
exit 1
}
}
if {[info exists ::env(RECORDER)] && ([string trim $::env(RECORDER)] != "")} {
if {[catch {after time 1 "record start -prefix [string trim $::env(RECORDER)]"} err_msg]} {
puts stderr "error: env.RECORDER value $err_msg"
exit 1
}
after quit {
record stop
}
}

View file

@ -17,21 +17,19 @@
#
# Supported environment variables by this script;
#
# FAIL_AFTER_PATH=.
# Enabled automatic screenshots saving in case of failures in the supplied path.
#
# FAIL_AFTER_BOOT=30
# BOOT_WATCHDOG=30
# Enables the boot watchdog timer which will exit openMSX after the timeout(in seconds).
# To cancel this timer give an `fail_after 0` or any new fail_after command.
# (exits with status 124 see `man timeout`)
#
set fail_after_prev_timer 0
set fail_after_prev_id 0
set fail_after_boot_timeout 0
proc fail_after_exit {{fail_id "fail_after_exit"} {fail_code 2}} {
global fail_after_path
if {$fail_after_path != 0} {
if {[catch {screenshot $fail_after_path/$fail_id.png} err_msg]} {
puts stderr "warning: $err_msg"
}
# maybe later add; if {is_text_mode} { [get_screen] ?> $fail_after_path/$fail_id.scr }
if {[catch {screenshot -prefix $fail_id} err_msg]} {
puts stderr "warning: $err_msg"
}
puts stderr "error: Failure request from $fail_id"
exit $fail_code
@ -43,7 +41,7 @@ proc fail_after { timeout {time_unit "time"} {fail_id "fail_after"} {fail_code 2
set msg ""
if {$fail_after_prev_timer != 0} {
after cancel $fail_after_prev_timer
set msg "$fail_after_prev_id: Stopped attempt."
set msg "$fail_after_prev_id: Stopped attempt"
}
set fail_after_prev_id $fail_id
if {$time_unit != "time"} {
@ -69,19 +67,7 @@ proc fail_after_reboot_watchdog {} {
}
}
# Globals
set fail_after_prev_timer 0
set fail_after_prev_id 0
set fail_after_path 0
set fail_after_boot_timeout 0
# Parse screenshot path env setting
if {[info exists ::env(FAIL_AFTER_PATH)] && ([string trim $::env(FAIL_AFTER_PATH)] != "")} {
set fail_after_path [string trim $::env(FAIL_AFTER_PATH)]
}
# Enables boot watch dog timer when FAIL_AFTER_BOOT env has a value. (124 see `man timeout`)
if {[info exists ::env(FAIL_AFTER_BOOT)] && ([string trim $::env(FAIL_AFTER_BOOT)] != "")} {
set fail_after_boot_timeout [string trim $::env(FAIL_AFTER_BOOT)]
if {[info exists ::env(BOOT_WATCHDOG)] && ([string trim $::env(BOOT_WATCHDOG)] != "")} {
set fail_after_boot_timeout [string trim $::env(BOOT_WATCHDOG)]
fail_after_reboot_watchdog
}

View file

@ -0,0 +1,63 @@
# safe_flight -- Setup the black box flight recorder for build pipelines.
#
# Adds the following command to openMSX;
#
# 'save_flight_screenshot'
# Takes an screenshot with optional prefix parameter.
#
# 'save_flight_video'
# Starts video recording with optional prefix parameter.
#
# Supported environment variables by this script;
#
# SAVE_FLIGHT_PREFIX=msxbuild
# Gives screenshots and videos an prefix; msxbuild0001.avi
#
# SAVE_FLIGHT_SEPERATOR=-
# Gives screenshots and videos an seperator; openmsx-0001.png
#
# SAVE_FLIGHT_RECORD_FLAG=-doublesize
# Flag given to the video record command.
#
set save_flight_prefix flight
set save_flight_seperator -
set save_flight_record_flag ""
proc save_flight_screenshot {{prefix_id 0}} {
global save_flight_prefix
global save_flight_seperator
if {$prefix_id != 0} {
set file_prefix "$prefix_id$save_flight_seperator"
} else {
set file_prefix "$save_flight_prefix$save_flight_seperator"
}
after time 1 "screenshot -prefix $file_prefix"
return "Flight screenshot saved"
}
proc save_flight_video {{prefix_id 0}} {
global save_flight_prefix
global save_flight_seperator
global save_flight_record_flag
if {$prefix_id != 0} {
set file_prefix "$prefix_id$save_flight_seperator"
} else {
set file_prefix "$save_flight_prefix$save_flight_seperator"
}
after quit "record stop"
after time 1 "record start $save_flight_record_flag -prefix $file_prefix"
return "Flight video started"
}
if {[info exists ::env(SAVE_FLIGHT_PREFIX)] && ([string trim $::env(SAVE_FLIGHT_PREFIX)] != "")} {
set save_flight_prefix [string trim $::env(SAVE_FLIGHT_PREFIX)]
}
if {[info exists ::env(SAVE_FLIGHT_SEPERATOR)] && ([string trim $::env(SAVE_FLIGHT_SEPERATOR)] != "")} {
set save_flight_seperator [string trim $::env(SAVE_FLIGHT_SEPERATOR)]
}
if {[info exists ::env(SAVE_FLIGHT_RECORD_FLAG)] && ([string trim $::env(SAVE_FLIGHT_RECORD_FLAG)] != "")} {
set save_flight_record_flag [string trim $::env(SAVE_FLIGHT_RECORD_FLAG)]
}