Browse Source

ut testcase

pull/438/head
jwx930962 4 years ago
parent
commit
ed4c99de02
1 changed files with 80 additions and 5 deletions
  1. +80
    -5
      tests/ut/parser/testcase/common/acl_graph_parser_unittest.cc

+ 80
- 5
tests/ut/parser/testcase/common/acl_graph_parser_unittest.cc View File

@@ -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<std::string, std::pair<int, string>> caffe_op_identifier_map;
std::map<std::string, std::pair<int, string>> 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<int, std::pair<string, string>> caffe_op_identifier_map;
std::map<int, std::pair<string, string>> 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<int, std::pair<string, string>> identifier_op_map;
std::map<std::string, std::pair<int, string>> 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

Loading…
Cancel
Save