• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 <cinttypes>
17 #include <sys/resource.h>
18 #include <sched.h>
19 #include <linux/sched.h>
20 #include "gtest/gtest.h"
21 #define private public
22 #include "func_loader.h"
23 #include "concurrent_task_controller_interface.h"
24 #include "rtg_interface.h"
25 #include "ipc_skeleton.h"
26 #include "concurrent_task_log.h"
27 #undef private
28 
29 namespace OHOS {
30 namespace FFRT_TEST {
31 using namespace testing;
32 using namespace testing::ext;
33 using namespace OHOS::ConcurrentTask;
34 using namespace std;
35 
36 class FuncLoaderTest : public testing::Test {
37 public:
38     static void SetUpTestCase();
39     static void TearDownTestCase();
40     void SetUp();
41     void TearDown();
42 };
43 
SetUpTestCase()44 void FuncLoaderTest::SetUpTestCase() {}
45 
TearDownTestCase()46 void FuncLoaderTest::TearDownTestCase() {}
47 
SetUp()48 void FuncLoaderTest::SetUp() {}
49 
TearDown()50 void FuncLoaderTest::TearDown() {}
51 
52 /**
53  * @tc.name: LoadFileTest
54  * @tc.desc: Test whether the ReportDataTest interface are normal.
55  * @tc.type: FUNC
56  */
57 HWTEST_F(FuncLoaderTest, LoadFileTest, TestSize.Level1)
58 {
59     FuncLoader funcLoader("111");
60     funcLoader.LoadFile("222");
61     EXPECT_FALSE(funcLoader.enable_);
62 }
63 
64 /**
65  * @tc.name: LoadSymbolTest
66  * @tc.desc: Test whether the ReportDataTest interface are normal.
67  * @tc.type: FUNC
68  */
69 HWTEST_F(FuncLoaderTest, LoadSymbolTest, TestSize.Level1)
70 {
71     FuncLoader funcLoader("/lib/libconcurrent_task_client.z.so");
72 
73     funcLoader.LoadSymbol("Init");
74     funcLoader.LoadSymbol("Release");
75     funcLoader.LoadSymbol("ReportData");
76     funcLoader.LoadSymbol("ReportSceneInfo");
77     funcLoader.LoadSymbol("QueryInterval");
78     funcLoader.LoadSymbol("QueryDeadline");
79     funcLoader.LoadSymbol("SetAudioDeadline");
80     void* funcSym = funcLoader.LoadSymbol("RequestAuth");
81     EXPECT_TRUE(funcSym == nullptr);
82 }
83 
84 /**
85  * @tc.name: GetLoadSuccessTest
86  * @tc.desc: Test whether the ReportDataTest interface are normal.
87  * @tc.type: FUNC
88  */
89 HWTEST_F(FuncLoaderTest, GetLoadSuccessTest, TestSize.Level1)
90 {
91     FuncLoader funcLoader("/lib/libconcurrent_task_client.z.so");
92     bool ret = funcLoader.GetLoadSuccess();
93     if (ret) {
94         EXPECT_EQ(ret, true);
95     } else {
96         EXPECT_EQ(ret, false);
97     }
98 }
99 
100 } // namespace FFRT_TEST
101 } // namespace OHOS