P4C
The P4 Compiler
Loading...
Searching...
No Matches
P4::Test::EventLoggerTest Class Reference
Inheritance diagram for P4::Test::EventLoggerTest:
[legend]

Protected Types

using EventLogger = EventLoggerTestable
 

Protected Member Functions

void compareFileWithExpected (std::ifstream &file, const std::vector< std::string > &expectedLines)
 
void deinitLogger ()
 
void initLogger (bool enable=true)
 
void SetUp ()
 
void TearDown ()
 

Protected Attributes

const std::string DEFAULT_PROPERTIES
 
const std::string DEFAULT_PROPERTIES_DISABLED
 
const std::string EVENT_IDS
 
const std::string FILE = "event-log-gtest.json"
 
std::istringstream inputCode = std::istringstream("header hdr { bit<8> field; }")
 
const std::string OUTDIR = "/tmp"
 
const std::string PATH = OUTDIR + "/" + FILE
 
const IR::P4Program * program = P4::P4ParserDriver::parse(inputCode, "file.cpp", 1)
 
const std::string PROPERTIES_WITH_FILE
 
const std::string PROPERTIES_WITH_MGRS
 
const std::string SCHEMA_VERSION = R"("schema_version":"1.2.0")"
 
const Util::SourceInfo srcInfo = program->objects[0]->srcInfo
 

Member Function Documentation

◆ SetUp()

void P4::Test::EventLoggerTest::SetUp ( )
inlineprotected

If you execute WHOLE testing suite then EventLogger instance already exists and nullInit has been called. But EventLoggerTestable does not exist and get2() will result in re-executing nullInit (which is an error). Because of that, setup deinits EventLogger using get(), then uses get2() to instantiate EventLoggerTestable and setup logger.

Member Data Documentation

◆ DEFAULT_PROPERTIES

const std::string P4::Test::EventLoggerTest::DEFAULT_PROPERTIES
protected
Initial value:
= R"({"enabled":true,)" + EVENT_IDS +
R"(,"file_ids":[],"i":0,"manager_ids":[],)" +
SCHEMA_VERSION + R"(,"start_time":"TIMESTAMP"})"

◆ DEFAULT_PROPERTIES_DISABLED

const std::string P4::Test::EventLoggerTest::DEFAULT_PROPERTIES_DISABLED
protected
Initial value:
=
R"({"enabled":false,)" + EVENT_IDS + R"(,"file_ids":[],"i":0,"manager_ids":[],)" +
SCHEMA_VERSION + R"(,"start_time":"TIMESTAMP"})"

◆ EVENT_IDS

const std::string P4::Test::EventLoggerTest::EVENT_IDS
protected
Initial value:
=
R"("event_ids":["Properties","Pass Changed","Parse Error","Compilation Error","Compilation Warning","Debug","Decision","Pipe Changed","Iteration Changed"])"

◆ PROPERTIES_WITH_FILE

const std::string P4::Test::EventLoggerTest::PROPERTIES_WITH_FILE
protected
Initial value:
= R"({"enabled":true,)" + EVENT_IDS +
R"(,"file_ids":["file.cpp"],"i":0,"manager_ids":[],)" +
SCHEMA_VERSION + R"(,"start_time":"TIMESTAMP"})"

◆ PROPERTIES_WITH_MGRS

const std::string P4::Test::EventLoggerTest::PROPERTIES_WITH_MGRS
protected
Initial value:
=
R"({"enabled":true,)" + EVENT_IDS +
R"(,"file_ids":[],"i":0,"manager_ids":["mgr","mgr2"],)" + SCHEMA_VERSION +
R"(,"start_time":"TIMESTAMP"})"