1fb299fa2Sopenharmony_ci/*
2fb299fa2Sopenharmony_ci * Copyright (c) 2021 Huawei Device Co., Ltd.
3fb299fa2Sopenharmony_ci * Licensed under the Apache License, Version 2.0 (the "License");
4fb299fa2Sopenharmony_ci * you may not use this file except in compliance with the License.
5fb299fa2Sopenharmony_ci * You may obtain a copy of the License at
6fb299fa2Sopenharmony_ci *
7fb299fa2Sopenharmony_ci *     http://www.apache.org/licenses/LICENSE-2.0
8fb299fa2Sopenharmony_ci *
9fb299fa2Sopenharmony_ci * Unless required by applicable law or agreed to in writing, software
10fb299fa2Sopenharmony_ci * distributed under the License is distributed on an "AS IS" BASIS,
11fb299fa2Sopenharmony_ci * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12fb299fa2Sopenharmony_ci * See the License for the specific language governing permissions and
13fb299fa2Sopenharmony_ci * limitations under the License.
14fb299fa2Sopenharmony_ci */
15fb299fa2Sopenharmony_ci
16fb299fa2Sopenharmony_ci#include <cstring>
17fb299fa2Sopenharmony_ci#include <fcntl.h>
18fb299fa2Sopenharmony_ci#include <gtest/gtest.h>
19fb299fa2Sopenharmony_ci#include <iostream>
20fb299fa2Sopenharmony_ci#include <sys/mman.h>
21fb299fa2Sopenharmony_ci#include <sys/stat.h>
22fb299fa2Sopenharmony_ci#include <unistd.h>
23fb299fa2Sopenharmony_ci#include "log.h"
24fb299fa2Sopenharmony_ci#include "pkg_algorithm.h"
25fb299fa2Sopenharmony_ci#include "pkg_manager.h"
26fb299fa2Sopenharmony_ci#include "pkg_manager_impl.h"
27fb299fa2Sopenharmony_ci#include "pkg_test.h"
28fb299fa2Sopenharmony_ci#include "pkg_utils.h"
29fb299fa2Sopenharmony_ci
30fb299fa2Sopenharmony_ciusing namespace std;
31fb299fa2Sopenharmony_ciusing namespace Hpackage;
32fb299fa2Sopenharmony_ciusing namespace Updater;
33fb299fa2Sopenharmony_ciusing namespace testing::ext;
34fb299fa2Sopenharmony_ci
35fb299fa2Sopenharmony_cinamespace UpdaterUt {
36fb299fa2Sopenharmony_ciclass PackageUnitTest : public PkgTest {
37fb299fa2Sopenharmony_cipublic:
38fb299fa2Sopenharmony_ci    PackageUnitTest() {}
39fb299fa2Sopenharmony_ci    ~PackageUnitTest() override {}
40fb299fa2Sopenharmony_cipublic:
41fb299fa2Sopenharmony_ci    int TestInvalidCreatePackage()
42fb299fa2Sopenharmony_ci    {
43fb299fa2Sopenharmony_ci        std::vector<ComponentInfoExt> compInfo;
44fb299fa2Sopenharmony_ci        uint8_t pkgType = PkgPackType::PKG_PACK_TYPE_UPGRADE;
45fb299fa2Sopenharmony_ci        int ret = CreatePackage(nullptr, compInfo, nullptr, GetTestPrivateKeyName(0).c_str());
46fb299fa2Sopenharmony_ci        EXPECT_EQ(ret, PKG_INVALID_PARAM);
47fb299fa2Sopenharmony_ci
48fb299fa2Sopenharmony_ci        UpgradePkgInfoExt pkgInfoExt {};
49fb299fa2Sopenharmony_ci        pkgInfoExt.pkgType = pkgType;
50fb299fa2Sopenharmony_ci        ret = CreatePackage(&pkgInfoExt, compInfo, nullptr, GetTestPrivateKeyName(0).c_str());
51fb299fa2Sopenharmony_ci        EXPECT_EQ(ret, PKG_INVALID_PARAM);
52fb299fa2Sopenharmony_ci
53fb299fa2Sopenharmony_ci        constexpr uint32_t digestLen = 32;
54fb299fa2Sopenharmony_ci        ret = VerifyPackage(nullptr, GetTestCertName(0).c_str(), nullptr, nullptr, digestLen);
55fb299fa2Sopenharmony_ci        EXPECT_EQ(ret, PKG_INVALID_PARAM);
56fb299fa2Sopenharmony_ci
57fb299fa2Sopenharmony_ci        std::string packagePath = TEST_PATH_TO + testPackageName;
58fb299fa2Sopenharmony_ci        pkgInfoExt.pkgType = pkgType;
59fb299fa2Sopenharmony_ci        ret = CreatePackage(&pkgInfoExt, compInfo, packagePath.c_str(), GetTestPrivateKeyName(0).c_str());
60fb299fa2Sopenharmony_ci        EXPECT_EQ(ret, PKG_INVALID_PARAM);
61fb299fa2Sopenharmony_ci
62fb299fa2Sopenharmony_ci        pkgType = PkgPackType::PKG_PACK_TYPE_ZIP;
63fb299fa2Sopenharmony_ci        pkgInfoExt.pkgType = pkgType;
64fb299fa2Sopenharmony_ci        ret = CreatePackage(&pkgInfoExt, compInfo, packagePath.c_str(), GetTestPrivateKeyName(0).c_str());
65fb299fa2Sopenharmony_ci        EXPECT_EQ(ret, PKG_INVALID_PARAM);
66fb299fa2Sopenharmony_ci
67fb299fa2Sopenharmony_ci        pkgType = PkgPackType::PKG_PACK_TYPE_LZ4;
68fb299fa2Sopenharmony_ci        pkgInfoExt.pkgType = pkgType;
69fb299fa2Sopenharmony_ci        ret = CreatePackage(&pkgInfoExt, compInfo, packagePath.c_str(), GetTestPrivateKeyName(0).c_str());
70fb299fa2Sopenharmony_ci        EXPECT_EQ(ret, PKG_INVALID_PARAM);
71fb299fa2Sopenharmony_ci
72fb299fa2Sopenharmony_ci        pkgType = PkgPackType::PKG_PACK_TYPE_GZIP;
73fb299fa2Sopenharmony_ci        pkgInfoExt.pkgType = pkgType;
74fb299fa2Sopenharmony_ci        ret = CreatePackage(&pkgInfoExt, compInfo, packagePath.c_str(), GetTestPrivateKeyName(0).c_str());
75fb299fa2Sopenharmony_ci        EXPECT_EQ(ret, PKG_INVALID_PARAM);
76fb299fa2Sopenharmony_ci
77fb299fa2Sopenharmony_ci        pkgType = PkgPackType::PKG_PACK_TYPE_NONE;
78fb299fa2Sopenharmony_ci        pkgInfoExt.pkgType = pkgType;
79fb299fa2Sopenharmony_ci        ret = CreatePackage(&pkgInfoExt, compInfo, packagePath.c_str(), GetTestPrivateKeyName(0).c_str());
80fb299fa2Sopenharmony_ci        EXPECT_EQ(ret, PKG_INVALID_PARAM);
81fb299fa2Sopenharmony_ci        return 0;
82fb299fa2Sopenharmony_ci    }
83fb299fa2Sopenharmony_ci
84fb299fa2Sopenharmony_ci    int TestPackagePack(int type = PKG_DIGEST_TYPE_SHA256)
85fb299fa2Sopenharmony_ci    {
86fb299fa2Sopenharmony_ci        int32_t ret;
87fb299fa2Sopenharmony_ci        uint32_t updateFileVersion = 1000;
88fb299fa2Sopenharmony_ci        UpgradePkgInfoExt pkgInfo;
89fb299fa2Sopenharmony_ci        pkgInfo.softwareVersion = strdup("100.100.100.100");
90fb299fa2Sopenharmony_ci        pkgInfo.date = strdup("2021-02-02");
91fb299fa2Sopenharmony_ci        pkgInfo.time = strdup("21:23:49");
92fb299fa2Sopenharmony_ci        pkgInfo.productUpdateId = strdup("555.555.100.555");
93fb299fa2Sopenharmony_ci        pkgInfo.entryCount = testFileNames_.size();
94fb299fa2Sopenharmony_ci        pkgInfo.digestMethod = type;
95fb299fa2Sopenharmony_ci        pkgInfo.signMethod = PKG_SIGN_METHOD_RSA;
96fb299fa2Sopenharmony_ci        pkgInfo.pkgType = PKG_PACK_TYPE_UPGRADE;
97fb299fa2Sopenharmony_ci        pkgInfo.updateFileVersion = updateFileVersion;
98fb299fa2Sopenharmony_ci        std::string filePath;
99fb299fa2Sopenharmony_ci        uint32_t componentIdBase = 100;
100fb299fa2Sopenharmony_ci        uint8_t componentFlags = 22;
101fb299fa2Sopenharmony_ci        std::vector<ComponentInfoExt> comp(testFileNames_.size());
102fb299fa2Sopenharmony_ci        for (size_t i = 0; i < testFileNames_.size(); i++) {
103fb299fa2Sopenharmony_ci            comp[i].componentAddr = strdup(testFileNames_[i].c_str());
104fb299fa2Sopenharmony_ci            filePath = TEST_PATH_FROM;
105fb299fa2Sopenharmony_ci            filePath += testFileNames_[i].c_str();
106fb299fa2Sopenharmony_ci            comp[i].filePath = strdup(filePath.c_str());
107fb299fa2Sopenharmony_ci            comp[i].version = strdup("55555555");
108fb299fa2Sopenharmony_ci            ret = BuildFileDigest(*comp[i].digest, sizeof(comp[i].digest), filePath);
109fb299fa2Sopenharmony_ci            EXPECT_EQ(ret, PKG_SUCCESS);
110fb299fa2Sopenharmony_ci            comp[i].size = GetFileSize(filePath);
111fb299fa2Sopenharmony_ci            comp[i].originalSize = comp[i].size;
112fb299fa2Sopenharmony_ci            comp[i].id = i + componentIdBase;
113fb299fa2Sopenharmony_ci            comp[i].resType = 1;
114fb299fa2Sopenharmony_ci            comp[i].type = 1;
115fb299fa2Sopenharmony_ci            comp[i].flags = componentFlags;
116fb299fa2Sopenharmony_ci            filePath.clear();
117fb299fa2Sopenharmony_ci        }
118fb299fa2Sopenharmony_ci        std::string packagePath = TEST_PATH_TO;
119fb299fa2Sopenharmony_ci        packagePath += testPackageName;
120fb299fa2Sopenharmony_ci        ret = CreatePackage(&pkgInfo, comp, packagePath.c_str(),
121fb299fa2Sopenharmony_ci            GetTestPrivateKeyName(pkgInfo.digestMethod).c_str());
122fb299fa2Sopenharmony_ci        EXPECT_EQ(ret, PKG_SUCCESS);
123fb299fa2Sopenharmony_ci        for (size_t i = 0; i < testFileNames_.size(); i++) {
124fb299fa2Sopenharmony_ci            free(comp[i].componentAddr);
125fb299fa2Sopenharmony_ci            free(comp[i].filePath);
126fb299fa2Sopenharmony_ci            free(comp[i].version);
127fb299fa2Sopenharmony_ci        }
128fb299fa2Sopenharmony_ci        free(pkgInfo.softwareVersion);
129fb299fa2Sopenharmony_ci        free(pkgInfo.date);
130fb299fa2Sopenharmony_ci        free(pkgInfo.time);
131fb299fa2Sopenharmony_ci        free(pkgInfo.productUpdateId);
132fb299fa2Sopenharmony_ci        return ret;
133fb299fa2Sopenharmony_ci    }
134fb299fa2Sopenharmony_ci
135fb299fa2Sopenharmony_ci    int TestPackageUnpack(int type)
136fb299fa2Sopenharmony_ci    {
137fb299fa2Sopenharmony_ci        EXPECT_NE(pkgManager_, nullptr);
138fb299fa2Sopenharmony_ci        std::vector<std::string> components;
139fb299fa2Sopenharmony_ci        // 使用上面打包的包进行解析
140fb299fa2Sopenharmony_ci        int32_t ret = pkgManager_->LoadPackage(
141fb299fa2Sopenharmony_ci            testPackagePath + "test_package.zip", GetTestCertName(type), components);
142fb299fa2Sopenharmony_ci        EXPECT_EQ(ret, PKG_SUCCESS);
143fb299fa2Sopenharmony_ci
144fb299fa2Sopenharmony_ci        for (size_t i = 0; i < components.size(); i++) {
145fb299fa2Sopenharmony_ci            PKG_LOGI("comp [%zu] file name: %s \r\n", i, (TEST_PATH_TO + components[i]).c_str());
146fb299fa2Sopenharmony_ci            ExtractFile(pkgManager_, components, i);
147fb299fa2Sopenharmony_ci        }
148fb299fa2Sopenharmony_ci        return PKG_SUCCESS;
149fb299fa2Sopenharmony_ci    }
150fb299fa2Sopenharmony_ci
151fb299fa2Sopenharmony_ci    int TestZipPkgCompress(int digestMethod)
152fb299fa2Sopenharmony_ci    {
153fb299fa2Sopenharmony_ci        return CreateZipPackage(testFileNames_, TEST_PATH_TO + testZipPackageName, TEST_PATH_FROM, digestMethod);
154fb299fa2Sopenharmony_ci    }
155fb299fa2Sopenharmony_ci
156fb299fa2Sopenharmony_ci    int TestZipPkgDecompress(int digestMethod)
157fb299fa2Sopenharmony_ci    {
158fb299fa2Sopenharmony_ci        EXPECT_NE(pkgManager_, nullptr);
159fb299fa2Sopenharmony_ci        std::vector<std::string> components;
160fb299fa2Sopenharmony_ci        int32_t ret = pkgManager_->LoadPackage(TEST_PATH_TO + testZipPackageName,
161fb299fa2Sopenharmony_ci            GetTestCertName(digestMethod), components);
162fb299fa2Sopenharmony_ci        EXPECT_EQ(ret, PKG_SUCCESS);
163fb299fa2Sopenharmony_ci
164fb299fa2Sopenharmony_ci        for (size_t i = 0; i < components.size(); i++) {
165fb299fa2Sopenharmony_ci            PKG_LOGI("file name: %s \r\n", (TEST_PATH_TO + components[i]).c_str());
166fb299fa2Sopenharmony_ci            ExtractFile(pkgManager_, components, i);
167fb299fa2Sopenharmony_ci        }
168fb299fa2Sopenharmony_ci        return ret;
169fb299fa2Sopenharmony_ci    }
170fb299fa2Sopenharmony_ci
171fb299fa2Sopenharmony_ci    int TestGZipPkgCompress()
172fb299fa2Sopenharmony_ci    {
173fb299fa2Sopenharmony_ci        int ret = TestPackagePack();
174fb299fa2Sopenharmony_ci        EXPECT_EQ(ret, PKG_SUCCESS);
175fb299fa2Sopenharmony_ci        EXPECT_NE(pkgManager_, nullptr);
176fb299fa2Sopenharmony_ci        std::vector<std::pair<std::string, ZipFileInfo>> files;
177fb299fa2Sopenharmony_ci        ZipFileInfo file;
178fb299fa2Sopenharmony_ci        file.fileInfo.identity = testPackageName;
179fb299fa2Sopenharmony_ci        file.fileInfo.packMethod = PKG_COMPRESS_METHOD_GZIP;
180fb299fa2Sopenharmony_ci        file.fileInfo.digestMethod = PKG_DIGEST_TYPE_CRC;
181fb299fa2Sopenharmony_ci        std::string fileName = TEST_PATH_TO + testPackageName;
182fb299fa2Sopenharmony_ci        files.push_back(std::pair<std::string, ZipFileInfo>(fileName, file));
183fb299fa2Sopenharmony_ci
184fb299fa2Sopenharmony_ci        PkgInfo pkgInfo;
185fb299fa2Sopenharmony_ci        pkgInfo.signMethod = PKG_SIGN_METHOD_RSA;
186fb299fa2Sopenharmony_ci        pkgInfo.digestMethod  = PKG_DIGEST_TYPE_SHA256;
187fb299fa2Sopenharmony_ci        pkgInfo.pkgType = PKG_PACK_TYPE_GZIP;
188fb299fa2Sopenharmony_ci        return pkgManager_->CreatePackage(TEST_PATH_TO + testGZipPackageName,
189fb299fa2Sopenharmony_ci            GetTestPrivateKeyName(pkgInfo.digestMethod), &pkgInfo, files);
190fb299fa2Sopenharmony_ci    }
191fb299fa2Sopenharmony_ci
192fb299fa2Sopenharmony_ci    int TestVerifyUpgradePackage()
193fb299fa2Sopenharmony_ci    {
194fb299fa2Sopenharmony_ci        constexpr size_t digestSize = 32;
195fb299fa2Sopenharmony_ci        std::vector<uint8_t> digest(digestSize);
196fb299fa2Sopenharmony_ci        std::string path = testPackagePath + "test_package.zip";
197fb299fa2Sopenharmony_ci        BuildFileDigest(*digest.data(), digest.capacity(), path.c_str());
198fb299fa2Sopenharmony_ci        int ret = VerifyPackage(path.c_str(), GetTestCertName(0).c_str(), "", digest.data(), digest.capacity());
199fb299fa2Sopenharmony_ci        EXPECT_EQ(0, ret);
200fb299fa2Sopenharmony_ci        ret = VerifyPackage(nullptr, nullptr, nullptr, nullptr, digest.capacity());
201fb299fa2Sopenharmony_ci        EXPECT_EQ(PKG_INVALID_PARAM, ret);
202fb299fa2Sopenharmony_ci        return 0;
203fb299fa2Sopenharmony_ci    }
204fb299fa2Sopenharmony_ci
205fb299fa2Sopenharmony_ci    int TestVerifyPackageWithCallback()
206fb299fa2Sopenharmony_ci    {
207fb299fa2Sopenharmony_ci        std::string path = testPackagePath + "test_package.zip";
208fb299fa2Sopenharmony_ci        int ret = VerifyPackageWithCallback(path.c_str(), GetTestCertName(0).c_str(),
209fb299fa2Sopenharmony_ci            [](int32_t result, uint32_t percent) { PKG_LOGI("current progress: %u\n", percent); });
210fb299fa2Sopenharmony_ci        EXPECT_EQ(0, ret);
211fb299fa2Sopenharmony_ci
212fb299fa2Sopenharmony_ci        std::string keyPath = "";
213fb299fa2Sopenharmony_ci        ret = VerifyPackageWithCallback(path.c_str(), keyPath.c_str(),
214fb299fa2Sopenharmony_ci            [](int32_t result, uint32_t percent) { PKG_LOGI("current progress: %u\n", percent); });
215fb299fa2Sopenharmony_ci        EXPECT_EQ(PKG_INVALID_PARAM, ret);
216fb299fa2Sopenharmony_ci
217fb299fa2Sopenharmony_ci        std::function<void(int32_t result, uint32_t percent)> cb = nullptr;
218fb299fa2Sopenharmony_ci        ret = VerifyPackageWithCallback(path.c_str(), GetTestCertName(0).c_str(), cb);
219fb299fa2Sopenharmony_ci        EXPECT_EQ(PKG_INVALID_PARAM, ret);
220fb299fa2Sopenharmony_ci
221fb299fa2Sopenharmony_ci        path = "";
222fb299fa2Sopenharmony_ci        ret = VerifyPackageWithCallback(path.c_str(), GetTestCertName(0).c_str(),
223fb299fa2Sopenharmony_ci            [](int32_t result, uint32_t percent) { PKG_LOGI("current progress: %u\n", percent); });
224fb299fa2Sopenharmony_ci        EXPECT_EQ(PKG_INVALID_PARAM, ret);
225fb299fa2Sopenharmony_ci        return 0;
226fb299fa2Sopenharmony_ci    }
227fb299fa2Sopenharmony_ci
228fb299fa2Sopenharmony_ci    int TestLz4PkgCompress()
229fb299fa2Sopenharmony_ci    {
230fb299fa2Sopenharmony_ci        int ret = TestPackagePack();
231fb299fa2Sopenharmony_ci        EXPECT_EQ(ret, PKG_SUCCESS);
232fb299fa2Sopenharmony_ci        EXPECT_NE(pkgManager_, nullptr);
233fb299fa2Sopenharmony_ci        std::vector<std::pair<std::string, Lz4FileInfo>> files;
234fb299fa2Sopenharmony_ci        Lz4FileInfo file;
235fb299fa2Sopenharmony_ci        int8_t compressionLevel = 14;
236fb299fa2Sopenharmony_ci        file.fileInfo.identity = testPackageName;
237fb299fa2Sopenharmony_ci        file.fileInfo.packMethod = PKG_COMPRESS_METHOD_LZ4;
238fb299fa2Sopenharmony_ci        file.fileInfo.digestMethod = PKG_DIGEST_TYPE_CRC;
239fb299fa2Sopenharmony_ci        file.compressionLevel = compressionLevel;
240fb299fa2Sopenharmony_ci        file.blockSizeID = 0;
241fb299fa2Sopenharmony_ci        file.contentChecksumFlag = 0;
242fb299fa2Sopenharmony_ci        file.blockIndependence = 0;
243fb299fa2Sopenharmony_ci        std::string fileName = TEST_PATH_TO + testPackageName;
244fb299fa2Sopenharmony_ci        files.push_back(std::pair<std::string, Lz4FileInfo>(fileName, file));
245fb299fa2Sopenharmony_ci
246fb299fa2Sopenharmony_ci        PkgInfo pkgInfo;
247fb299fa2Sopenharmony_ci        pkgInfo.pkgType = PKG_PACK_TYPE_LZ4;
248fb299fa2Sopenharmony_ci        pkgInfo.signMethod = PKG_SIGN_METHOD_RSA;
249fb299fa2Sopenharmony_ci        pkgInfo.digestMethod  = PKG_DIGEST_TYPE_SHA256;
250fb299fa2Sopenharmony_ci        return pkgManager_->CreatePackage(TEST_PATH_TO + testLz4PackageName,
251fb299fa2Sopenharmony_ci            GetTestPrivateKeyName(pkgInfo.digestMethod), &pkgInfo, files);
252fb299fa2Sopenharmony_ci    }
253fb299fa2Sopenharmony_ci};
254fb299fa2Sopenharmony_ci
255fb299fa2Sopenharmony_ciHWTEST_F(PackageUnitTest, TestLz4Package, TestSize.Level1)
256fb299fa2Sopenharmony_ci{
257fb299fa2Sopenharmony_ci    PackageUnitTest test;
258fb299fa2Sopenharmony_ci    EXPECT_EQ(0, test.TestLz4PkgCompress());
259fb299fa2Sopenharmony_ci}
260fb299fa2Sopenharmony_ci
261fb299fa2Sopenharmony_ciHWTEST_F(PackageUnitTest, TestInvalidCreatePackage, TestSize.Level1)
262fb299fa2Sopenharmony_ci{
263fb299fa2Sopenharmony_ci    PackageUnitTest test;
264fb299fa2Sopenharmony_ci    EXPECT_EQ(0, test.TestInvalidCreatePackage());
265fb299fa2Sopenharmony_ci}
266fb299fa2Sopenharmony_ci
267fb299fa2Sopenharmony_ciHWTEST_F(PackageUnitTest, TestVerifyUpgradePackage, TestSize.Level1)
268fb299fa2Sopenharmony_ci{
269fb299fa2Sopenharmony_ci    PackageUnitTest test;
270fb299fa2Sopenharmony_ci    EXPECT_EQ(0, test.TestVerifyUpgradePackage());
271fb299fa2Sopenharmony_ci}
272fb299fa2Sopenharmony_ci
273fb299fa2Sopenharmony_ciHWTEST_F(PackageUnitTest, TestVerifyPackageWithCallback, TestSize.Level1)
274fb299fa2Sopenharmony_ci{
275fb299fa2Sopenharmony_ci    PackageUnitTest test;
276fb299fa2Sopenharmony_ci    EXPECT_EQ(0, test.TestVerifyPackageWithCallback());
277fb299fa2Sopenharmony_ci}
278fb299fa2Sopenharmony_ci
279fb299fa2Sopenharmony_ciHWTEST_F(PackageUnitTest, TestPackage, TestSize.Level1)
280fb299fa2Sopenharmony_ci{
281fb299fa2Sopenharmony_ci    PackageUnitTest test;
282fb299fa2Sopenharmony_ci    EXPECT_EQ(0, test.TestPackagePack(PKG_DIGEST_TYPE_SHA256));
283fb299fa2Sopenharmony_ci    EXPECT_EQ(0, test.TestPackageUnpack(PKG_DIGEST_TYPE_SHA256));
284fb299fa2Sopenharmony_ci}
285fb299fa2Sopenharmony_ci
286fb299fa2Sopenharmony_ciHWTEST_F(PackageUnitTest, TestZipPackage, TestSize.Level1)
287fb299fa2Sopenharmony_ci{
288fb299fa2Sopenharmony_ci    PackageUnitTest test;
289fb299fa2Sopenharmony_ci    EXPECT_EQ(0, test.TestZipPkgCompress(PKG_DIGEST_TYPE_SHA256));
290fb299fa2Sopenharmony_ci    EXPECT_EQ(0, test.TestZipPkgDecompress(PKG_DIGEST_TYPE_SHA256));
291fb299fa2Sopenharmony_ci}
292fb299fa2Sopenharmony_ci
293fb299fa2Sopenharmony_ciHWTEST_F(PackageUnitTest, TestGZipPkg, TestSize.Level1)
294fb299fa2Sopenharmony_ci{
295fb299fa2Sopenharmony_ci    PackageUnitTest test;
296fb299fa2Sopenharmony_ci    EXPECT_EQ(0, test.TestGZipPkgCompress());
297fb299fa2Sopenharmony_ci}
298fb299fa2Sopenharmony_ci}
299