]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
run-ntp_restrict.c:
authorTomek Mrugalski <tomasz@isc.org>
Sat, 25 Jul 2015 00:08:32 +0000 (02:08 +0200)
committerTomek Mrugalski <tomasz@isc.org>
Sat, 25 Jul 2015 00:08:32 +0000 (02:08 +0200)
  autogenerated, but modified manually...
Makefile.am:
  removed something not longer in use
ntp_restrict.c:
  added another test
run-ntp_restrict.c, run-ntp_prio_q.c, run-sec-2853.c, run-bug-2803.c:
  autogenerated

bk: 55b2d380HUq9jTlGTeTacIN_VA18xQ

tests/bug-2803/run-bug-2803.c
tests/ntpd/Makefile.am
tests/ntpd/ntp_restrict.c
tests/ntpd/run-ntp_prio_q.c
tests/ntpd/run-ntp_restrict.c
tests/sec-2853/run-sec-2853.c

index 8382c5aa898a2b636497d0cb70f8525d4398437d..05e6a5d03c45ddf79f473387c961ad6dd7e0574c 100644 (file)
 #include "unity.h"
 #include <setjmp.h>
 #include <stdio.h>
+#include <config.h>
+#include <stdio.h>
+#include <sys/time.h>
+#include <ntp_fp.h>
+#include <timevalops.h>
 
 //=======External Functions This Runner Calls=====
 extern void setUp(void);
 extern void tearDown(void);
-void resetTest(void);
 extern void test_main(void );
 
 
 //=======Test Reset Option=====
-void resetTest()
+void resetTest(void);
+void resetTest(void)
 {
   tearDown();
   setUp();
 }
 
