]> git.ipfire.org Git - thirdparty/ntp.git/commitdiff
bug-2803.h~388af97e65bf386e:
authorDamir Tomic <viperus@ntp.org>
Sun, 14 Jun 2015 09:56:02 +0000 (11:56 +0200)
committerDamir Tomic <viperus@ntp.org>
Sun, 14 Jun 2015 09:56:02 +0000 (11:56 +0200)
  Delete: tests/bug-2803/bug-2803.h
TestProductionCode_Runner.c~1dd6cbb7f125c42a:
  Delete: tests/bug-2803/TestProductionCode_Runner.c
bug-2803.c~75ddf194e9fda1b8:
  Delete: tests/bug-2803/bug-2803.c
Makefile.am:
  removed outdated files
ut-2803.c:
  merged with bug-2803.c|h, they are obsolete now

bk: 557d4fb2Vpuc3oBog9nCJbs53E4eYA

tests/bug-2803/Makefile.am
tests/bug-2803/TestProductionCode_Runner.c [deleted file]
tests/bug-2803/bug-2803.c [deleted file]
tests/bug-2803/bug-2803.h [deleted file]
tests/bug-2803/run-bug-2803.c
tests/bug-2803/ut-2803.c

index 5f49c29a5276c4fe4d98f55d8066f4ddfaf90083..db089e8b40dae3d0399ee67ab243427be0db3065 100644 (file)
@@ -31,8 +31,6 @@ AM_CPPFLAGS += $(CPPFLAGS_NTP)
 AM_LDFLAGS = $(LDFLAGS_NTP)
 
 bug_2803_SOURCES =                     \
-       bug-2803.c                      \
-       bug-2803.h                      \
        run-bug-2803.c                  \
        ut-2803.c                       \
        $(NULL)
