test-decodenetnum \
test-timevalops \
test-timespecops \
+ test-ssl_init \
$(NULL)
if GTEST_AVAILABLE
g_refnumtoa.cpp \
sfptostr.cpp \
socktoa.cpp \
- ssl_init.cpp \
+ g_ssl_init.cpp \
g_statestr.cpp \
strtolfp.cpp \
- g_timespecops.cpp \
+ g_timespecops.cpp \
timestructs.cpp \
g_timevalops.cpp \
tstotv.cpp \
$(top_builddir)/sntp/unity/libunity.a \
$(NULL)
+test_ssl_init_CFLAGS = \
+ -I$(top_srcdir)/sntp/unity \
+ $(NULL)
+
+test_ssl_init_LDADD = \
+ $(LDADD) \
+ $(top_builddir)/sntp/unity/libunity.a \
+ $(NULL)
+
test_modetoa_SOURCES = \
modetoa.c \
run-test-timespecops.c \
$(NULL)
+test_ssl_init_SOURCES = \
+ ssl_init.c \
+ run-test-ssl_init.c \
+ $(NULL)
+
+
BUILT_SOURCES += \
$(srcdir)/run-test-a_md5encrypt.c \
$(srcdir)/run-test-atoint.c \
$(srcdir)/run-test-calendar.c \
$(srcdir)/run-test-timevalops.c \
$(srcdir)/run-test-timespecops.c \
+ $(srcdir)/run-test-ssl_init.c \
$(NULL)
$(srcdir)/run-test-modetoa.c: $(srcdir)/modetoa.c $(std_unity_list)
$(srcdir)/run-test-timespecops.c: $(srcdir)/timespecops.c $(std_unity_list)
$(run_unity) timespecops.c run-test-timespecops.c
+$(srcdir)/run-test-ssl_init.c: $(srcdir)/ssl_init.c $(std_unity_list)
+ $(run_unity) ssl_init.c run-test-ssl_init.c
TESTS =
RUN_TEST(test_ScopedIPv6AddressWithPort, 40);
RUN_TEST(test_HashEqual, 65);
RUN_TEST(test_HashNotEqual, 73);
- RUN_TEST(test_IgnoreIPv6Fields, 84);
+ RUN_TEST(test_IgnoreIPv6Fields, 86);
return (UnityEnd());
}
--- /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>
+
+//=======External Functions This Runner Calls=====
+extern void setUp(void);
+extern void tearDown(void);
+extern void test_MD5KeyTypeWithoutDigestLength();
+extern void test_MD5KeyTypeWithDigestLength();
+extern void test_SHA1KeyTypeWithDigestLength();
+extern void test_MD5KeyName();
+
+
+//=======Test Reset Option=====
+void resetTest()
+{
+ tearDown();
+ setUp();
+}
+
+char *progname;
+
+
+//=======MAIN=====
+int main(int argc, char *argv[])
+{
+ progname = argv[0];
+ Unity.TestFile = "ssl_init.c";
+ UnityBegin("ssl_init.c");
+ RUN_TEST(test_MD5KeyTypeWithoutDigestLength, 18);
+ RUN_TEST(test_MD5KeyTypeWithDigestLength, 22);
+ RUN_TEST(test_SHA1KeyTypeWithDigestLength, 31);
+ RUN_TEST(test_MD5KeyName, 45);
+
+ return (UnityEnd());
+}
--- /dev/null
+#include "config.h"
+
+#ifdef OPENSSL
+# include "openssl/err.h"
+# include "openssl/rand.h"
+# include "openssl/evp.h"
+#endif
+#include "ntp.h"
+
+#include "unity.h"
+
+
+static const size_t TEST_MD5_DIGEST_LENGTH = 16;
+static const size_t TEST_SHA1_DIGEST_LENGTH = 20;
+
+
+// keytype_from_text()
+void test_MD5KeyTypeWithoutDigestLength() {
+ TEST_ASSERT_EQUAL(KEY_TYPE_MD5, keytype_from_text("MD5", NULL));
+}
+
+void test_MD5KeyTypeWithDigestLength() {
+ size_t digestLength;
+ size_t expected = TEST_MD5_DIGEST_LENGTH;
+
+ TEST_ASSERT_EQUAL(KEY_TYPE_MD5, keytype_from_text("MD5", &digestLength));
+ TEST_ASSERT_EQUAL(expected, digestLength);
+}
+
+
+void test_SHA1KeyTypeWithDigestLength() {
+#ifdef OPENSSL
+ size_t digestLength;
+ size_t expected = TEST_SHA1_DIGEST_LENGTH;
+
+ TEST_ASSERT_EQUAL(NID_sha, keytype_from_text("SHA", &digestLength));
+ TEST_ASSERT_EQUAL(expected, digestLength);
+ /* OPENSSL */
+#else TEST_IGNORE_MESSAGE("Skipping because OPENSSL isn't defined");
+#endif
+}
+
+
+// keytype_name()
+void test_MD5KeyName() {
+ TEST_ASSERT_EQUAL_STRING("MD5", keytype_name(KEY_TYPE_MD5));
+}
+
+#ifdef OPENSSL
+TEvoid test_SHA1KeyName() {
+ TEST_ASSERT_EQUAL_STRING("SHA", keytype_name(NID_sha));
+}
+#endif /* OPENSSL */