@@ -10,14 +10,19 @@ The build system is set up to compile an executable called `test_bitcoin`
10
10
that runs all of the unit tests. The main source file for the test library is found in
11
11
` util/setup_common.cpp ` .
12
12
13
+ The examples in this document assume the build directory is named
14
+ ` build ` . You'll need to adapt them if you named it differently.
15
+
13
16
### Compiling/running unit tests
14
17
15
18
Unit tests will be automatically compiled if dependencies were met
16
19
during the generation of the Bitcoin Core build system
17
20
and tests weren't explicitly disabled.
18
21
19
- Assuming the build directory is named ` build ` , the unit tests can be run
20
- with ` ctest --test-dir build ` , which includes unit tests from subtrees.
22
+ The unit tests can be run with ` ctest --test-dir build ` , which includes unit
23
+ tests from subtrees.
24
+
25
+ Run ` test_bitcoin --list_content ` for the full list of tests.
21
26
22
27
To run the unit tests manually, launch ` build/src/test/test_bitcoin ` . To recompile
23
28
after a test file was modified, run ` cmake --build build ` and then run the test again. If you
@@ -35,34 +40,45 @@ the `src/qt/test/test_main.cpp` file.
35
40
36
41
### Running individual tests
37
42
38
- ` test_bitcoin ` accepts the command line arguments from the boost framework.
39
- For example, to run just the ` getarg_tests ` suite of tests:
43
+ The ` test_bitcoin ` runner accepts command line arguments from the Boost
44
+ framework. To see the list of arguments that may be passed, run:
45
+
46
+ ```
47
+ test_bitcoin --help
48
+ ```
49
+
50
+ For example, to run only the tests in the ` getarg_tests ` file, with full logging:
40
51
41
52
``` bash
42
53
build/src/test/test_bitcoin --log_level=all --run_test=getarg_tests
43
54
```
44
55
45
- ` log_level ` controls the verbosity of the test framework, which logs when a
46
- test case is entered, for example.
56
+ or
47
57
48
- ` test_bitcoin ` also accepts some of the command line arguments accepted by
49
- ` bitcoind ` . Use ` -- ` to separate these sets of arguments:
58
+ ``` bash
59
+ build/src/test/test_bitcoin -l all -t getarg_tests
60
+ ```
61
+
62
+ or to run only the doubledash test in ` getarg_tests `
50
63
51
64
``` bash
52
- build/src/test/test_bitcoin --log_level=all -- run_test=getarg_tests -- -printtoconsole=1
65
+ build/src/test/test_bitcoin --run_test=getarg_tests/doubledash
53
66
```
54
67
55
- The ` -printtoconsole=1 ` after the two dashes sends debug logging, which
56
- normally goes only to ` debug.log ` within the data directory, also to the
57
- standard terminal output.
68
+ The ` --log_level= ` (or ` -l ` ) argument controls the verbosity of the test output.
58
69
59
- ... or to run just the doubledash test:
70
+ The ` test_bitcoin ` runner also accepts some of the command line arguments accepted by
71
+ ` bitcoind ` . Use ` -- ` to separate these sets of arguments:
60
72
61
73
``` bash
62
- build/src/test/test_bitcoin --run_test=getarg_tests/doubledash
74
+ build/src/test/test_bitcoin --log_level=all -- run_test=getarg_tests -- -printtoconsole=1
63
75
```
64
76
65
- ` test_bitcoin ` creates a temporary working (data) directory with a randomly
77
+ The ` -printtoconsole=1 ` after the two dashes sends debug logging, which
78
+ normally goes only to ` debug.log ` within the data directory, to the
79
+ standard terminal output as well.
80
+
81
+ Running ` test_bitcoin ` creates a temporary working (data) directory with a randomly
66
82
generated pathname within ` test_common bitcoin/ ` , which in turn is within
67
83
the system's temporary directory (see
68
84
[ ` temp_directory_path ` ] ( https://en.cppreference.com/w/cpp/filesystem/temp_directory_path ) ).
@@ -97,8 +113,6 @@ If you run an entire test suite, such as `--run_test=getarg_tests`, or all the t
97
113
(by not specifying ` --run_test ` ), a separate directory
98
114
will be created for each individual test.
99
115
100
- Run ` test_bitcoin --help ` for the full list of tests.
101
-
102
116
### Adding test cases
103
117
104
118
To add a new unit test file to our test suite, you need
0 commit comments