diff --git a/tests/bug-2803/TestProductionCode_Runner.c b/tests/bug-2803/TestProductionCode_Runner.c
deleted file mode 100644 (file)
index 969df88..0000000
+++ /dev/null
@@ -1,55 +0,0 @@
-/* AUTOGENERATED FILE. DO NOT EDIT. */
-#include "unity.h"
-#include <setjmp.h>
-#include <stdio.h>
-
-char MessageBuffer[50];
-
-extern void setUp(void);
-extern void tearDown(void);
-
-extern void test_FindFunction_WhichIsBroken_ShouldReturnZeroIfItemIsNotInList_WhichWorksEvenInOurBrokenCode(void);
-extern void test_FindFunction_WhichIsBroken_ShouldReturnTheIndexForItemsInList_WhichWillFailBecauseOurFunctionUnderTestIsBroken(void);
-extern void test_FunctionWhichReturnsLocalVariable_ShouldReturnTheCurrentCounterValue(void);
-extern void test_FunctionWhichReturnsLocalVariable_ShouldReturnTheCurrentCounterValueAgain(void);
-extern void test_FunctionWhichReturnsLocalVariable_ShouldReturnCurrentCounter_ButFailsBecauseThisTestIsActuallyFlawed(void);
-extern void test_custom(void);
-extern void test_main(void);
-
-void resetTest(void);
-
-void resetTest(void)
-{
-  tearDown();
-  setUp();
-}
-
-
-int main(void)
-{
-  UnityBegin("test/TestProductionCode.c");
-  UnityBegin("test/test-2803.c");
-
-  /*
-  RUN_TEST(test_FindFunction_WhichIsBroken_ShouldReturnZeroIfItemIsNotInList_WhichWorksEvenInOurBrokenCode, 20);
-  RUN_TEST(test_FindFunction_WhichIsBroken_ShouldReturnTheIndexForItemsInList_WhichWillFailBecauseOurFunctionUnderTestIsBroken, 30);
-  RUN_TEST(test_FunctionWhichReturnsLocalVariable_ShouldReturnTheCurrentCounterValue, 41);
-  RUN_TEST(test_FunctionWhichReturnsLocalVariable_ShouldReturnTheCurrentCounterValueAgain, 51);
-  RUN_TEST(test_FunctionWhichReturnsLocalVariable_ShouldReturnCurrentCounter_ButFailsBecauseThisTestIsActuallyFlawed, 57);
-*/
-
-RUN_TEST(test_main);
-
-//RUN_TEST(test_FindFunction_WhichIsBroken_ShouldReturnZeroIfItemIsNotInList_WhichWorksEvenInOurBrokenCode);
-  //RUN_TEST(test_FindFunction_WhichIsBroken_ShouldReturnTheIndexForItemsInList_WhichWillFailBecauseOurFunctionUnderTestIsBroken);
-  //RUN_TEST(test_FunctionWhichReturnsLocalVariable_ShouldReturnTheCurrentCounterValue);
-  //RUN_TEST(test_FunctionWhichReturnsLocalVariable_ShouldReturnTheCurrentCounterValueAgain);
-  //RUN_TEST(test_FunctionWhichReturnsLocalVariable_ShouldReturnCurrentCounter_ButFailsBecauseThisTestIsActuallyFlawed);
-
-
-//RUN_TEST(test_FunctionWhichReturnsLocalVariable_ShouldReturnCurrentCounter_ButFailsBecauseThisTestIsActuallyFlawed);
-  RUN_TEST(test_custom);
-
-  UnityEnd();
-  return 0;
-}
diff --git a/tests/bug-2803/bug-2803.c b/tests/bug-2803/bug-2803.c
deleted file mode 100644 (file)
index 1806c6d..0000000
+++ /dev/null
@@ -1,99 +0,0 @@
-#include <config.h>
-
-#include <stdio.h>
-#include <sys/time.h>
-
-#include <ntp_fp.h>
-#include <timevalops.h>
-
-/* microseconds per second */
-#define MICROSECONDS 1000000
-
-
-static int verbose = 1;        // if not 0, also print results if test passed
-static int exit_on_err = 0;    // if not 0, exit if test failed
-
-
-/*
- * Test function calling the old and new code mentioned in
- * http://bugs.ntp.org/show_bug.cgi?id=2803#c22
- */
-static
-int do_test( struct timeval timetv, struct timeval tvlast )
-{
-       struct timeval tvdiff_old;
-       struct timeval tvdiff_new;
-
-       int cond_old;
-       int cond_new;
-       int failed;
-
-       cond_old = 0;
-       cond_new = 0;
-
-       // Here is the old code:
-       tvdiff_old = abs_tval(sub_tval(timetv, tvlast));
-       if (tvdiff_old.tv_sec > 0) {
-               cond_old = 1;
-       }
-
-       // Here is the new code:
-       tvdiff_new = sub_tval(timetv, tvlast);
-       if (tvdiff_new.tv_sec != 0) {
-               cond_new = 1;
-       }
-
-       failed = cond_new != cond_old;
-
-       if ( failed || verbose )
-               printf( "timetv %lli|%07li, tvlast  %lli|%07li: tvdiff_old: %lli|%07li -> %i, tvdiff_new: %lli|%07li -> %i, same cond: %s\n",
-                       (long long) timetv.tv_sec, timetv.tv_usec,
-                       (long long) tvlast.tv_sec, tvlast.tv_usec,
-                       (long long) tvdiff_old.tv_sec, tvdiff_old.tv_usec, cond_old,
-                       (long long) tvdiff_new.tv_sec, tvdiff_new.tv_usec, cond_new,
-                       failed ? "NO <<" : "yes" );
-
-       return failed ? -1 : 0;
-}
-
-
-
-/*
- * Call the test function in a loop for a given set of parameters.
- * Both timetv and tvlast iterate over the given range, in all combinations.
- */
-static
-int test_loop( long long start_sec, long start_usec,
-              long long stop_sec, long stop_usec,
-              long long step_sec, long step_usec )
-{
-       struct timeval timetv;
-       struct timeval tvlast;
-
-       for ( timetv.tv_sec = start_sec; timetv.tv_sec <= stop_sec; timetv.tv_sec += step_sec )
-         for ( timetv.tv_usec = start_usec; timetv.tv_usec <= stop_usec; timetv.tv_usec += step_usec )
-           for ( tvlast.tv_sec = start_sec; tvlast.tv_sec <= stop_sec; tvlast.tv_sec += step_sec )
-             for ( tvlast.tv_usec = start_usec; tvlast.tv_usec <= stop_usec; tvlast.tv_usec += step_usec )
-             {
-               int rc = do_test( timetv, tvlast );
-               if (rc < 0 && exit_on_err )
-                       return rc;
-             }
-
-       return 0;
-}
-
-
-
-int main2( void )
-{
-
-       // loop from {0.0} to {1.1000000} stepping by tv_sec by 1 and tv_usec by 100000
-       test_loop( 0, 0,   1,  MICROSECONDS,   1,  MICROSECONDS / 10 );
-
-       // test_loop( 0, 0,   5,  MICROSECONDS,   1,  MICROSECONDS / 1000 );
-       // test_loop( 0, 0,  -5, -MICROSECONDS,  -1, -MICROSECONDS / 1000 );
-
-       return 0;
-}
-
diff --git a/tests/bug-2803/bug-2803.h b/tests/bug-2803/bug-2803.h
deleted file mode 100644 (file)
index 4b8469d..0000000
+++ /dev/null
@@ -1 +0,0 @@
-int main2( void );
index d1fd0e25187625de895e3138406c31f280947058..7bc90a89c7ce8d3d98ef2da1af8b6c391598a648 100644 (file)
@@ -45,7 +45,7 @@ int main(int argc, char *argv[])
   progname = argv[0];
   Unity.TestFile = "ut-2803.c";
   UnityBegin("ut-2803.c");