-char *progname;
+char const *progname;
 
 
 //=======MAIN=====
 int main(int argc, char *argv[])
 {
   progname = argv[0];
-  Unity.TestFile = "bug-2803.c";
   UnityBegin("bug-2803.c");
   RUN_TEST(test_main, 18);
 
index edfb8fdd03bfca563e4a511a2275daa4523332d3..49bd20bb5add1aee51c6026ba4197721e201cdf0 100644 (file)
@@ -181,8 +181,5 @@ check-libunity: ../../sntp/unity/libunity.a
 $(top_builddir)/ntpd/ntpdsim-ntp_prio_q.o:
        cd ../../ntpd/ && $(MAKE) $(AM_MAKEFLAGS) ntpdsim-ntp_prio_q.o
 
-#$(top_builddir)/ntpd/ntpdsim-ntp_restrict.o:
-#      cd ../../ntpd/ && $(MAKE) $(AM_MAKEFLAGS) ntpdsim-ntp_restrict.o
-
 include $(top_srcdir)/depsver.mf
 include $(top_srcdir)/includes.mf
index 285b5b24818896b984d1a726a91e938b4360386a..98d6e83093380f010759e9668d4c57c2cbd84b82 100644 (file)
@@ -141,7 +141,7 @@ test_AddingNewRestriction(void) {
 
 void
 test_TheMostFittingRestrictionIsMatched(void) {
-       sockaddr_u resaddr = create_sockaddr_u(AF_INET, 54321, "11.22.33.44");
+       sockaddr_u resaddr_target = create_sockaddr_u(AF_INET, 54321, "11.22.33.44");
 
        sockaddr_u resaddr_not_matching = create_sockaddr_u(AF_INET, 54321, "11.99.33.44");
        sockaddr_u resmask_not_matching = create_sockaddr_u(AF_INET, 54321, "255.255.0.0");
@@ -157,13 +157,13 @@ test_TheMostFittingRestrictionIsMatched(void) {
        hack_restrict(RESTRICT_FLAGS, &resaddr_best_match, &resmask_best_match, 0, 22, 0);
        hack_restrict(RESTRICT_FLAGS, &resaddr_second_match, &resmask_second_match, 0, 128, 0);
 
-       TEST_ASSERT_EQUAL(22, restrictions(&resaddr));
+       TEST_ASSERT_EQUAL(22, restrictions(&resaddr_target));
 }
 
 
 void
 test_DeletedRestrictionIsNotMatched(void) {
-       sockaddr_u resaddr = create_sockaddr_u(AF_INET, 54321, "11.22.33.44");
+       sockaddr_u resaddr_target = create_sockaddr_u(AF_INET, 54321, "11.22.33.44");
 
        sockaddr_u resaddr_not_matching = create_sockaddr_u(AF_INET, 54321, "11.99.33.44");
        sockaddr_u resmask_not_matching = create_sockaddr_u(AF_INET, 54321, "255.255.0.0");
@@ -181,5 +181,18 @@ test_DeletedRestrictionIsNotMatched(void) {
        /* deleting the best match*/
        hack_restrict(RESTRICT_REMOVE, &resaddr_best_match, &resmask_best_match, 0, 22, 0);
 
-       TEST_ASSERT_EQUAL(128, restrictions(&resaddr));
+       TEST_ASSERT_EQUAL(128, restrictions(&resaddr_target));
+}
+
+
+void
+test_RestrictUnflagWorks(void) {
+       sockaddr_u resaddr = create_sockaddr_u(AF_INET, 54321, "11.22.30.20");
+       sockaddr_u resmask = create_sockaddr_u(AF_INET, 54321, "255.255.0.0");
+
+       hack_restrict(RESTRICT_FLAGS, &resaddr, &resmask, 0, 11, 0);
+
+       hack_restrict(RESTRICT_UNFLAG, &resaddr, &resmask, 0, 10, 0);
+
+       TEST_ASSERT_EQUAL(1, restrictions(&resaddr));
 }
index dc33e075911ab7edb81c125efcce28ee4485d79a..35af443de58e2dceb6c2d947f3949f89f3cf5e0c 100644 (file)
 #include "unity.h"
 #include <setjmp.h>
 #include <stdio.h>
+#include "config.h"
+#include "ntp.h"
+#include "ntp_calendar.h"
+#include "ntp_stdlib.h"
+#include "ntp_prio_q.h"
+#include <string.h>
 
 //=======External Functions This Runner Calls=====
 extern void setUp(void);
 extern void tearDown(void);
-void resetTest(void);
 extern void test_AllocateDeallocateNode(void);
 extern void test_EmptyQueue(void);
 extern void test_OneElementQueue(void);
@@ -37,20 +42,20 @@ extern void test_AppendQueues(void);
 
 
 //=======Test Reset Option=====
-void resetTest()
+void resetTest(void);
+void resetTest(void)
 {
   tearDown();
   setUp();
 }
 
-char *progname;
+char const *progname;
 
 
 //=======MAIN=====
 int main(int argc, char *argv[])
 {
   progname = argv[0];
-  Unity.TestFile = "ntp_prio_q.c";
   UnityBegin("ntp_prio_q.c");
   RUN_TEST(test_AllocateDeallocateNode, 39);
   RUN_TEST(test_EmptyQueue, 46);
index 26b1ef66b14fc84a4b3010b138728ec56bab0f9c..89fd457342c9d72ddc05ab84341662cf89be75f9 100644 (file)
 #include "unity.h"
 #include <setjmp.h>
 #include <stdio.h>
+#include "config.h"
+#include "ntpd.h"
+#include "ntp_lists.h"
 
 //=======External Functions This Runner Calls=====
 extern void setUp(void);
 extern void tearDown(void);
-void resetTest(void);
 extern void test_RestrictionsAreEmptyAfterInit(void);
 extern void test_ReturnsCorrectDefaultRestrictions(void);
 extern void test_HackingDefaultRestriction(void);
@@ -34,23 +36,24 @@ extern void test_CantRemoveDefaultEntry(void);
 extern void test_AddingNewRestriction(void);
 extern void test_TheMostFittingRestrictionIsMatched(void);
 extern void test_DeletedRestrictionIsNotMatched(void);
+extern void test_RestrictUnflagWorks(void);
 
 
 //=======Test Reset Option=====
-void resetTest()
+void resetTest(void);
+void resetTest(void)
 {
   tearDown();
   setUp();
 }
 
-char *progname;
+char const * progname;
 
 
 //=======MAIN=====
 int main(int argc, char *argv[])
 {
   progname = argv[0];
-  Unity.TestFile = "ntp_restrict.c";
   UnityBegin("ntp_restrict.c");
   RUN_TEST(test_RestrictionsAreEmptyAfterInit, 59);
   RUN_TEST(test_ReturnsCorrectDefaultRestrictions, 85);
@@ -59,6 +62,7 @@ int main(int argc, char *argv[])
   RUN_TEST(test_AddingNewRestriction, 130);
   RUN_TEST(test_TheMostFittingRestrictionIsMatched, 143);
   RUN_TEST(test_DeletedRestrictionIsNotMatched, 165);
+  RUN_TEST(test_RestrictUnflagWorks, 189);
 
   return (UnityEnd());
 }
index 66f0c34a02249b970676e7d1957f90dca853742e..1159a77c15d5ed36b4227672cc411b71b7330aca 100644 (file)
 #include "unity.h"
 #include <setjmp.h>
 #include <stdio.h>
+#include <config.h>
+#include <rc_cmdlength.h>
 
 //=======External Functions This Runner Calls=====
 extern void setUp(void);
 extern void tearDown(void);
-void resetTest(void);
-extern void test_main(void );
 extern void test_main(void );
 
 
 //=======Test Reset Option=====
-void resetTest()
+void resetTest(void);
+void resetTest(void)
 {
   tearDown();
   setUp();
 }
 
-char *progname;
+char const *progname;
 
 
 //=======MAIN=====
 int main(int argc, char *argv[])
 {
   progname = argv[0];
-  Unity.TestFile = "sec-2853.c";
   UnityBegin("sec-2853.c");
   RUN_TEST(test_main, 10);
-  RUN_TEST(test_main, 10);
 
   return (UnityEnd());
 }