Menu

Tree [0c50c7] bash-5.0 / test / integration /
 History

HTTPS access


File Date Author Commit
 .cvsignore 2008-08-24 rockyb rockyb [140de9] Break off hook routine from sig.sh. More kshdb,...
 .gitignore 2019-10-10 rocky rocky [48fbf3] Add BASH_REMATCH integration test
 Makefile.am 2019-10-10 rocky rocky [48fbf3] Add BASH_REMATCH integration test
 README.md 2019-10-08 rocky rocky [ff1068] Spelling mistakes
 check-common.sh.in 2015-10-26 rocky rocky [2a66b6] work aroud bash 4.3 signal handling
 interrupt-3.tests 2008-10-03 rockyb rockyb [ac23d5] Bash version 3 interrupt test
 interrupt.tests 2010-11-26 rocky rocky [548542] Clean up crud from bashdb.in and some from inte...
 lopts.tests 2017-06-04 rocky rocky [4e1479] Auto set highlight background
 settrace.tests 2010-12-02 rocky rocky [e80765] "make distcheck" works again!
 sopts.tests 2017-06-04 rocky rocky [4e1479] Auto set highlight background
 test-action 2013-01-29 rocky rocky [1ffbd0] /bin/bash -> /usr/bin/env bash for OS's like Fr...
 test-bash-rematch.in 2019-10-10 rocky rocky [48fbf3] Add BASH_REMATCH integration test
 test-brkpt 2013-01-29 rocky rocky [1ffbd0] /bin/bash -> /usr/bin/env bash for OS's like Fr...
 test-bug-args 2013-01-29 rocky rocky [1ffbd0] /bin/bash -> /usr/bin/env bash for OS's like Fr...
 test-bug-break.in 2017-08-02 rocky rocky [6792f1] Fix up bug-break integration test
 test-bug-clear 2014-12-14 rocky rocky [5d96ba] Make "make distcheck" work
 test-bug-loc 2015-01-23 rocky rocky [8baf47] --highlight changed from taking no parameters t...
 test-bug-set-e 2017-08-01 rocky rocky [384dae] Fix debugging in the presense of "set -e"
 test-bug-source 2013-01-29 rocky rocky [1ffbd0] /bin/bash -> /usr/bin/env bash for OS's like Fr...
 test-bug-step 2013-01-29 rocky rocky [1ffbd0] /bin/bash -> /usr/bin/env bash for OS's like Fr...
 test-bug-step-subshell.in 2011-05-01 rocky rocky [8ffdad] Improve require. Reorganize code so that initia...
 test-bugI 2013-01-29 rocky rocky [1ffbd0] /bin/bash -> /usr/bin/env bash for OS's like Fr...
 test-bugIFS 2013-01-29 rocky rocky [1ffbd0] /bin/bash -> /usr/bin/env bash for OS's like Fr...
 test-command 2013-01-29 rocky rocky [1ffbd0] /bin/bash -> /usr/bin/env bash for OS's like Fr...
 test-complete.in 2016-03-14 rocky rocky [3c3c93] Sort subcommand completions. Align test-complete
 test-debug.in 2011-04-30 rocky rocky [9c499b] Remove tabs and some git merge differences.
 test-delete.in 2010-10-25 rocky rocky [bb6991] Add test-delete integration test from zshdb.
 test-display 2013-01-29 rocky rocky [1ffbd0] /bin/bash -> /usr/bin/env bash for OS's like Fr...
 test-enable 2013-01-29 rocky rocky [1ffbd0] /bin/bash -> /usr/bin/env bash for OS's like Fr...
 test-export.in 2011-03-04 rocky rocky [029387] Forgot to add new files
 test-file-with-spaces.in 2014-09-13 rocky rocky [b533ef] tilde expansion reinstated, some embedded blank...
 test-finish 2013-01-29 rocky rocky [1ffbd0] /bin/bash -> /usr/bin/env bash for OS's like Fr...
 test-frame 2013-01-29 rocky rocky [1ffbd0] /bin/bash -> /usr/bin/env bash for OS's like Fr...
 test-info-args.in 2011-05-12 rocky rocky [f9c5bc] Correct "info args".
 test-interrupt.in 2014-09-13 rocky rocky [4be32d] More OS's where we skip tests.
 test-list 2013-01-29 rocky rocky [1ffbd0] /bin/bash -> /usr/bin/env bash for OS's like Fr...
 test-lopts 2013-01-29 rocky rocky [1ffbd0] /bin/bash -> /usr/bin/env bash for OS's like Fr...
 test-misc.in 2019-09-11 rocky rocky [0f14ae] Update integration test
 test-multi 2013-01-29 rocky rocky [1ffbd0] /bin/bash -> /usr/bin/env bash for OS's like Fr...
 test-parm 2010-11-25 rocky rocky [e144e7] Integration tests are less convoluted in logic.
 test-restart 2017-06-04 rocky rocky [4e1479] Auto set highlight background
 test-search 2013-01-29 rocky rocky [1ffbd0] /bin/bash -> /usr/bin/env bash for OS's like Fr...
 test-setshow.in 2011-05-11 rocky rocky [83e048] Small bug in show onoff
 test-settrace.in 2017-08-24 rocky rocky [5695de] Get ready for release 4.4-0.94
 test-sig.in 2019-09-02 rocky rocky [f2f889] Update for bash 5.0
 test-skip 2013-01-29 rocky rocky [1ffbd0] /bin/bash -> /usr/bin/env bash for OS's like Fr...
 test-sopts 2013-01-29 rocky rocky [1ffbd0] /bin/bash -> /usr/bin/env bash for OS's like Fr...
 test-subshell 2010-12-01 rocky rocky [4e46bd] A couple more tests work when building outside ...
 test-tbreak 2013-01-29 rocky rocky [1ffbd0] /bin/bash -> /usr/bin/env bash for OS's like Fr...
 test-trace 2011-03-15 rocky rocky [b9a9f3] Reinstate linetrace test. Remove "set linetrace...
 test-watch1 2013-01-29 rocky rocky [1ffbd0] /bin/bash -> /usr/bin/env bash for OS's like Fr...
 test-watch2 2013-01-29 rocky rocky [1ffbd0] /bin/bash -> /usr/bin/env bash for OS's like Fr...
 trace.tests 2017-06-04 rocky rocky [4e1479] Auto set highlight background
 trace2.tests 2010-12-02 rocky rocky [e80765] "make distcheck" works again!

