1 #include "artdaq-core/Utilities/ExceptionHandler.hh"
2 #include "artdaq-core/Utilities/configureMessageFacility.hh"
4 #define BOOST_TEST_MODULE configureMessageFacility_t
5 #include <fhiclcpp/make_ParameterSet.h>
6 #include <boost/filesystem.hpp>
7 #include "cetlib/quiet_unit_test.hpp"
8 #include "cetlib_except/exception.h"
10 #define TRACE_NAME "configureMessageFacility_t"
13 BOOST_AUTO_TEST_SUITE(configureMessageFacility_test)
15 BOOST_AUTO_TEST_CASE(configureTRACETest)
17 fhicl::ParameterSet pset;
18 pset.put(
"TRACE_MODE",
"3");
19 fhicl::ParameterSet namlvlset;
20 namlvlset.put<std::vector<uint64_t>>(
"ConfigureMessageFacility_t", {0x0123456789ABCDEF, 0xFEDCBA9876543210, 0x0});
21 pset.put(
"TRACE_NAMLVLSET", namlvlset);
25 BOOST_AUTO_TEST_CASE(generateMessageFacilityConfigurationTest)
28 std::string badDir =
"/this/directory/doesn't/exist";
29 setenv(
"ARTDAQ_LOG_TIMESTAMPS_TO_CONSOLE",
"0", 1);
30 setenv(
"ARTDAQ_LOG_ROOT", badDir.c_str(), 1);
32 setenv(
"ARTDAQ_LOG_ROOT",
"/tmp", 1);
34 setenv(
"ARTDAQ_LOG_FHICL",
"/this/file/doesn't/exist.fcl", 1);
36 unsetenv(
"ARTDAQ_LOG_FHICL");
40 boost::filesystem::remove_all(
"/tmp/configureMessageFacility_t");
43 BOOST_AUTO_TEST_CASE(configureMessageFacilityTest)
45 setenv(
"ARTDAQ_LOG_ROOT",
"/tmp", 1);
47 mf::LogInfo(
"Test") <<
"Test Message";
48 TLOG(TLVL_INFO) <<
"Test TRACE";
50 boost::filesystem::remove_all(
"/tmp/configureMessageFacility_t");
53 BOOST_AUTO_TEST_CASE(setMsgFacAppNameTest)
56 BOOST_REQUIRE(!appName.empty());
59 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.