Skip to content
Snippets Groups Projects
Commit c926d1de authored by Ger van Diepen's avatar Ger van Diepen
Browse files

bug 1166:

Added tests
parent dd7c3711
No related branches found
No related tags found
No related merge requests found
# -*- Mode:rpm-spec -*-
# SourceDB.spec.in
#
##############################################################################
#
# Preamble
#
##############################################################################
Summary: SourceDB is the Source Model Data Base
%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 = 1.2 ## define dependent packages here
Packager: %{packager}
Distribution: The LOFAR project
Vendor: ASTRON
AutoReqProv: no
%description
SourceDB is the module containing the classes and functions to handle the
sources in the Source model Data Base. The data base type used is hidden
from the user.
##############################################################################
#
# 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
check_PROGRAMS = tSourceDBStress
# programs to run through supplied checktools
CHECKTOOLPROGS =
# scripts used to run tests
TESTSCRIPTS = tsourcedb.sh tSourceDBStress.sh
# scripts and possible programs to run tests
TESTS = $(TESTSCRIPTS)
XFAIL_TESTS =
# all files (.run, .stdout, .in, .log_prop, etc.) needed to run tests
EXTRA_DIST = $(TESTSCRIPTS) \
tsourcedb.run tsourcedb.in tsourcedb.stdout \
tSourceDBStress.run
tSourceDBStress_SOURCES = tSourceDBStress.cc
tSourceDBStress_LDADD = ../src/libsourcedb.la
tSourceDBStress_DEPENDENCIES = ../src/libsourcedb.la $(LOFAR_DEPEND)
include $(top_srcdir)/Makefile.common
//# tSourceDBStress.cc: Stress test for adding and searching sources
//#
//# Copyright (C) 2008
//# 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 <SourceDB/SourceDB.h>
#include <casa/OS/Timer.h>
#include <iostream>
#include <sstream>
#include <stdexcept>
using namespace std;
using namespace casa;
using namespace LOFAR;
using namespace SourceDB;
using namespace ParmDB;
int main(int argc, const char* argv[])
{
try {
int nrsrc = 10000;
int nrsearch = 1;
if (argc > 1) {
istringstream istr(argv[1]);
istr >> nrsrc;
}
if (argc > 2) {
istringstream istr(argv[2]);
istr >> nrsearch;
}
SourceDBMeta meta ("aips", "tSourceDBStress_tmp.sdb");
LOFAR::SourceDB::SourceDB sourcetab (meta, true);
sourcetab.lock();
// Add all the sources.
Timer timer;
for (int i=0; i<nrsrc; ++i) {
SourceValue pvalue;
double ra = 1.2; // radians
double dec = 2.1;
double spindex = 1;
double flux[4] = {1,0,0,0};
pvalue.setPointSource ("src", ra, dec, flux, spindex);
sourcetab.addSource (pvalue);
}
cout << "added " << nrsrc << " sources";
timer.show();
// Now do a search for some sources.
timer.mark();
for (int i=0; i<nrsearch; ++i) {
sourcetab.getSources (0.1, 0.1, 0.00001, ParmDomain());
}
cout << "searched " << nrsearch << " sources";
timer.show();
} catch (std::exception& x) {
cout << "Unexpected exception: " << x.what() << endl;
}
}
#!/bin/sh
$lofar_sharedir/runtest.sh tSourceDBStress > tSourceDBStress.log 2>&1
create tablename='tsourcedb_tmp.sdb'
show ab*c
add casa ra=12:34:56.7, dec=12.34.56.7
show
close
open tablename='tsourcedb_tmp.sdb'
update casa spindex=2
show c*
add casb ra=12:34:56.7, dec=12.34.56.7, spindex=1.5
add virb domain=[st=[20000000,'2008/02/25/04:15:13'],size=[20000,3600]], ra=-8:76:54.321, dec=-12.34.56.7, spindex=1.5
add virb domain=[st=[20000000,'2008/02/25/05:15:13'],size=[20000,3600]], ra=-8:76:54.321, dec=-12.34.56.7, spindex=1.6
add vira domain=[st=[20000000],size=[20000]], ra=-6:76:54.321, dec=-72.34.56.7, spindex=1.75
show
show ra=-8:76:54.321, dec=-12.34.56.7
quit
#!/bin/sh
../src/sourcedb < tsourcedb.in
#!/bin/sh
$lofar_sharedir/runtest.sh tsourcedb > tsourcedb.log 2>&1
0 source records found
casa type=point ra=12:34:56.700 dec=+012.34.56.700
spectralindex=1 domain: freq=all time=all
Wrote new record for source casa
casa type=point ra=12:34:56.700 dec=+012.34.56.700
spectralindex=1 domain: freq=all time=all
casa type=point ra=12:34:56.700 dec=+012.34.56.700
spectralindex=2 domain: freq=all time=all
Updated 1 source record(s)
casa type=point ra=12:34:56.700 dec=+012.34.56.700
spectralindex=2 domain: freq=all time=all
casb type=point ra=12:34:56.700 dec=+012.34.56.700
spectralindex=1.5 domain: freq=all time=all
Wrote new record for source casb
virb type=point ra=14:43:05.679 dec=-012.34.56.700
spectralindex=1.5 domain: freq=[20 MHz +20 KHz] time=[2008/02/25/04:15:13 +3600 sec]
Wrote new record for source virb
virb type=point ra=14:43:05.679 dec=-012.34.56.700
spectralindex=1.6 domain: freq=[20 MHz +20 KHz] time=[2008/02/25/05:15:13 +3600 sec]
Wrote new record for source virb
vira type=point ra=16:43:05.679 dec=-072.34.56.700
spectralindex=1.75 domain: freq=[20 MHz +20 KHz] time=all
Wrote new record for source vira
casa type=point ra=12:34:56.700 dec=+012.34.56.700
spectralindex=2 domain: freq=all time=all
casb type=point ra=12:34:56.700 dec=+012.34.56.700
spectralindex=1.5 domain: freq=all time=all
virb type=point ra=14:43:05.679 dec=-012.34.56.700
spectralindex=1.5 domain: freq=[20 MHz +20 KHz] time=[2008/02/25/04:15:13 +3600 sec]
virb type=point ra=14:43:05.679 dec=-012.34.56.700
spectralindex=1.6 domain: freq=[20 MHz +20 KHz] time=[2008/02/25/05:15:13 +3600 sec]
vira type=point ra=16:43:05.679 dec=-072.34.56.700
spectralindex=1.75 domain: freq=[20 MHz +20 KHz] time=all
5 source records found
virb type=point ra=14:43:05.679 dec=-012.34.56.700
spectralindex=1.5 domain: freq=[20 MHz +20 KHz] time=[2008/02/25/04:15:13 +3600 sec]
virb type=point ra=14:43:05.679 dec=-012.34.56.700
spectralindex=1.6 domain: freq=[20 MHz +20 KHz] time=[2008/02/25/05:15:13 +3600 sec]
2 source records found
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment