Skip to content

Commit

Permalink
#2187: Add additional checks in tests for validating the end time
Browse files Browse the repository at this point in the history
  • Loading branch information
thearusable authored and cwschilly committed Sep 20, 2024
1 parent cecea06 commit c56a180
Showing 1 changed file with 18 additions and 13 deletions.
31 changes: 18 additions & 13 deletions tests/unit/trace/test_trace_user.cc
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ struct TestTraceUser : TestParallelHarness {
"--vt_trace_dir={}",
::testing::UnitTest::GetInstance()->current_test_info()->name());
addArgs(trace_dir);
addArgs(flush);
}

virtual void TearDown() override {
Expand All @@ -85,8 +84,6 @@ struct TestTraceUser : TestParallelHarness {

private:
std::string trace_dir;
// must be != 0 for the test to work
std::string flush = "--vt_trace_flush_size=100";
};

void validateLine(const std::string line, int& time) {
Expand All @@ -105,13 +102,14 @@ void validateLine(const std::string line, int& time) {
}

// validate the start time
int start_time = 0;
bool check_time = true;
int start_time = 0, end_time = 0;
bool check_start_time = true, check_end_time = false;
eTraceConstants type = static_cast<eTraceConstants>(std::stoi(tokens[0]));
switch(type) {
case eTraceConstants::Creation: // 1
case eTraceConstants::BeginProcessing: // 2
case eTraceConstants::EndProcessing: // 3
case eTraceConstants::CreationBcast: // 20
start_time = std::stoi(tokens[3]);
break;
case eTraceConstants::UserEvent: // 13
Expand All @@ -125,17 +123,25 @@ void validateLine(const std::string line, int& time) {
case eTraceConstants::BeginIdle: // 14
case eTraceConstants::EndIdle: // 15
case eTraceConstants::UserSuppliedNote: // 28
start_time = std::stoi(tokens[1]);
break;
// those with end time
case eTraceConstants::UserSuppliedBracketedNote: // 29
start_time = std::stoi(tokens[1]);
end_time = std::stoi(tokens[2]);
check_end_time = true;
break;
default:
check_time = false;
check_start_time = false;
}

if (check_time) {
if (check_start_time) {
EXPECT_GE(start_time, time);
time = start_time;
}
if (check_end_time) {
EXPECT_GE(end_time, start_time);
}
}

void validateAllTraceFiles() {
Expand Down Expand Up @@ -177,12 +183,11 @@ TEST_F(TestTraceUser, trace_user_add_note_pre_epi) {
// Only the begging of the note
{
trace::addUserNotePre("some note", 2);
trace::addUserNoteEpi("some note", 2); // will crash without it
}
// Two opening notes with the same id
{
// trace::addUserNotePre("note 1", 5); // will crash
// trace::addUserNotePre("note 2", 5); // will crash
trace::addUserNotePre("note 1", 5);
trace::addUserNotePre("note 2", 5);
}
// note with events in between
{
Expand Down Expand Up @@ -333,13 +338,13 @@ TEST_F(TestTraceUser, trace_user_bracketed_event) {
theTrace()->addUserEventBracketedBegin(2);
theTrace()->addUserEventBracketedEnd(2);
theTrace()->addUserEventBracketedBegin(3);

theTrace()->addUserEventManual(123);
theTrace()->addUserData(123456789);

theTrace()->addUserEventBracketedEnd(1);
theTrace()->addUserEventBracketedEnd(3);

theTrace()->addUserNote("Some Note 2");
theTrace()->addUserData(123456);
theTrace()->addUserEvent(124);
Expand Down

0 comments on commit c56a180

Please sign in to comment.