Module: Calypso
- Defined in:
- lib/calypso.rb,
lib/calypso/kbuild.rb,
lib/calypso/iparser.rb,
lib/calypso/version.rb,
lib/calypso/hardware.rb,
lib/calypso/unittest.rb,
lib/calypso/yamlparser.rb,
lib/calypso/parserproxy.rb,
lib/calypso/serialmonitor.rb,
lib/calypso/serialportdata.rb
Overview
Calypso base module
Defined Under Namespace
Classes: Hardware, IParser, Kbuild, ParserProxy, SerialMonitor, SerialPortData, UnitTest, YAMLParser
Constant Summary collapse
- VERSION =
Calypso version constant
'0.1.3'
Class Attribute Summary collapse
-
.options ⇒ Object
readonly
Returns the value of attribute options.
Class Method Summary collapse
-
.run(parser, options) ⇒ nil
Run all unit tests.
-
.run_hardware(config, options, hwid) ⇒ nil
Run all tests for a specific piece of hardware.
-
.run_single(parser, options) ⇒ nil
Run a single test.
-
.start(args) ⇒ nil
Start Calypso.
-
.tty_fix(serial) ⇒ nil
Fix the serial TTY configuration.
-
.update(parser, options) ⇒ nil
Update the Kbuild configurations.
-
.update_hw(parser, options, hwid) ⇒ nil
Update the Kbuild configurations.
Class Attribute Details
.options ⇒ Object (readonly)
Returns the value of attribute options.
32 33 34 |
# File 'lib/calypso.rb', line 32 def @options end |
Class Method Details
.run(parser, options) ⇒ nil
Run all unit tests.
225 226 227 228 229 230 231 |
# File 'lib/calypso.rb', line 225 def run(parser, ) hw = parser.hardware hw.each do |hwid, hwdata| Calypso.run_hardware(parser, , hwid) end end |
.run_hardware(config, options, hwid) ⇒ nil
Run all tests for a specific piece of hardware.
196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 |
# File 'lib/calypso.rb', line 196 def run_hardware(config, , hwid) hw = config.hardware[hwid] tests = hw.tests puts "Running #{hw.name} tests. Press enter to continue..." gets tests.each do |test| next unless test.autorun Calypso.tty_fix(test.serial) if .tty_fix test.execute success = "successfully" if test.success? success = "unsuccessfully" unless test.success? puts "" puts "#{test.name} ran #{success}!" puts "" end puts "Unit test results:\n" tests.each do |test| next unless test.autorun puts "[#{test.name}]: #{test.success? ? 'OK' : 'FAIL'}" end end |
.run_single(parser, options) ⇒ nil
Run a single test.
181 182 183 184 185 186 187 188 |
# File 'lib/calypso.rb', line 181 def run_single(parser, ) test = parser.tests[.single] puts "Running test [#{test.name}]" Calypso.tty_fix(test.serial) if .tty_fix test.execute puts "[#{test.name}]: #{test.success? ? 'OK' : 'FAIL'}" end |
.start(args) ⇒ nil
Start Calypso.
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 |
# File 'lib/calypso.rb', line 38 def start(args) = OpenStruct.new .parser = nil .config = nil .path = Dir.pwd .single = nil . = false .hardware = nil .run_mode = :all .tty_fix = false .tty_fix = true if ENV['TTY_FIX'].eql? 'true' .update = false parser = OptionParser.new do |p| p. = "Usage: calypso [options] -c [config]" p.separator "" p.separator "Specific options:" p.on('-y', '--yaml', "Parse configuration as YAML") do .parser = :yaml end p.on('-u', '--update', "Update configuration files") do .update = true end p.on('-b', '--bare', "Do not recompile ETA/OS before running the test") do . = true end p.on('-f', '--tty-fix', 'Enforce the correct TTY settings before trying to run a test') do .tty_fix = true end p.on('-t [TESTID]', '--test [TESTID]', 'Run a specific test') do |id| .single = id .run_mode = :single end p.on('-c [FILE]', '--config [FILE]', 'Path to the test configuration') do |conf| .config = conf end p.on('-H [hardware-id]', '--hardware [hardware-id]', 'Run all tests configured for a specific MCU') do |hardware| .hardware = hardware .run_mode = :hardware end p.separator "" p.separator "Common options:" p.on_tail("-h", "--help", "Show this message") do puts p exit end p.on_tail("-v", "--version", "Print the Calypso version") do puts "Calypso #{Calypso::VERSION}" exit end end parser.parse! mandatory = [:config, :parser] missing = mandatory.select do |param| if [param].nil? or [param] == false param end end unless missing.empty? puts "Missing mandatory options!" puts "" puts parser exit end unless .single.nil? or .hardware.nil? puts "The options -t and -H cannot be used together!" puts "" puts parser exit end @options = config = Calypso::ParserProxy.new(.parser, .config) config.parse if .update Calypso.update(config, ) exit end case .run_mode when :all Calypso.run(config, ) when :hardware Calypso.run_hardware(config, , .hardware) when :single Calypso.run_single(config, ) end end |
.tty_fix(serial) ⇒ nil
Fix the serial TTY configuration.
237 238 239 240 |
# File 'lib/calypso.rb', line 237 def tty_fix(serial) fix_cmd = "stty 57600 raw ignbrk hup < #{serial.port}" system(fix_cmd) end |
.update(parser, options) ⇒ nil
Update the Kbuild configurations.
168 169 170 171 172 173 174 |
# File 'lib/calypso.rb', line 168 def update(parser, ) hw = parser.hardware hw.each do |hwid, hwdata| Calypso.update_hw(parser, , hwid) end end |
.update_hw(parser, options, hwid) ⇒ nil
Update the Kbuild configurations.
152 153 154 155 156 157 158 159 160 161 |
# File 'lib/calypso.rb', line 152 def update_hw(parser, , hwid) hw = parser.hardware[hwid] tests = hw.tests tests.each do |test| puts "Updating #{test.name}" puts "" test.update end end |