From: Harlan Stenn Date: Sat, 16 May 2015 08:58:44 +0000 (+0000) Subject: Updates to bug-2803 tests X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=850b364287a252016b32758c2dbeca00a295c197;p=thirdparty%2Fntp.git Updates to bug-2803 tests bk: 555706c4MGvzDmvwJpzI4iyr_Kj2Lg --- diff --git a/tests/bug-2803/Makefile.am b/tests/bug-2803/Makefile.am index 6c7365407..c16a42482 100644 --- a/tests/bug-2803/Makefile.am +++ b/tests/bug-2803/Makefile.am @@ -24,8 +24,10 @@ AM_CPPFLAGS += $(CPPFLAGS_NTP) AM_LDFLAGS = $(LDFLAGS_NTP) -bug_2803_SOURCES = \ - bug-2803.c \ +bug_2803_SOURCES = \ + bug-2803.c \ + TestProductionCode_Runner.c \ + ut-2803.c \ $(NULL) # HMS: we may not need some of these: diff --git a/tests/bug-2803/TestProductionCode_Runner.c b/tests/bug-2803/TestProductionCode_Runner.c new file mode 100644 index 000000000..969df8861 --- /dev/null +++ b/tests/bug-2803/TestProductionCode_Runner.c @@ -0,0 +1,55 @@ +/* AUTOGENERATED FILE. DO NOT EDIT. */ +#include "unity.h" +#include +#include + +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 index a31fccfdd..1806c6d78 100644 --- a/tests/bug-2803/bug-2803.c +++ b/tests/bug-2803/bug-2803.c @@ -85,7 +85,7 @@ int test_loop( long long start_sec, long start_usec, -int main( void ) +int main2( void ) { // loop from {0.0} to {1.1000000} stepping by tv_sec by 1 and tv_usec by 100000 diff --git a/tests/bug-2803/bug-2803.h b/tests/bug-2803/bug-2803.h new file mode 100644 index 000000000..4b8469df1 --- /dev/null +++ b/tests/bug-2803/bug-2803.h @@ -0,0 +1 @@ +int main2( void ); diff --git a/tests/bug-2803/ut-2803.c b/tests/bug-2803/ut-2803.c new file mode 100644 index 000000000..885cb452c --- /dev/null +++ b/tests/bug-2803/ut-2803.c @@ -0,0 +1,41 @@ +#include "bug-2803.h" +#include "unity.h" + +#define VERSION 3 //change this to 5 and the test wont fail. + + +void setUp(void) +{ + +} + +void tearDown(void) +{ +} + +/* +int main( 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; +} +*/ +int test_main( void ) +{ + TEST_ASSERT_EQUAL(0, main2()); +} + +void test_custom(void) +{ + if(VERSION < 4 ){ + TEST_FAIL_MESSAGE("expected to fail"); + } + + else TEST_ASSERT_EQUAL(1,1); +}