_test_machines_and_extensions.tcl 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. # TCL script for openMSX for easy testing of known machines and extensions.
  2. # (c) 2012 Filip H.F. "FiXato" Slagter
  3. # For inclusion with openMSX, GNU General Public License version 2 (GPLv2,
  4. # http://www.gnu.org/licenses/gpl-2.0.html) applies.
  5. # Otherwise you may use this work without restrictions, as long as this notice
  6. # is included.
  7. # The work is provided "as is" without warranty of any kind, neither express
  8. # nor implied.
  9. set_help_text test_all_machines "Test all known machines and report errors. Pass 'stderr' as channel argument to get the return values on the commandline."
  10. proc test_all_machines {{channel "stdout"}} {
  11. set nof_machines [llength [openmsx_info machines]]
  12. set broken [list]
  13. set errors [list]
  14. puts $channel "Going to test $nof_machines machines..."
  15. foreach machine [openmsx_info machines] {
  16. puts -nonewline $channel "Testing $machine ([utils::get_machine_display_name_by_config_name $machine])... "
  17. set res [test_machine $machine]
  18. if {$res != ""} {
  19. lappend broken $machine
  20. lappend errors $res
  21. set res "BROKEN: $res"
  22. } else {
  23. set res "OK"
  24. }
  25. puts $channel $res
  26. }
  27. set nof_ok [expr {$nof_machines - [llength $broken]}]
  28. set perc [expr {($nof_ok*100)/$nof_machines}]
  29. puts $channel ""
  30. puts $channel "$nof_ok out of $nof_machines machines OK ($perc\%)"
  31. if {$nof_ok < $nof_machines} {
  32. puts $channel ""
  33. puts $channel "Broken machines:"
  34. foreach machine $broken errormsg $errors {
  35. puts $channel " $machine ([utils::get_machine_display_name_by_config_name $machine]): $errormsg"
  36. }
  37. }
  38. }
  39. set_help_text test_all_extensions "Test all known extensions and report errors. Defaults to using your current machine profile. You can optionally specify another machine configuration name to test on that profile. Pass 'stderr' as last argument to get the return values on the commandline."
  40. proc test_all_extensions {{machine ""} {channel "stdout"}} {
  41. if {$machine == ""} {
  42. set machine [machine_info config_name]
  43. }
  44. # Start a new machine to prevent any conflicts
  45. machine $machine
  46. set nof_extensions [llength [openmsx_info extensions]]
  47. set broken [list]
  48. set errors [list]
  49. puts $channel "Going to test $nof_extensions extensions on machine \"[utils::get_machine_display_name_by_config_name $machine]\"..."
  50. foreach extension [openmsx_info extensions] {
  51. # Try to plug in the extension and output any errors to the
  52. # given channel (defaults to stdout aka the openMSX console)
  53. puts -nonewline $channel "Testing $extension ([utils::get_extension_display_name_by_config_name $extension])... "
  54. set res ""
  55. if { [catch {ext $extension} errorText] } {
  56. lappend broken $extension
  57. lappend errors $errorText
  58. set res "BROKEN: $errorText"
  59. } else {
  60. set res "OK"
  61. incr nof_ok
  62. remove_extension $extension
  63. }
  64. puts $channel $res
  65. }
  66. set nof_ok [expr {$nof_extensions - [llength $broken]}]
  67. set perc [expr {($nof_ok*100)/$nof_extensions}]
  68. puts $channel ""
  69. puts $channel "$nof_ok out of $nof_extensions extensions OK ($perc\%)"
  70. if {$nof_ok < $nof_extensions} {
  71. puts $channel ""
  72. puts $channel "Broken extensions:"
  73. foreach extension $broken errormsg $errors {
  74. puts $channel " $extension ([utils::get_extension_display_name_by_config_name $extension]): $errormsg"
  75. }
  76. }
  77. }