rbx-trepanning 0.0.5-universal-rubinius-1.2.1
Sign up to get free protection for your applications and to get access to all the features.
- data/ChangeLog +2002 -0
- data/LICENSE +25 -0
- data/NEWS +31 -0
- data/README.textile +34 -0
- data/Rakefile +165 -0
- data/THANKS +14 -0
- data/app/breakpoint.rb +219 -0
- data/app/breakpoint.rbc +3551 -0
- data/app/brkptmgr.rb +140 -0
- data/app/brkptmgr.rbc +2903 -0
- data/app/client.rb +61 -0
- data/app/client.rbc +1225 -0
- data/app/complete.rb +52 -0
- data/app/complete.rbc +1288 -0
- data/app/default.rb +71 -0
- data/app/default.rbc +1132 -0
- data/app/display.rb +148 -0
- data/app/display.rbc +2578 -0
- data/app/frame.rb +98 -0
- data/app/frame.rbc +1808 -0
- data/app/irb.rb +111 -0
- data/app/irb.rbc +2094 -0
- data/app/iseq.rb +117 -0
- data/app/iseq.rbc +2192 -0
- data/app/llvm.rbc +2478 -0
- data/app/method.rb +173 -0
- data/app/method.rbc +2492 -0
- data/app/method_name.rbc +2467 -0
- data/app/mock.rb +13 -0
- data/app/mock.rbc +398 -0
- data/app/options.rb +137 -0
- data/app/options.rbc +2898 -0
- data/app/rbx-llvm.rb +165 -0
- data/app/rbx-llvm.rbc +2478 -0
- data/app/run.rb +86 -0
- data/app/run.rbc +1244 -0
- data/app/util.rb +49 -0
- data/app/util.rbc +1146 -0
- data/app/validate.rb +30 -0
- data/app/validate.rbc +676 -0
- data/bin/trepan.compiled.rbc +1043 -0
- data/bin/trepanx +69 -0
- data/bin/trepanx.compiled.rbc +1049 -0
- data/data/irbrc +41 -0
- data/data/irbrc.compiled.rbc +640 -0
- data/interface/base_intf.rb +105 -0
- data/interface/base_intf.rbc +1899 -0
- data/interface/client.rb +80 -0
- data/interface/client.rbc +1072 -0
- data/interface/comcodes.rb +20 -0
- data/interface/comcodes.rbc +385 -0
- data/interface/script.rb +104 -0
- data/interface/script.rbc +1642 -0
- data/interface/server.rb +143 -0
- data/interface/server.rbc +2213 -0
- data/interface/user.rb +150 -0
- data/interface/user.rbc +2867 -0
- data/io/base_io.rb +148 -0
- data/io/base_io.rbc +2111 -0
- data/io/input.rb +135 -0
- data/io/input.rbc +2528 -0
- data/io/null_output.rb +42 -0
- data/io/null_output.rbc +730 -0
- data/io/string_array.rb +156 -0
- data/io/string_array.rbc +2466 -0
- data/io/tcpclient.rb +129 -0
- data/io/tcpclient.rbc +2419 -0
- data/io/tcpfns.rb +33 -0
- data/io/tcpfns.rbc +694 -0
- data/io/tcpserver.rb +141 -0
- data/io/tcpserver.rbc +2638 -0
- data/lib/trepanning.rb +474 -0
- data/lib/trepanning.rbc +7705 -0
- data/lib/trepanning2.rb +441 -0
- data/processor/breakpoint.rb +164 -0
- data/processor/command/alias.rb +55 -0
- data/processor/command/backtrace.rb +76 -0
- data/processor/command/base/cmd.rb +173 -0
- data/processor/command/base/subcmd.rb +229 -0
- data/processor/command/base/submgr.rb +182 -0
- data/processor/command/base/subsubcmd.rb +103 -0
- data/processor/command/base/subsubmgr.rb +195 -0
- data/processor/command/break.rb +100 -0
- data/processor/command/complete.rb +37 -0
- data/processor/command/continue.rb +91 -0
- data/processor/command/delete.rb +30 -0
- data/processor/command/directory.rb +51 -0
- data/processor/command/disassemble.rb +145 -0
- data/processor/command/display.rb +82 -0
- data/processor/command/down.rb +54 -0
- data/processor/command/eval.rb +51 -0
- data/processor/command/exit.rb +62 -0
- data/processor/command/finish.rb +80 -0
- data/processor/command/frame.rb +89 -0
- data/processor/command/help.rb +251 -0
- data/processor/command/info.rb +28 -0
- data/processor/command/info_subcmd/breakpoints.rb +73 -0
- data/processor/command/info_subcmd/files.rb +209 -0
- data/processor/command/info_subcmd/line.rb +86 -0
- data/processor/command/info_subcmd/method.rb +71 -0
- data/processor/command/info_subcmd/program.rb +49 -0
- data/processor/command/info_subcmd/ruby.rb +62 -0
- data/processor/command/info_subcmd/variables.rb +48 -0
- data/processor/command/irb.rb +128 -0
- data/processor/command/kill.rb +70 -0
- data/processor/command/list.rb +300 -0
- data/processor/command/macro.rb +76 -0
- data/processor/command/next.rb +66 -0
- data/processor/command/nexti.rb +59 -0
- data/processor/command/pr.rb +38 -0
- data/processor/command/ps.rb +40 -0
- data/processor/command/restart.rb +60 -0
- data/processor/command/server.rb +72 -0
- data/processor/command/set.rb +47 -0
- data/processor/command/set_subcmd/auto.rb +27 -0
- data/processor/command/set_subcmd/auto_subcmd/dis.rb +33 -0
- data/processor/command/set_subcmd/auto_subcmd/eval.rb +54 -0
- data/processor/command/set_subcmd/auto_subcmd/irb.rb +34 -0
- data/processor/command/set_subcmd/auto_subcmd/list.rb +34 -0
- data/processor/command/set_subcmd/basename.rb +25 -0
- data/processor/command/set_subcmd/confirm.rb +24 -0
- data/processor/command/set_subcmd/debug.rb +26 -0
- data/processor/command/set_subcmd/debug_subcmd/dbgr.rb +36 -0
- data/processor/command/set_subcmd/debug_subcmd/skip.rb +23 -0
- data/processor/command/set_subcmd/debug_subcmd/step.rb +23 -0
- data/processor/command/set_subcmd/different.rb +59 -0
- data/processor/command/set_subcmd/hidelevel.rb +62 -0
- data/processor/command/set_subcmd/highlight.rb +33 -0
- data/processor/command/set_subcmd/kernelstep.rb +60 -0
- data/processor/command/set_subcmd/max.rb +26 -0
- data/processor/command/set_subcmd/max_subcmd/list.rb +49 -0
- data/processor/command/set_subcmd/max_subcmd/stack.rb +50 -0
- data/processor/command/set_subcmd/max_subcmd/string.rb +76 -0
- data/processor/command/set_subcmd/max_subcmd/width.rb +49 -0
- data/processor/command/set_subcmd/substitute.rb +24 -0
- data/processor/command/set_subcmd/substitute_subcmd/path.rb +56 -0
- data/processor/command/set_subcmd/trace.rb +36 -0
- data/processor/command/set_subcmd/trace_subcmd/print.rb +57 -0
- data/processor/command/show.rb +38 -0
- data/processor/command/show_subcmd/alias.rb +42 -0
- data/processor/command/show_subcmd/args.rb +25 -0
- data/processor/command/show_subcmd/auto.rb +28 -0
- data/processor/command/show_subcmd/auto_subcmd/dis.rb +37 -0
- data/processor/command/show_subcmd/auto_subcmd/eval.rb +28 -0
- data/processor/command/show_subcmd/auto_subcmd/irb.rb +23 -0
- data/processor/command/show_subcmd/auto_subcmd/list.rb +22 -0
- data/processor/command/show_subcmd/basename.rb +20 -0
- data/processor/command/show_subcmd/confirm.rb +18 -0
- data/processor/command/show_subcmd/debug.rb +26 -0
- data/processor/command/show_subcmd/debug_subcmd/dbgr.rb +21 -0
- data/processor/command/show_subcmd/debug_subcmd/skip.rb +22 -0
- data/processor/command/show_subcmd/debug_subcmd/step.rb +22 -0
- data/processor/command/show_subcmd/different.rb +26 -0
- data/processor/command/show_subcmd/hidelevel.rb +41 -0
- data/processor/command/show_subcmd/highlight.rb +24 -0
- data/processor/command/show_subcmd/kernelstep.rb +34 -0
- data/processor/command/show_subcmd/max.rb +27 -0
- data/processor/command/show_subcmd/max_subcmd/list.rb +38 -0
- data/processor/command/show_subcmd/max_subcmd/stack.rb +36 -0
- data/processor/command/show_subcmd/max_subcmd/string.rb +42 -0
- data/processor/command/show_subcmd/max_subcmd/width.rb +37 -0
- data/processor/command/show_subcmd/trace.rb +27 -0
- data/processor/command/show_subcmd/trace_subcmd/print.rb +38 -0
- data/processor/command/show_subcmd/version.rb +23 -0
- data/processor/command/source.rb +126 -0
- data/processor/command/step.rb +84 -0
- data/processor/command/tbreak.rb +19 -0
- data/processor/command/unalias.rb +44 -0
- data/processor/command/undisplay.rb +59 -0
- data/processor/command/up.rb +86 -0
- data/processor/default.rb +58 -0
- data/processor/disassemble.rb +46 -0
- data/processor/display.rb +18 -0
- data/processor/eval.rb +96 -0
- data/processor/frame.rb +211 -0
- data/processor/help.rb +72 -0
- data/processor/hook.rb +133 -0
- data/processor/load_cmds.rb +185 -0
- data/processor/location.rb +137 -0
- data/processor/main.rb +412 -0
- data/processor/mock.rb +144 -0
- data/processor/msg.rb +43 -0
- data/processor/running.rb +234 -0
- data/processor/stepping.rb +114 -0
- data/processor/subcmd.rb +161 -0
- data/processor/validate.rb +355 -0
- data/sample/list-terminal-colors.rb +139 -0
- data/sample/list-terminal-colors.rbc +2318 -0
- data/sample/rocky-dot-trepanxrc +14 -0
- data/sample/rocky-trepanx-colors.rb +47 -0
- data/sample/rocky-trepanx-colors.rbc +530 -0
- data/test/data/enable.right +36 -0
- data/test/data/fname-with-blank.cmd +6 -0
- data/test/data/fname-with-blank.right +4 -0
- data/test/data/inline-call.cmd +6 -0
- data/test/data/inline-call.right +13 -0
- data/test/data/quit-Xdebug.right +3 -0
- data/test/data/quit.cmd +5 -0
- data/test/data/quit.right +2 -0
- data/test/data/quit2.cmd +6 -0
- data/test/data/quit2.right +3 -0
- data/test/data/step-bug.cmd +11 -0
- data/test/data/step-bug.right +3 -0
- data/test/example/fname with blank.rb +1 -0
- data/test/example/gcd-server.rb +22 -0
- data/test/example/gcd.rb +19 -0
- data/test/example/inline-call.rb +23 -0
- data/test/example/null.rb +1 -0
- data/test/example/step-bug.rb +14 -0
- data/test/example/thread1.rb +3 -0
- data/test/functional/fn_helper.rb +112 -0
- data/test/functional/test-break-name.rb +52 -0
- data/test/functional/test-break.rb +51 -0
- data/test/functional/test-finish.rb +70 -0
- data/test/functional/test-fn_helper.rb +43 -0
- data/test/functional/test-list.rb +55 -0
- data/test/functional/test-next-bug.rb +49 -0
- data/test/functional/test-next.rb +101 -0
- data/test/functional/test-step.rb +272 -0
- data/test/functional/test-step2.rb +35 -0
- data/test/functional/test-tbreak.rb +41 -0
- data/test/integration/file-diff.rb +89 -0
- data/test/integration/helper.rb +78 -0
- data/test/integration/skip-test-step-bug.rb +17 -0
- data/test/integration/test-fname-with-blank.rb +16 -0
- data/test/integration/test-inline-call.rb +20 -0
- data/test/integration/test-quit.rb +47 -0
- data/test/unit/cmd-helper.rb +50 -0
- data/test/unit/mock-helper.rb +10 -0
- data/test/unit/test-app-brkpt.rb +29 -0
- data/test/unit/test-app-brkptmgr.rb +51 -0
- data/test/unit/test-app-iseq.rb +64 -0
- data/test/unit/test-app-method.rb +54 -0
- data/test/unit/test-app-options.rb +82 -0
- data/test/unit/test-app-run.rb +16 -0
- data/test/unit/test-app-util.rb +27 -0
- data/test/unit/test-app-validate.rb +18 -0
- data/test/unit/test-base-cmd.rb +47 -0
- data/test/unit/test-base-subcmd.rb +61 -0
- data/test/unit/test-base-submgr.rb +24 -0
- data/test/unit/test-bin-trepanx.rb +48 -0
- data/test/unit/test-cmd-alias.rb +48 -0
- data/test/unit/test-cmd-break.rb +22 -0
- data/test/unit/test-cmd-exit.rb +27 -0
- data/test/unit/test-cmd-finish.rb +27 -0
- data/test/unit/test-cmd-help.rb +104 -0
- data/test/unit/test-cmd-kill.rb +47 -0
- data/test/unit/test-cmd-source.rb +34 -0
- data/test/unit/test-cmd-step.rb +29 -0
- data/test/unit/test-completion.rb +38 -0
- data/test/unit/test-intf-user.rb +46 -0
- data/test/unit/test-io-input.rb +27 -0
- data/test/unit/test-io-tcp.rb +33 -0
- data/test/unit/test-io-tcpclient.rb +54 -0
- data/test/unit/test-io-tcpfns.rb +17 -0
- data/test/unit/test-io-tcpserver.rb +50 -0
- data/test/unit/test-proc-eval.rb +36 -0
- data/test/unit/test-proc-frame.rb +79 -0
- data/test/unit/test-proc-help.rb +16 -0
- data/test/unit/test-proc-hook.rb +30 -0
- data/test/unit/test-proc-load_cmds.rb +50 -0
- data/test/unit/test-proc-location.rb +53 -0
- data/test/unit/test-proc-main.rb +99 -0
- data/test/unit/test-proc-validate.rb +91 -0
- data/test/unit/test-subcmd-help.rb +47 -0
- metadata +398 -0
@@ -0,0 +1,48 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'test/unit'
|
3
|
+
require 'rbconfig'
|
4
|
+
load File.join(File.dirname(__FILE__), %w(.. .. bin trepanx))
|
5
|
+
|
6
|
+
# Test bin/trepan Module methods
|
7
|
+
class TestBinTrepan < Test::Unit::TestCase
|
8
|
+
|
9
|
+
include Trepanning
|
10
|
+
|
11
|
+
def test_ruby_path
|
12
|
+
rb_path = ruby_path
|
13
|
+
assert_equal(true, File.executable?(rb_path),
|
14
|
+
"#{rb_path} should be an executable Ruby interpreter")
|
15
|
+
|
16
|
+
# Let us test that we get *exactly* the same configuration as we
|
17
|
+
# have in this. I'm a ball buster.
|
18
|
+
cmd = "#{rb_path} -rrbconfig -e 'puts Marshal.dump(RbConfig::CONFIG)'"
|
19
|
+
rb_config = Marshal.load(`#{cmd}`)
|
20
|
+
assert_equal(RbConfig::CONFIG, rb_config,
|
21
|
+
"#{rb_path} config doesn't match got:
|
22
|
+
#{rb_config}
|
23
|
+
expected:
|
24
|
+
#{RbConfig::CONFIG}
|
25
|
+
")
|
26
|
+
end
|
27
|
+
|
28
|
+
def test_whence_file
|
29
|
+
abs_path_me = File.expand_path(__FILE__)
|
30
|
+
assert_equal(abs_path_me, whence_file(abs_path_me),
|
31
|
+
"whence_file should have just returned #{abs_path_me}")
|
32
|
+
|
33
|
+
basename_me = File.basename(__FILE__)
|
34
|
+
dirname_me = File.dirname(__FILE__)
|
35
|
+
|
36
|
+
# Add my directory onto the beginning of PATH
|
37
|
+
path_dirs = ENV['PATH'].split(File::PATH_SEPARATOR)
|
38
|
+
path_dirs.unshift(dirname_me)
|
39
|
+
ENV['PATH'] = path_dirs.join(File::PATH_SEPARATOR)
|
40
|
+
|
41
|
+
assert_equal(File.join(dirname_me, basename_me),
|
42
|
+
whence_file(basename_me),
|
43
|
+
"whence_file should have found me")
|
44
|
+
# Restore old path
|
45
|
+
path_dirs.shift
|
46
|
+
ENV['PATH'] = path_dirs.join(File::PATH_SEPARATOR)
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,48 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'rubygems'; require 'require_relative'
|
3
|
+
require_relative 'cmd-helper'
|
4
|
+
require_relative '../../processor/command/alias'
|
5
|
+
require_relative '../../processor/command/unalias'
|
6
|
+
|
7
|
+
# Test commands alias and unalias
|
8
|
+
class TestCommandAliasUnalias < Test::Unit::TestCase
|
9
|
+
|
10
|
+
include UnitHelper
|
11
|
+
def setup
|
12
|
+
common_setup
|
13
|
+
@name = File.basename(__FILE__, '.rb').split(/-/)[2]
|
14
|
+
end
|
15
|
+
|
16
|
+
def check_alias(should_not_have, cmd_name, *args)
|
17
|
+
@cmdproc.instance_variable_set('@msgs', [])
|
18
|
+
@cmdproc.instance_variable_set('@errmsgs', [])
|
19
|
+
arg_str = args.join(' ')
|
20
|
+
my_cmd = @cmds[cmd_name]
|
21
|
+
my_cmd.run([cmd_name] + args)
|
22
|
+
shoulda = should_not_have ? ['no ', ''] : ['', 'no ']
|
23
|
+
msgs = @cmdproc.instance_variable_get('@msgs')
|
24
|
+
errmsgs = @cmdproc.instance_variable_get('@errmsgs')
|
25
|
+
assert_equal(should_not_have, msgs.empty?,
|
26
|
+
"Expecting %s%s for #{arg_str}.\n Got #{msgs}" %
|
27
|
+
[shoulda[0], cmd_name])
|
28
|
+
assert_equal(!should_not_have, errmsgs.empty?,
|
29
|
+
"Expecting %serror for #{arg_str}.\n Got #{errmsgs}" %
|
30
|
+
shoulda[1])
|
31
|
+
end
|
32
|
+
|
33
|
+
def alias_defined?(alias_name)
|
34
|
+
@cmdproc.aliases.member?(alias_name)
|
35
|
+
end
|
36
|
+
|
37
|
+
def test_alias_command
|
38
|
+
|
39
|
+
assert_equal(false, @cmdproc.aliases.empty?,
|
40
|
+
'There should be some aliases defined')
|
41
|
+
|
42
|
+
assert_equal(false, alias_defined?('ki'))
|
43
|
+
check_alias(false, 'alias', 'ki', 'kill')
|
44
|
+
assert_equal(true, alias_defined?('ki'))
|
45
|
+
check_alias(false, 'unalias', 'ki')
|
46
|
+
assert_equal(false, alias_defined?('ki'))
|
47
|
+
end
|
48
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'rubygems'; require 'require_relative'
|
3
|
+
require_relative 'cmd-helper'
|
4
|
+
|
5
|
+
class TestCommandBreak < Test::Unit::TestCase
|
6
|
+
|
7
|
+
include UnitHelper
|
8
|
+
def setup
|
9
|
+
common_setup
|
10
|
+
@cmdproc.frame_setup
|
11
|
+
@name = File.basename(__FILE__, '.rb').split(/-/)[2]
|
12
|
+
@my_cmd = @cmds[@name]
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_basic
|
16
|
+
place = "#{self.class}#test_basic:#{__LINE__}"
|
17
|
+
@my_cmd.run([@name, place])
|
18
|
+
assert_equal(true, @cmdproc.errmsgs.empty?,
|
19
|
+
@cmdproc.errmsgs)
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'test/unit'
|
3
|
+
require 'rubygems'; require 'require_relative'
|
4
|
+
require_relative './mock-helper'
|
5
|
+
require_relative '../../processor/command/exit'
|
6
|
+
|
7
|
+
class TestCommandExit < Test::Unit::TestCase
|
8
|
+
include MockUnitHelper
|
9
|
+
def setup
|
10
|
+
@name = File.basename(__FILE__, '.rb').split(/-/)[2]
|
11
|
+
common_setup(@name)
|
12
|
+
end
|
13
|
+
|
14
|
+
def test_basic
|
15
|
+
pid = fork { @cmd.run([@name, '10']) }
|
16
|
+
Process.wait
|
17
|
+
assert_equal(10, $?.exitstatus)
|
18
|
+
pid = fork { @cmd.run([@name]) }
|
19
|
+
Process.wait
|
20
|
+
assert_equal(0, $?.exitstatus)
|
21
|
+
# FIXME: should test that finalization routines get run;
|
22
|
+
# should test 'confirm' gets run; and should test that
|
23
|
+
# 'unconditional' is handled correctly.
|
24
|
+
end
|
25
|
+
|
26
|
+
|
27
|
+
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'rubygems'; require 'require_relative'
|
3
|
+
require_relative 'cmd-helper'
|
4
|
+
|
5
|
+
class TestCommandFinish < Test::Unit::TestCase
|
6
|
+
|
7
|
+
include UnitHelper
|
8
|
+
def setup
|
9
|
+
common_setup
|
10
|
+
@cmdproc.frame_setup
|
11
|
+
@name = File.basename(__FILE__, '.rb').split(/-/)[2]
|
12
|
+
@my_cmd = @cmds[@name]
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_basic
|
16
|
+
[
|
17
|
+
[%W(#{@name}), 'finish', -1],
|
18
|
+
[%W(#{@name} 2-1), 'finish', -1],
|
19
|
+
].each do |c, rtp, count|
|
20
|
+
@cmdproc.instance_variable_set('@return_to_program', false)
|
21
|
+
@my_cmd.run(c)
|
22
|
+
assert_equal(rtp, @cmdproc.instance_variable_get('@return_to_program'))
|
23
|
+
assert_equal(count, @cmdproc.instance_variable_get('@step_count'))
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
end
|
@@ -0,0 +1,104 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'rubygems'; require 'require_relative'
|
3
|
+
require_relative 'cmd-helper'
|
4
|
+
require_relative '../../processor/command/help'
|
5
|
+
|
6
|
+
class TestCommandHelp < Test::Unit::TestCase
|
7
|
+
|
8
|
+
include UnitHelper
|
9
|
+
def setup
|
10
|
+
common_setup
|
11
|
+
@name = File.basename(__FILE__, '.rb').split(/-/)[2]
|
12
|
+
@my_cmd = @cmds[@name]
|
13
|
+
end
|
14
|
+
|
15
|
+
def check_help(should_not_have, *args)
|
16
|
+
@cmdproc.instance_variable_set('@msgs', [])
|
17
|
+
@cmdproc.instance_variable_set('@errmsgs', [])
|
18
|
+
arg_str = args.join(' ')
|
19
|
+
@my_cmd.run([@name] + args)
|
20
|
+
shoulda = should_not_have ? ['no ', ''] : ['', 'no ']
|
21
|
+
msgs = @cmdproc.instance_variable_get('@msgs')
|
22
|
+
errmsgs = @cmdproc.instance_variable_get('@errmsgs')
|
23
|
+
assert_equal(should_not_have, msgs.empty?,
|
24
|
+
"Expecting %shelp for %s.\n Got %s" %
|
25
|
+
[shoulda[0], arg_str, msgs])
|
26
|
+
assert_equal(!should_not_have, errmsgs.empty?,
|
27
|
+
"Expecting %serror for %s.\n Got %s" %
|
28
|
+
[shoulda[1], arg_str, msgs])
|
29
|
+
end
|
30
|
+
|
31
|
+
def test_help_command
|
32
|
+
|
33
|
+
# Test we can run 'help *cmd* for each command
|
34
|
+
@cmds.keys.each do |cmd_name|
|
35
|
+
check_help(false, cmd_name)
|
36
|
+
end
|
37
|
+
|
38
|
+
# Test we can run 'help *alias* for each alias
|
39
|
+
@cmdproc.aliases.keys.each do |alias_name|
|
40
|
+
check_help(false, alias_name)
|
41
|
+
end
|
42
|
+
|
43
|
+
# double-check specific commands and aliases
|
44
|
+
%w(kill n help).each do |cmd_pat|
|
45
|
+
check_help(false, cmd_pat)
|
46
|
+
end
|
47
|
+
|
48
|
+
# Test patterns
|
49
|
+
%w(* k.* ki).each do |cmd_pat|
|
50
|
+
check_help(false, cmd_pat)
|
51
|
+
end
|
52
|
+
|
53
|
+
# Test categories
|
54
|
+
%w(running stack).each do |cmd_pat|
|
55
|
+
check_help(false, cmd_pat)
|
56
|
+
end
|
57
|
+
|
58
|
+
# # Test sub help and subhelp patterns
|
59
|
+
# [%w(info file), %w(show *)].each do |args|
|
60
|
+
# check_help(false, args)
|
61
|
+
# end
|
62
|
+
|
63
|
+
# Test invalid commands
|
64
|
+
%w(bogus abcd.*).each do |cmd_pat|
|
65
|
+
check_help(true, cmd_pat)
|
66
|
+
end
|
67
|
+
|
68
|
+
# invalid help subcommands
|
69
|
+
[%w(info fdafds), %w(fedafdsa *)].each do |args|
|
70
|
+
check_help(true, *args)
|
71
|
+
end
|
72
|
+
|
73
|
+
# screwball error
|
74
|
+
check_help(true, '["info",')
|
75
|
+
|
76
|
+
end
|
77
|
+
|
78
|
+
# FIXME: Do better than this.
|
79
|
+
def check_subcmd_help(cmd_name, subcmd, *args)
|
80
|
+
def subcmd.msg(mess)
|
81
|
+
@msgs << mess
|
82
|
+
end
|
83
|
+
subcmd.instance_variable_set('@msgs', [])
|
84
|
+
subcmd.instance_variable_set('@errmsgs', [])
|
85
|
+
subcmd.help(cmd_name)
|
86
|
+
assert subcmd.instance_variable_get('@msgs')
|
87
|
+
# subcmd.help
|
88
|
+
end
|
89
|
+
|
90
|
+
def test_help_subcommand
|
91
|
+
# Get list of commands with subcmds
|
92
|
+
cmd_names = @cmds.values.map do |c|
|
93
|
+
c.instance_variable_defined?(:@subcmds) ? c.name : nil
|
94
|
+
end.compact
|
95
|
+
cmd_names.each do |cmd_name|
|
96
|
+
check_subcmd_help(cmd_name, @cmds[cmd_name].subcmds)
|
97
|
+
end
|
98
|
+
end
|
99
|
+
|
100
|
+
def test_help_complete
|
101
|
+
assert_equal(%w(break breakpoints), @my_cmd.complete('br'))
|
102
|
+
assert_equal(%w(unalias undisplay), @my_cmd.complete('un'))
|
103
|
+
end
|
104
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'rubygems'; require 'require_relative'
|
3
|
+
require_relative './mock-helper'
|
4
|
+
require_relative '../../processor/command/kill'
|
5
|
+
|
6
|
+
class TestCommandKill < Test::Unit::TestCase
|
7
|
+
include MockUnitHelper
|
8
|
+
def setup
|
9
|
+
@name = File.basename(__FILE__, '.rb').split(/-/)[2]
|
10
|
+
common_setup(@name)
|
11
|
+
def @cmd.msg(message)
|
12
|
+
@msgs << message
|
13
|
+
end
|
14
|
+
def @cmd.errmsg(message)
|
15
|
+
@errmsgs << message
|
16
|
+
end
|
17
|
+
reset_cmdproc_vars
|
18
|
+
end
|
19
|
+
|
20
|
+
def reset_cmdproc_vars
|
21
|
+
@cmd.instance_variable_set('@msgs', [])
|
22
|
+
@cmd.instance_variable_set('@errmsgs', [])
|
23
|
+
@cmd.proc.leave_cmd_loop = false
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_kill_command
|
27
|
+
@cmd.run([@name, 'foo'])
|
28
|
+
assert_equal(false, @cmd.proc.leave_cmd_loop)
|
29
|
+
assert_equal(1, @cmd.instance_variable_get('@errmsgs').size)
|
30
|
+
|
31
|
+
if false
|
32
|
+
save_trap = Signal.trap(10) {
|
33
|
+
@success = true
|
34
|
+
}
|
35
|
+
|
36
|
+
@success = false
|
37
|
+
@cmd.run([@name, '10'])
|
38
|
+
# assert_equal(true, @success,
|
39
|
+
# 'Should have run the handler')
|
40
|
+
end
|
41
|
+
|
42
|
+
ensure
|
43
|
+
# restore old trap if any
|
44
|
+
trap(10, save_trap)
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
@@ -0,0 +1,34 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'rubygems'; require 'require_relative'
|
3
|
+
require_relative './mock-helper'
|
4
|
+
require_relative '../../processor/command/source'
|
5
|
+
|
6
|
+
# Test command source
|
7
|
+
class TestCommandSource < Test::Unit::TestCase
|
8
|
+
|
9
|
+
include MockUnitHelper
|
10
|
+
def setup
|
11
|
+
@name = File.basename(__FILE__, '.rb').split(/-/)[2]
|
12
|
+
common_setup(@name)
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_source_opts
|
16
|
+
|
17
|
+
[['--quiet', :verbose, false],
|
18
|
+
['-q', :quiet, true],
|
19
|
+
['--no-quiet', :quiet, false],
|
20
|
+
['--continue', :abort_on_error, false],
|
21
|
+
['--no-continue', :abort_on_error, true],
|
22
|
+
['-c', :abort_on_error, false],
|
23
|
+
['-v', :verbose, true],
|
24
|
+
['--verbose', :verbose, true],
|
25
|
+
['--no-verbose', :verbose, false]
|
26
|
+
].each do |opt, key, expect|
|
27
|
+
options =
|
28
|
+
@cmd.parse_options(Trepan::Command::SourceCommand::DEFAULT_OPTIONS.dup,
|
29
|
+
opt)
|
30
|
+
assert_equal(expect, options[key],
|
31
|
+
"Option #{opt} using key #{key} failure")
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'rubygems'; require 'require_relative'
|
3
|
+
require_relative 'cmd-helper'
|
4
|
+
|
5
|
+
class TestCommandStep < Test::Unit::TestCase
|
6
|
+
|
7
|
+
include UnitHelper
|
8
|
+
def setup
|
9
|
+
common_setup
|
10
|
+
@cmdproc.frame_setup
|
11
|
+
@name = File.basename(__FILE__, '.rb').split(/-/)[2]
|
12
|
+
@my_cmd = @cmds[@name]
|
13
|
+
end
|
14
|
+
|
15
|
+
def test_basic
|
16
|
+
[
|
17
|
+
[%W(#{@name}), 'step', 1],
|
18
|
+
[%W(#{@name} 2), 'step', 2],
|
19
|
+
[%W(#{@name} into 1+2), 'step', 3],
|
20
|
+
[%W(#{@name} over), 'next', 1]
|
21
|
+
].each do |c, rtp, count|
|
22
|
+
@cmdproc.instance_variable_set('@return_to_program', false)
|
23
|
+
@my_cmd.run(c)
|
24
|
+
assert_equal(rtp, @cmdproc.instance_variable_get('@return_to_program'))
|
25
|
+
assert_equal(count, @cmdproc.instance_variable_get('@step_count'))
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
require 'test/unit'
|
3
|
+
require 'rubygems'; require 'require_relative'
|
4
|
+
require_relative '../../lib/trepanning'
|
5
|
+
|
6
|
+
# We don't want to do completion or save history.
|
7
|
+
# This is one hacky way to make sure this doesn't happen
|
8
|
+
def Trepan::GNU_readline?
|
9
|
+
false
|
10
|
+
end
|
11
|
+
|
12
|
+
# Test commands completion
|
13
|
+
class TestCompletion < Test::Unit::TestCase
|
14
|
+
def test_completion
|
15
|
+
dbgr = Trepan.new
|
16
|
+
[
|
17
|
+
['sh', 'sh', ['show']], # Simple single completion
|
18
|
+
['se', 'se', ['server', 'set']], # Simple multiple completion
|
19
|
+
['show', 'show', ['show ']], # Add a space because there is more
|
20
|
+
['irb ', 'irb ', []], # Don't add anything - no more
|
21
|
+
# ['irb ', 'irb', []], # Don't add anything - no more
|
22
|
+
['set au', 'au', ['auto']], # Single completion when there are two words
|
23
|
+
['set auto', 'auto', ['auto ']], # Add a space because there is more
|
24
|
+
['set auto ', '', ['dis', 'eval', 'irb', 'list']], # Many two-word completions
|
25
|
+
['set auto e', 'e', ['eval']],
|
26
|
+
['disas', 'disas ', ['disassemble']], # Another single completion
|
27
|
+
['help syn', 'syn', ['syntax']],
|
28
|
+
['help br', 'br', ['break', 'breakpoints']],
|
29
|
+
['set basename o', 'o', ['off', 'on']],
|
30
|
+
].each do |line, token, expect_completion|
|
31
|
+
assert_equal(expect_completion,
|
32
|
+
dbgr.completion_method(token, line),
|
33
|
+
"Bad completion of #{token.inspect} with #{line.inspect}")
|
34
|
+
end
|
35
|
+
assert(dbgr.completion_method('', '').size > 30,
|
36
|
+
'Initial completion should return more than 30 commands')
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,46 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
# Unit test for interface.user
|
3
|
+
|
4
|
+
require 'test/unit'
|
5
|
+
require 'rubygems'; require 'require_relative'
|
6
|
+
require_relative '../../interface/user'
|
7
|
+
|
8
|
+
# Tests Trepan::UserInterface
|
9
|
+
class TestInterfaceUser < Test::Unit::TestCase
|
10
|
+
|
11
|
+
# Test UserInterface.confirm()
|
12
|
+
def test_confirm
|
13
|
+
|
14
|
+
user_intf = Trepan::UserInterface.new(nil, nil, {:history_save => false})
|
15
|
+
def user_intf.readline(prompt)
|
16
|
+
$response_answer
|
17
|
+
end
|
18
|
+
|
19
|
+
['y', 'Y', 'Yes', ' YES '].each do |s|
|
20
|
+
$response_answer = s
|
21
|
+
ans = user_intf.confirm('Testing', true)
|
22
|
+
assert_equal(true, ans)
|
23
|
+
end
|
24
|
+
|
25
|
+
['n', 'N', 'No', ' NO '].each do |s|
|
26
|
+
$response_answer = s
|
27
|
+
ans = user_intf.confirm('Testing', true)
|
28
|
+
assert_equal(false, ans)
|
29
|
+
end
|
30
|
+
|
31
|
+
def user_intf.readline(prompt)
|
32
|
+
raise EOFError
|
33
|
+
end
|
34
|
+
|
35
|
+
[true, false].each do |tf|
|
36
|
+
assert_equal(tf, user_intf.confirm('default testing', tf))
|
37
|
+
end
|
38
|
+
|
39
|
+
# Ok, we'll throw in one test of EOFError
|
40
|
+
assert_raises EOFError do
|
41
|
+
user_intf.readline('')
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
# FIXME: more thorough testing of other routines in user.
|
46
|
+
end
|