Skip to content
Snippets Groups Projects
Commit db0d9862 authored by Loic Hausammann's avatar Loic Hausammann
Browse files

Logger: Add testHeader

parent 4818b1d1
Branches
Tags
1 merge request!685Logger loader
...@@ -2023,7 +2023,7 @@ AM_CONDITIONAL([HAVEEAGLEFEEDBACK], [test $with_feedback = "EAGLE"]) ...@@ -2023,7 +2023,7 @@ AM_CONDITIONAL([HAVEEAGLEFEEDBACK], [test $with_feedback = "EAGLE"])
# Handle .in files. # Handle .in files.
AC_CONFIG_FILES([Makefile src/Makefile examples/Makefile examples/Cooling/CoolingRates/Makefile doc/Makefile doc/Doxyfile tests/Makefile]) AC_CONFIG_FILES([Makefile src/Makefile examples/Makefile examples/Cooling/CoolingRates/Makefile doc/Makefile doc/Doxyfile tests/Makefile])
AC_CONFIG_FILES([argparse/Makefile tools/Makefile logger/Makefile]) AC_CONFIG_FILES([argparse/Makefile tools/Makefile logger/Makefile logger/tests/Makefile])
AC_CONFIG_FILES([tests/testReading.sh], [chmod +x tests/testReading.sh]) AC_CONFIG_FILES([tests/testReading.sh], [chmod +x tests/testReading.sh])
AC_CONFIG_FILES([tests/testActivePair.sh], [chmod +x tests/testActivePair.sh]) AC_CONFIG_FILES([tests/testActivePair.sh], [chmod +x tests/testActivePair.sh])
AC_CONFIG_FILES([tests/test27cells.sh], [chmod +x tests/test27cells.sh]) AC_CONFIG_FILES([tests/test27cells.sh], [chmod +x tests/test27cells.sh])
......
...@@ -41,6 +41,9 @@ lib_LTLIBRARIES = liblogger.la ...@@ -41,6 +41,9 @@ lib_LTLIBRARIES = liblogger.la
# lib_LTLIBRARIES += liblogger_mpi.la # lib_LTLIBRARIES += liblogger_mpi.la
# endif # endif
# subdirectories
SUBDIRS = tests
# List required headers # List required headers
include_HEADERS = logger_header.h logger_io.h logger_particle.h logger_time.h logger_tools.h logger_reader.h \ include_HEADERS = logger_header.h logger_io.h logger_particle.h logger_time.h logger_tools.h logger_reader.h \
logger_index.h logger_logfile.h logger_index.h logger_logfile.h
......
# This file is part of SWIFT.
# Copyright (c) 2019 loic.hausammann@epfl.ch.
#
# 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 3 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, see <http://www.gnu.org/licenses/>.
# Add the source directory and the non-standard paths to the included library headers to CFLAGS
AM_CFLAGS = -I$(top_srcdir)/src -I$(top_srcdir)/logger $(HDF5_CPPFLAGS) $(GSL_INCS) $(FFTW_INCS)
AM_LDFLAGS = ../../src/.libs/libswiftsim.a ../.libs/liblogger.a $(HDF5_LDFLAGS) $(HDF5_LIBS) $(FFTW_LIBS) $(TCMALLOC_LIBS) $(JEMALLOC_LIBS) $(TBBMALLOC_LIBS) $(GRACKLE_LIBS) $(GSL_LIBS) $(PROFILER_LIBS)
# List of programs and scripts to run in the test suite
TESTS = testHeader
# List of test programs to compile
check_PROGRAMS = testHeader
# Rebuild tests when SWIFT is updated.
$(check_PROGRAMS): ../../src/.libs/libswiftsim.a
# Sources for the individual programs
testHeader_SOURCES = testHeader.c
# Files necessary for distribution
EXTRA_DIST = swift_params.yml
# Parameter file for the tests
Logger:
delta_step: 10
initial_buffer_size: 0.1 # in GB
buffer_scale: 10
basename: index
\ No newline at end of file
/*******************************************************************************
* This file is part of SWIFT.
* Copyright (C) 2015 Matthieu Schaller (matthieu.schaller@durham.ac.uk).
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Lesser General Public License as published
* by the Free Software Foundation, either version 3 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 Lesser General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*
******************************************************************************/
#include "swift.h"
#include "logger_header.h"
#include "logger_logfile.h"
#include "logger_reader.h"
int main(int argc, char *argv[]) {
/*
First generate the file.
*/
message("Generating the dump.");
/* Create required structures. */
struct logger log;
struct swift_params params;
char filename[200] = "swift_params.yml";
/* Read parameters. */
parser_read_file(filename, &params);
/* Initialize the logger. */
logger_init(&log, &params);
/* get dump filename */
char dump_filename[PARSER_MAX_LINE_SIZE];
message("%s", log.base_name);
strcpy(dump_filename, log.base_name);
strcat(dump_filename, ".dump");
/* Write file header. */
logger_write_file_header(&log);
/* clean memory */
logger_clean(&log);
/*
Then read the file.
*/
message("Reading the header.");
/* Generate required structure for reading. */
struct logger_logfile logfile;
struct logger_reader reader;
/* Set verbose level */
reader.verbose = 1;
/* Read the header */
logger_logfile_init(&logfile, dump_filename, &reader,
/* only_header */ 1);
/*
Finally check everything
*/
struct header *h = &logfile.header;
message("Checking versions.");
assert(h->major_version == logger_major_version);
assert(h->minor_version == logger_minor_version);
message("Checking offset of first record");
assert(h->offset_first_record == logfile.log.file_size);
message("Checking number of masks");
assert(h->number_mask == logger_count_mask);
message("Checking masks");
for(int i = 0; i < logger_count_mask; i++) {
assert(logger_mask_data[i].size == h->masks[i].size);
assert(logger_mask_data[i].mask == h->masks[i].mask);
assert(strcmp(logger_mask_data[i].name, h->masks[i].name) == 0);
}
message("Checking offset direction");
assert(h->offset_direction == logger_offset_backward);
return 0;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment