diff --git a/.gitattributes b/.gitattributes index 2b0b6f9ce75a521801d672420e5915a7b1b7a717..85ffde47cfe4c6773e83c7468e741e0cb08f3811 100644 --- a/.gitattributes +++ b/.gitattributes @@ -358,6 +358,10 @@ MAC/APL/StationCU/src/HardwareMonitor/TBBMonitor.cc -text MAC/APL/StationCU/src/HardwareMonitor/TBBMonitor.h -text MAC/APL/StationCU/src/TBBControl/TBBObservation.cc -text MAC/APL/StationCU/src/TBBControl/TBBObservation.h -text +MAC/APL/TestSuite/Makefile.am -text svneol=native#application/octet-stream +MAC/APL/TestSuite/bootstrap -text svneol=native#application/octet-stream +MAC/APL/TestSuite/configure.in -text svneol=native#application/octet-stream +MAC/APL/TestSuite/src/Makefile.am -text svneol=native#application/octet-stream MAC/APL/lofarconf.in -text svneol=native#application/octet-stream MAC/Config/Apc/b1.apc -text svneol=native#application/octet-stream MAC/Config/Apc/b2.apc -text svneol=native#application/octet-stream diff --git a/.gitignore b/.gitignore index 79dac15d559f5c8a0d7f9cffea44f02aa9a8953b..0c16a63417245efb86bfc2e242ac672cdc563e00 100644 --- a/.gitignore +++ b/.gitignore @@ -165,6 +165,9 @@ MAC/APL/StsMisc/lofarconf MAC/APL/TestCtlr/Makefile.common MAC/APL/TestCtlr/autoconf_share MAC/APL/TestCtlr/lofarconf +MAC/APL/TestSuite/Makefile.common +MAC/APL/TestSuite/autoconf_share +MAC/APL/TestSuite/lofarconf MAC/Deployment/Makefile.common MAC/Deployment/autoconf_share MAC/Deployment/lofarconf diff --git a/MAC/APL/TestSuite/Makefile.am b/MAC/APL/TestSuite/Makefile.am new file mode 100644 index 0000000000000000000000000000000000000000..1ada844b8396a57a9eaacdc236c620b7dd7ade91 --- /dev/null +++ b/MAC/APL/TestSuite/Makefile.am @@ -0,0 +1,16 @@ +SUBDIRS=src include + +ACLOCAL_AMFLAGS = -I autoconf_share + +pkgextdir = $(prefix)/config/$(PACKAGE) +pkgext_DATA = pkgext pkgextcppflags pkgextcxxflags pkgextldflags + +DISTCHECK_CONFIGURE_FLAGS=\ + --with-common=$(prefix) + +EXTRA_DIST = \ + Makefile.common \ + Suite.spec \ + autoconf_share/compiletool + +include $(top_srcdir)/Makefile.common diff --git a/MAC/APL/TestSuite/Suite.spec.in b/MAC/APL/TestSuite/Suite.spec.in new file mode 100644 index 0000000000000000000000000000000000000000..ddb36255bb26d2ce0833d0615d1819db569cb83c --- /dev/null +++ b/MAC/APL/TestSuite/Suite.spec.in @@ -0,0 +1,161 @@ +# -*- Mode:rpm-spec -*- +# Suite.spec.in +# + +############################################################################## +# +# Preamble +# +############################################################################## + +Summary: The test Suite package contains the base classes for the test suite framework. + +%define release @RPM_RELEASE@ +%define version @VERSION@ +%define pkgname @PACKAGE@ +%define pkgdir %{pkgname}-%{version}-%{release} +%define prefix /opt/lofar +%define configure_args @RPM_CONFIGURE_ARGS@ +##define build_kernel_version @BUILD_KERNEL_VERSION@ + +Name: %{pkgname} +Version: %{version} +Release: %{release} +Copyright: LGPL +Group: Application/System +Source: %{pkgname}-%{version}.tar.gz +BuildRoot: %{_tmppath}/%{pkgdir}-root +URL: http://www.astron.nl +Prefix: %{prefix} +BuildArchitectures: i386 # Target platforms, i.e., i586 +Requires: Common >= 2.2 +Packager: %{packager} +Distribution: The LOFAR project +Vendor: ASTRON + +AutoReqProv: no + +%description + +The test Suite package contains the base classes for the test suite framework. + + +############################################################################## +# +# prep +# +############################################################################## +%prep +echo $prefix + +# create the build directory, untar the source +%setup + +############################################################################## +# +# build +# +############################################################################## +%build +./configure %{configure_args} --prefix=%{prefix} && make + +############################################################################## +# +# install +# +############################################################################## +%install +# To make things work with BUILDROOT +if [ "$RPM_BUILD_ROOT" != "%{_tmppath}/%{pkgdir}-root" ] +then + echo + echo @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ + echo @ @ + echo @ RPM_BUILD_ROOT is not what I expected. Please clean it yourself. @ + echo @ @ + echo @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ + echo +else + echo Cleaning RPM_BUILD_ROOT: "$RPM_BUILD_ROOT" + rm -rf "$RPM_BUILD_ROOT" +fi +mkdir -p $RPM_BUILD_ROOT%{prefix} +make DESTDIR="$RPM_BUILD_ROOT" install + +#uninstall + +############################################################################## +# +# verify +# +############################################################################## +#verify + +############################################################################## +# +# clean +# +############################################################################## +%clean +# Call me paranoid, but I do not want to be responsible for nuking +# someone's harddrive! +if [ "$RPM_BUILD_ROOT" != "%{_tmppath}/%{pkgdir}-root" ] +then + echo + echo @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ + echo @ @ + echo @ RPM_BUILD_ROOT is not what I expected. Please clean it yourself. @ + echo @ @ + echo @@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@@ + echo +else + echo Cleaning RPM_BUILD_ROOT: "$RPM_BUILD_ROOT" + rm -rf "$RPM_BUILD_ROOT" +fi + +############################################################################## +# +# files +# +############################################################################## + +# empty 'files' means all distributed files +%files +%defattr(-, root, root) +%{prefix} + +# Your application file list goes here +# %{prefix}/lib/lib*.so* + +# Documentation +# doc COPYING ChangeLog README AUTHORS NEWS +# doc doc/* + +# link the module to the correct path +%post + +# before uninstall +%preun + +# after uninstall +%postun + +############################################################################## +# +# package devel +# +############################################################################## + +#package devel +#Summary: Development files for %{pkgname} +#Group: Applications/System +#description devel +#Development files for %{pkgname}. + +#files devel + +# Your development files go here +# Programmers documentation goes here +#doc doc + +# end of file diff --git a/MAC/APL/TestSuite/bootstrap b/MAC/APL/TestSuite/bootstrap new file mode 100755 index 0000000000000000000000000000000000000000..06f18cde1dbfd6912ef7d927c4d35d25c7137a62 --- /dev/null +++ b/MAC/APL/TestSuite/bootstrap @@ -0,0 +1,3 @@ +#!/bin/sh + +../../../autoconf_share/bootstrap ../../../autoconf_share diff --git a/MAC/APL/TestSuite/configure.in b/MAC/APL/TestSuite/configure.in new file mode 100644 index 0000000000000000000000000000000000000000..935cc38b3d300027a19eeef1faef3bb895816465 --- /dev/null +++ b/MAC/APL/TestSuite/configure.in @@ -0,0 +1,66 @@ +dnl +dnl Process this file with autoconf to produce a configure script. +dnl +AC_INIT +dnl AC_CONFIG_AUX_DIR(config) +dnl AM_CONFIG_HEADER(config/config.h) +AM_CONFIG_HEADER(config.h) +AM_INIT_AUTOMAKE(Suite, 1.0, no-define) + +dnl Initialize for LOFAR (may set compilers) +lofar_INIT + +dnl Checks for programs. +AC_PROG_AWK +AC_PROG_CC +AC_PROG_CXX +AC_PROG_INSTALL +AC_PROG_LN_S +AC_DISABLE_SHARED +AC_PROG_LIBTOOL +AC_PROG_YACC +AM_PROG_LEX + +dnl Checks for libraries. + +dnl dnl Replace `main' with a function in -lfl: +dnl AC_CHECK_LIB(fl, main) +dnl dnl Replace `main' with a function in -lcosev_r: +dnl AC_CHECK_LIB(cosev_r, main) +dnl dnl Replace `main' with a function in -lcosnm_r: +dnl AC_CHECK_LIB(cosnm_r, main) +dnl dnl Replace `main' with a function in -lorb_r: +dnl AC_CHECK_LIB(orb_r, main) +dnl dnl Replace `main' with a function in -lpthread: +dnl AC_CHECK_LIB(pthread, main) +dnl dnl Replace `main' with a function in -lvport_r: +dnl AC_CHECK_LIB(vport_r, main) + +dnl Checks for header files. +AC_HEADER_STDC +AC_CHECK_HEADERS(unistd.h) + +dnl Checks for typedefs, structures, and compiler characteristics. +AC_C_CONST +AC_TYPE_SIZE_T + +dnl Checks for library functions. +AC_FUNC_VPRINTF + +dnl +dnl Check for LOFAR specific things +dnl +lofar_GENERAL +lofar_COMPILETOOLS +lofar_INTERNAL(LCS/Common, Common, , 1, Common/LofarTypes.h,,) + +dnl +dnl Output Makefiles +dnl +AC_OUTPUT( +include/Makefile +include/TestSuite/Makefile +src/Makefile +Makefile +TestSuite.spec +) diff --git a/MAC/APL/TestSuite/include/Makefile.am b/MAC/APL/TestSuite/include/Makefile.am new file mode 100644 index 0000000000000000000000000000000000000000..9d40ec31f223c343f1c6a054230e9fdda3a00f3f --- /dev/null +++ b/MAC/APL/TestSuite/include/Makefile.am @@ -0,0 +1,3 @@ +SUBDIRS = TestSuite + +include $(top_srcdir)/Makefile.common diff --git a/MAC/APL/TestSuite/src/Makefile.am b/MAC/APL/TestSuite/src/Makefile.am new file mode 100644 index 0000000000000000000000000000000000000000..2fdcb42941dbfffcc2d5ad36beb1bc2c22d0c526 --- /dev/null +++ b/MAC/APL/TestSuite/src/Makefile.am @@ -0,0 +1,38 @@ +pkgincludedir = $(includedir)/Suite + +NOINSTHDRS = + +INSTHDRS = + +pkginclude_HEADERS = $(NOINSTHDRS) $(INSTHDRS) + +DOCHDRS = $(pkginclude_HEADERS) + +lib_LTLIBRARIES = libsuite.la + +libaplcommon_la_CPPFLAGS= \ + -I$(top_srcdir)/include \ + -DBOOST_DISABLE_THREADS \ + -Wno-deprecated \ + -fmessage-length=0 \ + -fdiagnostics-show-location=once + +libsuite_la_SOURCES= Package__Version.cc $(DOCHDRS) \ + suite.cpp \ + test.cpp + +BUILT_SOURCES = + +EXTRA_DIST = + +clean-local: + rm -f *.ph + +bin_PROGRAMS = versionsuite + +versionsuite_SOURCES = versionsuite.cc +versionsuite_LDADD = libsuite.la +versionsuite_DEPENDENCIES = libsuite.la $(LOFAR_DEPEND) + +include $(top_srcdir)/Makefile.common + diff --git a/MAC/APL/TestSuite/src/suite.cpp b/MAC/APL/TestSuite/src/suite.cpp new file mode 100644 index 0000000000000000000000000000000000000000..aa2688bd72ef14b0bef397104fafa08c79d8cd18 --- /dev/null +++ b/MAC/APL/TestSuite/src/suite.cpp @@ -0,0 +1,135 @@ +//# suite.cpp +//# +//# Source: C++ Users Journal - September 2000 +//# Chuck Allison - The Simplest Automated Unit Test Framework That Could Possibly Work +//# Article: http://www.cuj.com/documents/s=8035/cuj0009allison1/ +//# code: ftp://ftp.cuj.com/pub/2000/cujsep2000.zip +//# +//# Modifications for LOFAR: +//# - removed TestSuiteError exception +//# - removed runtime type information +//# +//# Copyright (C) 2002-2004 +//# ASTRON (Netherlands Foundation for Research in Astronomy) +//# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands, seg@astron.nl +//# +//# This program is free software; you can redistribute it and/or modify +//# it under the terms of the GNU General Public License as published by +//# the Free Software Foundation; either version 2 of the License, or +//# (at your option) any later version. +//# +//# This program is distributed in the hope that it will be useful, +//# but WITHOUT ANY WARRANTY; without even the implied warranty of +//# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +//# GNU General Public License for more details. +//# +//# You should have received a copy of the GNU General Public License +//# along with this program; if not, write to the Free Software +//# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +//# +//# $Id$ + +#include <TestSuite/suite.h> +#include <Common/lofar_iostream.h> +#include <assert.h> + +void Suite::addTest(Test* t) +{ + // Make sure test has a stream: + if (t != 0) + { + if (m_osptr != 0 && t->getStream() == 0) + { + t->setStream(m_osptr); + } + m_tests.push_back(t); + t->reset(); + } +} + +void Suite::addSuite(const Suite& s) +{ + for (size_t i = 0; i < s.m_tests.size(); ++i) + addTest(s.m_tests[i]); +} + +void Suite::free() +{ + // This is not a destructor because tests + // don't have to be on the heap. + for (size_t i = 0; i < m_tests.size(); ++i) + { + delete m_tests[i]; + m_tests[i] = 0; + } +} + +void Suite::run() +{ + reset(); + for (size_t i = 0; i < m_tests.size(); ++i) + { + assert(m_tests[i]); + m_tests[i]->run(); + } +} + + +long Suite::report() const +{ + if (m_osptr) + { + long totFail = 0; + *m_osptr << "Test suite \"" << m_name << "\"\n======="; + size_t i; + for (i = 0; i < m_name.size(); ++i) + *m_osptr << '='; + *m_osptr << "=\n"; + + for (i = 0; i < m_tests.size(); ++i) + { + assert(m_tests[i]); + totFail += m_tests[i]->report(); + } + + *m_osptr << "======="; + for (i = 0; i < m_name.size(); ++i) + *m_osptr << '='; + *m_osptr << "=\n"; + return totFail; + } + else + return getNumFailed(); +} + +long Suite::getNumPassed() const +{ + long totPass = 0; + for (size_t i = 0; i < m_tests.size(); ++i) + { + assert(m_tests[i]); + totPass += m_tests[i]->getNumPassed(); + } + return totPass; +} + +long Suite::getNumFailed() const +{ + long totFail = 0; + for (size_t i = 0; i < m_tests.size(); ++i) + { + assert(m_tests[i]); + totFail += m_tests[i]->getNumFailed(); + } + return totFail; +} + +void Suite::reset() +{ + for (size_t i = 0; i < m_tests.size(); ++i) + { + assert(m_tests[i]); + m_tests[i]->reset(); + } +} + diff --git a/MAC/APL/TestSuite/src/test.cpp b/MAC/APL/TestSuite/src/test.cpp new file mode 100644 index 0000000000000000000000000000000000000000..6c06c4fb9689f5ae03e46c75da70bf0a91fdae38 --- /dev/null +++ b/MAC/APL/TestSuite/src/test.cpp @@ -0,0 +1,154 @@ +//# test.cpp +//# +//# Source: C++ Users Journal - September 2000 +//# Chuck Allison - The Simplest Automated Unit Test Framework That Could Possibly Work +//# Article: http://www.cuj.com/documents/s=8035/cuj0009allison1/ +//# code: ftp://ftp.cuj.com/pub/2000/cujsep2000.zip +//# +//# Modifications for LOFAR: +//# - removed TestSuiteError exception +//# - removed runtime type information +//# +//# Copyright (C) 2002-2004 +//# ASTRON (Netherlands Foundation for Research in Astronomy) +//# P.O.Box 2, 7990 AA Dwingeloo, The Netherlands, seg@astron.nl +//# +//# This program is free software; you can redistribute it and/or modify +//# it under the terms of the GNU General Public License as published by +//# the Free Software Foundation; either version 2 of the License, or +//# (at your option) any later version. +//# +//# This program is distributed in the hope that it will be useful, +//# but WITHOUT ANY WARRANTY; without even the implied warranty of +//# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +//# GNU General Public License for more details. +//# +//# You should have received a copy of the GNU General Public License +//# along with this program; if not, write to the Free Software +//# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +//# +//# $Id$ + +#include <lofar_config.h> +#include <TestSuite/test.h> +#include <Common/lofar_iostream.h> +#include <Common/LofarLogger.h> +#include <Common/StringUtil.h> + +using std::endl; + +#ifdef _MSC_VER +//Allow return-less mains: +#pragma warning(disable: 4541) +#endif + +bool Test::do_test(bool cond, const std::string& lbl, + const char* descr, + const char* fname, long lineno) +{ + if (!cond) + do_fail(lbl, descr, fname, lineno); + else + succeed(lbl, descr, fname, lineno); + + return cond; +} + +void Test::do_fail(const std::string& lbl, + const char* descr, + const char* fname, long lineno) +{ + ++m_nFail; + m_subTests[m_curSubTest].failed++; + string failure; + failure += "Test: (" + m_curSubTest +") "; + if (descr) failure += descr; + if (lbl.length() > 0) failure += " (" + lbl + ")"; + failure += LOFAR::formatString(" => FAILED!!! [%s:%d]", (strrchr(fname, '/') + 1), lineno); + if (m_osptr) + { + *m_osptr << failure << endl; + } + m_failures.push_back(failure); +} + +void Test::succeed(const std::string& lbl, + const char* descr, + const char* fname, long lineno) +{ + m_subTests[m_curSubTest].passed++; + ++m_nPass; + if (m_osptr) + { + *m_osptr << "Test: "; + if (descr) *m_osptr << descr; + *m_osptr << "(" << lbl << ") => succeed [" + << (strrchr(fname, '/') + 1) + << ":" << lineno << "]\n"; + } +} + +long Test::report() const +{ + if (m_osptr) + { + *m_osptr << "Test summary \"" + << m_name << "\":\n" + << "\tPassed: " << m_nPass + << "\tFailed: " << m_nFail + << endl << "Failures:" << endl; + + for (TFailures::const_iterator iter = m_failures.begin(); + iter != m_failures.end(); ++iter) + { + *m_osptr << "\t" << *iter << endl; + } + } + return m_nFail; +} + +void Test::reportSubTest() +{ + if (m_osptr && m_curSubTest != "") + { + *m_osptr << "Finish (sub)test " + << m_name << "." << m_curSubTest + << "\tPassed: " << m_subTests[m_curSubTest].passed + << "\tFailed: " << m_subTests[m_curSubTest].failed + << endl; + } +} + +void Test::setCurSubTest(const char* testname, const char* description) +{ + if (m_curSubTest != testname && m_osptr) + { + if (m_curSubTest.length() > 0) + { + *m_osptr << "Finish (sub)test " + << m_name << "." << m_curSubTest + << "\tPassed: " << m_subTests[m_curSubTest].passed + << "\tFailed: " << m_subTests[m_curSubTest].failed + << endl; + } + *m_osptr << "Start (sub)test " + << m_name << "." << testname; + if (description) *m_osptr << ": " << description; + *m_osptr << endl; + } + m_curSubTest = testname; + TSubTests::iterator iter = m_subTests.find(m_curSubTest); + if (iter != m_subTests.end()) + { + TSubTest subTest; + subTest.passed = 0; + subTest.failed = 0; + m_subTests[m_curSubTest] = subTest; + } +} + + +void Test::reset() +{ + m_nPass = m_nFail = 0; +}