#EXTRA_PROGRAMS += test-packetHandling test-packetProcessing
check_PROGRAMS = \
+ test-log \
test-crypto \
test-keyFile \
test-kodDatabase \
$(top_builddir)/version.c \
$(NULL)
+test_log_SOURCES = \
+ t-log.c \
+ run-t-log.c \
+ $(top_builddir)/version.c \
+ $(NULL)
+
$(srcdir)/run-kodFile.c: $(srcdir)/kodFile.c $(std_unity_list)
$(run_unity) kodFile.c run-kodFile.c
$(srcdir)/run-crypto.c: $(srcdir)/crypto.c $(std_unity_list)
$(run_unity) crypto.c run-crypto.c
+$(srcdir)/run-t-log.c: $(srcdir)/t-log.c $(std_unity_list)
+ $(run_unity) t-log.c run-t-log.c
+
+
#$(srcdir)/../version.c: $(srcdir)/../version.c
# gcc -o version.o ../version.c
--- /dev/null
+/* AUTOGENERATED FILE. DO NOT EDIT. */
+
+//=======Test Runner Used To Run Each Test Below=====
+#define RUN_TEST(TestFunc, TestLineNum) \
+{ \
+ Unity.CurrentTestName = #TestFunc; \
+ Unity.CurrentTestLineNumber = TestLineNum; \
+ Unity.NumberOfTests++; \
+ if (TEST_PROTECT()) \
+ { \
+ setUp(); \
+ TestFunc(); \
+ } \
+ if (TEST_PROTECT() && !TEST_IS_IGNORED) \
+ { \
+ tearDown(); \
+ } \
+ UnityConcludeTest(); \
+}
+
+//=======Automagically Detected Files To Include=====
+#include "unity.h"
+#include <setjmp.h>
+#include <stdio.h>
+#include "config.h"
+#include "ntp_types.h"
+#include "log.h"
+
+//=======External Functions This Runner Calls=====
+extern void setUp(void);
+extern void tearDown(void);
+extern void testChangePrognameInMysyslog(void);
+extern void testWriteInCustomLogfile(void);
+
+
+//=======Test Reset Option=====
+void resetTest(void);
+void resetTest(void)
+{
+ tearDown();
+ setUp();
+}
+
+const char *progname;
+
+
+//=======MAIN=====
+int main(int argc, char *argv[])
+{
+ progname = argv[0];
+ UnityBegin("t-log.c");
+ RUN_TEST(testChangePrognameInMysyslog, 9);
+ RUN_TEST(testWriteInCustomLogfile, 32);
+
+ return (UnityEnd());
+}
--- /dev/null
+#include "config.h"
+#include "unity.h"
+#include "ntp_types.h"
+
+//#include "sntptest.h"
+//#include "crypto.h"
+#include "log.h"
+
+void testChangePrognameInMysyslog(void);
+//void testOpenLogfileTest(void);
+
+
+//in var/log/syslog (may differ depending on your OS), logged name of the program will be "TEST_PROGNAME".
+
+void testChangePrognameInMysyslog(void){
+ sntp_init_logging("TEST_PROGNAME");
+ msyslog(LOG_ERR, "TESTING sntp_init_logging()"); //%m will print the last errno?
+}
+
+//writes log files in your own file instead of syslog! (MAY BE USEFUL TO SUPPRESS ERROR MESSAGES!)
+/*
+void testOpenLogfileTest(void){
+ sntp_init_logging("TEST_PROGNAME2"); //this name is consistent through the entire program unless changed
+ open_logfile("testLogfile.log");
+ //open_logfile("/var/log/syslog"); //this gives me "Permission Denied" when i do %m
+
+ msyslog(LOG_ERR, "Cannot open log file %s","abcXX");
+ //msyslog(LOG_INFO, "%s", "eee");
+}
+*/
+
+//multiple cleanup_log() causes segfault. Probably the reason it's static. Opening multiple open_logfile(name) will cause segfault x.x I'm guessing it's not intended to be changed. Cleanup after unity test doesn't fix it, looks like. Tried using counter's to only call atexit once, didn't help???
+
+void testWriteInCustomLogfile(void){
+ char testString[256] = "12345 ABC";
+ char testName[256] = "TEST_PROGNAME3";
+
+ remove("testLogfile2.log");
+
+ sntp_init_logging(testName);
+ open_logfile("testLogfile2.log"); // ./ causing issues
+ //sntp_init_logging(testName);
+
+
+ msyslog(LOG_ERR, testString);
+ FILE * f = fopen("testLogfile2.log","r");
+ char line[256];
+
+ //should be only 1 line
+ while (fgets(line, sizeof(line), f)) {
+ printf("%s", line);
+ }
+
+
+ char* x = strstr(line,testName);
+
+ TEST_ASSERT_TRUE( x != NULL);
+
+ x = strstr(line,testString);
+ TEST_ASSERT_TRUE( x != NULL);
+
+ //fclose(f); //using this will also cause segfault, because at the end, log.c will call (using atexit(func) function) cleanup_log(void)-> fclose(syslog_file); After the 1st fclose, syslog_file = NULL, and is never reset
+ //TEST_ASSERT_EQUAL_STRING(testString,line); //doesn't work, line is dynamic because the process name is random.
+}
+
+
bug-2803 \
libntp \
sec-2853 \
+ ntpq \
$(NULL)
DIST_SUBDIRS += \
ntpd \
sandbox \
sec-2853 \
+ ntpq \
$(NULL)
--- /dev/null
+NULL =
+BUILT_SOURCES =
+CLEANFILES =
+
+std_unity_list = \
+ $(top_srcdir)/sntp/unity/auto/generate_test_runner.rb \
+ $(NULL)
+
+run_unity = cd $(srcdir) && ruby ../../sntp/unity/auto/generate_test_runner.rb
+
+check_PROGRAMS = \
+ test-ntp_scanner \
+ test-ntp_signd \
+ $(NULL)
+
+
+LDADD = \
+ $(top_builddir)/ntpd/libntpd.a \
+ $(top_builddir)/libntp/libntp.a \
+ $(LDADD_LIBNTP) \
+ $(PTHREAD_LIBS) \
+ $(LDADD_NTP) \
+ $(GTEST_LDFLAGS) \
+ $(GTEST_LIBS) \
+ $(NULL)
+
+unity_tests_LDADD = \
+ $(LDADD) \
+ $(top_builddir)/sntp/unity/libunity.a \
+ $(LIBM) \
+ $(NULL)
+
+AM_CFLAGS = $(CFLAGS_NTP)
+AM_CXXFLAGS = $(GTEST_CXXFLAGS)
+
+AM_CPPFLAGS += -I$(top_srcdir)/ntpq
+
+AM_CPPFLAGS = $(NTP_INCS)
+#AM_CPPFLAGS += -I$(top_srcdir)/sntp
+#AM_CPPFLAGS += -I$(top_srcdir)/ntpd
+#AM_CPPFLAGS += -I$(top_srcdir)/tests/libntp
+AM_CPPFLAGS += $(GTEST_CPPFLAGS)
+AM_CPPFLAGS += $(CPPFLAGS_NTP)
+AM_CPPFLAGS += -DUNITY_INCLUDE_CONFIG_H
+AM_CPPFLAGS += -I$(top_srcdir)/sntp/unity
+
+AM_LDFLAGS = $(LDFLAGS_NTP)
+
+tests_SOURCES = $(top_srcdir)/sntp/tests_main.cpp \
+ t-ntp_signd.c \
+ $(NULL)
+
+BUILT_SOURCES += \
+ $(srcdir)/run-rc_cmdlength.c \
+ $(srcdir)/run-t-ntp_signd.c \
+ $(NULL)
+
+noinst_HEADERS = g_ntpdtest.h \
+ $(srcdir)/../libntp/test-libntp.h \
+ $(srcdir)/../libntp/sockaddrtest.h \
+ $(NULL)
+
+###
+test_ntp_signd_CFLAGS = \
+ -I$(top_srcdir)/sntp/unity \
+ -Iwhy.h \
+ $(NULL)
+
+test_ntp_signd_LDADD = \
+ $(unity_tests_LDADD) \
+ $(top_builddir)/ntpd/libntpd.a \
+ $(unity_tests_LDADD) \
+ $(top_builddir)/ntpd/ntp_config.o \
+ $(top_builddir)/ntpd/ntp_io.o \
+ $(NULL)
+
+# $(top_builddir)/ntpd/ntp_signd.o #not needed if you #include the file.c
+
+test_ntp_signd_SOURCES = \
+ t-ntp_signd.c \
+ run-t-ntp_signd.c \
+ $(srcdir)/../libntp/test-libntp.c \
+ $(srcdir)/../../ntpd/ntp_signd.c \
+ $(NULL)
+
+$(srcdir)/run-t-ntp_signd.c: $(srcdir)/t-ntp_signd.c $(std_unity_list)
+ $(run_unity) t-ntp_signd.c run-t-ntp_signd.c
+
+###
+test_ntp_scanner_CFLAGS = \
+ -I$(top_srcdir)/sntp/unity \
+ $(NULL)
+
+test_ntp_scanner_LDADD = \
+ $(unity_tests_LDADD) \
+ $(top_builddir)/ntpd/ntp_scanner.o \
+ $(NULL)
+
+test_ntp_scanner_SOURCES = \
+ ntp_scanner.c \
+ run-ntp_scanner.c \
+ $(srcdir)/../libntp/test-libntp.c \
+ $(NULL)
+
+$(srcdir)/run-ntp_scanner.c: $(srcdir)/ntp_scanner.c $(std_unity_list)
+ $(run_unity) ntp_scanner.c run-ntp_scanner.c
+
+
+
+TESTS =
+
+if !NTP_CROSSCOMPILE
+TESTS += $(check_PROGRAMS)
+endif
+
+## check-libntp.mf - automake fragment
+## slightly adapted for deeper directory
+
+BUILT_SOURCES += check-libntpd check-libntp check-libunity
+CLEANFILES += check-libntpd check-libntp check-libunity
+
+check-libntpd: ../../ntpd/libntpd.a
+ @echo stamp > $@
+
+../../ntpd/libntpd.a:
+ cd ../../ntpd && $(MAKE) $(AM_MAKEFLAGS) libntpd.a
+
+
+check-libntp: ../../libntp/libntp.a
+ @echo stamp > $@
+
+../../libntp/libntp.a:
+ cd ../../libntp && $(MAKE) $(AM_MAKEFLAGS) libntp.a
+
+
+check-libunity: ../../sntp/unity/libunity.a
+ @echo stamp > $@
+
+../../sntp/unity/libunity.a:
+ cd ../../sntp/unity && $(MAKE) $(AM_MAKEFLAGS) libunity.a
+
+$(top_builddir)/ntpd/ntpdsim-ntp_prio_q.o:
+ cd ../../ntpd/ && $(MAKE) $(AM_MAKEFLAGS) ntpdsim-ntp_prio_q.o
+
+include $(top_srcdir)/depsver.mf
+include $(top_srcdir)/includes.mf