artdaq_core  v3_06_11
SimpleLookupPolicy_t.cc
1 #include "artdaq-core/Utilities/SimpleLookupPolicy.hh"
2 
3 #define BOOST_TEST_MODULE SimpleLookupPolicy_t
4 #include <boost/filesystem.hpp>
5 #include "cetlib/quiet_unit_test.hpp"
6 #include "cetlib_except/exception.h"
7 
8 #define TRACE_NAME "SimpleLookupPolicy_t"
9 #include "tracemf.h"
10 
11 BOOST_AUTO_TEST_SUITE(SimpleLookupPolicy_test)
12 
13 BOOST_AUTO_TEST_CASE(Constructors)
14 {
18  BOOST_REQUIRE(true); // No exceptions
19 }
20 
21 BOOST_AUTO_TEST_CASE(AbsoluteFilePath)
22 {
24  auto absolutePath = boost::filesystem::current_path();
25  absolutePath += "LookupTarget.fcl";
26  p(absolutePath.string());
27  BOOST_REQUIRE(true); // No exceptions
28 }
29 
30 BOOST_AUTO_TEST_CASE(FallbackPath)
31 {
32  auto coreDir = getenv("ARTDAQ_CORE_DIR");
33  std::string coreDirStr = "";
34  if (coreDir != nullptr)
35  {
36  coreDirStr = std::string(coreDir);
37  }
38 
39  artdaq::SimpleLookupPolicy p("/tmp:.:" + coreDirStr + "/test/Utilities/fcl", artdaq::SimpleLookupPolicy::ArgType::PATH_STRING);
40  p("LookupTarget.fcl");
41  BOOST_REQUIRE_EXCEPTION(p("ThisFileDoesNotExist.fcl"), cet::exception, [](cet::exception const& e) { return e.category() == "search_path"; });
42 }
43 
44 BOOST_AUTO_TEST_SUITE_END()
Constructor argument is a list of directories.
This class is intended to find files using a set lookup order.