Commit 9cbdda39 authored by Giovanni La Mura's avatar Giovanni La Mura
Browse files

Create a memory sanity test suite for ParticleDescriptor

parent 60d181a0
Loading
Loading
Loading
Loading
+4 −2
Original line number Diff line number Diff line
@@ -2,7 +2,7 @@ LDADD=libnptm/libnptm.la -L/usr/lib64 ${USER_LDFLAGS} ${HDF5_LDFLAGS} ${LAPACKLD
lib_LTLIBRARIES=libnptm/libnptm.la
libnptm_libnptm_la_SOURCES=../src/libnptm/algebraic.cpp ../src/libnptm/clu_subs.cpp ../src/libnptm/Commons.cpp ../src/libnptm/Configuration.cpp ../src/libnptm/file_io.cpp ../src/libnptm/lapack_calls.cpp ../src/libnptm/logging.cpp ../src/libnptm/magma_calls.cpp ../src/libnptm/Parsers.cpp ../src/libnptm/sph_subs.cpp ../src/libnptm/utils.cpp ../src/libnptm/tfrfme.cpp ../src/libnptm/TransitionMatrix.cpp ../src/libnptm/tra_subs.cpp
if BUILDFORTRAN
PROGS=cluster/edfb_clu cluster/clu cluster/np_cluster inclusion/edfb_inclu inclusion/inclu inclusion/np_inclusion sphere/edfb_sph sphere/sph sphere/np_sphere trapping/frfme trapping/lffft trapping/np_trapping testing/test_TEDF testing/test_TTMS
PROGS=cluster/edfb_clu cluster/clu cluster/np_cluster inclusion/edfb_inclu inclusion/inclu inclusion/np_inclusion sphere/edfb_sph sphere/sph sphere/np_sphere trapping/frfme trapping/lffft trapping/np_trapping testing/test_ParticleDescriptor testing/test_TEDF testing/test_TTMS
bin_PROGRAMS=$(PROGS)
EDFBCLUSOURCES=../src/cluster/edfb_clu.f
CLUSOURCES=../src/cluster/clu.f
@@ -24,15 +24,17 @@ cluster_np_cluster_SOURCES=../src/cluster/np_cluster.cpp ../src/cluster/cluster.
inclusion_np_inclusion_SOURCES=../src/inclusion/np_inclusion.cpp ../src/inclusion/inclusion.cpp
sphere_np_sphere_SOURCES=../src/sphere/np_sphere.cpp ../src/sphere/sphere.cpp
trapping_np_trapping_SOURCES=../src/trapping/np_trapping.cpp ../src/trapping/cfrfme.cpp ../src/trapping/clffft.cpp
testing_test_ParticleDescriptor_SOURCES=../src/testing/test_ParticleDescriptor.cpp
testing_test_TEDF_SOURCES=../src/testing/test_TEDF.cpp
testing_test_TTMS_SOURCES=../src/testing/test_TTMS.cpp
else
PROGS=cluster/np_cluster inclusion/np_inclusion sphere/np_sphere trapping/np_trapping testing/test_TEDF testing/test_TTMS
PROGS=cluster/np_cluster inclusion/np_inclusion sphere/np_sphere trapping/np_trapping testing/test_ParticleDescriptor testing/test_TEDF testing/test_TTMS
bin_PROGRAMS=$(PROGS)
cluster_np_cluster_SOURCES=../src/cluster/np_cluster.cpp ../src/cluster/cluster.cpp
inclusion_np_inclusion_SOURCES=../src/inclusion/np_inclusion.cpp ../src/inclusion/inclusion.cpp
sphere_np_sphere_SOURCES=../src/sphere/np_sphere.cpp ../src/sphere/sphere.cpp
trapping_np_trapping_SOURCES=../src/trapping/np_trapping.cpp ../src/trapping/cfrfme.cpp ../src/trapping/clffft.cpp
testing_test_ParticleDescriptor_SOURCES=../src/testing/test_ParticleDescriptor.cpp
testing_test_TEDF_SOURCES=../src/testing/test_TEDF.cpp
testing_test_TTMS_SOURCES=../src/testing/test_TTMS.cpp
endif
+30 −3
Original line number Diff line number Diff line
@@ -107,6 +107,7 @@ CONFIG_CLEAN_VPATH_FILES =
@BUILDFORTRAN_FALSE@	inclusion/np_inclusion$(EXEEXT) \
@BUILDFORTRAN_FALSE@	sphere/np_sphere$(EXEEXT) \
@BUILDFORTRAN_FALSE@	trapping/np_trapping$(EXEEXT) \
@BUILDFORTRAN_FALSE@	testing/test_ParticleDescriptor$(EXEEXT) \
@BUILDFORTRAN_FALSE@	testing/test_TEDF$(EXEEXT) \
@BUILDFORTRAN_FALSE@	testing/test_TTMS$(EXEEXT)
@BUILDFORTRAN_TRUE@am__EXEEXT_1 = cluster/edfb_clu$(EXEEXT) \
@@ -121,6 +122,7 @@ CONFIG_CLEAN_VPATH_FILES =
@BUILDFORTRAN_TRUE@	trapping/frfme$(EXEEXT) \
@BUILDFORTRAN_TRUE@	trapping/lffft$(EXEEXT) \
@BUILDFORTRAN_TRUE@	trapping/np_trapping$(EXEEXT) \
@BUILDFORTRAN_TRUE@	testing/test_ParticleDescriptor$(EXEEXT) \
@BUILDFORTRAN_TRUE@	testing/test_TEDF$(EXEEXT) \
@BUILDFORTRAN_TRUE@	testing/test_TTMS$(EXEEXT)
am__installdirs = "$(DESTDIR)$(bindir)" "$(DESTDIR)$(libdir)"
@@ -258,6 +260,16 @@ sphere_sph_LDADD = $(LDADD)
sphere_sph_DEPENDENCIES = libnptm/libnptm.la $(am__DEPENDENCIES_1) \
	$(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
	$(am__DEPENDENCIES_1)
am__testing_test_ParticleDescriptor_SOURCES_DIST =  \
	../src/testing/test_ParticleDescriptor.cpp
@BUILDFORTRAN_FALSE@am_testing_test_ParticleDescriptor_OBJECTS = ../src/testing/test_ParticleDescriptor.$(OBJEXT)
@BUILDFORTRAN_TRUE@am_testing_test_ParticleDescriptor_OBJECTS = ../src/testing/test_ParticleDescriptor.$(OBJEXT)
testing_test_ParticleDescriptor_OBJECTS =  \
	$(am_testing_test_ParticleDescriptor_OBJECTS)
testing_test_ParticleDescriptor_LDADD = $(LDADD)
testing_test_ParticleDescriptor_DEPENDENCIES = libnptm/libnptm.la \
	$(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1) \
	$(am__DEPENDENCIES_1) $(am__DEPENDENCIES_1)
am__testing_test_TEDF_SOURCES_DIST = ../src/testing/test_TEDF.cpp
@BUILDFORTRAN_FALSE@am_testing_test_TEDF_OBJECTS =  \
@BUILDFORTRAN_FALSE@	../src/testing/test_TEDF.$(OBJEXT)
@@ -345,6 +357,7 @@ am__depfiles_remade = ../src/cluster/$(DEPDIR)/cluster.Po \
	../src/libnptm/$(DEPDIR)/utils.Plo \
	../src/sphere/$(DEPDIR)/np_sphere.Po \
	../src/sphere/$(DEPDIR)/sphere.Po \
	../src/testing/$(DEPDIR)/test_ParticleDescriptor.Po \
	../src/testing/$(DEPDIR)/test_TEDF.Po \
	../src/testing/$(DEPDIR)/test_TTMS.Po \
	../src/trapping/$(DEPDIR)/cfrfme.Po \
@@ -407,6 +420,7 @@ SOURCES = $(libnptm_libnptm_la_SOURCES) $(cluster_clu_SOURCES) \
	$(inclusion_edfb_inclu_SOURCES) $(inclusion_inclu_SOURCES) \
	$(inclusion_np_inclusion_SOURCES) $(sphere_edfb_sph_SOURCES) \
	$(sphere_np_sphere_SOURCES) $(sphere_sph_SOURCES) \
	$(testing_test_ParticleDescriptor_SOURCES) \
	$(testing_test_TEDF_SOURCES) $(testing_test_TTMS_SOURCES) \
	$(trapping_frfme_SOURCES) $(trapping_lffft_SOURCES) \
	$(trapping_np_trapping_SOURCES)
@@ -420,6 +434,7 @@ DIST_SOURCES = $(libnptm_libnptm_la_SOURCES) \
	$(am__sphere_edfb_sph_SOURCES_DIST) \
	$(am__sphere_np_sphere_SOURCES_DIST) \
	$(am__sphere_sph_SOURCES_DIST) \
	$(am__testing_test_ParticleDescriptor_SOURCES_DIST) \
	$(am__testing_test_TEDF_SOURCES_DIST) \
	$(am__testing_test_TTMS_SOURCES_DIST) \
	$(am__trapping_frfme_SOURCES_DIST) \
@@ -623,8 +638,8 @@ top_srcdir = @top_srcdir@
LDADD = libnptm/libnptm.la -L/usr/lib64 ${USER_LDFLAGS} ${HDF5_LDFLAGS} ${LAPACKLDFLAGS} ${MAGMALDFLAGS}
lib_LTLIBRARIES = libnptm/libnptm.la
libnptm_libnptm_la_SOURCES = ../src/libnptm/algebraic.cpp ../src/libnptm/clu_subs.cpp ../src/libnptm/Commons.cpp ../src/libnptm/Configuration.cpp ../src/libnptm/file_io.cpp ../src/libnptm/lapack_calls.cpp ../src/libnptm/logging.cpp ../src/libnptm/magma_calls.cpp ../src/libnptm/Parsers.cpp ../src/libnptm/sph_subs.cpp ../src/libnptm/utils.cpp ../src/libnptm/tfrfme.cpp ../src/libnptm/TransitionMatrix.cpp ../src/libnptm/tra_subs.cpp
@BUILDFORTRAN_FALSE@PROGS = cluster/np_cluster inclusion/np_inclusion sphere/np_sphere trapping/np_trapping testing/test_TEDF testing/test_TTMS
@BUILDFORTRAN_TRUE@PROGS = cluster/edfb_clu cluster/clu cluster/np_cluster inclusion/edfb_inclu inclusion/inclu inclusion/np_inclusion sphere/edfb_sph sphere/sph sphere/np_sphere trapping/frfme trapping/lffft trapping/np_trapping testing/test_TEDF testing/test_TTMS
@BUILDFORTRAN_FALSE@PROGS = cluster/np_cluster inclusion/np_inclusion sphere/np_sphere trapping/np_trapping testing/test_ParticleDescriptor testing/test_TEDF testing/test_TTMS
@BUILDFORTRAN_TRUE@PROGS = cluster/edfb_clu cluster/clu cluster/np_cluster inclusion/edfb_inclu inclusion/inclu inclusion/np_inclusion sphere/edfb_sph sphere/sph sphere/np_sphere trapping/frfme trapping/lffft trapping/np_trapping testing/test_ParticleDescriptor testing/test_TEDF testing/test_TTMS
@BUILDFORTRAN_TRUE@EDFBCLUSOURCES = ../src/cluster/edfb_clu.f
@BUILDFORTRAN_TRUE@CLUSOURCES = ../src/cluster/clu.f
@BUILDFORTRAN_TRUE@EDFBINCLUSOURCES = ../src/inclusion/edfb_inclu.f
@@ -649,6 +664,8 @@ libnptm_libnptm_la_SOURCES = ../src/libnptm/algebraic.cpp ../src/libnptm/clu_sub
@BUILDFORTRAN_TRUE@sphere_np_sphere_SOURCES = ../src/sphere/np_sphere.cpp ../src/sphere/sphere.cpp
@BUILDFORTRAN_FALSE@trapping_np_trapping_SOURCES = ../src/trapping/np_trapping.cpp ../src/trapping/cfrfme.cpp ../src/trapping/clffft.cpp
@BUILDFORTRAN_TRUE@trapping_np_trapping_SOURCES = ../src/trapping/np_trapping.cpp ../src/trapping/cfrfme.cpp ../src/trapping/clffft.cpp
@BUILDFORTRAN_FALSE@testing_test_ParticleDescriptor_SOURCES = ../src/testing/test_ParticleDescriptor.cpp
@BUILDFORTRAN_TRUE@testing_test_ParticleDescriptor_SOURCES = ../src/testing/test_ParticleDescriptor.cpp
@BUILDFORTRAN_FALSE@testing_test_TEDF_SOURCES = ../src/testing/test_TEDF.cpp
@BUILDFORTRAN_TRUE@testing_test_TEDF_SOURCES = ../src/testing/test_TEDF.cpp
@BUILDFORTRAN_FALSE@testing_test_TTMS_SOURCES = ../src/testing/test_TTMS.cpp
@@ -910,12 +927,19 @@ sphere/sph$(EXEEXT): $(sphere_sph_OBJECTS) $(sphere_sph_DEPENDENCIES) $(EXTRA_sp
../src/testing/$(DEPDIR)/$(am__dirstamp):
	@$(MKDIR_P) ../src/testing/$(DEPDIR)
	@: > ../src/testing/$(DEPDIR)/$(am__dirstamp)
../src/testing/test_TEDF.$(OBJEXT): ../src/testing/$(am__dirstamp) \
../src/testing/test_ParticleDescriptor.$(OBJEXT):  \
	../src/testing/$(am__dirstamp) \
	../src/testing/$(DEPDIR)/$(am__dirstamp)
testing/$(am__dirstamp):
	@$(MKDIR_P) testing
	@: > testing/$(am__dirstamp)

testing/test_ParticleDescriptor$(EXEEXT): $(testing_test_ParticleDescriptor_OBJECTS) $(testing_test_ParticleDescriptor_DEPENDENCIES) $(EXTRA_testing_test_ParticleDescriptor_DEPENDENCIES) testing/$(am__dirstamp)
	@rm -f testing/test_ParticleDescriptor$(EXEEXT)
	$(AM_V_CXXLD)$(CXXLINK) $(testing_test_ParticleDescriptor_OBJECTS) $(testing_test_ParticleDescriptor_LDADD) $(LIBS)
../src/testing/test_TEDF.$(OBJEXT): ../src/testing/$(am__dirstamp) \
	../src/testing/$(DEPDIR)/$(am__dirstamp)

testing/test_TEDF$(EXEEXT): $(testing_test_TEDF_OBJECTS) $(testing_test_TEDF_DEPENDENCIES) $(EXTRA_testing_test_TEDF_DEPENDENCIES) testing/$(am__dirstamp)
	@rm -f testing/test_TEDF$(EXEEXT)
	$(AM_V_CXXLD)$(CXXLINK) $(testing_test_TEDF_OBJECTS) $(testing_test_TEDF_LDADD) $(LIBS)
@@ -991,6 +1015,7 @@ distclean-compile:
@AMDEP_TRUE@@am__include@ @am__quote@../src/libnptm/$(DEPDIR)/utils.Plo@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@../src/sphere/$(DEPDIR)/np_sphere.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@../src/sphere/$(DEPDIR)/sphere.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@../src/testing/$(DEPDIR)/test_ParticleDescriptor.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@../src/testing/$(DEPDIR)/test_TEDF.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@../src/testing/$(DEPDIR)/test_TTMS.Po@am__quote@ # am--include-marker
@AMDEP_TRUE@@am__include@ @am__quote@../src/trapping/$(DEPDIR)/cfrfme.Po@am__quote@ # am--include-marker
@@ -1366,6 +1391,7 @@ distclean: distclean-am
	-rm -f ../src/libnptm/$(DEPDIR)/utils.Plo
	-rm -f ../src/sphere/$(DEPDIR)/np_sphere.Po
	-rm -f ../src/sphere/$(DEPDIR)/sphere.Po
	-rm -f ../src/testing/$(DEPDIR)/test_ParticleDescriptor.Po
	-rm -f ../src/testing/$(DEPDIR)/test_TEDF.Po
	-rm -f ../src/testing/$(DEPDIR)/test_TTMS.Po
	-rm -f ../src/trapping/$(DEPDIR)/cfrfme.Po
@@ -1438,6 +1464,7 @@ maintainer-clean: maintainer-clean-am
	-rm -f ../src/libnptm/$(DEPDIR)/utils.Plo
	-rm -f ../src/sphere/$(DEPDIR)/np_sphere.Po
	-rm -f ../src/sphere/$(DEPDIR)/sphere.Po
	-rm -f ../src/testing/$(DEPDIR)/test_ParticleDescriptor.Po
	-rm -f ../src/testing/$(DEPDIR)/test_TEDF.Po
	-rm -f ../src/testing/$(DEPDIR)/test_TTMS.Po
	-rm -f ../src/trapping/$(DEPDIR)/cfrfme.Po
+101 −0
Original line number Diff line number Diff line
#include <string>

#ifndef INCLUDE_TYPES_H_
#include "../include/types.h"
#endif

#ifndef INCLUDE_ERRORS_H_
#include "../include/errors.h"
#endif

#ifndef INCLUDE_CONFIGURATION_H_
#include "../include/Configuration.h"
#endif

#ifndef INCLUDE_COMMONS_H_
#include "../include/Commons.h"
#endif

using namespace std;

int test_cluster_case_3();
int test_cluster_devel();
int test_inclusion();
int test_sphere();

int main() {
  int result = 0;
  result += test_sphere(); // 1 if failed
  result += test_cluster_devel(); // 10 if failed
  result += test_cluster_case_3(); // 100 if failed
  result += test_inclusion(); // 1000 if failed
  return result;
}

int test_cluster_case_3() {
  int result = 0;
  try {
    const string geom_data_file = "../../test_data/cluster/case_3/DCLU";
    const string scat_data_file = "../../test_data/cluster/case_3/DEDFB_33";
    GeometryConfiguration *gconf = GeometryConfiguration::from_legacy(geom_data_file);
    ScattererConfiguration *sconf = ScattererConfiguration::from_dedfb(scat_data_file);
    ParticleDescriptor *pd = new ParticleDescriptorCluster(gconf, sconf);
    delete gconf;
    delete sconf;
    delete pd;
  } catch (const exception& ex) {
    result = 100;
  }
  return result;
}

int test_cluster_devel() {
  int result = 0;
  try {
    const string geom_data_file = "../../test_data/cluster/DCLU";
    const string scat_data_file = "../../test_data/cluster/DEDFB";
    GeometryConfiguration *gconf = GeometryConfiguration::from_legacy(geom_data_file);
    ScattererConfiguration *sconf = ScattererConfiguration::from_dedfb(scat_data_file);
    ParticleDescriptor *pd = new ParticleDescriptorCluster(gconf, sconf);
    delete gconf;
    delete sconf;
    delete pd;
  } catch (const exception& ex) {
    result = 10;
  }
  return result;
}

int test_inclusion() {
  int result = 0;
  try {
    const string geom_data_file = "../../test_data/inclusion/DINCLU";
    const string scat_data_file = "../../test_data/inclusion/DEDFB";
    GeometryConfiguration *gconf = GeometryConfiguration::from_legacy(geom_data_file);
    ScattererConfiguration *sconf = ScattererConfiguration::from_dedfb(scat_data_file);
    ParticleDescriptor *pd = new ParticleDescriptorInclusion(gconf, sconf);
    delete gconf;
    delete sconf;
    delete pd;
  } catch (const exception& ex) {
    result = 1000;
  }
  return result;
}

int test_sphere() {
  int result = 0;
  try {
    const string geom_data_file = "../../test_data/sphere/DSPH";
    const string scat_data_file = "../../test_data/sphere/DEDFB";
    GeometryConfiguration *gconf = GeometryConfiguration::from_legacy(geom_data_file);
    ScattererConfiguration *sconf = ScattererConfiguration::from_dedfb(scat_data_file);
    ParticleDescriptor *pd = new ParticleDescriptorSphere(gconf, sconf);
    delete gconf;
    delete sconf;
    delete pd;
  } catch (const exception& ex) {
    result = 1;
  }
  return result;
}