From 87a7a044d58a518740f2a14e2266b5631c4aee10 Mon Sep 17 00:00:00 2001 From: Andrew Moss <1043609+amoss@users.noreply.github.com> Date: Thu, 7 Nov 2019 15:29:43 +0100 Subject: Initial CMocka testing against web_client.c (issue #7229). (#7264) * Start of unit-test for http request processing. A CMocka test-driver has been added to replay the live-capture headers against the http request processing code. Enough stubs / mocking code have been written to check that we can inject a chosen raw request into the web_client code and check how it was processed. A parameterised buffer building function can setup requests for testing in `web_buffer` structures. Each endpoint in the API will be checked against a variety of http requests. This PoC demonstrates enough functionality to show building the request on demand for each test-case and cleaning up afterwards. --- Makefile.am | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'Makefile.am') diff --git a/Makefile.am b/Makefile.am index ccd26d1f7f..094581bcc0 100644 --- a/Makefile.am +++ b/Makefile.am @@ -644,10 +644,32 @@ if ENABLE_UNITTESTS check_PROGRAMS = \ libnetdata/tests/str2ld_testdriver \ libnetdata/storage_number/tests/storage_number_testdriver \ + web/api/tests/web_api_testdriver \ $(NULL) TESTS = $(check_PROGRAMS) + web_api_tests_web_api_testdriver_LDFLAGS = \ + -Wl,--wrap=rrdhost_find_by_hostname \ + -Wl,--wrap=finished_web_request_statistics \ + -Wl,--wrap=config_get \ + -Wl,--wrap=web_client_api_request_v1 \ + -Wl,--wrap=rrdhost_find_by_guid \ + -Wl,--wrap=rrdset_find_byname \ + -Wl,--wrap=rrdset_find \ + -Wl,--wrap=rrdpush_receiver_thread_spawn \ + -Wl,--wrap=debug_int \ + -Wl,--wrap=error_int \ + -Wl,--wrap=info_int \ + $(TEST_LDFLAGS) \ + $(NULL) + web_api_tests_web_api_testdriver_SOURCES = \ + web/api/tests/web_api.c \ + web/server/web_client.c \ + $(LIBNETDATA_FILES) \ + $(NULL) + web_api_tests_web_api_testdriver_LDADD = $(NETDATA_COMMON_LIBS) $(TEST_LIBS) + libnetdata_tests_str2ld_testdriver_SOURCES = \ libnetdata/tests/test_str2ld.c \ $(LIBNETDATA_FILES) \ -- cgit v1.2.3