• Home
Name Date Size #Lines LOC

..--

CMakeLists.txtD03-May-20241.3 KiB5650

Makefile.amD03-May-20242.8 KiB8035

Makefile.incD03-May-20243.4 KiB12182

READMED03-May-20242.2 KiB7149

curlcheck.hD03-May-20244.5 KiB10263

unit1300.cD03-May-20248.9 KiB272117

unit1301.cD03-May-20241.8 KiB5521

unit1302.cD03-May-20245.7 KiB166115

unit1303.cD03-May-20245.3 KiB15084

unit1304.cD03-May-20248.2 KiB215141

unit1305.cD03-May-20243.3 KiB14091

unit1307.cD03-May-202414.6 KiB324257

unit1308.cD03-May-20243 KiB9648

unit1309.cD03-May-20243.6 KiB14391

unit1323.cD03-May-20241.9 KiB6738

unit1330.cD03-May-20241.2 KiB4213

unit1394.cD03-May-20244.6 KiB13098

unit1395.cD03-May-20242.6 KiB9561

unit1396.cD03-May-20243.2 KiB11678

unit1397.cD03-May-20243 KiB8042

unit1398.cD03-May-20243.2 KiB9242

unit1399.cD03-May-20244.1 KiB11868

unit1600.cD03-May-20242.5 KiB7236

unit1601.cD03-May-20241.6 KiB5521

unit1602.cD03-May-20242.1 KiB7943

unit1603.cD03-May-20245.9 KiB15192

unit1604.cD03-May-202411.4 KiB358311

unit1605.cD03-May-20241.6 KiB5625

unit1606.cD03-May-20242.6 KiB9055

unit1607.cD03-May-20246.2 KiB226160

unit1608.cD03-May-20242 KiB7437

unit1609.cD03-May-20246.3 KiB219121

unit1620.cD03-May-20242.8 KiB9150

unit1621.cD03-May-20242.4 KiB9057

unit1650.cD03-May-20249.2 KiB295233

unit1651.cD03-May-202426 KiB389349

unit1652.cD03-May-20244.4 KiB13476

unit1653.cD03-May-20245.4 KiB193144

unit1654.cD03-May-20243.7 KiB12588

README

1Unit tests
2==========
3
4The goal is to add tests for *ALL* functions in libcurl. If functions are too
5big and complicated, we should split them into smaller and testable ones.
6
7Build Unit Tests
8================
9
10'./configure --enable-debug' is required for the unit tests to build. To
11enable unit tests, there will be a separate static libcurl built that will be
12used exclusively for linking unit test programs. Just build everything as
13normal, and then you can run the unit test cases as well.
14
15Run Unit Tests
16==============
17
18Unit tests are run as part of the regular test suite. If you have built
19everything to run unit tests, to can do 'make test' at the root level. Or you
20can 'cd tests' and 'make' and then invoke individual unit tests with
21./runtests.pl NNNN where NNNN is the specific test number.
22
23Debug Unit Tests
24================
25
26If a specific test fails you will get told. The test case then has output left
27in the log/ subdirectory, but most importantly you can re-run the test again
28using gdb by doing ./runtests.pl -g NNNN. That is, add a -g to make it start
29up gdb and run the same case using that.
30
31Write Unit Tests
32================
33
34We put tests that focus on an area or a specific function into a single C
35source file. The source file should be named 'unitNNNN.c' where NNNN is a
36number that starts with 1300 and you can pick the next free number.
37
38You also need a separate file called tests/data/testNNNN (using the same
39number) that describes your test case. See the test1300 file for inspiration
40and the tests/FILEFORMAT documentation.
41
42For the actual C file, here's a very simple example:
43
44----------------------- start -------------------------------
45#include "curlcheck.h"
46
47#include "a libcurl header.h" /* from the lib dir */
48
49static void unit_setup( void )
50{
51  /* whatever you want done first */
52}
53
54static void unit_stop( void )
55{
56  /* done before shutting down and exiting */
57}
58
59UNITTEST_START
60
61  /* here you start doing things and checking that the results are good */
62
63  fail_unless( size == 0 , "initial size should be zero" );
64  fail_if( head == NULL , "head should not be initiated to NULL" );
65
66  /* you end the test code like this: */
67
68UNITTEST_STOP
69
70----------------------- end -------------------------------
71