Commit Graph
44 Commits
Author SHA1 Message Date
Olaf Bergmann db48a839b6 test_uri.c: additional unit tests for URI creation
Added several unit tests for coap_get_uri_path():

* Check corner cases such as one or more zero-length Uri-Paths.
* Check percent-encoding of reserved characters.
* Check non-reserved characters that should not be percent-encoded.

This change also removes a couple of trailing LWS by accident.
2018-04-04 17:40:03 +02:00
Jon Shallow 1d61c32fee tests/test_uri.c: Update to use uri_path instead of key for resource hash. 2018-04-04 16:19:36 +01:00
Olaf Bergmann 8f9ca22e05 tests: add unit tests for session handling
This change adds an initial set of unit tests for sessions:

* reference counting and release
* timeout calculation
2018-03-06 16:45:28 +01:00
Olaf Bergmann 67291e397b tests: revert commit a3da53d to re-enable IPv6 in unit tests 2018-02-15 20:05:01 +01:00
Olaf Bergmann c74e1da5a9 tests: add unit test boilerplate for (D)TLS
A simple structure for (D)TLS-specific unit tests has been added.
Currently, only general support and the version number as reported
by coap_get_tls_library_version() are checked.
2018-02-14 17:28:37 +01:00
Olaf Bergmann a3da53d5e3 tests: use IPv4 in unit tests for robustness
As unit tests with IPv6 addresses keep failing on docker-based
travis CI, this changes reverts to IPv4 usage in following files:

    test_wellknown.c
    test_sendqueue.c
2018-02-14 16:06:52 +01:00
jcmichelou f81cb43fd3 session, pdu: Enforce maximum message size. 2017-10-21 16:11:12 +02:00
jcmichelou dfff930805 io, net: Add TCP accept/connect/read/write 2017-10-21 16:11:12 +02:00
jcmichelou bcfd7a0753 pdu: add support for TCP-style headers
Make coap_pdu-t independent of the header style.
Use C99 sized types when applicable.
Use transaction ids in host byte order in the library.
Make coap_pdu_t payload storage grow on demand.
Add parsing and encoding of PDUs with UDP or TCP style headers.
Adapt examples and unit tests to the new PDU format.
2017-10-21 16:11:11 +02:00
Diego Santa Cruz 9b12571804 Makefile.am: fix building outside of source tree
When building outside the source tree compilation fails on
examples, because the libcoap headers expect to be all in the
same directory but coap.h is generated under the build
directory, so it is necessary to add an extra include path
for it.

Also, build directories should always appear before source
directories in the include path, so that any leftover
generated files in the source tree are ignored.
2017-09-20 10:48:54 +02:00
Olaf Bergmann 5687681d71 {tests/examples}/Makefile.am: add DTLS variables for static linkage
Statically linked executables require DTLS_CFLAGS and DTLS_LIBS.
2017-07-10 15:33:39 +02:00
Olaf Bergmann 4c38c6a7b2 test_{sendqueue,wellknown}.c: use new session-specific API
Sendqueue nodes and send operations now require a session object.
This modification calls coap_new_client_session() on a global
coap_context_t object to create a fake session on the loopback
interface.
2017-07-10 14:21:36 +02:00
jcmichelou b2fe4a64de Make MTU configurable.
Use static or stack storage for coap_packet_t.
2017-06-26 17:34:01 +02:00
jcmichelou 9b647d5d05 Add visual studio 2015 solution and project files for building libcoap on windows.
Merge changes from PR #47 related to windows platform support.
Add full windows platform support including correct error checking and working regression tests and examples.
Remove need to build applications using libcoap with -DWITH_POSIX and to include coap_config.h. This applies to the examples as well.
2017-05-05 20:29:10 +02:00
Olaf Bergmann d7763a295a test_options.c: unit test for extended delta
PR #65 reports wrong encoding of option value 269. The new
unit test t_encode_option9() tests for correct encoding
according to [RFC 7252, Section 3.1](https://tools.ietf.org/html/rfc7252#section-3.1).
2017-03-08 11:05:31 +01:00
Olaf Bergmann df2a6d1f10 test_error_response.c: free storage from responses
Free the storage allocated by coap_new_error_response() in unit tests.
This change simplifies automated leak checks as it avoids cluttering
the output with almost false positives.
2016-12-02 13:18:38 +01:00
Olaf Bergmann 731a3f7cbb test_pdu.c: fix condition inside CUnit assertion
The test condition accidentally contained an assignment instead
of the equal operator.
2016-12-01 17:11:11 +01:00
Carsten Schoenert 18f2309759 make: enable out of tree build
The build environment was lacking the possibility to get libcoap
buildable out of tree, simply checkable by the running 'make distcheck'.
Without this fix the users are impossible to build libcoap in a own
folder that's independed from the source containing folder. Typical use
case would be:

  $ mkdir libcoap-build && cd libcoap-build
  $ /path/to/libcoap-source/configure \
      --srcdir=/path/to/libcoap-source \
      --prefix=/somethere/to-install

This commit enables the out of tree build by adding and changing some
needed variables.
2016-10-26 10:46:50 +02:00
Carsten Schoenert 7df48fc897 tests/Makefile.am: adding CUNIT_CFLAGS to AM_CFLAGS
The CUNIT_LIBS are already used, the CUNIT_CFLAGS are also needed to
ensure that get also header files that are not inside the default search
patch of the compiler. For example header within /usr/local/include
instead /usr/include.

CUNIT_LIBS and CUNIT_CFLAGS are generated by PKG_CHECK_MODULES([CUNIT] ...
in configure.ac.
2016-10-26 10:46:50 +02:00
Olaf Bergmann 5567ea3613 test_uri.c: additional unit tests for option encoding
These tests cover the Uri-Query encoding bug.
2016-06-10 13:43:38 +02:00
Carsten Schoenert 63924379e3 testdriver: switch linking to the shared library
The testdriver was linked against the statically generated library of
libcoap. By this the testdriver will *always* find any symbols, no
matter if it is a private or public symbol.
Due this the testing behavior isn't the same as a user would use the
shared library and can get a potentially pitfall even if the testdriver
was successful.

Due previous changes to the public header the testdriver source needs
now the local header coap_config.h to find all needed functions so there
are small changes needed to the source files.
2015-07-04 19:35:10 +02:00
Olaf Bergmann 774fc01ec1 tests: temporarily change log-level to remove expected warnings
Some unit tests in tests/test_options.c and tests/test_pdu.c check
for error cases, causing warning messages to be emitted by the
library code. As the expected result is checked separately, the
warnings can be suppressed to avoid confusion.
2015-06-07 12:32:09 +02:00
Olaf Bergmann 8e73295b66 tests/test_options.c: Added unit tests for option filters
A new test suite 'option filter' was added to the CUnit tests to
check correctness of the new option filter implementation.
2015-06-07 12:21:58 +02:00
Olaf Bergmann 83c17e8f17 testdriver.c: Remove comment on known bugs
With commit eec9ad2, the two outstanding bugs in the test suite
have been fixed.
2015-06-07 12:21:57 +02:00
Olaf Bergmann eb2251f06f Update boilerplate text in testdriver
The errors in the URI parser test suite have been fixed,
making the description in testdriver.c obsolete.
2015-03-09 18:30:20 +01:00
Olaf Bergmann 04e1d8e7de Make test data unsigned to shut up compiler warnings. 2015-03-09 14:59:22 +01:00
Olaf Bergmann fa3f09cdb7 Fix warnings in unit tests 2015-03-04 15:10:09 +01:00
Carsten Schoenert 96d875ab7a CFLAGS: reorder the various CFLAGS inside the files
Doing up some housekeeping around the used CFLAGS.
To be more generic put the default declaration for additional warning
CFLAGS into configure.ac and clean up the Makefile.am's.

There are the default CFLAGS variable that is a global variable if not
re adjusted inside the different targets.

The second variable for CFLAGS is the AM_CFLAGS definition that is used
inside a Makefile as a global variable.

There is also the possibility to graduate the CFLAGS for a single
target. But currently there are nothing more than one target within each
Makefile so we can set for now the target specific CFLAGS to the
AM_CFLAGS.

A new variable called WARNING_CFLAGS is inside the configure.ac created,
this variable holds all the warnings flags inside. The Makefile.am's are
taking the values and is setting the variable AM_CFLAGS which is used in
the target specific CFLAGS. Also the options 'DWITH_POSIX' and
'D_GNU_SOURCE' are now appended to the CFLAGS if the configure script is
detecting a *-[uc]linux* system.
2015-03-03 19:21:43 +01:00
Carsten Schoenert c9c1a80271 adding the tests/ folder to the build environment
To let the previous added configure option '--enable-tests' really build
the testdriver binary adding the needed changes to the files in the main
folder.
Finally adding a new Makefile.am within the tests/ folder.
2015-03-03 19:21:43 +01:00
Olaf Bergmann 652bdd5f63 resolved conflict after cherry-picking from branch relative-timestamps 2014-02-05 15:04:39 +01:00
Olaf Bergmann a4358bd2ce added tests for relative timestamps 2014-02-05 14:53:58 +01:00
Olaf Bergmann 160f570c6f include tests with distribution 2014-02-04 18:15:26 +01:00
Olaf Bergmann 660deefe73 Support for block-wise transfer of /.well-known/core. 2014-02-04 17:56:31 +01:00
Olaf Bergmann a391c9e9cb Fixed delta for Accept option.
The number has changed from 16 to 17 in coap-18.
2014-02-04 17:48:45 +01:00
Olaf Bergmann 05713f48e8 Unit tests for the new functionality of coap_print_link() and print_wellknown() 2014-01-07 17:37:49 +01:00
Olaf Bergmann ada296efaf added new test cases for error response generation
test t_error_response8 will fail when COAP_MAX_OPT < 2000
2013-09-03 14:07:16 +02:00
Olaf Bergmann 5d9ba55303 option number for Accept has changed in coap-18, fixed test_encode_pdu5() 2013-09-03 13:51:30 +02:00
Olaf Bergmann b376fccf2d add missing licensing information when creating tar archive 2013-01-24 16:59:26 +01:00
Olaf Bergmann 5026b5e59a more tests 2013-01-18 16:44:36 +01:00
Olaf Bergmann 961a0b0e4d check default hash value for '.well-known/core' 2013-01-18 15:20:39 +01:00
Olaf Bergmann 3e0c8280c9 more tests 2013-01-15 16:51:12 +01:00
Olaf Bergmann cd10925056 modified option parser 2013-01-11 11:32:22 +01:00
Olaf Bergmann 019a922918 document known bugs 2013-01-07 17:48:09 +01:00
Olaf Bergmann c6412f2038 Rework of option parser to support "Klaus encoding" (coap-13), unit tests
The subdirectory "tests" now contains a growing set of unit tests for the
libcoap API. To use this, you will need CUnit (see http://cunit.sourceforge.net)
and must configure with the option --with-tests.
2013-01-07 17:37:49 +01:00