ReFRACtor
global_fixture.cc
Go to the documentation of this file.
1 #include "global_fixture.h"
2 #include <boost/test/unit_test.hpp>
3 #include <boost/foreach.hpp>
4 #include <cstdlib>
5 #include <sys/types.h>
6 #include <dirent.h>
7 #include "fp_logger.h"
8 #include <fenv.h>
9 #include <unistd.h>
10 
11 using namespace FullPhysics;
12 //-----------------------------------------------------------------------
14 //-----------------------------------------------------------------------
15 
17 {
18  // Turn on floating point exceptions, so we don't silently do things
19  // like divide by 0.
20 
21  // Mac doesn't have this function, even though it is a C99
22  // function. We check for this during configuration.
23 #ifdef HAVE_FEENABLEEXCEPT
24  feclearexcept(FE_INVALID | FE_DIVBYZERO | FE_OVERFLOW);
25  feenableexcept(FE_INVALID | FE_DIVBYZERO | FE_OVERFLOW);
26 #endif
27  set_default_value();
28 }
29 
30 //-----------------------------------------------------------------------
32 //-----------------------------------------------------------------------
33 
35 {
36  // Make sure logger gets turned off if we have turned it on.
38 
39  // Remove all files in the cleanup list.
40  BOOST_FOREACH(const std::string& Fname, cleanup_list) {
41  unlink(Fname.c_str()); // Ignore status, ok if cleanup fails.
42  }
43 }
44 
45 //-----------------------------------------------------------------------
50 //-----------------------------------------------------------------------
51 
53 {
56 }
57 
58 //-----------------------------------------------------------------------
61 //-----------------------------------------------------------------------
62 
63 std::string GlobalFixture::input_dir() const
64 {
65  char* srcdir = getenv("abs_top_srcdir");
66  // This should get set in set_default_value, but just in case
67  // something odd happens print an error message.
68  if(!srcdir)
69  BOOST_FAIL("To run this test, you must set the 'abs_top_srcdir' environment\n"
70  "variable to the top of the source tree. This is automatically\n"
71  "done if you are running 'make check', but you need to\n"
72  "manually set this if you are running outside of make (e.g.,\n"
73  "running in a debugger");
74  return std::string(srcdir) + "/input/";
75 }
76 
77 //-----------------------------------------------------------------------
81 //-----------------------------------------------------------------------
82 
83 std::string GlobalFixture::test_data_dir() const
84 {
85  char* srcdir = getenv("abs_top_srcdir");
86  // This should get set in set_default_value, but just in case
87  // something odd happens print an error message.
88  if(!srcdir)
89  BOOST_FAIL("To run this test, you must set the 'abs_top_srcdir' environment\n"
90  "variable to the top of the source tree. This is automatically\n"
91  "done if you are running 'make check', but you need to\n"
92  "manually set this if you are running outside of make (e.g.,\n"
93  "running in a debugger");
94  return std::string(srcdir) + "/test/unit/data/";
95 }
96 
97 //-----------------------------------------------------------------------
99 //-----------------------------------------------------------------------
100 
101 std::string GlobalFixture::absco_data_dir() const
102 {
103  char* srcdir = getenv("abscodir");
104  // This should get set in set_default_value, but just in case
105  // something odd happens print an error message.
106  if(!srcdir)
107  BOOST_FAIL("To run this test, you must set the 'abscodir' environment\n"
108  "variable to the top of the source tree. This is automatically\n"
109  "done if you are running 'make check', but you need to\n"
110  "manually set this if you are running outside of make (e.g.,\n"
111  "running in a debugger");
112  return std::string(srcdir) + "/v3.3.0/lowres";
113 }
114 
115 //-----------------------------------------------------------------------
117 //-----------------------------------------------------------------------
118 
119 std::string GlobalFixture::merra_data_dir() const
120 {
121  char* srcdir = getenv("merradir");
122  // This should get set in set_default_value, but just in case
123  // something odd happens print an error message.
124  if(!srcdir)
125  BOOST_FAIL("To run this test, you must set the 'merradir' environment\n"
126  "variable to the top of the source tree. This is automatically\n"
127  "done if you are running 'make check', but you need to\n"
128  "manually set this if you are running outside of make (e.g.,\n"
129  "running in a debugger");
130  return std::string(srcdir) + "/";
131 }
132 
133 //-----------------------------------------------------------------------
138 //-----------------------------------------------------------------------
139 
140 std::string GlobalFixture::absco_4d_dir() const
141 {
142  char* srcdir = getenv("abscodir");
143  // This should get set in set_default_value, but just in case
144  // something odd happens print an error message.
145  if(!srcdir)
146  BOOST_FAIL("To run this test, you must set the 'abscodir' environment\n"
147  "variable to the top of the source tree. This is automatically\n"
148  "done if you are running 'make check', but you need to\n"
149  "manually set this if you are running outside of make (e.g.,\n"
150  "running in a debugger");
151  return std::string(srcdir) + "/v4.2.0_unscaled";
152 }
153 
154 
void turn_on_logger() const
Normally log messages don&#39;t go anywhere, so we don&#39;t clutter our unit test output.
std::string absco_4d_dir() const
Location of absco 4d table.
GlobalFixture()
Setup for all unit tests.
std::string absco_data_dir() const
Location of absco table.
std::string input_dir() const
Directory where input data such as static input files and default Lua configuration files are located...
virtual ~GlobalFixture()
Teardown for all unit tests.
Contains classes to abstract away details in various Spurr Radiative Transfer software.
Definition: doxygen_python.h:1
std::string test_data_dir() const
Directory where test data is.
This is the implementation of the Logger used for the Full Physics program.
Definition: fp_logger.h:12
std::string merra_data_dir() const
Location of merra data.
static void set_implementation(const boost::shared_ptr< LogImp > &imp)
Set the implementation.
Definition: logger.h:77

Copyright © 2017, California Institute of Technology.
ALL RIGHTS RESERVED.
U.S. Government Sponsorship acknowledged.
Generated Fri Aug 24 2018 15:44:11