xref: /petsc/doc/developers/testing.md (revision 4c2e35b6396e22c1c2cca8135aae69ecaa138bb7)
14bcd95a3SBarry Smith(test_harness)=
24bcd95a3SBarry Smith
34bcd95a3SBarry Smith# PETSc Testing System
44bcd95a3SBarry Smith
54bcd95a3SBarry SmithThe PETSc test system consists of
64bcd95a3SBarry Smith
74bcd95a3SBarry Smith- Formatted comments at the bottom of the tutorials and test source files that describes the tests to be run.
84bcd95a3SBarry Smith- The *test generator* (`config/gmakegentest.py`) that parses the tutorial and test source files and generates the makefiles and shell scripts. This is run
94bcd95a3SBarry Smith  automatically by the make system and rarely is run directly.
104bcd95a3SBarry Smith- The *PETSc test harness* that consists of makefile and shell scripts that runs the executables with several logging and reporting features.
114bcd95a3SBarry Smith
124bcd95a3SBarry SmithDetails on using the harness may be found in the {ref}`user's manual <sec_runningtests>`. The testing system is used by {any}`pipelines`.
134bcd95a3SBarry Smith
144bcd95a3SBarry Smith## PETSc Test Description Language
154bcd95a3SBarry Smith
164bcd95a3SBarry SmithPETSc tests and tutorials contain at the bottom of the their source files a simple language to
174bcd95a3SBarry Smithdescribe tests and subtests required to run executables associated with
184bcd95a3SBarry Smithcompilation of that file. The general skeleton of the file is
194bcd95a3SBarry Smith
204bcd95a3SBarry Smith```
214bcd95a3SBarry Smithstatic const char help[] = "A simple MOAB example\n";
224bcd95a3SBarry Smith
234bcd95a3SBarry Smith...
244bcd95a3SBarry Smith<source code>
254bcd95a3SBarry Smith...
264bcd95a3SBarry Smith
274bcd95a3SBarry Smith/*TEST
284bcd95a3SBarry Smith   build:
294bcd95a3SBarry Smith     requires: moab
304bcd95a3SBarry Smith   testset:
314bcd95a3SBarry Smith     suffix: 1
324bcd95a3SBarry Smith     requires: !complex
334bcd95a3SBarry Smith   testset:
344bcd95a3SBarry Smith     suffix: 2
354bcd95a3SBarry Smith     args: -debug -fields v1,v2,v3
364bcd95a3SBarry Smith     test:
374bcd95a3SBarry Smith     test:
384bcd95a3SBarry Smith       args: -foo bar
394bcd95a3SBarry SmithTEST*/
404bcd95a3SBarry Smith```
414bcd95a3SBarry Smith
424bcd95a3SBarry SmithFor our language, a *test* is associated with the following
434bcd95a3SBarry Smith
444bcd95a3SBarry Smith- A single shell script
454bcd95a3SBarry Smith
464bcd95a3SBarry Smith- A single makefile
474bcd95a3SBarry Smith
484bcd95a3SBarry Smith- An output file that represents the *expected results*. It is also possible -- though unusual -- to have multiple output files for a single test
494bcd95a3SBarry Smith
504bcd95a3SBarry Smith- Two or more command tests, usually:
514bcd95a3SBarry Smith
524bcd95a3SBarry Smith  - one or more `mpiexec` tests that run the executable
534bcd95a3SBarry Smith  - one or more `diff` tests to compare output with the expected result
544bcd95a3SBarry Smith
554bcd95a3SBarry SmithOur language also supports a *testset* that specifies either a new test
564bcd95a3SBarry Smithentirely or multiple executable/diff tests within a single test. At the
574bcd95a3SBarry Smithcore, the executable/diff test combination will look something like
584bcd95a3SBarry Smiththis:
594bcd95a3SBarry Smith
604bcd95a3SBarry Smith```sh
614bcd95a3SBarry Smithmpiexec -n 1 ../ex1 1> ex1.tmp 2> ex1.err
624bcd95a3SBarry Smithdiff ex1.tmp output/ex1.out 1> diff-ex1.tmp 2> diff-ex1.err
634bcd95a3SBarry Smith```
644bcd95a3SBarry Smith
654bcd95a3SBarry SmithIn practice, we want to do various logging and counting by the test
664bcd95a3SBarry Smithharness; as are explained further below. The input language supports
674bcd95a3SBarry Smithsimple yet flexible test control.
684bcd95a3SBarry Smith
694bcd95a3SBarry Smith### Runtime Language Options
704bcd95a3SBarry Smith
714bcd95a3SBarry SmithAt the end of each test file, a marked comment block is
724bcd95a3SBarry Smithinserted to describe the test(s) to be run. The elements of the test are
734bcd95a3SBarry Smithdone with a set of supported key words that sets up the test.
744bcd95a3SBarry Smith
754bcd95a3SBarry SmithThe goals of the language are to be
764bcd95a3SBarry Smith
774bcd95a3SBarry Smith- as minimal as possible with the simplest test requiring only one keyword,
784bcd95a3SBarry Smith- independent of the filename such that a file can be renamed without rewriting the tests, and
794bcd95a3SBarry Smith- intuitive.
804bcd95a3SBarry Smith
814bcd95a3SBarry SmithIn order to enable the second goal, the *basestring* of the filename is
824bcd95a3SBarry Smithdefined as the filename without the extension; for example, if the
834bcd95a3SBarry Smithfilename is `ex1.c`, then `basestring=ex1`.
844bcd95a3SBarry Smith
854bcd95a3SBarry SmithWith this background, these keywords are as follows.
864bcd95a3SBarry Smith
874bcd95a3SBarry Smith- **testset** or **test**: (*Required*)
884bcd95a3SBarry Smith
894bcd95a3SBarry Smith  - At the top level either a single test or a test set must be
904bcd95a3SBarry Smith    specified. All other keywords are sub-entries of this keyword.
914bcd95a3SBarry Smith
924bcd95a3SBarry Smith- **suffix**: (*Optional*; *Default:* `suffix=""`)
934bcd95a3SBarry Smith
944bcd95a3SBarry Smith  - The test name is given by `testname = basestring` if the suffix
954bcd95a3SBarry Smith    is set to an empty string, and by
964bcd95a3SBarry Smith    `testname = basestring + "_" + suffix` otherwise.
974bcd95a3SBarry Smith  - This can be specified only for top level test nodes.
984bcd95a3SBarry Smith
994bcd95a3SBarry Smith- **output_file**: (*Optional*; *Default:*
1004bcd95a3SBarry Smith  `output_file = "output/" + testname + ".out"`)
1014bcd95a3SBarry Smith
1024bcd95a3SBarry Smith  - The output of the test is to be compared with an *expected result*
1034bcd95a3SBarry Smith    whose name is given by `output_file`.
1044bcd95a3SBarry Smith  - This file is described relative to the source directory of the
1054bcd95a3SBarry Smith    source file and should be in the output subdirectory (for example,
1064bcd95a3SBarry Smith    `output/ex1.out`)
1074bcd95a3SBarry Smith
1084bcd95a3SBarry Smith- **nsize**: (*Optional*; *Default:* `nsize=1`)
1094bcd95a3SBarry Smith
1104bcd95a3SBarry Smith  - This integer is passed to mpiexec; i.e., `mpiexec -n nsize`
1114bcd95a3SBarry Smith
1124bcd95a3SBarry Smith- **args**: (*Optional*; *Default:* `""`)
1134bcd95a3SBarry Smith
1144bcd95a3SBarry Smith  - These arguments are passed to the executable.
1154bcd95a3SBarry Smith
1164bcd95a3SBarry Smith- **diff_args**: (*Optional*; *Default:* `""`)
1174bcd95a3SBarry Smith
1184bcd95a3SBarry Smith  - These arguments are passed to the `lib/petsc/bin/petscdiff` script that
1194bcd95a3SBarry Smith    is used in the diff part of the test. For example, `-j` enables testing
1204bcd95a3SBarry Smith    the floating point numbers.
1214bcd95a3SBarry Smith
1224bcd95a3SBarry Smith- **TODO**: (*Optional*; *Default:* `False`)
1234bcd95a3SBarry Smith
1244bcd95a3SBarry Smith  - Setting this Boolean to True will tell the test to appear in the
1254bcd95a3SBarry Smith    test harness but report only TODO per the TAP standard. Optionally
1264bcd95a3SBarry Smith    provide a string indicating why it is todo.
1274bcd95a3SBarry Smith  - A runscript will be generated and can easily be modified by hand
1284bcd95a3SBarry Smith    to run.
1294bcd95a3SBarry Smith
1304bcd95a3SBarry Smith- **filter**: (*Optional*; *Default:* `""`)
1314bcd95a3SBarry Smith
1324bcd95a3SBarry Smith  - Sometimes only a subset of the output is meant to be tested
1334bcd95a3SBarry Smith    against the expected result. If this keyword is used, it filters
1344bcd95a3SBarry Smith    the executable output to
1354bcd95a3SBarry Smith    compare with `output_file`.
1364bcd95a3SBarry Smith  - The value of this is the command to be run, for example,
1374bcd95a3SBarry Smith    `grep foo` or `sort -nr`.
1384bcd95a3SBarry Smith  - **NOTE: this method of testing error output is NOT recommended. See section on**
1394bcd95a3SBarry Smith    {ref}`testing errors <sec_testing_error_testing>` **instead.** If the filter begins
1404bcd95a3SBarry Smith    with `Error:`, then the test is assumed to be testing the `stderr` output, and the
1414bcd95a3SBarry Smith    error code and output are set up to be tested.
1424bcd95a3SBarry Smith
1434bcd95a3SBarry Smith- **filter_output**: (*Optional*; *Default:* `""`)
1444bcd95a3SBarry Smith
1454bcd95a3SBarry Smith  - Sometimes filtering the output file is useful for standardizing
1464bcd95a3SBarry Smith    tests. For example, in order to handle the issues related to
1474bcd95a3SBarry Smith    parallel output, both the output from the test example and the
1484bcd95a3SBarry Smith    output file need to be sorted (since sort does not produce the
1494bcd95a3SBarry Smith    same output on all machines). This works the same as filter to
1504bcd95a3SBarry Smith    implement this feature
1514bcd95a3SBarry Smith
1524bcd95a3SBarry Smith- **localrunfiles**: (*Optional*; *Default:* `""`)
1534bcd95a3SBarry Smith
1544bcd95a3SBarry Smith  - Some tests
1554bcd95a3SBarry Smith    require runtime files that are maintained in the source tree.
1564bcd95a3SBarry Smith    Files in this (space-delimited) list will be copied over to the
1574bcd95a3SBarry Smith    testing directory so they will be found by the executable. If you
1584bcd95a3SBarry Smith    list a directory instead of files, it will copy the entire
1594bcd95a3SBarry Smith    directory (this is limited currently to a single directory)
1604bcd95a3SBarry Smith  - The copying is done by the test generator and not by creating
1614bcd95a3SBarry Smith    makefile dependencies.
1624bcd95a3SBarry Smith
1634bcd95a3SBarry Smith- **temporaries**: (*Optional*; *Default:* `""`)
1644bcd95a3SBarry Smith
1654bcd95a3SBarry Smith  - Some tests produce temporary files that are read by the filter
1664bcd95a3SBarry Smith    to compare to expected results.
1674bcd95a3SBarry Smith    Files in this (space-delimited) list will cleared before
1684bcd95a3SBarry Smith    the test is run to ensure that stale temporary files are not read.
1694bcd95a3SBarry Smith
1704bcd95a3SBarry Smith- **requires**: (*Optional*; *Default:* `""`)
1714bcd95a3SBarry Smith
1724bcd95a3SBarry Smith  - This is a space-delimited list of run requirements (not build
1734bcd95a3SBarry Smith    requirements; see Build requirements below).
1744bcd95a3SBarry Smith  - In general, the language supports `and` and `not` constructs
1754bcd95a3SBarry Smith    using `! => not` and `, => and`.
1764bcd95a3SBarry Smith  - MPIUNI should work for all -n 1 examples so this need not be in
1774bcd95a3SBarry Smith    the requirements list.
1784bcd95a3SBarry Smith  - Inputs sometimes require external matrices that are found in the
1794bcd95a3SBarry Smith    directory given by the environmental variable `DATAFILESPATH`.
1804bcd95a3SBarry Smith    The repository [datafiles](https://gitlab.com/petsc/datafiles)
1814bcd95a3SBarry Smith    contains all the test files needed for the test suite.
1824bcd95a3SBarry Smith    For these tests `requires: datafilespath` can be
1834bcd95a3SBarry Smith    specified.
1844bcd95a3SBarry Smith  - Packages are indicated with lower-case specification, for example,
1854bcd95a3SBarry Smith    `requires: superlu_dist`.
1864bcd95a3SBarry Smith  - Any defined variable in petscconf.h can be specified with the
1874bcd95a3SBarry Smith    `defined(...)` syntax, for example, `defined(PETSC_USE_INFO)`.
1884bcd95a3SBarry Smith  - Any definition of the form `PETSC_HAVE_FOO` can just use
1894bcd95a3SBarry Smith    `requires: foo` similar to how third-party packages are handled.
1904bcd95a3SBarry Smith
1914bcd95a3SBarry Smith- **timeoutfactor**: (*Optional*; *Default:* `"1"`)
1924bcd95a3SBarry Smith
1934bcd95a3SBarry Smith  - This parameter allows you to extend the default timeout for an
1944bcd95a3SBarry Smith    individual test such that the new timeout time is
1954bcd95a3SBarry Smith    `timeout=(default timeout) x (timeoutfactor)`.
1964bcd95a3SBarry Smith  - Tests are limited to a set time that is found at the top of
1974bcd95a3SBarry Smith    `"config/petsc_harness.sh"` and can be overwritten by passing in
1984bcd95a3SBarry Smith    the `TIMEOUT` argument to `gmakefile`
1994bcd95a3SBarry Smith
2004bcd95a3SBarry Smith- **env**: (*Optional*; *Default:* `env=""`)
2014bcd95a3SBarry Smith
2024bcd95a3SBarry Smith  - Allows you to set environment variables for the test. Values are copied verbatim to
2034bcd95a3SBarry Smith    the runscript and defined and exported prior to all other variables.
2044bcd95a3SBarry Smith
2054bcd95a3SBarry Smith  - Variables defined within `env:` blocks are expanded and processed by the shell that
2064bcd95a3SBarry Smith    runs the runscript. No prior preprocessing (other than splitting the lines into
2074bcd95a3SBarry Smith    separate declarations) is done. This means that any escaping of special characters
2084bcd95a3SBarry Smith    must be done in the text of the `TEST` block.
2094bcd95a3SBarry Smith
2104bcd95a3SBarry Smith  - Defining the `env:` keyword more than once is allowed. Subsequent declarations are
2114bcd95a3SBarry Smith    then appended to prior list of declarations . Multiple environment variables may also
2124bcd95a3SBarry Smith    be defined in the same `env:` block, i.e. given a test `ex1.c` with the following
2134bcd95a3SBarry Smith    spec:
2144bcd95a3SBarry Smith
2154bcd95a3SBarry Smith    ```yaml
2164bcd95a3SBarry Smith    test:
2174bcd95a3SBarry Smith      env: FOO=1 BAR=1
2184bcd95a3SBarry Smith
2194bcd95a3SBarry Smith    # equivalently
2204bcd95a3SBarry Smith    test:
2214bcd95a3SBarry Smith      env: FOO=1
2224bcd95a3SBarry Smith      env: BAR=1
2234bcd95a3SBarry Smith    ```
2244bcd95a3SBarry Smith
2254bcd95a3SBarry Smith    results in
2264bcd95a3SBarry Smith
2274bcd95a3SBarry Smith    ```console
2284bcd95a3SBarry Smith    $ export FOO=1; export BAR=1; ./ex1
2294bcd95a3SBarry Smith    ```
2304bcd95a3SBarry Smith
2314bcd95a3SBarry Smith  - Variables defined in an `env:` block are evaluated by the runscript in the order in
2324bcd95a3SBarry Smith    which they are defined in the `TEST` block. Thus it is possible for later variables
2334bcd95a3SBarry Smith    to refer to previously defined ones:
2344bcd95a3SBarry Smith
2354bcd95a3SBarry Smith    ```yaml
2364bcd95a3SBarry Smith    test:
2374bcd95a3SBarry Smith      env: FOO='hello' BAR=${FOO}
2384bcd95a3SBarry Smith    ```
2394bcd95a3SBarry Smith
2404bcd95a3SBarry Smith    results in
2414bcd95a3SBarry Smith
2424bcd95a3SBarry Smith    ```console
2434bcd95a3SBarry Smith    $ export FOO='hello'; export BAR=${FOO}; ./ex1
2444bcd95a3SBarry Smith    # expanded by shell to
2454bcd95a3SBarry Smith    $ export FOO='hello'; export BAR='hello'; ./ex1
2464bcd95a3SBarry Smith    ```
2474bcd95a3SBarry Smith
2484bcd95a3SBarry Smith    Note this also implies that
2494bcd95a3SBarry Smith
2504bcd95a3SBarry Smith    ```yaml
2514bcd95a3SBarry Smith    test:
2524bcd95a3SBarry Smith      env: FOO=1 FOO=0
2534bcd95a3SBarry Smith    ```
2544bcd95a3SBarry Smith
2554bcd95a3SBarry Smith    results in
2564bcd95a3SBarry Smith
2574bcd95a3SBarry Smith    ```console
2584bcd95a3SBarry Smith    $ export FOO=1; export FOO=0; ./ex1
2594bcd95a3SBarry Smith    ```
2604bcd95a3SBarry Smith
2614bcd95a3SBarry Smith### Additional Specifications
2624bcd95a3SBarry Smith
2634bcd95a3SBarry SmithIn addition to the above keywords, other language features are
2644bcd95a3SBarry Smithsupported.
2654bcd95a3SBarry Smith
2664bcd95a3SBarry Smith- **for loops**: Specifying `{{list of values}}` will generate a loop over
2674bcd95a3SBarry Smith  an enclosed space-delimited list of values.
2684bcd95a3SBarry Smith  It is supported within `nsize` and `args`. For example,
2694bcd95a3SBarry Smith
2704bcd95a3SBarry Smith  ```
2714bcd95a3SBarry Smith  nsize: {{1 2 4}}
2724bcd95a3SBarry Smith  args: -matload_block_size {{2 3}shared output}
2734bcd95a3SBarry Smith  ```
2744bcd95a3SBarry Smith
2754bcd95a3SBarry Smith  Here the output for each `-matload_block_size` value is assumed to be
2764bcd95a3SBarry Smith  the same so that only one output file is needed.
2774bcd95a3SBarry Smith
2784bcd95a3SBarry Smith  If the loop causes different output for each loop iteration, then `separate output` needs to be used:
2794bcd95a3SBarry Smith
2804bcd95a3SBarry Smith  ```
2814bcd95a3SBarry Smith  args: -matload_block_size {{2 3}separate output}
2824bcd95a3SBarry Smith  ```
2834bcd95a3SBarry Smith
2844bcd95a3SBarry Smith  In this case, each loop value generates a separate script,
2854bcd95a3SBarry Smith  and uses a separate output file for comparison.
2864bcd95a3SBarry Smith
2874bcd95a3SBarry Smith  Note that `{{...}}` is equivalent to `{{...}shared output}`.
2884bcd95a3SBarry Smith
2894bcd95a3SBarry Smith(sec_testing_error_testing)=
2904bcd95a3SBarry Smith
2914bcd95a3SBarry Smith### Testing Errors And Exceptional Code
2924bcd95a3SBarry Smith
2934bcd95a3SBarry SmithIt is possible (and encouraged!) to test error conditions within the test harness. Since
2944bcd95a3SBarry Smitherror messages produced by `SETERRQ()` and friends are not portable between systems,
2954bcd95a3SBarry Smithadditional arguments must be passed to tests to modify error handling, specifically:
2964bcd95a3SBarry Smith
2974bcd95a3SBarry Smith```yaml
2984bcd95a3SBarry Smithargs: -petsc_ci_portable_error_output -error_output_stdout
2994bcd95a3SBarry Smith```
3004bcd95a3SBarry Smith
3014bcd95a3SBarry SmithThese arguments have the following effect:
3024bcd95a3SBarry Smith
3034bcd95a3SBarry Smith- `-petsc_ci_portable_error_output`: Strips system or configuration-specific information
3044bcd95a3SBarry Smith  from error messages. Specifically this:
3054bcd95a3SBarry Smith
3064bcd95a3SBarry Smith  - Removes all path components except the file name from the traceback
3074bcd95a3SBarry Smith  - Removes line and column numbers from the traceback
3084bcd95a3SBarry Smith  - Removes PETSc version information
3094bcd95a3SBarry Smith  - Removes `configure` options used
3104bcd95a3SBarry Smith  - Removes system name
3114bcd95a3SBarry Smith  - Removes hostname
3124bcd95a3SBarry Smith  - Removes date
3134bcd95a3SBarry Smith
3144bcd95a3SBarry Smith  With this option error messages will be identical across systems, runs, and PETSc
3154bcd95a3SBarry Smith  configurations (barring of course configurations in which the error is not raised).
3164bcd95a3SBarry Smith
3174bcd95a3SBarry Smith  Furthermore, this option also changes the default behavior of the error handler to
3184bcd95a3SBarry Smith  **gracefully** exit where possible. For single-ranked runs this means returning with
3194bcd95a3SBarry Smith  exit-code `0` and calling `MPI_Finalize()` instead of `MPI_Abort()`. Multi-rank
3204bcd95a3SBarry Smith  tests will call `MPI_Abort()` on errors raised on `PETSC_COMM_SELF`, but will call
3214bcd95a3SBarry Smith  `MPI_Finalize()` otherwise.
3224bcd95a3SBarry Smith
3234bcd95a3SBarry Smith- `-error_output_stdout`: Forces `SETERRQ()` and friends to dump error messages to
3244bcd95a3SBarry Smith  `stdout` instead of `stderr`. While using `stderr` (alongside the `Error:`
3254bcd95a3SBarry Smith  sub-directive under `filter:`) also works it appears to be unstable under heavy
3264bcd95a3SBarry Smith  load, especially in CI.
3274bcd95a3SBarry Smith
3284bcd95a3SBarry SmithUsing both options in tandem allows one to use the normal `output:` mechanism to compare
3294bcd95a3SBarry Smithexpected and actual error outputs.
3304bcd95a3SBarry Smith
3314bcd95a3SBarry SmithWhen writing ASCII output that may be not portable, so one wants `-petsc_ci_portable_error_output` to
3324bcd95a3SBarry Smithcause the output to be skipped, enclose the output with code such as
3334bcd95a3SBarry Smith
3344bcd95a3SBarry Smith```
3354bcd95a3SBarry Smithif (!PetscCIEnabledPortableErrorOutput)
3364bcd95a3SBarry Smith```
3374bcd95a3SBarry Smith
3384bcd95a3SBarry Smithto prevent it from being output when the CI test harness is running.
3394bcd95a3SBarry Smith
3404bcd95a3SBarry Smith### Test Block Examples
3414bcd95a3SBarry Smith
3424bcd95a3SBarry SmithThe following is the simplest test block:
3434bcd95a3SBarry Smith
3444bcd95a3SBarry Smith```yaml
3454bcd95a3SBarry Smith/*TEST
3464bcd95a3SBarry Smith  test:
3474bcd95a3SBarry SmithTEST*/
3484bcd95a3SBarry Smith```
3494bcd95a3SBarry Smith
3504bcd95a3SBarry SmithIf this block is in `src/a/b/examples/tutorials/ex1.c`, then it will
3514bcd95a3SBarry Smithcreate `a_b_tutorials-ex1` test that requires only one
3524bcd95a3SBarry Smithprocess, with no arguments, and diff the resultant output with
3534bcd95a3SBarry Smith`src/a/b/examples/tutorials/output/ex1.out`.
3544bcd95a3SBarry Smith
3554bcd95a3SBarry SmithFor Fortran, the equivalent is
3564bcd95a3SBarry Smith
3574bcd95a3SBarry Smith```fortran
3584bcd95a3SBarry Smith!/*TEST
3594bcd95a3SBarry Smith!  test:
3604bcd95a3SBarry Smith!TEST*/
3614bcd95a3SBarry Smith```
3624bcd95a3SBarry Smith
3634bcd95a3SBarry SmithA more complete example, showing just the lines between `/*TEST` and `TEST*/`:
3644bcd95a3SBarry Smith
3654bcd95a3SBarry Smith```yaml
3664bcd95a3SBarry Smithtest:
3674bcd95a3SBarry Smithtest:
3684bcd95a3SBarry Smith  suffix: 1
3694bcd95a3SBarry Smith  nsize: 2
3704bcd95a3SBarry Smith  args: -t 2 -pc_type jacobi -ksp_monitor_short -ksp_type gmres
3714bcd95a3SBarry Smith  args: -ksp_gmres_cgs_refinement_type refine_always -s2_ksp_type bcgs
3724bcd95a3SBarry Smith  args: -s2_pc_type jacobi -s2_ksp_monitor_short
3734bcd95a3SBarry Smith  requires: x
3744bcd95a3SBarry Smith```
3754bcd95a3SBarry Smith
3764bcd95a3SBarry SmithThis creates two tests. Assuming that this is
3774bcd95a3SBarry Smith`src/a/b/examples/tutorials/ex1.c`, the tests would be
3784bcd95a3SBarry Smith`a_b_tutorials-ex1` and `a_b_tutorials-ex1_1`.
3794bcd95a3SBarry Smith
3804bcd95a3SBarry SmithFollowing is an example of how to test a permutation of arguments
3814bcd95a3SBarry Smithagainst the same output file:
3824bcd95a3SBarry Smith
3834bcd95a3SBarry Smith```yaml
3844bcd95a3SBarry Smithtestset:
3854bcd95a3SBarry Smith  suffix: 19
3864bcd95a3SBarry Smith  requires: datafilespath
3874bcd95a3SBarry Smith  args: -f0 ${DATAFILESPATH}/matrices/poisson1
3884bcd95a3SBarry Smith  args: -ksp_type cg -pc_type icc -pc_factor_levels 2
3894bcd95a3SBarry Smith  test:
3904bcd95a3SBarry Smith  test:
3914bcd95a3SBarry Smith    args: -mat_type seqsbaij
3924bcd95a3SBarry Smith```
3934bcd95a3SBarry Smith
3944bcd95a3SBarry SmithAssuming that this is `ex10.c`, there would be two mpiexec/diff
3954bcd95a3SBarry Smithinvocations in `runex10_19.sh`.
3964bcd95a3SBarry Smith
3974bcd95a3SBarry SmithHere is a similar example, but the permutation of arguments creates
3984bcd95a3SBarry Smithdifferent output:
3994bcd95a3SBarry Smith
4004bcd95a3SBarry Smith```yaml
4014bcd95a3SBarry Smithtestset:
4024bcd95a3SBarry Smith  requires: datafilespath
4034bcd95a3SBarry Smith  args: -f0 ${DATAFILESPATH}/matrices/medium
4044bcd95a3SBarry Smith  args: -ksp_type bicg
4054bcd95a3SBarry Smith  test:
4064bcd95a3SBarry Smith    suffix: 4
4074bcd95a3SBarry Smith    args: -pc_type lu
4084bcd95a3SBarry Smith  test:
4094bcd95a3SBarry Smith    suffix: 5
4104bcd95a3SBarry Smith```
4114bcd95a3SBarry Smith
4124bcd95a3SBarry SmithAssuming that this is `ex10.c`, two shell scripts will be created:
4134bcd95a3SBarry Smith`runex10_4.sh` and `runex10_5.sh`.
4144bcd95a3SBarry Smith
4154bcd95a3SBarry SmithAn example using a for loop is:
4164bcd95a3SBarry Smith
4174bcd95a3SBarry Smith```yaml
4184bcd95a3SBarry Smithtestset:
4194bcd95a3SBarry Smith  suffix: 1
4204bcd95a3SBarry Smith  args: -f ${DATAFILESPATH}/matrices/small -mat_type aij
4214bcd95a3SBarry Smith  requires: datafilespath
4224bcd95a3SBarry Smithtestset:
4234bcd95a3SBarry Smith  suffix: 2
4244bcd95a3SBarry Smith  output_file: output/ex138_1.out
4254bcd95a3SBarry Smith  args: -f ${DATAFILESPATH}/matrices/small
4264bcd95a3SBarry Smith  args: -mat_type baij -matload_block_size {{2 3}shared output}
4274bcd95a3SBarry Smith  requires: datafilespath
4284bcd95a3SBarry Smith```
4294bcd95a3SBarry Smith
4304bcd95a3SBarry SmithIn this example, `ex138_2` will invoke `runex138_2.sh` twice with
4314bcd95a3SBarry Smithtwo different arguments, but both are diffed with the same file.
4324bcd95a3SBarry Smith
4334bcd95a3SBarry SmithFollowing is an example showing the hierarchical nature of the test
4344bcd95a3SBarry Smithspecification.
4354bcd95a3SBarry Smith
4364bcd95a3SBarry Smith```yaml
4374bcd95a3SBarry Smithtestset:
4384bcd95a3SBarry Smith  suffix:2
4394bcd95a3SBarry Smith  output_file: output/ex138_1.out
4404bcd95a3SBarry Smith  args: -f ${DATAFILESPATH}/matrices/small -mat_type baij
4414bcd95a3SBarry Smith  test:
4424bcd95a3SBarry Smith    args: -matload_block_size 2
4434bcd95a3SBarry Smith  test:
4444bcd95a3SBarry Smith    args: -matload_block_size 3
4454bcd95a3SBarry Smith```
4464bcd95a3SBarry Smith
4474bcd95a3SBarry SmithThis is functionally equivalent to the for loop shown above.
4484bcd95a3SBarry Smith
4494bcd95a3SBarry SmithHere is a more complex example using for loops:
4504bcd95a3SBarry Smith
4514bcd95a3SBarry Smith```yaml
4524bcd95a3SBarry Smithtestset:
4534bcd95a3SBarry Smith  suffix: 19
4544bcd95a3SBarry Smith  requires: datafilespath
4554bcd95a3SBarry Smith  args: -f0 ${DATAFILESPATH}/matrices/poisson1
4564bcd95a3SBarry Smith  args: -ksp_type cg -pc_type icc
4574bcd95a3SBarry Smith  args: -pc_factor_levels {{0 2 4}separate output}
4584bcd95a3SBarry Smith  test:
4594bcd95a3SBarry Smith  test:
4604bcd95a3SBarry Smith    args: -mat_type seqsbaij
4614bcd95a3SBarry Smith```
4624bcd95a3SBarry Smith
4634bcd95a3SBarry SmithIf this is in `ex10.c`, then the shell scripts generated would be
4644bcd95a3SBarry Smith
4654bcd95a3SBarry Smith- `runex10_19_pc_factor_levels-0.sh`
4664bcd95a3SBarry Smith- `runex10_19_pc_factor_levels-2.sh`
4674bcd95a3SBarry Smith- `runex10_19_pc_factor_levels-4.sh`
4684bcd95a3SBarry Smith
4694bcd95a3SBarry SmithEach shell script would invoke twice.
4704bcd95a3SBarry Smith
4714bcd95a3SBarry Smith### Build Language Options
4724bcd95a3SBarry Smith
4734bcd95a3SBarry SmithYou can specify issues related to the compilation of the source file
4744bcd95a3SBarry Smithwith the `build:` block. The language is as follows.
4754bcd95a3SBarry Smith
4764bcd95a3SBarry Smith- **requires:** (*Optional*; *Default:* `""`)
4774bcd95a3SBarry Smith
4784bcd95a3SBarry Smith  - Same as the runtime requirements (for example, can include
4794bcd95a3SBarry Smith    `requires: fftw`) but also requirements related to types:
4804bcd95a3SBarry Smith
4814bcd95a3SBarry Smith    1. Precision types: `single`, `double`, `quad`, `int32`
4824bcd95a3SBarry Smith    2. Scalar types: `complex` (and `!complex`)
4834bcd95a3SBarry Smith
4844bcd95a3SBarry Smith  - In addition, `TODO` is available to allow you to skip the build
4854bcd95a3SBarry Smith    of this file but still maintain it in the source tree.
4864bcd95a3SBarry Smith
4874bcd95a3SBarry Smith- **depends:** (*Optional*; *Default:* `""`)
4884bcd95a3SBarry Smith
4894bcd95a3SBarry Smith  - List any dependencies required to compile the file
4904bcd95a3SBarry Smith
4914bcd95a3SBarry SmithA typical example for compiling for only real numbers is
4924bcd95a3SBarry Smith
4934bcd95a3SBarry Smith```
4944bcd95a3SBarry Smith/*TEST
4954bcd95a3SBarry Smith  build:
4964bcd95a3SBarry Smith    requires: !complex
4974bcd95a3SBarry Smith  test:
4984bcd95a3SBarry SmithTEST*/
4994bcd95a3SBarry Smith```
5004bcd95a3SBarry Smith
5014bcd95a3SBarry Smith## Running the tests
5024bcd95a3SBarry Smith
5034bcd95a3SBarry SmithThe make rules for running tests are contained in `gmakefile.test` in the PETSc root directory. They can usually be accessed by
5044bcd95a3SBarry Smithsimply using commands such as
5054bcd95a3SBarry Smith
5064bcd95a3SBarry Smith```console
5074bcd95a3SBarry Smith$ make test
5084bcd95a3SBarry Smith```
5094bcd95a3SBarry Smith
5104bcd95a3SBarry Smithor, for a list of test options,
5114bcd95a3SBarry Smith
5124bcd95a3SBarry Smith```console
5134bcd95a3SBarry Smith$ make help-test
5144bcd95a3SBarry Smith```
5154bcd95a3SBarry Smith
5164bcd95a3SBarry Smith### Determining the failed jobs of a given run
5174bcd95a3SBarry Smith
5184bcd95a3SBarry SmithThe running of the test harness will show which tests fail, but you may not have
5194bcd95a3SBarry Smithlogged the output or run without showing the full error. The best way of
5204bcd95a3SBarry Smithexamining the errors is with this command:
5214bcd95a3SBarry Smith
5224bcd95a3SBarry Smith```console
5234bcd95a3SBarry Smith$ $EDITOR $PETSC_DIR/$PETSC_ARCH/tests/test*err.log
5244bcd95a3SBarry Smith```
5254bcd95a3SBarry Smith
5264bcd95a3SBarry SmithThis method can also be used for the PETSc continuous integration (CI) pipeline jobs. For failed jobs you can download the
5274bcd95a3SBarry Smithlog files from the `artifacts download` tab on the right side:
5284bcd95a3SBarry Smith
5294bcd95a3SBarry Smith:::{figure} /images/developers/test-artifacts.png
5304bcd95a3SBarry Smith:alt: Test Artifacts at Gitlab
5314bcd95a3SBarry Smith
5324bcd95a3SBarry SmithTest artifacts can be downloaded from GitLab.
5334bcd95a3SBarry Smith:::
5344bcd95a3SBarry Smith
5354bcd95a3SBarry SmithTo see the list of all tests that failed from the last run, you can also run this command:
5364bcd95a3SBarry Smith
5374bcd95a3SBarry Smith```console
5384bcd95a3SBarry Smith$ make print-test test-fail=1
5394bcd95a3SBarry Smith```
5404bcd95a3SBarry Smith
5414bcd95a3SBarry SmithTo print it out in a column format:
5424bcd95a3SBarry Smith
5434bcd95a3SBarry Smith```console
5444bcd95a3SBarry Smith$ make print-test test-fail=1 | tr ' ' '\n' | sort
5454bcd95a3SBarry Smith```
5464bcd95a3SBarry Smith
5474bcd95a3SBarry SmithOnce you know which tests failed, the question is how to debug them.
5484bcd95a3SBarry Smith
5494bcd95a3SBarry Smith### Introduction to debugging workflows
5504bcd95a3SBarry Smith
5514bcd95a3SBarry SmithHere, two different workflows on developing with the test harness are presented,
5524bcd95a3SBarry Smithand then the language for adding a new test is described. Before describing the
5534bcd95a3SBarry Smithworkflow, we first discuss the output of the test harness and how it maps onto
5544bcd95a3SBarry Smithmakefile targets and shell scripts.
5554bcd95a3SBarry Smith
5564bcd95a3SBarry SmithConsider this line from running the PETSc test system:
5574bcd95a3SBarry Smith
5584bcd95a3SBarry Smith```
5594bcd95a3SBarry SmithTEST arch-ci-linux-uni-pkgs/tests/counts/vec_is_sf_tests-ex1_basic_1.counts
5604bcd95a3SBarry Smith```
5614bcd95a3SBarry Smith
5624bcd95a3SBarry SmithThe string `vec_is_sf_tests-ex1_basic_1` gives the following information:
5634bcd95a3SBarry Smith
5644bcd95a3SBarry Smith- The file generating the tests is found in `$PETSC_DIR/src/vec/is/sf/tests/ex1.c`
5654bcd95a3SBarry Smith- The makefile target for the *test* is `vec_is_sf_tests-ex1_basic_1`
5664bcd95a3SBarry Smith- The makefile target for the *executable* is `$PETSC_ARCH/tests/vec/is/sf/tests/ex1`
5674bcd95a3SBarry Smith- The shell script running the test is located at: `$PETSC_DIR/$PETSC_ARCH/tests/vec/is/sf/tests/runex1_basic_1.sh`
5684bcd95a3SBarry Smith
5694bcd95a3SBarry SmithLet's say that you want to debug a single test as part of development. There
5704bcd95a3SBarry Smithare two basic methods of doing this: 1) use shell script directly in test
5714bcd95a3SBarry Smithdirectory, or 2) use the gmakefile.test from the top level directory. We present both
5724bcd95a3SBarry Smithworkflows.
5734bcd95a3SBarry Smith
5744bcd95a3SBarry Smith### Debugging a test using shell the generated scripts
5754bcd95a3SBarry Smith
5764bcd95a3SBarry SmithFirst, look at the working directory and the options for the
5774bcd95a3SBarry Smithscripts:
5784bcd95a3SBarry Smith
5794bcd95a3SBarry Smith```console
5804bcd95a3SBarry Smith$ cd $PETSC_ARCH/tests/vec/is/sf/tests
5814bcd95a3SBarry Smith$ ./runex1_basic_1.sh -h
5824bcd95a3SBarry SmithUsage: ./runex1_basic_1.sh [options]
5834bcd95a3SBarry Smith
5844bcd95a3SBarry SmithOPTIONS
5854bcd95a3SBarry Smith  -a <args> ......... Override default arguments
5864bcd95a3SBarry Smith  -c ................ Cleanup (remove generated files)
5874bcd95a3SBarry Smith  -C ................ Compile
5884bcd95a3SBarry Smith  -d ................ Launch in debugger
5894bcd95a3SBarry Smith  -e <args> ......... Add extra arguments to default
5904bcd95a3SBarry Smith  -f ................ force attempt to run test that would otherwise be skipped
5914bcd95a3SBarry Smith  -h ................ help: print this message
5924bcd95a3SBarry Smith  -n <integer> ...... Override the number of processors to use
5934bcd95a3SBarry Smith  -j ................ Pass -j to petscdiff (just use diff)
5944bcd95a3SBarry Smith  -J <arg> .......... Pass -J to petscdiff (just use diff with arg)
5954bcd95a3SBarry Smith  -m ................ Update results using petscdiff
5964bcd95a3SBarry Smith  -M ................ Update alt files using petscdiff
5974bcd95a3SBarry Smith  -o <arg> .......... Output format: 'interactive', 'err_only'
5984bcd95a3SBarry Smith  -p ................ Print command: Print first command and exit
5994bcd95a3SBarry Smith  -t ................ Override the default timeout (default=60 sec)
6004bcd95a3SBarry Smith  -U ................ run cUda-memcheck
6014bcd95a3SBarry Smith  -V ................ run Valgrind
6024bcd95a3SBarry Smith  -v ................ Verbose: Print commands
6034bcd95a3SBarry Smith```
6044bcd95a3SBarry Smith
6054bcd95a3SBarry SmithWe will be using the `-C`, `-V`, and `-p` flags.
6064bcd95a3SBarry Smith
6074bcd95a3SBarry SmithA basic workflow is something similar to:
6084bcd95a3SBarry Smith
6094bcd95a3SBarry Smith```console
6104bcd95a3SBarry Smith$ <edit>
6114bcd95a3SBarry Smith$ runex1_basic_1.sh -C
6124bcd95a3SBarry Smith$ <edit>
6134bcd95a3SBarry Smith$ ...
6144bcd95a3SBarry Smith$ runex1_basic_1.sh -m # If need to update results
6154bcd95a3SBarry Smith$ ...
6164bcd95a3SBarry Smith$ runex1_basic_1.sh -V # Make sure valgrind clean
6174bcd95a3SBarry Smith$ cd $PETSC_DIR
6184bcd95a3SBarry Smith$ git commit -a
6194bcd95a3SBarry Smith```
6204bcd95a3SBarry Smith
6214bcd95a3SBarry SmithFor loops it sometimes can become onerous to run the whole test.
6224bcd95a3SBarry SmithIn this case, you can use the `-p` flag to print just the first
6234bcd95a3SBarry Smithcommand. It will print a command suitable for running from
6244bcd95a3SBarry Smith`$PETSC_DIR`, but it is easy to modify for execution in the test
6254bcd95a3SBarry Smithdirectory:
6264bcd95a3SBarry Smith
6274bcd95a3SBarry Smith```console
6284bcd95a3SBarry Smith$ runex1_basic_1.sh -p
6294bcd95a3SBarry Smith```
6304bcd95a3SBarry Smith
6314bcd95a3SBarry Smith### Debugging a PETSc test using the gmakefile.test
6324bcd95a3SBarry Smith
6334bcd95a3SBarry SmithFirst recall how to find help for the options:
6344bcd95a3SBarry Smith
6354bcd95a3SBarry Smith```console
6364bcd95a3SBarry Smith$ make help-test
637*4c2e35b6SJunchao ZhangTest usage:
638*4c2e35b6SJunchao Zhang   /usr/bin/gmake --no-print-directory test <options>
639*4c2e35b6SJunchao Zhang
640*4c2e35b6SJunchao ZhangOptions:
641*4c2e35b6SJunchao Zhang  NO_RM=1           Do not remove the executables after running
642*4c2e35b6SJunchao Zhang  REPLACE=1         Replace the output in PETSC_DIR source tree (-m to test scripts)
643*4c2e35b6SJunchao Zhang  OUTPUT=1          Show only the errors on stdout
644*4c2e35b6SJunchao Zhang  ALT=1             Replace 'alt' output in PETSC_DIR source tree (-M to test scripts)
645*4c2e35b6SJunchao Zhang  DIFF_NUMBERS=1    Diff the numbers in the output (-j to test scripts and petscdiff)
646*4c2e35b6SJunchao Zhang  CUDAMEMCHECK=1    Execute the tests using cuda-memcheck (-U to test scripts)
647*4c2e35b6SJunchao Zhang                    Use PETSC_CUDAMEMCHECK_COMMAND to change the executable to run and
648*4c2e35b6SJunchao Zhang                    PETSC_CUDAMEMCHECK_ARGS to change the arguments (note: both
649*4c2e35b6SJunchao Zhang                    cuda-memcheck and compute-sanitizer are supported)
650*4c2e35b6SJunchao Zhang  VALGRIND=1        Execute the tests using valgrind (-V to test scripts)
651*4c2e35b6SJunchao Zhang  DEBUG=1           Launch tests in the debugger (-d to the scripts)
652*4c2e35b6SJunchao Zhang  NP=<num proc>     Set a number of processors to pass to scripts.
653*4c2e35b6SJunchao Zhang  FORCE=1           Force SKIP or TODO tests to run
654*4c2e35b6SJunchao Zhang  PRINTONLY=1       Print the command, but do not run.  For loops print first command
655*4c2e35b6SJunchao Zhang  TIMEOUT=<time>    Test timeout limit in seconds (default in config/petsc_harness.sh)
656*4c2e35b6SJunchao Zhang  TESTDIR='tests'   Subdirectory where tests are run ($PETSC_DIR/$PETSC_ARCH
657*4c2e35b6SJunchao Zhang                    or /
658*4c2e35b6SJunchao Zhang                    or /share/petsc/examples/)
659*4c2e35b6SJunchao Zhang  TESTBASE='tests'   Subdirectory where tests are run ($PETSC_DIR/$PETSC_ARCH)
660*4c2e35b6SJunchao Zhang  OPTIONS='<args>'  Override options to scripts (-a to test scripts)
661*4c2e35b6SJunchao Zhang  EXTRA_OPTIONS='<args>'  Add options to scripts (-e to test scripts)
662*4c2e35b6SJunchao Zhang
663*4c2e35b6SJunchao ZhangSpecial options for macOS:
664*4c2e35b6SJunchao Zhang  MACOS_FIREWALL=1  Add each built test to the macOS firewall list to prevent popups. Configure --with-macos-firewall-rules to make this default
665*4c2e35b6SJunchao Zhang
666*4c2e35b6SJunchao ZhangTests can be generated by searching with multiple methods
667*4c2e35b6SJunchao Zhang  For general searching (using config/query_tests.py):
668*4c2e35b6SJunchao Zhang    /usr/bin/gmake --no-print-directory test search='sys*ex2*'
669*4c2e35b6SJunchao Zhang   or the shortcut using s
670*4c2e35b6SJunchao Zhang    /usr/bin/gmake --no-print-directory test s='sys*ex2*'
671*4c2e35b6SJunchao Zhang  You can also use the full path to a file directory
672*4c2e35b6SJunchao Zhang    /usr/bin/gmake --no-print-directory test s='src/sys/tests/'
673*4c2e35b6SJunchao Zhang   or a file
674*4c2e35b6SJunchao Zhang    /usr/bin/gmake --no-print-directory test s='src/sys/tests/ex1.c'
675*4c2e35b6SJunchao Zhang
676*4c2e35b6SJunchao Zhang  To search for fields from the original test definitions:
677*4c2e35b6SJunchao Zhang    /usr/bin/gmake --no-print-directory test query='requires' queryval='*MPI_PROCESS_SHARED_MEMORY*'
678*4c2e35b6SJunchao Zhang   or the shortcut using q and qv
679*4c2e35b6SJunchao Zhang    /usr/bin/gmake --no-print-directory test q='requires' qv='*MPI_PROCESS_SHARED_MEMORY*'
680*4c2e35b6SJunchao Zhang  To filter results from other searches, use searchin
681*4c2e35b6SJunchao Zhang    /usr/bin/gmake --no-print-directory test s='src/sys/tests/' searchin='*options*'
682*4c2e35b6SJunchao Zhang
683*4c2e35b6SJunchao Zhang  To re-run the last tests which failed:
684*4c2e35b6SJunchao Zhang    /usr/bin/gmake --no-print-directory test test-fail='1'
685*4c2e35b6SJunchao Zhang
686*4c2e35b6SJunchao Zhang  To see which targets match a given pattern (useful for doing a specific target):
687*4c2e35b6SJunchao Zhang    /usr/bin/gmake --no-print-directory print-test search=sys*
688*4c2e35b6SJunchao Zhang
689*4c2e35b6SJunchao Zhang  To build an executable, give full path to location:
690*4c2e35b6SJunchao Zhang    /usr/bin/gmake --no-print-directory ${PETSC_ARCH}/tests/sys/tests/ex1
691*4c2e35b6SJunchao Zhang  or make the test with NO_RM=1
6924bcd95a3SBarry Smith```
6934bcd95a3SBarry Smith
6944bcd95a3SBarry SmithTo compile the test and run it:
6954bcd95a3SBarry Smith
6964bcd95a3SBarry Smith```console
6974bcd95a3SBarry Smith$ make test search=vec_is_sf_tests-ex1_basic_1
6984bcd95a3SBarry Smith```
6994bcd95a3SBarry Smith
7004bcd95a3SBarry SmithThis can consist of your basic workflow. However,
7014bcd95a3SBarry Smithfor the normal compile and edit, running the entire harness with search can be
7024bcd95a3SBarry Smithcumbersome. So first get the command:
7034bcd95a3SBarry Smith
7044bcd95a3SBarry Smith```console
7054bcd95a3SBarry Smith$ make vec_is_sf_tests-ex1_basic_1 PRINTONLY=1
7064bcd95a3SBarry Smith<copy command>
7074bcd95a3SBarry Smith<edit>
7084bcd95a3SBarry Smith$ make $PETSC_ARCH/tests/vec/is/sf/tests/ex1
7094bcd95a3SBarry Smith$ /scratch/kruger/contrib/petsc-mpich-cxx/bin/mpiexec -n 1 arch-mpich-cxx-py3/tests/vec/is/sf/tests/ex1
7104bcd95a3SBarry Smith...
7114bcd95a3SBarry Smith$ cd $PETSC_DIR
7124bcd95a3SBarry Smith$ git commit -a
7134bcd95a3SBarry Smith```
7144bcd95a3SBarry Smith
7154bcd95a3SBarry Smith### Advanced searching
7164bcd95a3SBarry Smith
7174bcd95a3SBarry SmithFor forming a search, it is recommended to always use `print-test` instead of
7184bcd95a3SBarry Smith`test` to make sure it is returning the values that you want.
7194bcd95a3SBarry Smith
7204bcd95a3SBarry SmithThe three basic and recommended arguments are:
7214bcd95a3SBarry Smith
7224bcd95a3SBarry Smith- `search` (or `s`)
7234bcd95a3SBarry Smith
7244bcd95a3SBarry Smith  - Searches based on name of test target (see above)
7254bcd95a3SBarry Smith
7264bcd95a3SBarry Smith  - Use the familiar glob syntax (like the Unix `ls` command). Example:
7274bcd95a3SBarry Smith
7284bcd95a3SBarry Smith    ```console
7294bcd95a3SBarry Smith    $ make print-test search='vec_is*ex1*basic*1'
7304bcd95a3SBarry Smith    ```
7314bcd95a3SBarry Smith
7324bcd95a3SBarry Smith    Equivalently:
7334bcd95a3SBarry Smith
7344bcd95a3SBarry Smith    ```console
7354bcd95a3SBarry Smith    $ make print-test s='vec_is*ex1*basic*1'
7364bcd95a3SBarry Smith    ```
7374bcd95a3SBarry Smith
7384bcd95a3SBarry Smith  - It also takes full paths. Examples:
7394bcd95a3SBarry Smith
7404bcd95a3SBarry Smith    ```console
7414bcd95a3SBarry Smith    $ make print-test s='src/vec/is/tests/ex1.c'
7424bcd95a3SBarry Smith    ```
7434bcd95a3SBarry Smith
7444bcd95a3SBarry Smith    ```console
7454bcd95a3SBarry Smith    $ make print-test s='src/dm/impls/plex/tests/'
7464bcd95a3SBarry Smith    ```
7474bcd95a3SBarry Smith
7484bcd95a3SBarry Smith    ```console
7494bcd95a3SBarry Smith    $ make print-test s='src/dm/impls/plex/tests/ex1.c'
7504bcd95a3SBarry Smith    ```
7514bcd95a3SBarry Smith
7524bcd95a3SBarry Smith- `query` and `queryval` (or `q` and `qv`)
7534bcd95a3SBarry Smith
7544bcd95a3SBarry Smith  - `query` corresponds to test harness keyword, `queryval` to the value. Example:
7554bcd95a3SBarry Smith
7564bcd95a3SBarry Smith    ```console
7574bcd95a3SBarry Smith    $ make print-test query='suffix' queryval='basic_1'
7584bcd95a3SBarry Smith    ```
7594bcd95a3SBarry Smith
7604bcd95a3SBarry Smith  - Invokes `config/query_tests.py` to query the tests (see
7614bcd95a3SBarry Smith    `config/query_tests.py --help` for more information).
7624bcd95a3SBarry Smith
7634bcd95a3SBarry Smith  - See below for how to use as it has many features
7644bcd95a3SBarry Smith
7654bcd95a3SBarry Smith- `searchin` (or `i`)
7664bcd95a3SBarry Smith
7674bcd95a3SBarry Smith  - Filters results of above searches. Example:
7684bcd95a3SBarry Smith
7694bcd95a3SBarry Smith    ```console
7704bcd95a3SBarry Smith    $ make print-test s='src/dm/impls/plex/tests/ex1.c' i='*refine_overlap_2d*'
7714bcd95a3SBarry Smith    ```
7724bcd95a3SBarry Smith
7734bcd95a3SBarry SmithSearching using GNU make's native regexp functionality is kept for people who like it, but most developers will likely prefer the above methods:
7744bcd95a3SBarry Smith
7754bcd95a3SBarry Smith- `gmakesearch`
7764bcd95a3SBarry Smith
7774bcd95a3SBarry Smith  - Use GNU make's own filter capability.
7784bcd95a3SBarry Smith
7794bcd95a3SBarry Smith  - Fast, but requires knowing GNU make regex syntax which uses `%` instead of `*`
7804bcd95a3SBarry Smith
7814bcd95a3SBarry Smith  - Also very limited (cannot use two `%`'s for example)
7824bcd95a3SBarry Smith
7834bcd95a3SBarry Smith  - Example:
7844bcd95a3SBarry Smith
7854bcd95a3SBarry Smith    ```console
7864bcd95a3SBarry Smith    $ make test gmakesearch='vec_is%ex1_basic_1'
7874bcd95a3SBarry Smith    ```
7884bcd95a3SBarry Smith
7894bcd95a3SBarry Smith- `gmakesearchin`
7904bcd95a3SBarry Smith
7914bcd95a3SBarry Smith  - Use GNU make's own filter capability to search in previous results. Example:
7924bcd95a3SBarry Smith
7934bcd95a3SBarry Smith    ```console
7944bcd95a3SBarry Smith    $ make test gmakesearch='vec_is%1' gmakesearchin='basic'
7954bcd95a3SBarry Smith    ```
7964bcd95a3SBarry Smith
7974bcd95a3SBarry Smith### Query-based searching
7984bcd95a3SBarry Smith
7994bcd95a3SBarry SmithNote the use of glob style matching is also accepted in the value field:
8004bcd95a3SBarry Smith
8014bcd95a3SBarry Smith```console
8024bcd95a3SBarry Smith$ make print-test query='suffix' queryval='basic_1'
8034bcd95a3SBarry Smith```
8044bcd95a3SBarry Smith
8054bcd95a3SBarry Smith```console
8064bcd95a3SBarry Smith$ make print-test query='requires' queryval='cuda'
8074bcd95a3SBarry Smith```
8084bcd95a3SBarry Smith
8094bcd95a3SBarry Smith```console
8104bcd95a3SBarry Smith$ make print-test query='requires' queryval='defined(PETSC_HAVE_MPI_GPU_AWARE)'
8114bcd95a3SBarry Smith```
8124bcd95a3SBarry Smith
8134bcd95a3SBarry Smith```console
8144bcd95a3SBarry Smith$ make print-test query='requires' queryval='*GPU_AWARE*'
8154bcd95a3SBarry Smith```
8164bcd95a3SBarry Smith
8174bcd95a3SBarry SmithUsing the `name` field is equivalent to the search above:
8184bcd95a3SBarry Smith
8194bcd95a3SBarry Smith- Example:
8204bcd95a3SBarry Smith
8214bcd95a3SBarry Smith  ```console
8224bcd95a3SBarry Smith  $ make print-test query='name' queryval='vec_is*ex1*basic*1'
8234bcd95a3SBarry Smith  ```
8244bcd95a3SBarry Smith
8254bcd95a3SBarry Smith- This can be combined with union/intersect queries as discussed below
8264bcd95a3SBarry Smith
8274bcd95a3SBarry SmithArguments are tricky to search for. Consider
8284bcd95a3SBarry Smith
8294bcd95a3SBarry Smith```none
8304bcd95a3SBarry Smithargs: -ksp_monitor_short -pc_type ml -ksp_max_it 3
8314bcd95a3SBarry Smith```
8324bcd95a3SBarry Smith
8334bcd95a3SBarry SmithSearch terms are
8344bcd95a3SBarry Smith
8354bcd95a3SBarry Smith```none
8364bcd95a3SBarry Smithksp_monitor, pc_type ml, ksp_max_it
8374bcd95a3SBarry Smith```
8384bcd95a3SBarry Smith
8394bcd95a3SBarry SmithCertain items are ignored:
8404bcd95a3SBarry Smith
8414bcd95a3SBarry Smith- Numbers (see `ksp_max_it` above), but floats are ignored as well.
8424bcd95a3SBarry Smith- Loops: `args: -pc_fieldsplit_diag_use_amat {{0 1}}` gives `pc_fieldsplit_diag_use_amat` as the search term
8434bcd95a3SBarry Smith- Input files: `-f *`
8444bcd95a3SBarry Smith
8454bcd95a3SBarry SmithExamples of argument searching:
8464bcd95a3SBarry Smith
8474bcd95a3SBarry Smith```console
8484bcd95a3SBarry Smith$ make print-test query='args' queryval='ksp_monitor'
8494bcd95a3SBarry Smith```
8504bcd95a3SBarry Smith
8514bcd95a3SBarry Smith```console
8524bcd95a3SBarry Smith$ make print-test query='args' queryval='*monitor*'
8534bcd95a3SBarry Smith```
8544bcd95a3SBarry Smith
8554bcd95a3SBarry Smith```console
8564bcd95a3SBarry Smith$ make print-test query='args' queryval='pc_type ml'
8574bcd95a3SBarry Smith```
8584bcd95a3SBarry Smith
8594bcd95a3SBarry SmithMultiple simultaneous queries can be performed with union (`,`), and intersection
8604bcd95a3SBarry Smith(`|`) operators in the `query` field. One may also use their alternate spellings
8614bcd95a3SBarry Smith(`%AND%` and `%OR%` respectively). The alternate spellings are useful in cases where
8624bcd95a3SBarry Smithone cannot avoid (possibly multiple) shell expansions that might otherwise interpret the
8634bcd95a3SBarry Smith`|` operator as a shell pipe. Examples:
8644bcd95a3SBarry Smith
8654bcd95a3SBarry Smith- All examples using `cuda` and all examples using `hip`:
8664bcd95a3SBarry Smith
8674bcd95a3SBarry Smith  ```console
8684bcd95a3SBarry Smith  $ make print-test query='requires,requires' queryval='cuda,hip'
8694bcd95a3SBarry Smith  # equivalently
8704bcd95a3SBarry Smith  $ make print-test query='requires%AND%requires' queryval='cuda%AND%hip'
8714bcd95a3SBarry Smith  ```
8724bcd95a3SBarry Smith
8734bcd95a3SBarry Smith- Examples that require both triangle and ctetgen (intersection of tests)
8744bcd95a3SBarry Smith
8754bcd95a3SBarry Smith  ```console
8764bcd95a3SBarry Smith  $ make print-test query='requires|requires' queryval='ctetgen,triangle'
8774bcd95a3SBarry Smith  # equivalently
8784bcd95a3SBarry Smith  $ make print-test query='requires%OR%requires' queryval='ctetgen%AND%triangle'
8794bcd95a3SBarry Smith  ```
8804bcd95a3SBarry Smith
8814bcd95a3SBarry Smith- Tests that require either `ctetgen` or `triangle`
8824bcd95a3SBarry Smith
8834bcd95a3SBarry Smith  ```console
8844bcd95a3SBarry Smith  $ make print-test query='requires,requires' queryval='ctetgen,triangle'
8854bcd95a3SBarry Smith  # equivalently
8864bcd95a3SBarry Smith  $ make print-test query='requires%AND%requires' queryval='ctetgen%AND%triangle'
8874bcd95a3SBarry Smith  ```
8884bcd95a3SBarry Smith
8894bcd95a3SBarry Smith- Find `cuda` examples in the `dm` package.
8904bcd95a3SBarry Smith
8914bcd95a3SBarry Smith  ```console
8924bcd95a3SBarry Smith  $ make print-test query='requires|name' queryval='cuda,dm*'
8934bcd95a3SBarry Smith  # equivalently
8944bcd95a3SBarry Smith  $ make print-test query='requires%OR%name' queryval='cuda%AND%dm*'
8954bcd95a3SBarry Smith  ```
8964bcd95a3SBarry Smith
8974bcd95a3SBarry SmithHere is a way of getting a feel for how the union and intersect operators work:
8984bcd95a3SBarry Smith
8994bcd95a3SBarry Smith```console
9004bcd95a3SBarry Smith$ make print-test query='requires' queryval='ctetgen' | tr ' ' '\n' | wc -l
9014bcd95a3SBarry Smith170
9024bcd95a3SBarry Smith$ make print-test query='requires' queryval='triangle' | tr ' ' '\n' | wc -l
9034bcd95a3SBarry Smith330
9044bcd95a3SBarry Smith$ make print-test query='requires,requires' queryval='ctetgen,triangle' | tr ' ' '\n' | wc -l
9054bcd95a3SBarry Smith478
9064bcd95a3SBarry Smith$ make print-test query='requires|requires' queryval='ctetgen,triangle' | tr ' ' '\n' | wc -l
9074bcd95a3SBarry Smith22
9084bcd95a3SBarry Smith```
9094bcd95a3SBarry Smith
9104bcd95a3SBarry SmithThe total number of tests for running only ctetgen or triangle is 500. They have 22 tests in common, and 478 that
9114bcd95a3SBarry Smithrun independently of each other.
9124bcd95a3SBarry Smith
9134bcd95a3SBarry SmithThe union and intersection have fixed grouping. So this string argument
9144bcd95a3SBarry Smith
9154bcd95a3SBarry Smith```none
9164bcd95a3SBarry Smithquery='requires,requires|args' queryval='cuda,hip,*log*'
9174bcd95a3SBarry Smith# equivalently
9184bcd95a3SBarry Smithquery='requires%AND%requires%OR%args' queryval='cuda%AND%hip%AND%*log*'
9194bcd95a3SBarry Smith```
9204bcd95a3SBarry Smith
9214bcd95a3SBarry Smithwill can be read as
9224bcd95a3SBarry Smith
9234bcd95a3SBarry Smith```none
9244bcd95a3SBarry Smithrequires:cuda && (requires:hip || args:*log*)
9254bcd95a3SBarry Smith```
9264bcd95a3SBarry Smith
9274bcd95a3SBarry Smithwhich is probably not what is intended.
9284bcd95a3SBarry Smith
9294bcd95a3SBarry Smith`query/queryval` also support negation (`!`, alternate `%NEG%`), but is limited.
9304bcd95a3SBarry SmithThe negation only applies to tests that have a related field in it. So for example, the
9314bcd95a3SBarry Smitharguments of
9324bcd95a3SBarry Smith
9334bcd95a3SBarry Smith```console
9344bcd95a3SBarry Smithquery=requires queryval='!cuda'
9354bcd95a3SBarry Smith# equivalently
9364bcd95a3SBarry Smithquery=requires queryval='%NEG%cuda'
9374bcd95a3SBarry Smith```
9384bcd95a3SBarry Smith
9394bcd95a3SBarry Smithwill only match if they explicitly have:
9404bcd95a3SBarry Smith
9414bcd95a3SBarry Smith```
9424bcd95a3SBarry Smithrequires: !cuda
9434bcd95a3SBarry Smith```
9444bcd95a3SBarry Smith
9454bcd95a3SBarry SmithIt does not match all cases that do not require cuda.
9464bcd95a3SBarry Smith
9474bcd95a3SBarry Smith### Debugging for loops
9484bcd95a3SBarry Smith
9494bcd95a3SBarry SmithOne of the more difficult issues is how to debug for loops when a subset of the
9504bcd95a3SBarry Smitharguments are the ones that cause a code crash. The default naming scheme is
9514bcd95a3SBarry Smithnot always helpful for figuring out the argument combination.
9524bcd95a3SBarry Smith
9534bcd95a3SBarry SmithFor example:
9544bcd95a3SBarry Smith
9554bcd95a3SBarry Smith```console
9564bcd95a3SBarry Smith$ make test s='src/ksp/ksp/tests/ex9.c' i='*1'
9574bcd95a3SBarry SmithUsing MAKEFLAGS: i=*1 s=src/ksp/ksp/tests/ex9.c
9584bcd95a3SBarry Smith        TEST arch-osx-pkgs-opt-new/tests/counts/ksp_ksp_tests-ex9_1.counts
9594bcd95a3SBarry Smith ok ksp_ksp_tests-ex9_1+pc_fieldsplit_diag_use_amat-0_pc_fieldsplit_diag_use_amat-0_pc_fieldsplit_type-additive
9604bcd95a3SBarry Smith not ok diff-ksp_ksp_tests-ex9_1+pc_fieldsplit_diag_use_amat-0_pc_fieldsplit_diag_use_amat-0_pc_fieldsplit_type-additive
9614bcd95a3SBarry Smith ok ksp_ksp_tests-ex9_1+pc_fieldsplit_diag_use_amat-0_pc_fieldsplit_diag_use_amat-0_pc_fieldsplit_type-multiplicative
9624bcd95a3SBarry Smith ...
9634bcd95a3SBarry Smith```
9644bcd95a3SBarry Smith
9654bcd95a3SBarry SmithIn this case, the trick is to use the verbose option, `V=1` (or for the shell script workflows, `-v`) to have it show the commands:
9664bcd95a3SBarry Smith
9674bcd95a3SBarry Smith```console
9684bcd95a3SBarry Smith$ make test s='src/ksp/ksp/tests/ex9.c' i='*1' V=1
9694bcd95a3SBarry SmithUsing MAKEFLAGS: V=1 i=*1 s=src/ksp/ksp/tests/ex9.c
9704bcd95a3SBarry Smitharch-osx-pkgs-opt-new/tests/ksp/ksp/tests/runex9_1.sh  -v
9714bcd95a3SBarry Smith ok ksp_ksp_tests-ex9_1+pc_fieldsplit_diag_use_amat-0_pc_fieldsplit_diag_use_amat-0_pc_fieldsplit_type-additive # mpiexec  -n 1 ../ex9 -ksp_converged_reason -ksp_error_if_not_converged  -pc_fieldsplit_diag_use_amat 0 -pc_fieldsplit_diag_use_amat 0 -pc_fieldsplit_type additive > ex9_1.tmp 2> runex9_1.err
9724bcd95a3SBarry Smith...
9734bcd95a3SBarry Smith```
9744bcd95a3SBarry Smith
9754bcd95a3SBarry SmithThis can still be hard to read and pick out what you want. So use the fact that you want `not ok`
9764bcd95a3SBarry Smithcombined with the fact that `#` is the delimiter:
9774bcd95a3SBarry Smith
9784bcd95a3SBarry Smith```console
9794bcd95a3SBarry Smith$ make test s='src/ksp/ksp/tests/ex9.c' i='*1' v=1 | grep 'not ok' | cut -d# -f2
9804bcd95a3SBarry Smithmpiexec  -n 1 ../ex9 -ksp_converged_reason -ksp_error_if_not_converged  -pc_fieldsplit_diag_use_amat 0 -pc_fieldsplit_diag_use_amat 0 -pc_fieldsplit_type multiplicative > ex9_1.tmp 2> runex9_1.err
9814bcd95a3SBarry Smith```
9824bcd95a3SBarry Smith
9834bcd95a3SBarry Smith## PETSC Test Harness
9844bcd95a3SBarry Smith
9854bcd95a3SBarry SmithThe goals of the PETSc test harness are threefold.
9864bcd95a3SBarry Smith
9874bcd95a3SBarry Smith1. Provide standard output used by other testing tools
9884bcd95a3SBarry Smith2. Be as lightweight as possible and easily fit within the PETSc build chain
9894bcd95a3SBarry Smith3. Provide information on all tests, even those that are not built or run because they do not meet the configuration requirements
9904bcd95a3SBarry Smith
9914bcd95a3SBarry SmithBefore understanding the test harness, you should first understand the
9924bcd95a3SBarry Smithdesired requirements for reporting and logging.
9934bcd95a3SBarry Smith
9944bcd95a3SBarry Smith### Testing the Parsing
9954bcd95a3SBarry Smith
9964bcd95a3SBarry SmithAfter inserting the language into the file, you can test the parsing by
9974bcd95a3SBarry Smithexecuting
9984bcd95a3SBarry Smith
9994bcd95a3SBarry SmithA dictionary will be pretty-printed. From this dictionary printout, any
10004bcd95a3SBarry Smithproblems in the parsing are is usually obvious. This python file is used
10014bcd95a3SBarry Smithby
10024bcd95a3SBarry Smith
10034bcd95a3SBarry Smithin generating the test harness.
10044bcd95a3SBarry Smith
10054bcd95a3SBarry Smith## Test Output Standards: TAP
10064bcd95a3SBarry Smith
10074bcd95a3SBarry SmithThe PETSc test system is designed to be compliant with the [Test Anything Protocol (TAP)](https://testanything.org/tap-specification.html).
10084bcd95a3SBarry Smith
10094bcd95a3SBarry SmithThis is a simple standard designed to allow testing tools to work
10104bcd95a3SBarry Smithtogether easily. There are libraries to enable the output to be used
10114bcd95a3SBarry Smitheasily, including sharness, which is used by the Git team. However, the
10124bcd95a3SBarry Smithsimplicity of the PETSc tests and TAP specification means that we use
10134bcd95a3SBarry Smithour own simple harness given by a single shell script that each file
10144bcd95a3SBarry Smithsources: `$PETSC_DIR/config/petsc_harness.sh`.
10154bcd95a3SBarry Smith
10164bcd95a3SBarry SmithAs an example, consider this test input:
10174bcd95a3SBarry Smith
10184bcd95a3SBarry Smith```yaml
10194bcd95a3SBarry Smithtest:
10204bcd95a3SBarry Smith  suffix: 2
10214bcd95a3SBarry Smith  output_file: output/ex138.out
10224bcd95a3SBarry Smith  args: -f ${DATAFILESPATH}/matrices/small -mat_type {{aij baij sbaij}} -matload_block_size {{2 3}}
10234bcd95a3SBarry Smith  requires: datafilespath
10244bcd95a3SBarry Smith```
10254bcd95a3SBarry Smith
10264bcd95a3SBarry SmithA sample output from this would be:
10274bcd95a3SBarry Smith
10284bcd95a3SBarry Smith```
10294bcd95a3SBarry Smithok 1 In mat...tests: "./ex138 -f ${DATAFILESPATH}/matrices/small -mat_type aij -matload_block_size 2"
10304bcd95a3SBarry Smithok 2 In mat...tests: "Diff of ./ex138 -f ${DATAFILESPATH}/matrices/small -mat_type aij -matload_block_size 2"
10314bcd95a3SBarry Smithok 3 In mat...tests: "./ex138 -f ${DATAFILESPATH}/matrices/small -mat_type aij -matload_block_size 3"
10324bcd95a3SBarry Smithok 4 In mat...tests: "Diff of ./ex138 -f ${DATAFILESPATH}/matrices/small -mat_type aij -matload_block_size 3"
10334bcd95a3SBarry Smithok 5 In mat...tests: "./ex138 -f ${DATAFILESPATH}/matrices/small -mat_type baij -matload_block_size 2"
10344bcd95a3SBarry Smithok 6 In mat...tests: "Diff of ./ex138 -f ${DATAFILESPATH}/matrices/small -mat_type baij -matload_block_size 2"
10354bcd95a3SBarry Smith...
10364bcd95a3SBarry Smith
10374bcd95a3SBarry Smithok 11 In mat...tests: "./ex138 -f ${DATAFILESPATH}/matrices/small -mat_type saij -matload_block_size 2"
10384bcd95a3SBarry Smithok 12 In mat...tests: "Diff of ./ex138 -f ${DATAFILESPATH}/matrices/small -mat_type aij -matload_block_size 2"
10394bcd95a3SBarry Smith```
10404bcd95a3SBarry Smith
10414bcd95a3SBarry Smith## Test Harness Implementation
10424bcd95a3SBarry Smith
10434bcd95a3SBarry SmithMost of the requirements for being TAP-compliant lie in the shell
10444bcd95a3SBarry Smithscripts, so we focus on that description.
10454bcd95a3SBarry Smith
10464bcd95a3SBarry SmithA sample shell script is given the following.
10474bcd95a3SBarry Smith
10484bcd95a3SBarry Smith```sh
10494bcd95a3SBarry Smith#!/bin/sh
10504bcd95a3SBarry Smith. petsc_harness.sh
10514bcd95a3SBarry Smith
10524bcd95a3SBarry Smithpetsc_testrun ./ex1 ex1.tmp ex1.err
10534bcd95a3SBarry Smithpetsc_testrun 'diff ex1.tmp output/ex1.out' diff-ex1.tmp diff-ex1.err
10544bcd95a3SBarry Smith
10554bcd95a3SBarry Smithpetsc_testend
10564bcd95a3SBarry Smith```
10574bcd95a3SBarry Smith
10584bcd95a3SBarry Smith`petsc_harness.sh` is a small shell script that provides the logging and reporting
10594bcd95a3SBarry Smithfunctions `petsc_testrun` and `petsc_testend`.
10604bcd95a3SBarry Smith
10614bcd95a3SBarry SmithA small sample of the output from the test harness is as follows.
10624bcd95a3SBarry Smith
10634bcd95a3SBarry Smith```none
10644bcd95a3SBarry Smithok 1 ./ex1
10654bcd95a3SBarry Smithok 2 diff ex1.tmp output/ex1.out
10664bcd95a3SBarry Smithnot ok 4 ./ex2
10674bcd95a3SBarry Smith#   ex2: Error: cannot read file
10684bcd95a3SBarry Smithnot ok 5 diff ex2.tmp output/ex2.out
10694bcd95a3SBarry Smithok 7 ./ex3 -f /matrices/small -mat_type aij -matload_block_size 2
10704bcd95a3SBarry Smithok 8 diff ex3.tmp output/ex3.out
10714bcd95a3SBarry Smithok 9 ./ex3 -f /matrices/small -mat_type aij -matload_block_size 3
10724bcd95a3SBarry Smithok 10 diff ex3.tmp output/ex3.out
10734bcd95a3SBarry Smithok 11 ./ex3 -f /matrices/small -mat_type baij -matload_block_size 2
10744bcd95a3SBarry Smithok 12 diff ex3.tmp output/ex3.out
10754bcd95a3SBarry Smithok 13 ./ex3 -f /matrices/small -mat_type baij -matload_block_size 3
10764bcd95a3SBarry Smithok 14 diff ex3.tmp output/ex3.out
10774bcd95a3SBarry Smithok 15 ./ex3 -f /matrices/small -mat_type sbaij -matload_block_size 2
10784bcd95a3SBarry Smithok 16 diff ex3.tmp output/ex3.out
10794bcd95a3SBarry Smithok 17 ./ex3 -f /matrices/small -mat_type sbaij -matload_block_size 3
10804bcd95a3SBarry Smithok 18 diff ex3.tmp output/ex3.out
10814bcd95a3SBarry Smith# FAILED   4 5
10824bcd95a3SBarry Smith# failed 2/16 tests; 87.500% ok
10834bcd95a3SBarry Smith```
10844bcd95a3SBarry Smith
10854bcd95a3SBarry SmithFor developers, modifying the lines that get written to the file can be
10864bcd95a3SBarry Smithdone by modifying `$PETSC_DIR/config/example_template.py`.
10874bcd95a3SBarry Smith
10884bcd95a3SBarry SmithTo modify the test harness, you can modify `$PETSC_DIR/config/petsc_harness.sh`.
10894bcd95a3SBarry Smith
10904bcd95a3SBarry Smith### Additional Tips
10914bcd95a3SBarry Smith
10924bcd95a3SBarry SmithTo rerun just the reporting use
10934bcd95a3SBarry Smith
10944bcd95a3SBarry Smith```console
10954bcd95a3SBarry Smith$ config/report_tests.py
10964bcd95a3SBarry Smith```
10974bcd95a3SBarry Smith
10984bcd95a3SBarry SmithTo see the full options use
10994bcd95a3SBarry Smith
11004bcd95a3SBarry Smith```console
11014bcd95a3SBarry Smith$ config/report_tests.py -h
11024bcd95a3SBarry Smith```
11034bcd95a3SBarry Smith
11044bcd95a3SBarry SmithTo see the full timing information for the five most expensive tests use
11054bcd95a3SBarry Smith
11064bcd95a3SBarry Smith```console
11074bcd95a3SBarry Smith$ config/report_tests.py -t 5
11084bcd95a3SBarry Smith```
1109