1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 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
|
#!@SH_PROG@
# -*- shell-script -*-
PS4='-(${BASH_SOURCE}:${LINENO}): ${FUNCNAME[0]} - [${SHLVL},${BASH_SUBSHELL}, $?]
'
# Test breakpoint set, unset, enable, disable, clear
test_breakpoint() {
# Some mock functions
_Dbg_errmsg() {
errmsgs+=("$@")
}
_Dbg_msg() {
msgs+=("$@")
}
_Dbg_adjust_filename() {
echo $*
}
_Dbg_expand_filename() {
echo $*
}
typeset -a msgs
msgs=()
# Test parameter count checking for _Dbg_set_brkpt
_Dbg_set_brkpt
assertNotEquals '0' "$?"
_Dbg_set_brkpt 1 2 3 4 5
assertNotEquals '0' "$?"
# This should work
_curline=5
_Dbg_set_brkpt test.sh 5 0
assertEquals 'Breakpoint 1 set in file test.sh, line 5.' "${msgs[0]}"
msgs=()
# Test parameter count checking for _Dbg_unset_brkpt
_Dbg_unset_brkpt
assertEquals '0' "$?"
_Dbg_unset_brkpt 1 2 3
assertEquals '0' "$?"
# FIXME
# # Shouldn't find this breakpoint
# _Dbg_unset_brkpt test.sh 6
# assertEquals '0' "$?"
# assertEquals 'No breakpoint found at test.sh:6' "${msgs[0]}"
msgs=()
# This should work and remove a breakpoint
_Dbg_unset_brkpt test.sh 5
assertEquals '1' "$?"
assertEquals '0' "${#msgs[@]}"
# FIXME
# # This should not work since breakpoint has already been removed.
# _Dbg_unset_brkpt test.sh 5
# assertEquals '0' "$?"
# assertEquals 'No breakpoint found at test.sh:5' "${msgs[0]}"
msgs=(); errmsgs=()
# Enable/disable parameter checking
_Dbg_enable_disable_brkpt
assertEquals '1' "$?"
# Enable a non-existent breakpoint
msgs=()
_Dbg_enable_disable_brkpt 1 'enabled' 1
assertEquals "Breakpoint entry 1 doesn't exist, so nothing done." "${errmsgs[0]}"
msgs=(); errmsgs=()
# Add another breakpoint for testing
_Dbg_set_brkpt test.sh 6 1
assertEquals 'One-time breakpoint 2 set in file test.sh, line 6.' "${msgs[0]}"
msgs=(); errmsgs=()
_Dbg_enable_disable_brkpt 1 'enabled' 2
assertEquals 'Breakpoint entry 2 already enabled, so nothing done.' "${errmsgs[0]}"
msgs=(); errmsgs=()
_Dbg_enable_disable_brkpt 0 'enabled' 2
assertEquals 'Breakpoint entry 2 enabled.' "${msgs[0]}"
msgs=(); errmsgs=()
_Dbg_enable_disable_brkpt 1 'disabled' 2
assertEquals '0' "$?"
assertEquals 'Breakpoint entry 2 disabled.' "${msgs[0]}"
_Dbg_clear_all_brkpt
}
abs_top_srcdir=@abs_top_srcdir@
abs_top_srcdir=${abs_top_srcdir%%/}/
srcdir=@srcdir@
srcdir=${srcdir%%/}/
_Dbg_libdir=$abs_top_srcdir
set -- -q # Don't need to show banner
. $abs_top_srcdir/dbg-pre.sh
. $abs_top_srcdir/lib/file.sh
. $abs_top_srcdir/lib/fns.sh
. $abs_top_srcdir/lib/journal.sh
. $abs_top_srcdir/lib/break.sh
# load shunit2
. ${abs_top_srcdir}/test/unit/shunit2
|