Sha256: 91271fd5cf628aeb41fa06c6e2de1df2b537367055cb4f49409c0f849f7fa9ca

Contents?: true

Size: 1.59 KB

Versions: 2

Compression:

Stored size: 1.59 KB

Contents

#!/usr/bin/env ruby
require_relative 'cmd-helper'
require_relative '../../app/breakpoint'

class TestCommandEnableDisable < Test::Unit::TestCase

  include UnitHelper
  def setup
    Trepan::Breakpoint::reset
    common_setup
    @break_cmd   = @cmds['break']
    @disable_cmd = @cmds['disable']
    @enable_cmd  = @cmds['enable']
  end

  def test_basic

    # Some simple errors in running enable/disable commands
    [[@enable_cmd, ['enable', '1'], 0, 1],
     [@disable_cmd, ['disable', '1'], 0, 1]].each do
      |cmd, args, nmsgs, nerrs|
      # No breakpoint number given
      cmd.run(args[0..0])
      assert_equal(nmsgs, @cmdproc.msgs.size,
                   "#{args} - msgs: #{@cmdproc.msgs.inspect}")
      assert_equal(nerrs, @cmdproc.errmsgs.size,
                   "#{args} - errmsgs: #{@cmdproc.errmsgs.inspect}")
      reset_cmdproc_vars

      # Non-existent breakpoint
      cmd.run(args)
      assert_equal(true, @cmdproc.msgs.empty?)
      assert_equal(1, @cmdproc.errmsgs.size)
      reset_cmdproc_vars
    end

    tf = RubyVM::Frame.get
    @cmdproc.frame_setup(tf)
    pc_offset = tf.pc_offset
    @break_cmd.run(['break'])
    p @cmdproc.errmsgs
    assert_equal(true, @cmdproc.errmsgs.empty?)
    assert_equal(1, @cmdproc.msgs.size)
    reset_cmdproc_vars

    @disable_cmd.run(['disable', '1'])
    assert_equal(0,
                 @cmdproc.msgs[0] =~ /^Breakpoint 1 disabled./,
                 @cmdproc.msgs)
    reset_cmdproc_vars

    @enable_cmd.run(['enable', '1'])
    assert_equal(0,
                 @cmdproc.msgs[0] =~ /^Breakpoint 1 enabled./,
                 @cmdproc.msgs)
  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
trepanning-2.15.35 test/unit/test-cmd-endisable.rb
trepanning-2.15.33 test/unit/test-cmd-endisable.rb