[cpp-sp] 01/02: Prelim. unittest support for other builds.

Scott Cantor cantor.2 at osu.edu
Wed May 2 13:45:07 EDT 2018


This is an automated email from the git hooks/post-receive script.

scantor pushed a commit to branch master
in repository cpp-sp.

View the commit online:
http://git.shibboleth.net/view/?p=cpp-sp.git;a=commit;h=1451f650691e1c3cecddad9fa4e7197f305123f6

commit 1451f650691e1c3cecddad9fa4e7197f305123f6
Author: Scott Cantor <cantor.2 at osu.edu>
AuthorDate: Wed May 2 13:44:42 2018 -0400

    Prelim. unittest support for other builds.
---
 .gitignore                              |  1 +
 Makefile.am                             |  3 ++-
 configure.ac                            | 18 +++++++++++++++
 unittests/BaseTestCase.h                |  2 --
 unittests/DynamicMetadataProviderTest.h |  2 +-
 unittests/Makefile.am                   | 38 ++++++++++++++++++++++++++++++++
 unittests/SPTest.h                      | 39 +++++++++++++++++++++++++--------
 unittests/TestApplication.cpp           | 31 +++++++++++++++++++++-----
 unittests/TestApplication.h             | 20 +++++++++++++++++
 9 files changed, 135 insertions(+), 19 deletions(-)

diff --git a/.gitignore b/.gitignore
index 28926b2..a4f217f 100644
--- a/.gitignore
+++ b/.gitignore
@@ -95,5 +95,6 @@ x64
 /util/mdquery
 /util/resolvertest
 /unittests/*.cpp
+/unittests/shibsptest
 .deps
 .dirstamp
diff --git a/Makefile.am b/Makefile.am
index 5fa116d..671961c 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -23,7 +23,8 @@ DIST_SUBDIRS = \
 	fastcgi \
 	odbc-store \
 	memcache-store \
-	selinux
+	selinux \
+	unittests
 
 if DX_COND_doc
 all-local: doxygen-doc
diff --git a/configure.ac b/configure.ac
index 028ec43..e0ad52e 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1302,6 +1302,24 @@ else
   CPPFLAGS="$save_CPPFLAGS"
 fi
 
+# Check for unit test support
+AC_CONFIG_FILES([unittests/Makefile])
+CXXTEST="/usr/bin/cxxtestgen.pl"
+CXXTESTFLAGS=""
+AC_ARG_WITH(cxxtest,
+    AS_HELP_STRING([--with-cxxtest=PATH], [where cxxtest is installed]),
+    [if test x_$with_cxxtest != x_/usr; then
+        CXXTEST="${with_cxxtest}/cxxtestgen.pl"
+        CXXTESTFLAGS="-I${with_cxxtest}"
+    fi])
+if ! test -f "${CXXTEST}"; then
+    AC_MSG_WARN([cxxtestgen not found, won't build unit tests])
+fi
+
+AC_SUBST(CXXTEST)
+AC_SUBST(CXXTESTFLAGS)
+AM_CONDITIONAL(BUILD_UNITTEST,test -f ${CXXTEST})
+WANT_SUBDIRS="$WANT_SUBDIRS unittests"
 
 AC_SUBST(WANT_SUBDIRS)
 
diff --git a/unittests/BaseTestCase.h b/unittests/BaseTestCase.h
deleted file mode 100644
index 345f02f..0000000
--- a/unittests/BaseTestCase.h
+++ /dev/null
@@ -1,2 +0,0 @@
-#pragma once
-#include <cxxtest/TestSuite.h>
diff --git a/unittests/DynamicMetadataProviderTest.h b/unittests/DynamicMetadataProviderTest.h
index def7610..c3ae016 100644
--- a/unittests/DynamicMetadataProviderTest.h
+++ b/unittests/DynamicMetadataProviderTest.h
@@ -19,7 +19,7 @@
 */
 #include <fstream>
 
-#include "BaseTestCase.h"
+#include <cxxtest/TestSuite.h>
 
 #include <xercesc/dom/DOMDocument.hpp>
 
