From: Lokesh Walase Date: Fri, 10 Jul 2015 18:49:36 +0000 (+0530) Subject: rc_cmdlength testing X-Git-Tag: NTP_4_3_65~7^2~11^2~1 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=affa49f5e0992379cb41aa63c1e7bbbf347cde2e;p=thirdparty%2Fntp.git rc_cmdlength testing bk: 55a013c0WYMjM88XOeEUvAZhQcuAXw --- diff --git a/tests/ntpd/Makefile.am b/tests/ntpd/Makefile.am index b372781de..e7dfeb5fa 100644 --- a/tests/ntpd/Makefile.am +++ b/tests/ntpd/Makefile.am @@ -6,6 +6,7 @@ run_unity = cd $(srcdir) && ruby ../../sntp/unity/auto/generate_test_runner.rb check_PROGRAMS = \ test-leapsec \ + test-rc_cmdlength \ $(NULL) if GTEST_AVAILABLE @@ -47,11 +48,13 @@ AM_LDFLAGS = $(LDFLAGS_NTP) tests_SOURCES = $(top_srcdir)/sntp/tests_main.cpp \ g_ntpdtest.cpp \ $(top_srcdir)/ntpd/ntp_leapsec.c \ + $(top_srcdir)/ntpd/rc_cmdlength.c \ g_leapsec.cpp \ $(NULL) BUILT_SOURCES += \ $(srcdir)/run-leapsec.c \ + $(srcdir)/run-rc_cmdlength.c \ $(NULL) noinst_HEADERS = g_ntpdtest.h \ @@ -78,6 +81,23 @@ $(srcdir)/run-leapsec.c: $(srcdir)/leapsec.c $(std_unity_list) $(run_unity) leapsec.c run-leapsec.c ### +test_rc_cmdlength_CFLAGS = \ + -I$(top_srcdir)/sntp/unity \ + $(NULL) + +test_rc_cmdlength_LDADD = \ + $(unity_tests_LDADD) \ + $(NULL) + +test_rc_cmdlength_SOURCES = \ + rc_cmdlength.c \ + run-rc_cmdlength.c \ + $(srcdir)/../libntp/test-libntp.c \ + $(NULL) + +$(srcdir)/run-rc_cmdlength.c: $(srcdir)/rc_cmdlength.c $(std_unity_list) + $(run_unity) rc_cmdlength.c run-rc_cmdlength.c + TESTS = diff --git a/tests/ntpd/rc_cmdlength.c b/tests/ntpd/rc_cmdlength.c new file mode 100644 index 000000000..bd1ed5e86 --- /dev/null +++ b/tests/ntpd/rc_cmdlength.c @@ -0,0 +1,22 @@ +#include "config.h" + +#include "ntp.h" +#include "ntp_calendar.h" +#include "ntp_stdlib.h" + +#include "unity.h" + +#include + +#include "test-libntp.h" + + +void +test_EvaluateCommandLength(void){ + const char *src_buf = "This is random command"; + const char *src_end = "This is random command"; + + size_t commandLength = remoteconfig_cmdlength(src_buf, src_end); + + TEST_ASSERT_EQUAL(strlen(src_buf), commandLength ); +}