-  RUN_TEST(test_main, 27);
+  RUN_TEST(test_main, 117);
 
   return (UnityEnd());
 }
index c5462b1aac6dc0ce2c5af614ab9c038600e2dec7..1bb6bbc15fb21594de913b87c57d6a7ca65b3a17 100644 (file)
@@ -1,18 +1,94 @@
-#include "bug-2803.h"
+#include <config.h>
+
+#include <stdio.h>
+#include <sys/time.h>
+
+#include <ntp_fp.h>
+#include <timevalops.h>
+
 #include "unity.h"
 
+/* microseconds per second */
+#define MICROSECONDS 1000000
 
-void setUp(void)
+int simpleTest( void );
+
+
+static int verbose = 1;        // if not 0, also print results if test passed
+static int exit_on_err = 0;    // if not 0, exit if test failed
+
+
+/*
+ * Test function calling the old and new code mentioned in
+ * http://bugs.ntp.org/show_bug.cgi?id=2803#c22
+ */
+static int do_test( struct timeval timetv, struct timeval tvlast )
 {
-  
+       struct timeval tvdiff_old;
+       struct timeval tvdiff_new;
+
+       int cond_old;
+       int cond_new;
+       int failed;
+
+       cond_old = 0;
+       cond_new = 0;
+
+       // Here is the old code:
+       tvdiff_old = abs_tval(sub_tval(timetv, tvlast));
+       if (tvdiff_old.tv_sec > 0) {
+               cond_old = 1;
+       }
+
+       // Here is the new code:
+       tvdiff_new = sub_tval(timetv, tvlast);
+       if (tvdiff_new.tv_sec != 0) {
+               cond_new = 1;
+       }
+
+       failed = cond_new != cond_old;
+
+       if ( failed || verbose )
+               printf( "timetv %lli|%07li, tvlast  %lli|%07li: tvdiff_old: %lli|%07li -> %i, tvdiff_new: %lli|%07li -> %i, same cond: %s\n",
+                       (long long) timetv.tv_sec, timetv.tv_usec,
+                       (long long) tvlast.tv_sec, tvlast.tv_usec,
+                       (long long) tvdiff_old.tv_sec, tvdiff_old.tv_usec, cond_old,
+                       (long long) tvdiff_new.tv_sec, tvdiff_new.tv_usec, cond_new,
+                       failed ? "NO <<" : "yes" );
+
+       return failed ? -1 : 0;
 }
 
-void tearDown(void)
+
+
+/*
+ * Call the test function in a loop for a given set of parameters.
+ * Both timetv and tvlast iterate over the given range, in all combinations.
+ */
+static
+int test_loop( long long start_sec, long start_usec,
+              long long stop_sec, long stop_usec,
+              long long step_sec, long step_usec )
 {
+       struct timeval timetv;
+       struct timeval tvlast;
+
+       for ( timetv.tv_sec = start_sec; timetv.tv_sec <= stop_sec; timetv.tv_sec += step_sec )
+         for ( timetv.tv_usec = start_usec; timetv.tv_usec <= stop_usec; timetv.tv_usec += step_usec )
+           for ( tvlast.tv_sec = start_sec; tvlast.tv_sec <= stop_sec; tvlast.tv_sec += step_sec )
+             for ( tvlast.tv_usec = start_usec; tvlast.tv_usec <= stop_usec; tvlast.tv_usec += step_usec )
+             {
+               int rc = do_test( timetv, tvlast );
+               if (rc < 0 && exit_on_err )
+                       return rc;
+             }
+
+       return 0;
 }
 
-/*
-int main( void )
+
+
+int simpleTest( void )
 {
 
        // loop from {0.0} to {1.1000000} stepping by tv_sec by 1 and tv_usec by 100000
@@ -23,8 +99,22 @@ int main( void )
 
        return 0;
 }
-*/
+
+
+
+
+
+void setUp(void)
+{
+  
+}
+
+void tearDown(void)
+{
+}
+
+
 void test_main( void )
 {
-       TEST_ASSERT_EQUAL(0, main2());
+       TEST_ASSERT_EQUAL(0, simpleTest());
 }