diff --git a/unittests/Makefile.am b/unittests/Makefile.am
new file mode 100644
index 0000000..dabef81
--- /dev/null
+++ b/unittests/Makefile.am
@@ -0,0 +1,38 @@
+AUTOMAKE_OPTIONS = foreign subdir-objects
+
+if BUILD_UNITTEST
+bin_PROGRAMS = shibsptest
+shibsptest_CXXFLAGS = $(CXXFLAGS) $(CXXTESTFLAGS)
+else
+bin_PROGRAMS = 
+endif
+
+shibsptest_h = \
+    SPTest.h \
+    DynamicMetadataProviderTest.h
+    
+noinst_HEADERS = \
+    TestApplication.h \
+    $(shibsptest_h)
+
+nodist_shibsptest_SOURCES = $(shibsptest_h:.h=.cpp)
+shibsptest_SOURCES = TestApplication.cpp
+
+if BUILD_UNITTEST
+BUILT_SOURCES = $(nodist_shibsptest_SOURCES)
+CLEANFILES = $(nodist_shibsptest_SOURCES)
+endif
+
+do-cxxtestgen:
+	if test "$(CPPFILE)" = "SPTest.cpp"; then \
+		$(CXXTEST) --error-printer --have-eh --have-std --abort-on-fail -o $(CPPFILE) $(HFILE); \
+	else \
+		$(CXXTEST) --part --have-eh --have-std --abort-on-fail -o $(CPPFILE) $(HFILE); \
+	fi;
+
+$(nodist_shibsptest_SOURCES): %.cpp: %.h
+	$(MAKE) do-cxxtestgen HFILE=$< CPPFILE=$@
+
+shibsptest_LDADD = $(top_builddir)/shibsp/libshibsp.la
+
+EXTRA_DIST = data
diff --git a/unittests/SPTest.h b/unittests/SPTest.h
index 45bfb2c..c595d9c 100644
--- a/unittests/SPTest.h
+++ b/unittests/SPTest.h
@@ -1,15 +1,36 @@
-#include <Windows.h>
+/**
+* Licensed to the University Corporation for Advanced Internet
+* Development, Inc. (UCAID) under one or more contributor license
+* agreements. See the NOTICE file distributed with this work for
+* additional information regarding copyright ownership.
+*
+* UCAID licenses this file to you under the Apache License,
+* Version 2.0 (the "License"); you may not use this file except
+* in compliance with the License. You may obtain a copy of the
+* License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+* either express or implied. See the License for the specific
+* language governing permissions and limitations under the License.
+*/
+
 #include <fstream>
-#include "BaseTestCase.h"
-#include <shibsp/SPConfig.h>
+
+#include <cxxtest/TestSuite.h>
 #include <cxxtest/GlobalFixture.h>
-#include <shibsp\metadata\MetadataExt.h>
-#include <shibsp\ServiceProvider.h>
+
+#include <shibsp/SPConfig.h>
+#include <shibsp/metadata/MetadataExt.h>
+#include <shibsp/ServiceProvider.h>
 
 using namespace shibsp;
 
-std::string data_path = "unittests/data/";
-std::string config_path = "unittests/config";
+std::string data_path = "../unittests/data/";
+std::string config_path = "../unittests/config";
 
 class ToolingFixture : public CxxTest::GlobalFixture
 {
@@ -26,7 +47,7 @@ public:
             return false;
         }
 
-        if (!conf.instantiate("./configs/shibboleth3.xml")) {
+        if (!conf.instantiate("../configs/shibboleth3.xml")) {
             fprintf(stderr, "configuration is invalid, see console for specific problems\n");
             return false;
         }
@@ -51,4 +72,4 @@ public:
     void testssrf(void) {
         TS_ASSERT(true);
     }
-};
\ No newline at end of file
+};
diff --git a/unittests/TestApplication.cpp b/unittests/TestApplication.cpp
index fe0ba31..b24d0f1 100644
--- a/unittests/TestApplication.cpp
+++ b/unittests/TestApplication.cpp
@@ -1,10 +1,29 @@
-
-#include <Windows.h>
-#include <xmltooling\unicode.h>
-
+/**
+* Licensed to the University Corporation for Advanced Internet
+* Development, Inc. (UCAID) under one or more contributor license
+* agreements. See the NOTICE file distributed with this work for
+* additional information regarding copyright ownership.
+*
+* UCAID licenses this file to you under the Apache License,
+* Version 2.0 (the "License"); you may not use this file except
+* in compliance with the License. You may obtain a copy of the
+* License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+* either express or implied. See the License for the specific
+* language governing permissions and limitations under the License.
+*/
+
+#include <xmltooling/unicode.h>
 #include <shibsp/Application.h>
 #include <shibsp/util/DOMPropertySet.h>
-#include <TestApplication.h>
+
+#include "TestApplication.h"
+
 using namespace std;
 using namespace shibsp;
 using namespace opensaml;
@@ -174,4 +193,4 @@ namespace ta {
         return nullptr;
     }
 
-}
\ No newline at end of file
+}
diff --git a/unittests/TestApplication.h b/unittests/TestApplication.h
index 937ebd0..8af9cf5 100644
--- a/unittests/TestApplication.h
+++ b/unittests/TestApplication.h
@@ -1,3 +1,23 @@
+/**
+* Licensed to the University Corporation for Advanced Internet
+* Development, Inc. (UCAID) under one or more contributor license
+* agreements. See the NOTICE file distributed with this work for
+* additional information regarding copyright ownership.
+*
+* UCAID licenses this file to you under the Apache License,
+* Version 2.0 (the "License"); you may not use this file except
+* in compliance with the License. You may obtain a copy of the
+* License at
+*
+* http://www.apache.org/licenses/LICENSE-2.0
+*
+* Unless required by applicable law or agreed to in writing,
+* software distributed under the License is distributed on an
+* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND,
+* either express or implied. See the License for the specific
+* language governing permissions and limitations under the License.
+*/
+
 #include <shibsp/SPConfig.h>
 #include <shibsp/Application.h>
 #include <shibsp/util/DOMPropertySet.h>

-- 
To stop receiving notification emails like this one, please contact
the administrator of this repository.


More information about the commits mailing list