Skip to content

Commit

Permalink
modifies makefile for debugging and tests
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexandruAntonescuKeysight committed May 13, 2024
1 parent 982f03a commit 35b846b
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 14 deletions.
2 changes: 1 addition & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ CHAKRA_ET_DIR := $(SCRIPT_DIR)/et_def

# Compiler and flags
CXX = g++
CXXFLAGS = -Wall
CXXFLAGS = -Wall -g

# Source files
SRCS = $(CHAKRA_ET_DIR)/et_def.pb.cc $(SCRIPT_DIR)/et_feeder/et_feeder.cpp $(SCRIPT_DIR)/et_feeder/et_feeder_node.cpp $(SCRIPT_DIR)/third_party/utils/protoio.cc $(SCRIPT_DIR)/et_feeder/tests.cpp
Expand Down
77 changes: 64 additions & 13 deletions et_feeder/tests.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,25 +20,76 @@ class ETFeederTest : public ::testing::Test {
Chakra::ETFeeder* trace;
};

// Example test case
TEST_F(ETFeederTest, MyTestCaseName) {
// Constructor test case
TEST_F(ETFeederTest, ConstructorTestID) {
SetUp("et_feeder/chakra.0.et");
std::shared_ptr<Chakra::ETFeederNode> node = trace->getNextIssuableNode();
uint64_t ceva = node->id();
std::cout << ceva << '\n';
std::cout << node->type() << '\n';
uint64_t firstNodeID = node->id();
ASSERT_EQ(firstNodeID, 216);

node = trace->getNextIssuableNode();
ceva = node->id();
std::cout << ceva << '\n';
std::cout << node->type() << '\n';
uint64_t secondNodeID = node->id();
ASSERT_EQ(secondNodeID, 432);
}

// Constructor test case
TEST_F(ETFeederTest, ConstructorTestValues) {
SetUp("et_feeder/chakra.0.et");
std::shared_ptr<Chakra::ETFeederNode> node = trace->getNextIssuableNode();
ChakraProtoMsg::NodeType firstNodeType = node->type();
ASSERT_EQ(firstNodeType, ChakraProtoMsg::COMP_NODE);
ASSERT_TRUE(node->is_cpu_op());

std::string attr = "rf_id";
ChakraProtoMsg::AttributeProto rf_id = node->get_other_attr(attr);
ASSERT_EQ(rf_id.int64_val(), 2);
// std::cout << node->getChakraNode()->Utf8DebugString();

node = trace->getNextIssuableNode();
uint64_t secondNodeType = node->type();
ASSERT_EQ(secondNodeType, ChakraProtoMsg::COMM_COLL_NODE);
ASSERT_TRUE(node->is_cpu_op());

rf_id = node->get_other_attr(attr);
ASSERT_EQ(rf_id.int64_val(), 110);
}

TEST_F(ETFeederTest, ConstructorTestETFeeder) {
SetUp("et_feeder/chakra.0.et");
std::shared_ptr<Chakra::ETFeederNode> node = trace->getNextIssuableNode();
std::vector<std::shared_ptr<Chakra::ETFeederNode>> children = node->getChildren();
ASSERT_EQ(children[0]->id(), 217);
ASSERT_EQ(children[1]->id(), 430);
ASSERT_EQ(children[2]->id(), 435);
}

TEST_F(ETFeederTest, RemoveTest) {
SetUp("et_feeder/llama_chakra.4.et");
std::shared_ptr<Chakra::ETFeederNode> node;
// std::shared_ptr<Chakra::ETFeederNode> node = trace->lookupNode(5);
// std::cout << node->id() << " " << "\n";
// trace->removeNode(5);
// std::cout << "aiciii " << "\n";
// trace->removeNode(432);
// node = trace->lookupNode(216);
node = trace->getNextIssuableNode();
std::cout << node->id() << " " << "\n";
// std::cout << "aiciii " << "\n";
node = trace->getNextIssuableNode();
std::cout << node->id() << " " << "\n";
node = trace->getNextIssuableNode();
node = trace->getNextIssuableNode();
ceva = node->id();
std::cout << ceva << '\n';
std::cout << node->type() << '\n';
// Your test logic here
// ...
// std::cout << "aiciii " << "\n";
// node = trace->getNextIssuableNode();
// trace->removeNode(node->id());
// trace->removeNode(node->id());
// std::cout << node->id() << " " << "\n";
// trace->removeNode(node->id());
// trace->removeNode(node->id());
// std::vector<std::shared_ptr<Chakra::ETFeederNode>> children = node->getChildren();
// ASSERT_EQ(children[0]->id(), 217);
// ASSERT_EQ(children[1]->id(), 430);
// ASSERT_EQ(children[2]->id(), 435);
}

// Add more test cases as needed
Expand Down

0 comments on commit 35b846b

Please sign in to comment.