Browse Source

fix ut core

tags/v1.2.0
wangxiaotian22 4 years ago
parent
commit
395fddbcff
2 changed files with 24 additions and 1 deletions
  1. +3
    -1
      tests/depends/error_manager/src/error_manager_stub.cc
  2. +21
    -0
      tests/ut/common/graph/testcase/ge_graph/ge_anchor_utils_unittest.cc

+ 3
- 1
tests/depends/error_manager/src/error_manager_stub.cc View File

@@ -18,6 +18,8 @@


using namespace ErrorMessage; using namespace ErrorMessage;


thread_local Context ErrorManager::error_context_ = {0, "", "", ""};

ErrorManager &ErrorManager::GetInstance() { ErrorManager &ErrorManager::GetInstance() {
static ErrorManager instance; static ErrorManager instance;
return instance; return instance;
@@ -88,7 +90,7 @@ using namespace ErrorMessage;


void ErrorManager::GenWorkStreamIdBySessionGraph(uint64_t session_id, uint64_t graph_id) {} void ErrorManager::GenWorkStreamIdBySessionGraph(uint64_t session_id, uint64_t graph_id) {}


const std::string &ErrorManager::GetLogHeader() { return "[TEST][TEST]"; }
const std::string &ErrorManager::GetLogHeader() { return error_context_.log_header; }


struct Context &ErrorManager::GetErrorContext() { struct Context &ErrorManager::GetErrorContext() {
struct Context error_context; struct Context error_context;


+ 21
- 0
tests/ut/common/graph/testcase/ge_graph/ge_anchor_utils_unittest.cc View File

@@ -36,31 +36,52 @@ class UtestGeAnchorUtils : public testing::Test {


TEST_F(UtestGeAnchorUtils, base) { TEST_F(UtestGeAnchorUtils, base) {
ComputeGraphPtr graph_ptr = std::make_shared<ComputeGraph>("name"); ComputeGraphPtr graph_ptr = std::make_shared<ComputeGraph>("name");
if (graph_ptr == nullptr) {
return;
}
OpDescPtr desc_ptr = std::make_shared<OpDesc>("name1", "type1"); OpDescPtr desc_ptr = std::make_shared<OpDesc>("name1", "type1");
if (desc_ptr == nullptr) {
return;
}
NodePtr n1 = graph_ptr->AddNode(desc_ptr); NodePtr n1 = graph_ptr->AddNode(desc_ptr);
InDataAnchorPtr a1 = std::make_shared<InDataAnchor>(n1, 0); InDataAnchorPtr a1 = std::make_shared<InDataAnchor>(n1, 0);
if (a1 == nullptr) {
return;
}


EXPECT_EQ(AnchorUtils::SetFormat(a1, FORMAT_ND), GRAPH_SUCCESS); EXPECT_EQ(AnchorUtils::SetFormat(a1, FORMAT_ND), GRAPH_SUCCESS);
Format f1 = AnchorUtils::GetFormat(a1); Format f1 = AnchorUtils::GetFormat(a1);
EXPECT_EQ(f1, FORMAT_ND); EXPECT_EQ(f1, FORMAT_ND);


InDataAnchorPtr a2 = std::make_shared<InDataAnchor>(n1, 0); InDataAnchorPtr a2 = std::make_shared<InDataAnchor>(n1, 0);
if (a2 == nullptr) {
return;
}
EXPECT_EQ(AnchorUtils::SetFormat(nullptr, FORMAT_ND), GRAPH_FAILED); EXPECT_EQ(AnchorUtils::SetFormat(nullptr, FORMAT_ND), GRAPH_FAILED);
Format f2 = AnchorUtils::GetFormat(nullptr); Format f2 = AnchorUtils::GetFormat(nullptr);
EXPECT_EQ(f2, FORMAT_RESERVED); EXPECT_EQ(f2, FORMAT_RESERVED);


// has control edge // has control edge
OpDescPtr desc_ptr1 = std::make_shared<OpDesc>("name1", "type1"); OpDescPtr desc_ptr1 = std::make_shared<OpDesc>("name1", "type1");
if (desc_ptr1 == nullptr) {
return;
}
EXPECT_EQ(desc_ptr1->AddInputDesc("x", GeTensorDesc(GeShape({1, 16, 16, 16}), FORMAT_NCHW)), GRAPH_SUCCESS); EXPECT_EQ(desc_ptr1->AddInputDesc("x", GeTensorDesc(GeShape({1, 16, 16, 16}), FORMAT_NCHW)), GRAPH_SUCCESS);
EXPECT_EQ(desc_ptr1->AddInputDesc("w", GeTensorDesc(GeShape({1, 1, 1, 1}), FORMAT_NCHW)), GRAPH_SUCCESS); EXPECT_EQ(desc_ptr1->AddInputDesc("w", GeTensorDesc(GeShape({1, 1, 1, 1}), FORMAT_NCHW)), GRAPH_SUCCESS);
EXPECT_EQ(desc_ptr1->AddOutputDesc("y", GeTensorDesc(GeShape({1, 32, 8, 8}), FORMAT_NCHW)), GRAPH_SUCCESS); EXPECT_EQ(desc_ptr1->AddOutputDesc("y", GeTensorDesc(GeShape({1, 32, 8, 8}), FORMAT_NCHW)), GRAPH_SUCCESS);


OpDescPtr desc_ptr2 = std::make_shared<OpDesc>("name2", "type2"); OpDescPtr desc_ptr2 = std::make_shared<OpDesc>("name2", "type2");
if (desc_ptr2 == nullptr) {
return;
}
EXPECT_EQ(desc_ptr2->AddInputDesc("x", GeTensorDesc(GeShape({1, 16, 16, 16}), FORMAT_NCHW)), GRAPH_SUCCESS); EXPECT_EQ(desc_ptr2->AddInputDesc("x", GeTensorDesc(GeShape({1, 16, 16, 16}), FORMAT_NCHW)), GRAPH_SUCCESS);
EXPECT_EQ(desc_ptr2->AddInputDesc("w", GeTensorDesc(GeShape({1, 1, 1, 1}), FORMAT_NCHW)), GRAPH_SUCCESS); EXPECT_EQ(desc_ptr2->AddInputDesc("w", GeTensorDesc(GeShape({1, 1, 1, 1}), FORMAT_NCHW)), GRAPH_SUCCESS);
EXPECT_EQ(desc_ptr2->AddOutputDesc("y", GeTensorDesc(GeShape({1, 32, 8, 8}), FORMAT_NCHW)), GRAPH_SUCCESS); EXPECT_EQ(desc_ptr2->AddOutputDesc("y", GeTensorDesc(GeShape({1, 32, 8, 8}), FORMAT_NCHW)), GRAPH_SUCCESS);


ComputeGraphPtr graph_ptr1 = std::make_shared<ComputeGraph>("name"); ComputeGraphPtr graph_ptr1 = std::make_shared<ComputeGraph>("name");
if (graph_ptr1 == nullptr) {
return;
}
n1 = graph_ptr1->AddNode(desc_ptr1); n1 = graph_ptr1->AddNode(desc_ptr1);
NodePtr n2 = graph_ptr1->AddNode(desc_ptr2); NodePtr n2 = graph_ptr1->AddNode(desc_ptr2);




Loading…
Cancel
Save