Name |
Date |
Size |
#Lines |
LOC |
||
---|---|---|---|---|---|---|
.. | - | - | ||||
CMakeLists.txt | D | 03-May-2024 | 2.1 KiB | 70 | 64 | |
Makefile.am | D | 03-May-2024 | 2.8 KiB | 80 | 35 | |
Makefile.inc | D | 03-May-2024 | 4.7 KiB | 157 | 91 | |
README.md | D | 03-May-2024 | 2.1 KiB | 67 | 46 | |
curlcheck.h | D | 03-May-2024 | 4.5 KiB | 102 | 63 | |
unit1300.c | D | 03-May-2024 | 7.3 KiB | 222 | 97 | |
unit1301.c | D | 03-May-2024 | 1.8 KiB | 55 | 21 | |
unit1302.c | D | 03-May-2024 | 5.7 KiB | 166 | 115 | |
unit1303.c | D | 03-May-2024 | 5.3 KiB | 150 | 84 | |
unit1304.c | D | 03-May-2024 | 8.1 KiB | 211 | 141 | |
unit1305.c | D | 03-May-2024 | 3.4 KiB | 135 | 87 | |
unit1307.c | D | 03-May-2024 | 14.6 KiB | 324 | 257 | |
unit1308.c | D | 03-May-2024 | 3 KiB | 96 | 48 | |
unit1309.c | D | 03-May-2024 | 3.6 KiB | 143 | 91 | |
unit1323.c | D | 03-May-2024 | 1.9 KiB | 67 | 38 | |
unit1330.c | D | 03-May-2024 | 1.2 KiB | 42 | 13 | |
unit1394.c | D | 03-May-2024 | 4.6 KiB | 132 | 100 | |
unit1395.c | D | 03-May-2024 | 2.6 KiB | 95 | 61 | |
unit1396.c | D | 03-May-2024 | 3.2 KiB | 116 | 78 | |
unit1397.c | D | 03-May-2024 | 3 KiB | 80 | 42 | |
unit1398.c | D | 03-May-2024 | 3.1 KiB | 91 | 42 | |
unit1399.c | D | 03-May-2024 | 4.1 KiB | 118 | 68 | |
unit1600.c | D | 03-May-2024 | 2.5 KiB | 72 | 36 | |
unit1601.c | D | 03-May-2024 | 1.7 KiB | 57 | 23 | |
unit1602.c | D | 03-May-2024 | 2.1 KiB | 79 | 43 | |
unit1603.c | D | 03-May-2024 | 5.9 KiB | 151 | 92 | |
unit1604.c | D | 03-May-2024 | 11.4 KiB | 359 | 312 | |
unit1605.c | D | 03-May-2024 | 1.6 KiB | 56 | 25 | |
unit1606.c | D | 03-May-2024 | 2.6 KiB | 90 | 55 | |
unit1607.c | D | 03-May-2024 | 6 KiB | 220 | 158 | |
unit1608.c | D | 03-May-2024 | 2 KiB | 75 | 38 | |
unit1609.c | D | 03-May-2024 | 6.3 KiB | 219 | 126 | |
unit1610.c | D | 03-May-2024 | 2 KiB | 61 | 27 | |
unit1611.c | D | 03-May-2024 | 1.8 KiB | 59 | 25 | |
unit1612.c | D | 03-May-2024 | 2.1 KiB | 67 | 33 | |
unit1620.c | D | 03-May-2024 | 2.7 KiB | 89 | 49 | |
unit1621.c | D | 03-May-2024 | 2.5 KiB | 92 | 59 | |
unit1650.c | D | 03-May-2024 | 9.2 KiB | 296 | 234 | |
unit1651.c | D | 03-May-2024 | 26.1 KiB | 389 | 349 | |
unit1652.c | D | 03-May-2024 | 4.4 KiB | 134 | 76 | |
unit1653.c | D | 03-May-2024 | 5.4 KiB | 193 | 144 | |
unit1654.c | D | 03-May-2024 | 4.1 KiB | 139 | 100 | |
unit1655.c | D | 03-May-2024 | 6.8 KiB | 191 | 128 |
README.md
1# Unit tests 2 3The goal is to add tests for *all* functions in libcurl. If functions are too 4big and complicated, we should split them into smaller and testable ones. 5 6## Build Unit Tests 7 8`./configure --enable-debug` is required for the unit tests to build. To 9enable unit tests, there will be a separate static libcurl built that will be 10used exclusively for linking unit test programs. Just build everything as 11normal, and then you can run the unit test cases as well. 12 13## Run Unit Tests 14 15Unit tests are run as part of the regular test suite. If you have built 16everything to run unit tests, to can do 'make test' at the root level. Or you 17can `cd tests` and `make` and then invoke individual unit tests with 18`./runtests.pl NNNN` where `NNNN` is the specific test number. 19 20## Debug Unit Tests 21 22If a specific test fails you will get told. The test case then has output left 23in the log/ subdirectory, but most importantly you can re-run the test again 24using gdb by doing `./runtests.pl -g NNNN`. That is, add a `-g` to make it 25start up gdb and run the same case using that. 26 27## Write Unit Tests 28 29We put tests that focus on an area or a specific function into a single C 30source file. The source file should be named 'unitNNNN.c' where NNNN is a 31previously unused number. 32 33Add your test to `tests/unit/Makefile.inc` (if it is a unit test). Add your 34test data file name to `tests/data/Makefile.inc` 35 36You also need a separate file called `tests/data/testNNNN` (using the same 37number) that describes your test case. See the test1300 file for inspiration 38and the `tests/FILEFORMAT.md` documentation. 39 40For the actual C file, here's a very simple example: 41~~~c 42#include "curlcheck.h" 43 44#include "a libcurl header.h" /* from the lib dir */ 45 46static CURLcode unit_setup( void ) 47{ 48 /* whatever you want done first */ 49 return CURLE_OK; 50} 51 52static void unit_stop( void ) 53{ 54 /* done before shutting down and exiting */ 55} 56 57UNITTEST_START 58 59 /* here you start doing things and checking that the results are good */ 60 61 fail_unless( size == 0 , "initial size should be zero" ); 62 fail_if( head == NULL , "head should not be initiated to NULL" ); 63 64 /* you end the test code like this: */ 65 66UNITTEST_STOP 67