1 /*
2  * Copyright (c) 2022 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 
16 #include <cstring>
17 #include <unistd.h>
18 
19 #include "gtest/gtest.h"
20 
21 #include "plugin_manager/include/aie_plugin_info.h"
22 #include "plugin_manager/include/plugin_label.h"
23 #include "utils/log/aie_log.h"
24 
25 using namespace OHOS::AI;
26 using namespace testing::ext;
27 
28 namespace {
29     const std::string AID_DEMO_PLUGIN_SYNC = "cv_card_rectification";
30     long long AID_DEMO_PLUGIN_VERSION = 20001001;
31 }
32 
33 class PluginLabelTest : public testing::Test {
34 public:
35     // SetUpTestCase:The preset action of the test suite is executed before the first TestCase
SetUpTestCase()36     static void SetUpTestCase() {};
37 
38     // TearDownTestCase:The test suite cleanup action is executed after the last TestCase
TearDownTestCase()39     static void TearDownTestCase() {};
40 
41     // SetUp:Execute before each test case
SetUp()42     void SetUp() {};
43 
44     // TearDown:Execute after each test case
TearDown()45     void TearDown() {};
46 };
47 
TestPluginLabel(const std::string & aid,long long & version,std::string & libPath)48 static void TestPluginLabel(const std::string &aid, long long &version, std::string &libPath)
49 {
50     PluginLabel *pluginLabel = PluginLabel::GetInstance();
51     ASSERT_NE(pluginLabel, nullptr) << "pluginLabel test failed.";
52 
53     int retCode = pluginLabel->GetLibPath(aid, version, libPath);
54     if (retCode != RETCODE_SUCCESS) {
55         HILOGE("[Test]Failed to get lib path. return retCode:%d;", retCode);
56         return;
57     }
58     HILOGE("[Test]SUCCESS return retCode:%d;", retCode);
59 }
60 
61 /**
62  * @tc.name: TestPluginLabel001
63  * @tc.desc: Test Get algorithm path.
64  * @tc.type: FUNC
65  * @tc.require: AR000F77ON
66  */
67 static HWTEST_F(PluginLabelTest, TestPluginLabel001, TestSize.Level0)
68 {
69     HILOGI("[Test]TestPluginLabel001.");
70     std::string libPath;
71     TestPluginLabel(AID_DEMO_PLUGIN_SYNC, AID_DEMO_PLUGIN_VERSION, libPath);
72 }