1 /*
2 * Copyright (c) 2021 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 #include <cstdio>
16 #include <gtest/gtest.h>
17 #include "modulemgr.h"
18
19 using namespace testing::ext;
20 using namespace std;
21
22 namespace initModuleTest {
23 class ModuleMgrModuleTest : public testing::Test {
24 public:
SetUpTestCase(void)25 static void SetUpTestCase(void) {};
TearDownTestCase(void)26 static void TearDownTestCase(void) {};
SetUp(void)27 void SetUp(void) {};
TearDown(void)28 void TearDown(void) {};
29 };
30
TestModuleDump(const MODULE_INFO * moduleInfo)31 static void TestModuleDump(const MODULE_INFO *moduleInfo)
32 {
33 printf("%s\n", moduleInfo->name);
34 }
35
36 HWTEST_F(ModuleMgrModuleTest, ModuleMrgTest, TestSize.Level1)
37 {
38 int cnt;
39 MODULE_MGR *moduleMgr = nullptr;
40 moduleMgr = ModuleMgrCreate("init");
41
42 // Install one module
43 ModuleMgrInstall(moduleMgr, "bootchart", 0, NULL);
44 ModuleMgrDestroy(moduleMgr);
45
46 // Scan all modules
47 moduleMgr = ModuleMgrScan("init");
48 ASSERT_NE(moduleMgr, nullptr);
49
50 ModuleMgrTraversal(moduleMgr, NULL, TestModuleDump);
51
52 ModuleMgrUninstall(moduleMgr, NULL);
53 cnt = ModuleMgrGetCnt(moduleMgr);
54 EXPECT_EQ(cnt, 0);
55 ModuleMgrGetArgs();
56 ModuleMgrDestroy(moduleMgr);
57 }
58 } // namespace init_ut
59