Read Me

A Guide to writing test cases

This directory has the more coarse-grain integration tests which work
by running the full debugger. You might also want to check out the
unit tests which handle smaller components of the debugger.

Here is a guide for writing a new test case.

How integration tests are set up to get run

In general, each integration test case in this directory starts with a file that ends in .in like test-delete.in.

This is a bash program however with some text to be substituted based on information in configuration. The text to be substituted is delimited with @.

For example, the first shbang or #! line looks like this:

    #!@SH_PROG@ -f

You will see this file listed in configure.ac, as a file that is to be used as a template to create the actual shell program that gets run in integration testing.

In configure (produced via configure.ac) @SH_PROG@ is substituted with the full path of bash that is to be run. For example @SH_PROG@ could be /bin/bash or /usr/local/bin/bash.

The line in configure.ac that cause this to happen when configure is run looks like this:

AC_CONFIG_FILES([test/integration/test-delete],
                [chmod +x test/integration/test-delete])

Anatomy of integration tests.

At a high level, an integration test does these things:

  • Unless the test is to be skipped, the test is run under bashdb with some bashdb flags
  • the output, possibly filtered, is compared with expected results
  • the scripts exits with an exit code based on the results from above:
  • 0 means the test passed
  • 77 indicates a test was skipped
  • anything else is a failure

Let's describe this in more detail. Here is test-delete.in:

1: #!@SH_PROG@ -f
2: # -*- shell-script -*-
3: t=${0##*/}; TEST_NAME=${t:5}   # basename $0 with 'test-' stripped off
4:
5: [ -z "$builddir" ] && builddir=$PWD
6: . ${builddir}/check-common.sh
7:. run_test_check stepping

Line 1: this gets changed into a valid shbang line, like #!/bin/bash -f

Line 2: this is for GNU Emacs to indicate the program is a shell script.

Line 3: pulls out the name of the test so that this can be used to figure out (by default) what bash script to run a debugger under and what output to compare results with. Here the extracted value is delete.

Line 5: get where we are so that we can reference the script to run and the expected results files

Line 6: source in library routines based on the directory set in line 5.

Line 7: runs bashdb. The parameter stepping the variable portion is the name of the bash script in test/example to run. Here it is test/example/stepping.sh. If this parameter were not given we would have used test/example/delete.sh because this is was the extracted value in line 3.

Lets look at an example that is slightly (but only slightly) more complicated,
test-file-with-spaces.in:

 1: #!@SH_PROG@
 2: # -*- shell-script -*-
 3: TEST_NAME='file with spaces'
 4:
 5: [ -z "$builddir" ] && builddir=$PWD
 6: . ${builddir}/check-common.sh
 7:
 8: if [[ -f "$top_srcdir/test/example/file with spaces.sh" ]] ; then
 9:    run_test_check
10: else
11:    echo "Skipping test due to autoconf problems"
12:    exit 77
13: fi

Notice that in line 9 here we do not pass the name of an script to be debugged so the script to be debugged is test/example/test-file-with-spaces. In this respect this is simpler than the first test case.

Line 8 has an if statement that is testing whether we should run this script on not. The way we indicate the test was skipped is line 12.

Finally, let's look at part of a more complicated test case that involves filtering output. This is from test-misc.in:

. ${builddir}/check-common.sh
...
# Different OS's handle ARGV differently, and "info args" may come out
# differently depending on that.
cat ${TEST_FILE} | @SED@ -e "s:1 = .*/dbg-test2.sh:1 = ./example/dbg-test2.sh:" \
| @SED@ -e 's:record the command history is .*:record the command history is: ' \
| @SED@ -e 's:step-:step+:' \
| @GREP@ -v '^set dollar0' > ${TEST_FILTERED_FILE}

if (( BASH_VERSINFO[0] == 5 )) ; then
    RIGHT_FILE="${top_srcdir}/test/data/${TEST_NAME}-output-50.right"
elif (( (BASH_VERSINFO[0] == 4 && BASH_VERSINFO[1] >= 1) )) ; then
    RIGHT_FILE="${top_srcdir}/test/data/${TEST_NAME}-output-41.right"
fi

check_output $TEST_FILTERED_FILE $RIGHT_FILE

Notice we use @SED@ and @GREP@ which are replaced the specific sed and grep path that the configure finds.

The expected output changes from bash 4.x to bash 5.x and that is set using the if statement. Finally the check_output call then gives the name of a filtered file to compare from rather that . The variable TEST_FILTERED_FILE is automatically generated when we source check_common.sh.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.