]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
rc_cmdlength testing
authorLokesh Walase <lokeshw24@ntp.org>
Fri, 10 Jul 2015 18:49:36 +0000 (00:19 +0530)
committerLokesh Walase <lokeshw24@ntp.org>
Fri, 10 Jul 2015 18:49:36 +0000 (00:19 +0530)
bk: 55a013c0WYMjM88XOeEUvAZhQcuAXw

tests/ntpd/Makefile.am
tests/ntpd/rc_cmdlength.c [new file with mode: 0644]

index b372781deed0f2373567a7a4aa722e28b62589dc..e7dfeb5fa2bb220d20612806b0f6e30a92d0af35 100644 (file)
@@ -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 (file)
index 0000000..bd1ed5e
--- /dev/null
@@ -0,0 +1,22 @@
+#include "config.h"
+
+#include "ntp.h"
+#include "ntp_calendar.h"
+#include "ntp_stdlib.h"
+
+#include "unity.h"
+
+#include <string.h>
+
+#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 );
+}