1 /*
2 * Copyright (c) 2021-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 <gtest/gtest.h>
17 #include "sandbox_utils.h"
18 #include "appspawn_service.h"
19
20 using namespace testing;
21 using namespace testing::ext;
22 using namespace OHOS::AppSpawn;
23 using nlohmann::json;
24
25 namespace OHOS {
26 class AppSpawnSandboxTest : public testing::Test {
27 public:
28 static void SetUpTestCase();
29 static void TearDownTestCase();
30 void SetUp();
31 void TearDown();
32 };
33
SetUpTestCase()34 void AppSpawnSandboxTest::SetUpTestCase()
35 {}
36
TearDownTestCase()37 void AppSpawnSandboxTest::TearDownTestCase()
38 {}
39
SetUp()40 void AppSpawnSandboxTest::SetUp()
41 {}
42
TearDown()43 void AppSpawnSandboxTest::TearDown()
44 {}
45
GetAppProperty(void)46 static ClientSocket::AppProperty *GetAppProperty(void)
47 {
48 static AppSpawnClientExt client;
49 return &client.property;
50 }
51
52 HWTEST(AppSpawnSandboxTest, App_Spawn_Sandbox_33, TestSize.Level0)
53 {
54 GTEST_LOG_(INFO) << "App_Spawn_Sandbox_33 start";
55 ClientSocket::AppProperty *m_appProperty = GetAppProperty();
56 m_appProperty->uid = 1000;
57 m_appProperty->gid = 1000;
58
59 const char *srcPath = "/data/app/el1";
60 std::string path = srcPath;
61 OHOS::AppSpawn::SandboxUtils::CheckAndPrepareSrcPath(m_appProperty, path);
62
63 const char *srcPath1 = "/data/app/el2/100/base/ohos.test.bundle1";
64 std::string path1 = srcPath1;
65 OHOS::AppSpawn::SandboxUtils::CheckAndPrepareSrcPath(m_appProperty, path1);
66
67 const char *srcPath2 = "/data/app/el2/100/database/ohos.test.bundle2";
68 std::string path2 = srcPath2;
69 OHOS::AppSpawn::SandboxUtils::CheckAndPrepareSrcPath(m_appProperty, path2);
70
71 const char *srcPath3 = "/data/app/el2/100/test123/ohos.test.bundle3";
72 std::string path3 = srcPath3;
73 OHOS::AppSpawn::SandboxUtils::CheckAndPrepareSrcPath(m_appProperty, path3);
74
75 const char *srcPath4 = "/data/serivce/el2/100/hmdfs/account/data/ohos.test.bundle4";
76 std::string path4 = srcPath4;
77 OHOS::AppSpawn::SandboxUtils::CheckAndPrepareSrcPath(m_appProperty, path4);
78
79 const char *srcPath5 = "/data/serivce/el2/100/hmdfs/non_account/data/ohos.test.bundle5";
80 std::string path5 = srcPath5;
81 OHOS::AppSpawn::SandboxUtils::CheckAndPrepareSrcPath(m_appProperty, path5);
82
83 const char *srcPath6 = "/data/serivce/el2/100/hmdfs/non_account/test/ohos.test.bundle6";
84 std::string path6 = srcPath6;
85 OHOS::AppSpawn::SandboxUtils::CheckAndPrepareSrcPath(m_appProperty, path6);
86 SUCCEED();
87 }
88 } // namespace OHOS