Home | History | Annotate | only in /external/curl/tests/unit
Up to higher level directory
NameDateSize
CMakeLists.txt21-Aug-20181.2K
curlcheck.h21-Aug-20184.5K
Makefile.am21-Aug-20182.7K
Makefile.inc21-Aug-20182.5K
README21-Aug-20182.2K
unit1300.c21-Aug-20188.9K
unit1301.c21-Aug-20181.8K
unit1302.c21-Aug-20185.7K
unit1303.c21-Aug-20185.3K
unit1304.c21-Aug-20186.8K
unit1305.c21-Aug-20183.3K
unit1307.c21-Aug-201812.3K
unit1308.c21-Aug-20183K
unit1309.c21-Aug-20183.6K
unit1323.c21-Aug-20181.9K
unit1330.c21-Aug-20181.2K
unit1394.c21-Aug-20184.4K
unit1395.c21-Aug-20182.6K
unit1396.c21-Aug-20183.2K
unit1397.c21-Aug-20183.1K
unit1398.c21-Aug-20183.2K
unit1399.c21-Aug-20184.1K
unit1600.c21-Aug-20182.5K
unit1601.c21-Aug-20181.6K
unit1602.c21-Aug-20182.1K
unit1603.c21-Aug-20185.9K
unit1604.c21-Aug-201811.2K
unit1605.c21-Aug-20181.6K
unit1606.c21-Aug-20182.6K

README

      1 Unit tests
      2 ==========
      3 
      4 The goal is to add tests for *ALL* functions in libcurl. If functions are too
      5 big and complicated, we should split them into smaller and testable ones.
      6 
      7 Build Unit Tests
      8 ================
      9 
     10 './configure --enable-debug' is required for the unit tests to build. To
     11 enable unit tests, there will be a separate static libcurl built that will be
     12 used exclusively for linking unit test programs. Just build everything as
     13 normal, and then you can run the unit test cases as well.
     14 
     15 Run Unit Tests
     16 ==============
     17 
     18 Unit tests are run as part of the regular test suite. If you have built
     19 everything to run unit tests, to can do 'make test' at the root level. Or you
     20 can 'cd tests' and then invoke individual unit tests with ./runtests.pl NNNN
     21 where NNNN is the specific test number.
     22 
     23 Debug Unit Tests
     24 ================
     25 
     26 If a specific test fails you will get told. The test case then has output left
     27 in the log/ subdirectory, but most importantly you can re-run the test again
     28 using gdb by doing ./runtests.pl -g NNNN. That is, add a -g to make it start
     29 up gdb and run the same case using that.
     30 
     31 Write Unit Tests
     32 ================
     33 
     34 We put tests that focus on an area or a specific function into a single C
     35 source file. The source file should be named 'unitNNNN.c' where NNNN is a
     36 number that starts with 1300 and you can pick the next free number.
     37 
     38 You also need a separate file called tests/data/testNNNN (using the same
     39 number) that describes your test case. See the test1300 file for inspiration
     40 and the tests/FILEFORMAT documentation.
     41 
     42 For 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 
     49 static void unit_setup( void )
     50 {
     51   /* whatever you want done first */
     52 }
     53 
     54 static void unit_stop( void )
     55 {
     56   /* done before shutting down and exiting */
     57 }
     58 
     59 UNITTEST_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 
     68 UNITTEST_STOP
     69 
     70 ----------------------- end -------------------------------
     71