diff --git a/tests/ut/parser/testcase/common/acl_graph_parser_unittest.cc b/tests/ut/parser/testcase/common/acl_graph_parser_unittest.cc index 5631b10..bd071a4 100644 --- a/tests/ut/parser/testcase/common/acl_graph_parser_unittest.cc +++ b/tests/ut/parser/testcase/common/acl_graph_parser_unittest.cc @@ -28,9 +28,14 @@ #include "ut/parser/parser_ut_utils.h" #include "external/ge/ge_api_types.h" #include "parser/common/proto_file_parser.h" +#include "omg/parser/parser_factory.h" +#include "parser/caffe/caffe_parser.h" #undef protected #undef private +using namespace domi; +using namespace testing; + namespace ge { class UtestAclGraphParser : public testing::Test { protected: @@ -104,8 +109,9 @@ TEST_F(UtestAclGraphParser, test_parse_acl_output_nodes) { TEST_F(UtestAclGraphParser, test_CheckConflictOp) { ge::ProtoFileParser op; - char *caffe_proto_file = "/dev/null"; - char *custom_proto_file = "/dev/null"; + std::string custom_file = "/dev/null"; + const char *caffe_proto_file = custom_file.c_str(); + const char *custom_proto_file = custom_file.c_str(); std::map> caffe_op_identifier_map; std::map> custom_op_identifier_map; custom_op_identifier_map.insert(std::make_pair("ge", std::make_pair(1, "ge"))); @@ -120,8 +126,9 @@ TEST_F(UtestAclGraphParser, test_CheckConflictOp) TEST_F(UtestAclGraphParser, test_CheckConflictIdentifier) { ge::ProtoFileParser op; - char *caffe_proto_file = "/dev/null"; - char *custom_proto_file = "/dev/null"; + std::string custom_file = "/dev/null"; + const char *caffe_proto_file = custom_file.c_str(); + const char *custom_proto_file = custom_file.c_str(); std::map> caffe_op_identifier_map; std::map> custom_op_identifier_map; custom_op_identifier_map.insert(std::make_pair(1, std::make_pair("ge", "ge"))); @@ -136,12 +143,80 @@ TEST_F(UtestAclGraphParser, test_CheckConflictIdentifier) TEST_F(UtestAclGraphParser, test_AddCustomAndConflictLayer) { Status ret; - char *custom_proto_file = "/dev/null"; + std::string custom_file = "/dev/null"; + const char *custom_proto_file = custom_file.c_str(); ge::ProtoFileParser op; std::ofstream write_tmp; ret = op.ProtoFileParser::AddCustomAndConflictLayer(custom_proto_file, write_tmp); EXPECT_EQ(ret, SUCCESS); } +TEST_F(UtestAclGraphParser, test_FindConflictLine) +{ + Status ret; + ProtoFileParser op; + int identifier = 0; + std::string dest_line; + std::string file = "../parser/caffe/caffe_parser.h"; + const char *proto_file = file.c_str(); + ret = op.FindConflictLine(proto_file, identifier, dest_line); + EXPECT_EQ(ret, FAILED); +} + +TEST_F(UtestAclGraphParser, test_ParseProtoFile) +{ + Status ret; + ProtoFileParser op; + std::string dest_line; + std::map> identifier_op_map; + std::map> op_identifier_map; + string proto_file = "../parser/caffe/caffe_parser.h"; + ret = op.ParseProtoFile(proto_file, identifier_op_map, op_identifier_map); + EXPECT_EQ(ret, SUCCESS); +} + +TEST_F(UtestAclGraphParser, test_AddCustomAndConflictMessage) +{ + Status ret; + ProtoFileParser op; + std::ofstream write_tmp; + std::string file = "../parser/caffe/caffe_parser.h"; + const char *proto_file = file.c_str(); + ret = op.AddCustomAndConflictMessage(proto_file, write_tmp); + EXPECT_EQ(ret, SUCCESS); +} + +TEST_F(UtestAclGraphParser, test_RecordProtoMessage) +{ + Status ret; + ProtoFileParser op; + std::string file = "../parser/caffe/caffe_parser.h"; + const char *proto_file = file.c_str(); + ret = op.RecordProtoMessage(proto_file); + EXPECT_EQ(ret, SUCCESS); +} + + +TEST_F(UtestAclGraphParser, test_WriteCaffeProtoFile) +{ + Status ret; + ProtoFileParser op; + std::string file = "../parser/caffe/caffe_parser.h"; + const char *proto_file = file.c_str(); + std::ifstream read_caffe("../parser/caffe/caffe_parser.h", std::ifstream::in); + std::ofstream write_tmp("/dev/null", std::ifstream::in); + ret = op.WriteCaffeProtoFile(proto_file, read_caffe, write_tmp); + EXPECT_EQ(ret, SUCCESS); +} + +TEST_F(UtestAclGraphParser, test_CreatProtoFile) +{ + Status ret; + ProtoFileParser op; + op.fusion_proto_path = "/ge/ge/ge/ge.c"; + ret = op.CreatProtoFile(); + EXPECT_EQ(ret, FAILED); +} + } // namespace ge \ No newline at end of file