From: Lokesh Walase Date: Tue, 23 Jun 2015 07:26:23 +0000 (+0530) Subject: PacketHandling test changes X-Git-Tag: NTP_4_2_8P3_RC3~22^2 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=abae0be2a9ba25e6398c51ec523aea9937e36981;p=thirdparty%2Fntp.git PacketHandling test changes bk: 55890a1f7oUKpcQ7FnLvfCqGpu_7BQ --- diff --git a/sntp/tests/Makefile.am b/sntp/tests/Makefile.am index 9ccb1ca8e..ba9ac671f 100644 --- a/sntp/tests/Makefile.am +++ b/sntp/tests/Makefile.am @@ -16,7 +16,7 @@ check_PROGRAMS = \ test-kodDatabase \ test-kodFile \ test-networking \ - test-nameresolution \ + test-packetHandling \ test-utilities \ $(NULL) @@ -41,8 +41,8 @@ tests_SOURCES = \ g_kodDatabase.cpp \ g_kodFile.cpp \ g_networking.cpp \ - g_nameresolution.cpp \ - packetHandling.cpp \ + nameresolution.cpp \ + g_packetHandling.cpp \ packetProcessing.cpp \ g_utilities.cpp \ $(NULL) @@ -118,7 +118,7 @@ BUILT_SOURCES += \ $(srcdir)/run-kodDatabase.c \ $(srcdir)/run-kodFile.c \ $(srcdir)/run-networking.c \ - $(srcdir)/run-nameresolution.c \ + $(srcdir)/run-packetHandling.c \ $(srcdir)/run-utilities.c \ $(NULL) @@ -154,11 +154,11 @@ test_networking_LDADD = \ $(unity_tests_LDADD) \ $(NULL) -test_nameresolution_CFLAGS = \ +test_packetHandling_CFLAGS = \ -I$(top_srcdir)/unity \ $(NULL) -test_nameresolution_LDADD = \ +test_packetHandling_LDADD = \ $(unity_tests_LDADD) \ $(NULL) @@ -184,9 +184,9 @@ test_networking_SOURCES = \ $(top_builddir)/version.c \ $(NULL) -test_nameresolution_SOURCES = \ - nameresolution.c \ - run-nameresolution.c \ +test_packetHandling_SOURCES = \ + packetHandling.c \ + run-packetHandling.c \ $(top_builddir)/version.c \ $(NULL) @@ -233,8 +233,8 @@ $(srcdir)/run-kodDatabase.c: $(srcdir)/kodDatabase.c $(std_unity_list) $(srcdir)/run-networking.c: $(srcdir)/networking.c $(std_unity_list) $(run_unity) networking.c run-networking.c -$(srcdir)/run-nameresolution.c: $(srcdir)/nameresolution.c $(std_unity_list) - $(run_unity) nameresolution.c run-nameresolution.c +$(srcdir)/run-packetHandling.c: $(srcdir)/packetHandling.c $(std_unity_list) + $(run_unity) packetHandling.c run-packetHandling.c $(srcdir)/run-utilities.c: $(srcdir)/utilities.c $(std_unity_list) $(run_unity) utilities.c run-utilities.c diff --git a/sntp/tests/g_packetHandling.cpp b/sntp/tests/g_packetHandling.cpp new file mode 100644 index 000000000..bd5b14e0d --- /dev/null +++ b/sntp/tests/g_packetHandling.cpp @@ -0,0 +1,264 @@ +#include "g_sntptest.h" + +extern "C" { +#include "kod_management.h" +#include "main.h" +#include "networking.h" +#include "ntp.h" +}; + +class mainTest : public sntptest { +protected: + ::testing::AssertionResult LfpEquality(const l_fp &expected, const l_fp &actual) { + if (L_ISEQU(&expected, &actual)) { + return ::testing::AssertionSuccess(); + } else { + return ::testing::AssertionFailure() + << " expected: " << lfptoa(&expected, FRACTION_PREC) + << " (" << expected.l_ui << "." << expected.l_uf << ")" + << " but was: " << lfptoa(&actual, FRACTION_PREC) + << " (" << actual.l_ui << "." << actual.l_uf << ")"; + } + } +}; + +TEST_F(mainTest, GenerateUnauthenticatedPacket) { + pkt testpkt; + + timeval xmt; + GETTIMEOFDAY(&xmt, NULL); + xmt.tv_sec += JAN_1970; + + EXPECT_EQ(LEN_PKT_NOMAC, + generate_pkt(&testpkt, &xmt, 0, NULL)); + + EXPECT_EQ(LEAP_NOTINSYNC, PKT_LEAP(testpkt.li_vn_mode)); + EXPECT_EQ(NTP_VERSION, PKT_VERSION(testpkt.li_vn_mode)); + EXPECT_EQ(MODE_CLIENT, PKT_MODE(testpkt.li_vn_mode)); + + EXPECT_EQ(STRATUM_UNSPEC, PKT_TO_STRATUM(testpkt.stratum)); + EXPECT_EQ(8, testpkt.ppoll); + + l_fp expected_xmt, actual_xmt; + TVTOTS(&xmt, &expected_xmt); + NTOHL_FP(&testpkt.xmt, &actual_xmt); + EXPECT_TRUE(LfpEquality(expected_xmt, actual_xmt)); +} + +TEST_F(mainTest, GenerateAuthenticatedPacket) { + key testkey; + testkey.next = NULL; + testkey.key_id = 30; + testkey.key_len = 9; + memcpy(testkey.key_seq, "123456789", testkey.key_len); + memcpy(testkey.type, "MD5", 3); + + pkt testpkt; + + timeval xmt; + GETTIMEOFDAY(&xmt, NULL); + xmt.tv_sec += JAN_1970; + + const int EXPECTED_PKTLEN = LEN_PKT_NOMAC + MAX_MD5_LEN; + + EXPECT_EQ(EXPECTED_PKTLEN, + generate_pkt(&testpkt, &xmt, testkey.key_id, &testkey)); + + EXPECT_EQ(LEAP_NOTINSYNC, PKT_LEAP(testpkt.li_vn_mode)); + EXPECT_EQ(NTP_VERSION, PKT_VERSION(testpkt.li_vn_mode)); + EXPECT_EQ(MODE_CLIENT, PKT_MODE(testpkt.li_vn_mode)); + + EXPECT_EQ(STRATUM_UNSPEC, PKT_TO_STRATUM(testpkt.stratum)); + EXPECT_EQ(8, testpkt.ppoll); + + l_fp expected_xmt, actual_xmt; + TVTOTS(&xmt, &expected_xmt); + NTOHL_FP(&testpkt.xmt, &actual_xmt); + EXPECT_TRUE(LfpEquality(expected_xmt, actual_xmt)); + + EXPECT_EQ(testkey.key_id, ntohl(testpkt.exten[0])); + + char expected_mac[MAX_MD5_LEN]; + ASSERT_EQ(MAX_MD5_LEN - 4, // Remove the key_id, only keep the mac. + make_mac((char*)&testpkt, LEN_PKT_NOMAC, MAX_MD5_LEN, &testkey, expected_mac)); + EXPECT_TRUE(memcmp(expected_mac, (char*)&testpkt.exten[1], MAX_MD5_LEN -4) == 0); +} + +TEST_F(mainTest, OffsetCalculationPositiveOffset) { + pkt rpkt; + + rpkt.precision = -16; // 0,000015259 + rpkt.rootdelay = HTONS_FP(DTOUFP(0.125)); + rpkt.rootdisp = HTONS_FP(DTOUFP(0.25)); + // Synch Distance: (0.125+0.25)/2.0 == 0.1875 + l_fp reftime; + get_systime(&reftime); + HTONL_FP(&reftime, &rpkt.reftime); + + l_fp tmp; + + // T1 - Originate timestamp + tmp.l_ui = 1000000000UL; + tmp.l_uf = 0UL; + HTONL_FP(&tmp, &rpkt.org); + + // T2 - Receive timestamp + tmp.l_ui = 1000000001UL; + tmp.l_uf = 2147483648UL; + HTONL_FP(&tmp, &rpkt.rec); + + // T3 - Transmit timestamp + tmp.l_ui = 1000000002UL; + tmp.l_uf = 0UL; + HTONL_FP(&tmp, &rpkt.xmt); + + // T4 - Destination timestamp as standard timeval + tmp.l_ui = 1000000001UL; + tmp.l_uf = 0UL; + timeval dst; + TSTOTV(&tmp, &dst); + dst.tv_sec -= JAN_1970; + + double offset, precision, synch_distance; + offset_calculation(&rpkt, LEN_PKT_NOMAC, &dst, &offset, &precision, &synch_distance); + + EXPECT_DOUBLE_EQ(1.25, offset); + EXPECT_DOUBLE_EQ(1. / ULOGTOD(16), precision); + // 1.1250150000000001 ? + EXPECT_DOUBLE_EQ(1.125015, synch_distance); +} + +TEST_F(mainTest, OffsetCalculationNegativeOffset) { + pkt rpkt; + + rpkt.precision = -1; + rpkt.rootdelay = HTONS_FP(DTOUFP(0.5)); + rpkt.rootdisp = HTONS_FP(DTOUFP(0.5)); + // Synch Distance is (0.5+0.5)/2.0, or 0.5 + l_fp reftime; + get_systime(&reftime); + HTONL_FP(&reftime, &rpkt.reftime); + + l_fp tmp; + + // T1 - Originate timestamp + tmp.l_ui = 1000000001UL; + tmp.l_uf = 0UL; + HTONL_FP(&tmp, &rpkt.org); + + // T2 - Receive timestamp + tmp.l_ui = 1000000000UL; + tmp.l_uf = 2147483648UL; + HTONL_FP(&tmp, &rpkt.rec); + + // T3 - Transmit timestamp + tmp.l_ui = 1000000001UL; + tmp.l_uf = 2147483648UL; + HTONL_FP(&tmp, &rpkt.xmt); + + // T4 - Destination timestamp as standard timeval + tmp.l_ui = 1000000003UL; + tmp.l_uf = 0UL; + timeval dst; + TSTOTV(&tmp, &dst); + dst.tv_sec -= JAN_1970; + + double offset, precision, synch_distance; + offset_calculation(&rpkt, LEN_PKT_NOMAC, &dst, &offset, &precision, &synch_distance); + + EXPECT_DOUBLE_EQ(-1, offset); + EXPECT_DOUBLE_EQ(1. / ULOGTOD(1), precision); + EXPECT_DOUBLE_EQ(1.3333483333333334, synch_distance); +} + +TEST_F(mainTest, HandleUnusableServer) { + pkt rpkt; + sockaddr_u host; + int rpktl; + + ZERO(rpkt); + ZERO(host); + rpktl = SERVER_UNUSEABLE; + EXPECT_EQ(-1, handle_pkt(rpktl, &rpkt, &host, "")); +} + +TEST_F(mainTest, HandleUnusablePacket) { + pkt rpkt; + sockaddr_u host; + int rpktl; + + ZERO(rpkt); + ZERO(host); + rpktl = PACKET_UNUSEABLE; + EXPECT_EQ(1, handle_pkt(rpktl, &rpkt, &host, "")); +} + +TEST_F(mainTest, HandleServerAuthenticationFailure) { + pkt rpkt; + sockaddr_u host; + int rpktl; + + ZERO(rpkt); + ZERO(host); + rpktl = SERVER_AUTH_FAIL; + EXPECT_EQ(1, handle_pkt(rpktl, &rpkt, &host, "")); +} + +TEST_F(mainTest, HandleKodDemobilize) { + const char * HOSTNAME = "192.0.2.1"; + const char * REASON = "DENY"; + pkt rpkt; + sockaddr_u host; + int rpktl; + kod_entry * entry; + + rpktl = KOD_DEMOBILIZE; + ZERO(rpkt); + memcpy(&rpkt.refid, REASON, 4); + ZERO(host); + host.sa4.sin_family = AF_INET; + host.sa4.sin_addr.s_addr = inet_addr(HOSTNAME); + + // Test that the KOD-entry is added to the database. + kod_init_kod_db("/dev/null", TRUE); + + EXPECT_EQ(1, handle_pkt(rpktl, &rpkt, &host, HOSTNAME)); + + ASSERT_EQ(1, search_entry(HOSTNAME, &entry)); + EXPECT_TRUE(memcmp(REASON, entry->type, 4) == 0); +} + +TEST_F(mainTest, HandleKodRate) { + pkt rpkt; + sockaddr_u host; + int rpktl; + + ZERO(rpkt); + ZERO(host); + rpktl = KOD_RATE; + EXPECT_EQ(1, handle_pkt(rpktl, &rpkt, &host, "")); +} + +TEST_F(mainTest, HandleCorrectPacket) { + pkt rpkt; + sockaddr_u host; + int rpktl; + l_fp now; + + // We don't want our testing code to actually change the system clock. + ASSERT_FALSE(ENABLED_OPT(STEP)); + ASSERT_FALSE(ENABLED_OPT(SLEW)); + + get_systime(&now); + HTONL_FP(&now, &rpkt.reftime); + HTONL_FP(&now, &rpkt.org); + HTONL_FP(&now, &rpkt.rec); + HTONL_FP(&now, &rpkt.xmt); + rpktl = LEN_PKT_NOMAC; + ZERO(host); + AF(&host) = AF_INET; + + EXPECT_EQ(0, handle_pkt(rpktl, &rpkt, &host, "")); +} + +/* packetHandling.cpp */ diff --git a/sntp/tests/packetHandling.c b/sntp/tests/packetHandling.c new file mode 100644 index 000000000..2766fcfce --- /dev/null +++ b/sntp/tests/packetHandling.c @@ -0,0 +1,260 @@ +#include "config.h" +#include "unity.h" +//#include "ntp_stdlib.h" +#include "ntp_types.h" +#include "ntp_debug.h" +#include "sntptest.h" + +#include "kod_management.h" +#include "main.h" +#include "networking.h" +#include "ntp.h" + +int LfpEquality(const l_fp expected, const l_fp actual) { + if (L_ISEQU(&expected, &actual)) { + return TRUE; + } else { + return FALSE; + } +} + +void test_GenerateUnauthenticatedPacket(void) { + struct pkt testpkt; + + struct timeval xmt; + GETTIMEOFDAY(&xmt, NULL); + xmt.tv_sec += JAN_1970; + + TEST_ASSERT_EQUAL(LEN_PKT_NOMAC, + generate_pkt(&testpkt, &xmt, 0, NULL)); + + TEST_ASSERT_EQUAL(LEAP_NOTINSYNC, PKT_LEAP(testpkt.li_vn_mode)); + TEST_ASSERT_EQUAL(NTP_VERSION, PKT_VERSION(testpkt.li_vn_mode)); + TEST_ASSERT_EQUAL(MODE_CLIENT, PKT_MODE(testpkt.li_vn_mode)); + + TEST_ASSERT_EQUAL(STRATUM_UNSPEC, PKT_TO_STRATUM(testpkt.stratum)); + TEST_ASSERT_EQUAL(8, testpkt.ppoll); + + l_fp expected_xmt, actual_xmt; + TVTOTS(&xmt, &expected_xmt); + NTOHL_FP(&testpkt.xmt, &actual_xmt); + TEST_ASSERT_TRUE(LfpEquality(expected_xmt, actual_xmt)); +} + +void test_GenerateAuthenticatedPacket(void) { + struct key testkey; + testkey.next = NULL; + testkey.key_id = 30; + testkey.key_len = 9; + memcpy(testkey.key_seq, "123456789", testkey.key_len); + memcpy(testkey.type, "MD5", 3); + + struct pkt testpkt; + + struct timeval xmt; + GETTIMEOFDAY(&xmt, NULL); + xmt.tv_sec += JAN_1970; + + const int EXPECTED_PKTLEN = LEN_PKT_NOMAC + MAX_MD5_LEN; + + TEST_ASSERT_EQUAL(EXPECTED_PKTLEN, + generate_pkt(&testpkt, &xmt, testkey.key_id, &testkey)); + + TEST_ASSERT_EQUAL(LEAP_NOTINSYNC, PKT_LEAP(testpkt.li_vn_mode)); + TEST_ASSERT_EQUAL(NTP_VERSION, PKT_VERSION(testpkt.li_vn_mode)); + TEST_ASSERT_EQUAL(MODE_CLIENT, PKT_MODE(testpkt.li_vn_mode)); + + TEST_ASSERT_EQUAL(STRATUM_UNSPEC, PKT_TO_STRATUM(testpkt.stratum)); + TEST_ASSERT_EQUAL(8, testpkt.ppoll); + + l_fp expected_xmt, actual_xmt; + TVTOTS(&xmt, &expected_xmt); + NTOHL_FP(&testpkt.xmt, &actual_xmt); + TEST_ASSERT_TRUE(LfpEquality(expected_xmt, actual_xmt)); + + TEST_ASSERT_EQUAL(testkey.key_id, ntohl(testpkt.exten[0])); + + char expected_mac[MAX_MD5_LEN]; + TEST_ASSERT_EQUAL(MAX_MD5_LEN - 4, // Remove the key_id, only keep the mac. + make_mac((char*)&testpkt, LEN_PKT_NOMAC, MAX_MD5_LEN, &testkey, expected_mac)); + TEST_ASSERT_TRUE(memcmp(expected_mac, (char*)&testpkt.exten[1], MAX_MD5_LEN -4) == 0); +} + +void test_OffsetCalculationPositiveOffset(void) { + struct pkt rpkt; + + rpkt.precision = -16; // 0,000015259 + rpkt.rootdelay = HTONS_FP(DTOUFP(0.125)); + rpkt.rootdisp = HTONS_FP(DTOUFP(0.25)); + // Synch Distance: (0.125+0.25)/2.0 == 0.1875 + l_fp reftime; + get_systime(&reftime); + HTONL_FP(&reftime, &rpkt.reftime); + + l_fp tmp; + + // T1 - Originate timestamp + tmp.l_ui = 1000000000UL; + tmp.l_uf = 0UL; + HTONL_FP(&tmp, &rpkt.org); + + // T2 - Receive timestamp + tmp.l_ui = 1000000001UL; + tmp.l_uf = 2147483648UL; + HTONL_FP(&tmp, &rpkt.rec); + + // T3 - Transmit timestamp + tmp.l_ui = 1000000002UL; + tmp.l_uf = 0UL; + HTONL_FP(&tmp, &rpkt.xmt); + + // T4 - Destination timestamp as standard timeval + tmp.l_ui = 1000000001UL; + tmp.l_uf = 0UL; + struct timeval dst; + TSTOTV(&tmp, &dst); + dst.tv_sec -= JAN_1970; + + double offset, precision, synch_distance; + offset_calculation(&rpkt, LEN_PKT_NOMAC, &dst, &offset, &precision, &synch_distance); + + TEST_ASSERT_EQUAL_FLOAT(1.25, offset); + TEST_ASSERT_EQUAL_FLOAT(1. / ULOGTOD(16), precision); + // 1.1250150000000001 ? + TEST_ASSERT_EQUAL_FLOAT(1.125015, synch_distance); +} + +void test_OffsetCalculationNegativeOffset(void) { + struct pkt rpkt; + + rpkt.precision = -1; + rpkt.rootdelay = HTONS_FP(DTOUFP(0.5)); + rpkt.rootdisp = HTONS_FP(DTOUFP(0.5)); + // Synch Distance is (0.5+0.5)/2.0, or 0.5 + l_fp reftime; + get_systime(&reftime); + HTONL_FP(&reftime, &rpkt.reftime); + + l_fp tmp; + + // T1 - Originate timestamp + tmp.l_ui = 1000000001UL; + tmp.l_uf = 0UL; + HTONL_FP(&tmp, &rpkt.org); + + // T2 - Receive timestamp + tmp.l_ui = 1000000000UL; + tmp.l_uf = 2147483648UL; + HTONL_FP(&tmp, &rpkt.rec); + + // T3 - Transmit timestamp + tmp.l_ui = 1000000001UL; + tmp.l_uf = 2147483648UL; + HTONL_FP(&tmp, &rpkt.xmt); + + // T4 - Destination timestamp as standard timeval + tmp.l_ui = 1000000003UL; + tmp.l_uf = 0UL; + struct timeval dst; + TSTOTV(&tmp, &dst); + dst.tv_sec -= JAN_1970; + + double offset, precision, synch_distance; + offset_calculation(&rpkt, LEN_PKT_NOMAC, &dst, &offset, &precision, &synch_distance); + + TEST_ASSERT_EQUAL_FLOAT(-1, offset); + TEST_ASSERT_EQUAL_FLOAT(1. / ULOGTOD(1), precision); + TEST_ASSERT_EQUAL_FLOAT(1.3333483333333334, synch_distance); +} + +void test_HandleUnusableServer(void) { + struct pkt rpkt; + sockaddr_u host; + int rpktl; + + ZERO(rpkt); + ZERO(host); + rpktl = SERVER_UNUSEABLE; + TEST_ASSERT_EQUAL(-1, handle_pkt(rpktl, &rpkt, &host, "")); +} + +void test_HandleUnusablePacket(void) { + struct pkt rpkt; + sockaddr_u host; + int rpktl; + + ZERO(rpkt); + ZERO(host); + rpktl = PACKET_UNUSEABLE; + TEST_ASSERT_EQUAL(1, handle_pkt(rpktl, &rpkt, &host, "")); +} + +void test_HandleServerAuthenticationFailure(void) { + struct pkt rpkt; + sockaddr_u host; + int rpktl; + + ZERO(rpkt); + ZERO(host); + rpktl = SERVER_AUTH_FAIL; + TEST_ASSERT_EQUAL(1, handle_pkt(rpktl, &rpkt, &host, "")); +} + +void test_HandleKodDemobilize(void) { + const char * HOSTNAME = "192.0.2.1"; + const char * REASON = "DENY"; + struct pkt rpkt; + sockaddr_u host; + int rpktl; + struct kod_entry * entry; + + rpktl = KOD_DEMOBILIZE; + ZERO(rpkt); + memcpy(&rpkt.refid, REASON, 4); + ZERO(host); + host.sa4.sin_family = AF_INET; + host.sa4.sin_addr.s_addr = inet_addr(HOSTNAME); + + // Test that the KOD-entry is added to the database. + kod_init_kod_db("/dev/null", TRUE); + + TEST_ASSERT_EQUAL(1, handle_pkt(rpktl, &rpkt, &host, HOSTNAME)); + + TEST_ASSERT_EQUAL(1, search_entry(HOSTNAME, &entry)); + TEST_ASSERT_TRUE(memcmp(REASON, entry->type, 4) == 0); +} + +void test_HandleKodRate(void) { + struct pkt rpkt; + sockaddr_u host; + int rpktl; + + ZERO(rpkt); + ZERO(host); + rpktl = KOD_RATE; + TEST_ASSERT_EQUAL(1, handle_pkt(rpktl, &rpkt, &host, "")); +} + +void test_HandleCorrectPacket(void) { + struct pkt rpkt; + sockaddr_u host; + int rpktl; + l_fp now; + + // We don't want our testing code to actually change the system clock. + TEST_ASSERT_FALSE(ENABLED_OPT(STEP)); + TEST_ASSERT_FALSE(ENABLED_OPT(SLEW)); + + get_systime(&now); + HTONL_FP(&now, &rpkt.reftime); + HTONL_FP(&now, &rpkt.org); + HTONL_FP(&now, &rpkt.rec); + HTONL_FP(&now, &rpkt.xmt); + rpktl = LEN_PKT_NOMAC; + ZERO(host); + AF(&host) = AF_INET; + + TEST_ASSERT_EQUAL(0, handle_pkt(rpktl, &rpkt, &host, "")); +} + +/* packetHandling.c */ diff --git a/sntp/tests/run-packetHandling.c b/sntp/tests/run-packetHandling.c new file mode 100644 index 000000000..e8b6b3a9e --- /dev/null +++ b/sntp/tests/run-packetHandling.c @@ -0,0 +1,70 @@ +/* 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 +#include + +//=======External Functions This Runner Calls===== +extern void setUp(void); +extern void tearDown(void); +void resetTest(void); +extern void test_GenerateUnauthenticatedPacket(void); +extern void test_GenerateAuthenticatedPacket(void); +extern void test_OffsetCalculationPositiveOffset(void); +extern void test_OffsetCalculationNegativeOffset(void); +extern void test_HandleUnusableServer(void); +extern void test_HandleUnusablePacket(void); +extern void test_HandleServerAuthenticationFailure(void); +extern void test_HandleKodDemobilize(void); +extern void test_HandleKodRate(void); +extern void test_HandleCorrectPacket(void); + + +//=======Test Reset Option===== +void resetTest() +{ + tearDown(); + setUp(); +} + +char *progname; + + +//=======MAIN===== +int main(int argc, char *argv[]) +{ + progname = argv[0]; + Unity.TestFile = "packetHandling.c"; + UnityBegin("packetHandling.c"); + RUN_TEST(test_GenerateUnauthenticatedPacket, 21); + RUN_TEST(test_GenerateAuthenticatedPacket, 44); + RUN_TEST(test_OffsetCalculationPositiveOffset, 83); + RUN_TEST(test_OffsetCalculationNegativeOffset, 127); + RUN_TEST(test_HandleUnusableServer, 170); + RUN_TEST(test_HandleUnusablePacket, 181); + RUN_TEST(test_HandleServerAuthenticationFailure, 192); + RUN_TEST(test_HandleKodDemobilize, 203); + RUN_TEST(test_HandleKodRate, 227); + RUN_TEST(test_HandleCorrectPacket, 238); + + return (UnityEnd()); +}