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
16#ifndef UNITTEST_COMM
17#define UNITTEST_COMM
18
19#include <cstring>
20#include <fcntl.h>
21#include <iostream>
22#include <sys/mman.h>
23#include <sys/stat.h>
24#include <unistd.h>
25
26#include "package/package.h"
27
28const std::string TEST_PATH_FROM = "/data/updater/src/";
29const std::string TEST_PATH_TO = "/data/updater/dst/";
30
31inline std::string GetTestPrivateKeyName(int type = 0)
32{
33    std::string name = TEST_PATH_FROM;
34    if (type != PKG_DIGEST_TYPE_SHA384) {
35        name += "rsa_private_key2048.pem";
36    } else {
37        name += "rsa_private_key384.pem";
38    }
39    return name;
40}
41
42inline std::string GetTestCertName(int type = 0)
43{
44    std::string name = TEST_PATH_FROM;
45    if (type != PKG_DIGEST_TYPE_SHA384) {
46        name += "signing_cert.crt";
47    } else {
48        name += "signing_cert384.crt";
49    }
50    return name;
51}
52#endif // UNITTEST_COMM
53