1 #include "artdaq-core/Utilities/ExceptionHandler.hh"
2 #include "artdaq-core/Utilities/configureMessageFacility.hh"
4 #define BOOST_TEST_MODULE configureMessageFacility_t
5 #include "cetlib/quiet_unit_test.hpp"
7 #include "cetlib_except/exception.h"
8 #include "fhiclcpp/ParameterSet.h"
9 #include "fhiclcpp/make_ParameterSet.h"
10 #include "messagefacility/MessageLogger/MessageLogger.h"
12 #include <boost/filesystem.hpp>
14 #define TRACE_NAME "configureMessageFacility_t"
15 #include "TRACE/tracemf.h"
17 BOOST_AUTO_TEST_SUITE(configureMessageFacility_test)
19 BOOST_AUTO_TEST_CASE(configureTRACETest)
21 fhicl::ParameterSet pset;
22 pset.put(
"TRACE_MODE",
"3");
23 fhicl::ParameterSet namlvlset;
24 namlvlset.put<std::vector<uint64_t>>(
"ConfigureMessageFacility_t", {0x0123456789ABCDEF, 0xFEDCBA9876543210, 0x0});
25 pset.put(
"TRACE_NAMLVLSET", namlvlset);
29 BOOST_AUTO_TEST_CASE(generateMessageFacilityConfigurationTest)
32 std::string badDir =
"/this/directory/doesn't/exist";
33 setenv(
"ARTDAQ_LOG_TIMESTAMPS_TO_CONSOLE",
"0", 1);
34 setenv(
"ARTDAQ_LOG_ROOT", badDir.c_str(), 1);
36 setenv(
"ARTDAQ_LOG_ROOT",
"/tmp", 1);
38 setenv(
"ARTDAQ_LOG_FHICL",
"/this/file/doesn't/exist.fcl", 1);
40 unsetenv(
"ARTDAQ_LOG_FHICL");
44 boost::filesystem::remove_all(
"/tmp/configureMessageFacility_t");
47 BOOST_AUTO_TEST_CASE(configureMessageFacilityTest)
49 setenv(
"ARTDAQ_LOG_ROOT",
"/tmp", 1);
51 mf::LogInfo(
"Test") <<
"Test Message";
52 TLOG(TLVL_INFO) <<
"Test TRACE";
54 boost::filesystem::remove_all(
"/tmp/configureMessageFacility_t");
57 BOOST_AUTO_TEST_CASE(setMsgFacAppNameTest)
60 BOOST_REQUIRE(!appName.empty());
63 BOOST_AUTO_TEST_SUITE_END()
void configureTRACE(fhicl::ParameterSet &trace_pset)
Configure TRACE.
void configureMessageFacility(char const *progname, bool useConsole=true, bool printDebug=false)
Configure and start the message facility. Provide the program name so that messages will be appropria...
std::string setMsgFacAppName(const std::string &appType, unsigned short port)
Set the message facility application name using the specified application type and port number...
std::string generateMessageFacilityConfiguration(char const *progname, bool useConsole=true, bool printDebug=false, char const *fileExtraName="")
Create the MessageFacility configuration Fhicl string.