Class: Calypso::UnitTest

Inherits:
Object
  • Object
show all
Defined in:
lib/calypso/unittest.rb

Overview

Unit test model class

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(conf, serial, hw) ⇒ UnitTest

Create a new UnitTest model.

Parameters:



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
# File 'lib/calypso/unittest.rb', line 49

def initialize(conf, serial, hw)
  @name = conf['name']
  @path = File.expand_path conf['path']
  @mode = conf['mode'] == 'manual' ? :manual : :auto
  @hw = hw
  @hardware = hw
  @exec = conf['execute']
  config = conf['config']
  @conf = "#{@path}/#{config}" unless conf.nil?
  @libdir = File.expand_path conf['libdir'] unless conf['libdir'].nil?
  @serial = serial
  @raw = conf
  @success = false
  @autorun = conf['autorun']
  @compare_file = conf['compare']
end

Instance Attribute Details

#autorunBoolean (readonly)

Returns Whether or not the test should be ran automatically.

Returns:

  • (Boolean)

    Whether or not the test should be ran automatically.



40
41
42
# File 'lib/calypso/unittest.rb', line 40

def autorun
  @autorun
end

#execString (readonly)

Returns Unit test build and execution targets.

Returns:

  • (String)

    Unit test build and execution targets.



38
39
40
# File 'lib/calypso/unittest.rb', line 38

def exec
  @exec
end

#hardwareCalypso::Hardware (readonly)

Returns Unit test hardware.

Returns:



36
37
38
# File 'lib/calypso/unittest.rb', line 36

def hardware
  @hardware
end

#hwCalypso::Hardware (readonly)

Returns Unit test hardware.

Returns:



34
35
36
# File 'lib/calypso/unittest.rb', line 34

def hw
  @hw
end

#modeSymbol (readonly)

Returns Unit test mode.

Returns:

  • (Symbol)

    Unit test mode.



32
33
34
# File 'lib/calypso/unittest.rb', line 32

def mode
  @mode
end

#nameString (readonly)

Returns Unit test name.

Returns:

  • (String)

    Unit test name.



28
29
30
# File 'lib/calypso/unittest.rb', line 28

def name
  @name
end

#pathString (readonly)

Returns Unit test path.

Returns:

  • (String)

    Unit test path.



30
31
32
# File 'lib/calypso/unittest.rb', line 30

def path
  @path
end

#serialSerialPortData (readonly)

Returns Information about the serial port used by the test.

Returns:

  • (SerialPortData)

    Information about the serial port used by the test



42
43
44
# File 'lib/calypso/unittest.rb', line 42

def serial
  @serial
end

Instance Method Details

#executeBoolean

Execute the unit test.

Returns:

  • (Boolean)

    Whether or not the test executed succesfully.



69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
# File 'lib/calypso/unittest.rb', line 69

def execute
  kbuild = Kbuild.new(@conf, @path)

  unless Calypso.options.bare
    kbuild.clean
    kbuild.build
    kbuild.install_modules(@libdir)
  end
  
  kbuild.build_test(@exec)
  sp = Calypso::SerialMonitor.new(@serial.port)
  manual_stop = sp.monitor

  if manual_stop or @mode == :manual
    print "Did the test run succesfully? [y/n]: "
    reply = gets.chomp
    @success = true if reply.eql? 'y' or reply.eql? 'Y'
  else
    @success = compare(sp)
  end
end

#success?Boolean

Check if the test ran succesfully.

Returns:

  • (Boolean)

    Whether or not the test executed succesfully.



103
104
105
# File 'lib/calypso/unittest.rb', line 103

def success?
  @success
end

#updatenil

Update the unit test configuration file.

Returns:

  • (nil)


94
95
96
97
98
# File 'lib/calypso/unittest.rb', line 94

def update
  kbuild = Kbuild.new(@conf, @path)
  kbuild.prepare
  kbuild.save_config
end