Using Units Tests

Several Unit Tests are provided with TinyOWS archive (from OGC CITE one), we use them to check several kind of behaviour:

Valgrind Tests

  • To check memory leak, and inconsistent memory access
  • To launch the whole unit tests:
    make test-valgrind
    
  • Of course require valgrind (so a linux box)
  • No error should appears in report

On a debian like distribution, I need to add following Valgrind suppress items:

Related to libc6 (time.h):

{
   Debian ctime tz (libc6) I
   Memcheck:Leak
   fun:malloc
   fun:__tzstring
   fun:__tzfile_read
   fun:tzset_internal
   fun:__tz_convert
   fun:ctime
}
{
   Debian ctime tz (libc6) II
   Memcheck:Leak
   fun:malloc
   fun:strdup
   fun:tzset_internal
   fun:__tz_convert
   fun:ctime
}
{
   Debian ctime tz (libc6) III
   Memcheck:Leak
   fun:malloc
   fun:__tzfile_read
   fun:tzset_internal
   fun:__tz_convert
   fun:ctime
}

Related to Debian packaging (libpq)

{
   Debian PostgreSQL libpq
   Memcheck:Leak
   fun:malloc
   fun:set_binding_values
   fun:bindtextdomain
   obj:/usr/lib/libpq.so.5.2
}

Related to gethostbyname (libxml2)

{
   Debian libxml2
   Memcheck:Leak
   fun:malloc
   fun:gethostbyname
   obj:/usr/lib/libxml2.so.2.7.5
   fun:xmlNanoHTTPMethodRedir
   fun:xmlNanoHTTPMethod
   fun:__xmlParserInputBufferCreateFilename
   fun:xmlNewInputFromFile
   obj:/usr/lib/libxml2.so.2.7.5
   fun:xmlLoadExternalEntity
   fun:xmlCtxtReadFile
   obj:/usr/lib/libxml2.so.2.7.5
   obj:/usr/lib/libxml2.so.2.7.5
}

{
   Debian libxml2 II
   Memcheck:Leak
   fun:malloc
   fun:gethostbyname
   fun:xmlNanoHTTPConnectHost
   fun:xmlNanoHTTPMethodRedir
   fun:xmlNanoHTTPMethod
   fun:__xmlParserInputBufferCreateFilename
   fun:xmlNewInputFromFile
   fun:xmlDefaultExternalEntityLoader
   fun:xmlLoadExternalEntity
   fun:xmlCtxtReadFile
   fun:xmlSchemaAddSchemaDoc
   fun:xmlSchemaParseSchemaTopLevel
}

Output Tests

Test Output

  • Output on stdout the whole unit tests
  • Could be interresting to have a look on TinyOWS output, to check that PostgreSQL logs are cleans...
    make test-output
    

Test http

  • A bit the same than output, but use real HTTP connection and (F)CGI rather than local binary
  • Notice: HTTP headers and file name are also printed.
    make test-http
    

Test exception

  • Output every unit test producing OWS or WFS Exception, and print the related exception message
  • (A lot of exception messages are prefectly normals output on tests)
    make test-exception
    

Test on Stderr

  • Print every unit test who produce an sterr message
  • Aim is to have no results here
    make test-stderr
    

Howto Launch a single unit test

ALWAYS launch the unit test from the TinyOWS root dir.

  • Valgrind one:
    test/unit_test UNIT_TEST_FILEPATH 1
    
  • Valgrind verbose one:
    test/unit_test UNIT_TEST_FILEPATH 2
    
  • TinyOWS Output:
    test/unit_test UNIT_TEST_FILEPATH 3
    
  • TinyOWS HTTP Output
    test/unit_test UNIT_TEST_FILEPATH 4
    
  • TinyOWS OWS/WFS Exceptions
    test/unit_test UNIT_TEST_FILEPATH 5
    
  • TinyOWS Stderr
    test/unit_test UNIT_TEST_FILEPATH 6