mirror of
https://gitee.com/openharmony/startup_appspawn
synced 2024-11-23 07:00:17 +00:00
fix
Signed-off-by: 王达 <wangda20@huawei.com>
This commit is contained in:
parent
ffd72735b5
commit
d366886b5b
@ -19,6 +19,7 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <limits.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "securec.h"
|
||||
|
||||
@ -78,11 +79,6 @@ enum {
|
||||
HNP_INDEX_7
|
||||
};
|
||||
|
||||
typedef enum {
|
||||
FALSE,
|
||||
TRUE
|
||||
} Bool;
|
||||
|
||||
// 错误码生成
|
||||
#define HNP_ERRNO_HNP_MID 0x80
|
||||
#define HNP_ERRNO_HIGH16_MAKE() (HNP_ERRNO_HNP_MID << 16)
|
||||
@ -202,6 +198,8 @@ int HnpDeleteFolder(const char *path);
|
||||
|
||||
int HnpCreateFolder(const char* path);
|
||||
|
||||
int HnpWriteInfoToFile(const char* filePath, char *buff, int len);
|
||||
|
||||
#define HNP_LOGI(args...) \
|
||||
HnpLogPrintf(HNP_LOG_INFO, "HNP", ##args)
|
||||
|
||||
|
@ -130,6 +130,25 @@ int ReadFileToStreamBySize(const char *filePath, char **stream, int readSize)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int HnpWriteInfoToFile(const char* filePath, char *buff, int len)
|
||||
{
|
||||
FILE *fp = fopen(filePath, "w");
|
||||
if (fp == NULL) {
|
||||
HNP_LOGE("open file:%s unsuccess!", filePath);
|
||||
return HNP_ERRNO_BASE_FILE_OPEN_FAILED;
|
||||
}
|
||||
int writeLen = fwrite(buff, sizeof(char), len, fp);
|
||||
if (writeLen != len) {
|
||||
HNP_LOGE("write file:%s unsuccess! len=%d, write=%d", filePath, len, writeLen);
|
||||
(void)fclose(fp);
|
||||
return HNP_ERRNO_BASE_FILE_WRITE_FAILED;
|
||||
}
|
||||
|
||||
(void)fclose(fp);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int GetRealPath(char *srcPath, char *realPath)
|
||||
{
|
||||
char dstTmpPath[PATH_MAX];
|
||||
@ -159,11 +178,14 @@ int GetRealPath(char *srcPath, char *realPath)
|
||||
|
||||
int HnpDeleteFolder(const char *path)
|
||||
{
|
||||
int ret = 0;
|
||||
#ifdef _WIN32
|
||||
return ret;
|
||||
#else
|
||||
DIR *dir = opendir(path);
|
||||
struct dirent *entry;
|
||||
struct stat statbuf;
|
||||
char filePath[MAX_FILE_PATH_LEN];
|
||||
int ret;
|
||||
|
||||
if (dir == NULL) {
|
||||
HNP_LOGE("delete folder open dir=%s unsuccess ", path);
|
||||
@ -208,6 +230,7 @@ int HnpDeleteFolder(const char *path)
|
||||
HNP_LOGE("rmdir path unsuccess.ret=%d, path=%s, errno=%d", ret, path, errno);
|
||||
}
|
||||
return ret;
|
||||
#endif
|
||||
}
|
||||
|
||||
int HnpCreateFolder(const char* path)
|
||||
|
@ -30,6 +30,8 @@ int HnpProgramRunCheck(const char *programName)
|
||||
char command[HNP_COMMAND_LEN];
|
||||
int ret;
|
||||
|
||||
HNP_LOGI("program[%s] running check", programName);
|
||||
|
||||
/* 对programName进行空格过滤,防止外部命令注入 */
|
||||
if (strchr(programName, ' ') != NULL) {
|
||||
HNP_LOGE("hnp install program name[%s] inval", programName);
|
||||
|
@ -44,13 +44,15 @@ int HnpShowHelp(int argc, char *argv[])
|
||||
|
||||
HNP_LOGI("\r\nusage:hnp <command> <args>\r\n"
|
||||
"\r\nThese are common hnp commands used in various situations:\r\n"
|
||||
"\r\nIf the [package name] is null, it represents a public install/nuninstall,\r\n"
|
||||
" or it represents a private install/nuninstall\r\n"
|
||||
"\r\ninstall: install native software"
|
||||
"\r\n hnp install [user id] [hnp package dir] <-f>\r\n"
|
||||
"\r\n hnp install [user id] [hnp package dir] [package name] <-f>\r\n"
|
||||
"\r\nuninstall: uninstall native software"
|
||||
"\r\n hnp uninstall [user id] [software name] [software version]\r\n"
|
||||
"\r\n hnp uninstall [user id] [software name] [software version] [package name]\r\n"
|
||||
"\r\nfor example:\r\n"
|
||||
"\r\n hnp install 1000 /usr1/hnp -f\r\n"
|
||||
" hnp uninstall 1000 native_sample 1.1\r\n");
|
||||
"\r\n hnp install 1000 /usr1/hnp wechat -f\r\n"
|
||||
" hnp uninstall 1000 native_sample 1.1 wechat\r\n");
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -54,6 +54,8 @@ typedef struct NativeHnpPathStru {
|
||||
|
||||
#define HNP_DEFAULT_INSTALL_ROOT_PATH "/data/app/el1/bundle/"
|
||||
|
||||
#define HNP_UNSTALL_INFO_FILE "hnp_uninstall.txt"
|
||||
|
||||
int HnpCmdInstall(int argc, char *argv[]);
|
||||
|
||||
int HnpCmdUnInstall(int argc, char *argv[]);
|
||||
|
@ -47,10 +47,18 @@ static int HnpGenerateSoftLinkAllByJson(const char *installPath, const char *dst
|
||||
{
|
||||
char srcFile[MAX_FILE_PATH_LEN];
|
||||
char dstFile[MAX_FILE_PATH_LEN];
|
||||
char uninstallFile[MAX_FILE_PATH_LEN];
|
||||
NativeBinLink *currentLink = hnpHead->links;
|
||||
char *fileName;
|
||||
int ret;
|
||||
|
||||
if (access(dstPath, F_OK) != 0) {
|
||||
ret = mkdir(dstPath, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
|
||||
if ((ret != 0) && (errno != EEXIST)) {
|
||||
HNP_LOGE("mkdir [%s] unsuccess, ret=%d, errno:%d", dstPath, ret, errno);
|
||||
}
|
||||
}
|
||||
|
||||
for (unsigned int i = 0; i < hnpHead->linkNum; i++) {
|
||||
ret = sprintf_s(srcFile, MAX_FILE_PATH_LEN, "%s%s", installPath, currentLink->source);
|
||||
if (ret < 0) {
|
||||
@ -82,7 +90,15 @@ static int HnpGenerateSoftLinkAllByJson(const char *installPath, const char *dst
|
||||
currentLink++;
|
||||
}
|
||||
|
||||
return 0;
|
||||
ret = sprintf_s(uninstallFile, MAX_FILE_PATH_LEN, "%s"HNP_UNSTALL_INFO_FILE, installPath);
|
||||
if (ret < 0) {
|
||||
HNP_LOGE("sprintf install info file unsuccess.");
|
||||
return HNP_ERRNO_BASE_SPRINTF_FAILED;
|
||||
}
|
||||
/* 向生成的hnp_unstall.txt文件头写入配置信息便于卸载 */
|
||||
ret = HnpWriteInfoToFile(uninstallFile, (char*)hnpHead, hnpHead->headLen);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int HnpGenerateSoftLinkAll(const char *installPath, const char *dstPath)
|
||||
@ -102,8 +118,16 @@ static int HnpGenerateSoftLinkAll(const char *installPath, const char *dstPath)
|
||||
|
||||
if ((dir = opendir(srcPath)) == NULL) {
|
||||
HNP_LOGE("generate soft link opendir:%s unsuccess", srcPath);
|
||||
return HNP_ERRNO_BASE_DIR_OPEN_FAILED;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (access(dstPath, F_OK) != 0) {
|
||||
ret = mkdir(dstPath, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
|
||||
if ((ret != 0) && (errno != EEXIST)) {
|
||||
HNP_LOGE("mkdir [%s] unsuccess, ret=%d, errno:%d", dstPath, ret, errno);
|
||||
}
|
||||
}
|
||||
|
||||
while (((entry = readdir(dir)) != NULL)) {
|
||||
/* 非二进制文件跳过 */
|
||||
if (entry->d_type != DT_REG) {
|
||||
@ -145,13 +169,6 @@ static int HnpGenerateSoftLink(const char *installPath, const char *hnpBasePath,
|
||||
return HNP_ERRNO_BASE_SPRINTF_FAILED;
|
||||
}
|
||||
|
||||
if (access(binPath, F_OK) != 0) {
|
||||
ret = mkdir(binPath, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
|
||||
if ((ret != 0) && (errno != EEXIST)) {
|
||||
HNP_LOGE("mkdir [%s] unsuccess, ret=%d, errno:%d", binPath, ret, errno);
|
||||
}
|
||||
}
|
||||
|
||||
if (hnpHead->linkNum == 0) {
|
||||
ret = HnpGenerateSoftLinkAll(installPath, binPath);
|
||||
} else {
|
||||
@ -175,24 +192,111 @@ static int HnpInstall(const char *hnpFile, const char *installPath, const char *
|
||||
return HnpGenerateSoftLink(installPath, hnpBasePath, hnpHead);
|
||||
}
|
||||
|
||||
static int HnpUnInstall(const char *uninstallPath, const char *programName)
|
||||
static int HnpProgramRunCheckWithFile(const char *file)
|
||||
{
|
||||
int ret;
|
||||
NativeHnpHead *hnpHead;
|
||||
NativeBinLink *currentLink;
|
||||
char *fileName;
|
||||
|
||||
HNP_LOGI("\r\n hnp uninstall start now! path=%s program name[%s]", uninstallPath, programName);
|
||||
ret = HnpReadFromZipHead(file, &hnpHead);
|
||||
if (ret != 0) {
|
||||
return ret; /* 内部已打印日志 */
|
||||
}
|
||||
|
||||
currentLink = hnpHead->links;
|
||||
for (unsigned int i = 0; i < hnpHead->linkNum; i++) {
|
||||
/* 如果target为空则使用源二进制名称 */
|
||||
if (strcmp(currentLink->target, "") == 0) {
|
||||
fileName = strrchr(currentLink->source, '/');
|
||||
if (fileName == NULL) {
|
||||
fileName = currentLink->source;
|
||||
} else {
|
||||
fileName++;
|
||||
}
|
||||
ret = HnpProgramRunCheck(fileName);
|
||||
} else {
|
||||
ret = HnpProgramRunCheck(currentLink->target);
|
||||
}
|
||||
if (ret != 0) {
|
||||
free(hnpHead);
|
||||
return ret;
|
||||
}
|
||||
currentLink++;
|
||||
}
|
||||
|
||||
free(hnpHead);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int HnpProgramRunCheckWithPath(const char *path)
|
||||
{
|
||||
DIR *dir;
|
||||
struct dirent *entry;
|
||||
int ret;
|
||||
|
||||
if ((dir = opendir(path)) == NULL) {
|
||||
HNP_LOGE("uninstall run check opendir:%s unsuccess", path);
|
||||
return 0; /* 无bin文件继续删除目录 */
|
||||
}
|
||||
while (((entry = readdir(dir)) != NULL)) {
|
||||
/* 非二进制文件跳过 */
|
||||
if (entry->d_type != DT_REG) {
|
||||
continue;
|
||||
}
|
||||
/* 查询软件是否正在运行 */
|
||||
ret = HnpProgramRunCheck(entry->d_name);
|
||||
if (ret != 0) {
|
||||
closedir(dir);
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
closedir(dir);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int HnpUnInstall(const char *uninstallPath, const char *programName, const char *hnpVersion, bool runCheck)
|
||||
{
|
||||
int ret;
|
||||
char uninstallFile[MAX_FILE_PATH_LEN];
|
||||
char binPath[MAX_FILE_PATH_LEN];
|
||||
|
||||
HNP_LOGI("hnp uninstall start now! path=%s program name[%s], run check=%d", uninstallPath, programName, runCheck);
|
||||
|
||||
if (runCheck == false) {
|
||||
ret = HnpDeleteFolder(uninstallPath);
|
||||
HNP_LOGI("hnp uninstall end! ret=%d", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = sprintf_s(uninstallFile, MAX_FILE_PATH_LEN, "%s%s_%s/"HNP_UNSTALL_INFO_FILE, uninstallPath, programName,
|
||||
hnpVersion);
|
||||
if (ret < 0) {
|
||||
HNP_LOGE("sprintf uninstall info file unsuccess.");
|
||||
return HNP_ERRNO_BASE_SPRINTF_FAILED;
|
||||
}
|
||||
if (access(uninstallFile, F_OK) == 0) {
|
||||
ret = HnpProgramRunCheckWithFile(uninstallFile);
|
||||
} else {
|
||||
ret = sprintf_s(binPath, MAX_FILE_PATH_LEN, "%s%s_%s/bin", uninstallPath, programName, hnpVersion);
|
||||
if (ret < 0) {
|
||||
HNP_LOGE("sprintf uninstall info file unsuccess.");
|
||||
return HNP_ERRNO_BASE_SPRINTF_FAILED;
|
||||
}
|
||||
ret = HnpProgramRunCheckWithPath(binPath);
|
||||
}
|
||||
|
||||
/* 查询软件是否正在运行 */
|
||||
ret = HnpProgramRunCheck(programName);
|
||||
if (ret != 0) {
|
||||
return ret;
|
||||
}
|
||||
|
||||
ret = HnpDeleteFolder(uninstallPath);
|
||||
HNP_LOGI("\r\n hnp uninstall end! ret=%d", ret);
|
||||
HNP_LOGI("hnp uninstall end! ret=%d", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int HnpInstallPathGet(const char *fileName, const char *basePath, Bool isForce, char* hnpVersion,
|
||||
static int HnpInstallPathGet(const char *fileName, const char *basePath, bool isForce, char* hnpVersion,
|
||||
NativeHnpPath *hnpDstPath)
|
||||
{
|
||||
int ret;
|
||||
@ -220,11 +324,11 @@ static int HnpInstallPathGet(const char *fileName, const char *basePath, Bool is
|
||||
|
||||
/* 判断安装目录是否存在,存在判断是否是强制安装,如果是则走卸载流程,否则返回错误 */
|
||||
if (access(hnpDstPath->hnpProgramPath, F_OK) == 0) {
|
||||
if (isForce == FALSE) {
|
||||
if (isForce == false) {
|
||||
HNP_LOGE("hnp install path[%s] exist, but force is false", hnpDstPath->hnpProgramPath);
|
||||
return HNP_ERRNO_INSTALLER_PATH_IS_EXIST;
|
||||
} else {
|
||||
ret = HnpUnInstall(hnpDstPath->hnpProgramPath, hnpDstPath->hnpProgramName);
|
||||
ret = HnpUnInstall(hnpDstPath->hnpProgramPath, hnpDstPath->hnpProgramName, hnpVersion, true);
|
||||
if (ret != 0) {
|
||||
return ret;
|
||||
}
|
||||
@ -246,7 +350,7 @@ static int HnpInstallPathGet(const char *fileName, const char *basePath, Bool is
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int HnpDirReadAndInstall(const char *srcPath, const char *basePath, Bool isForce)
|
||||
static int HnpDirReadAndInstall(const char *srcPath, const char *basePath, bool isForce)
|
||||
{
|
||||
struct dirent *entry;
|
||||
char hnpFile[MAX_FILE_PATH_LEN];
|
||||
@ -293,12 +397,12 @@ static int HnpDirReadAndInstall(const char *srcPath, const char *basePath, Bool
|
||||
closedir(dir);
|
||||
free(hnpHead);
|
||||
/* 安装失败卸载当前包 */
|
||||
HnpUnInstall(hnpDstPath.hnpProgramPath, hnpDstPath.hnpProgramName);
|
||||
HnpUnInstall(hnpDstPath.hnpProgramPath, hnpDstPath.hnpProgramName, hnpHead->hnpVersion, false);
|
||||
return ret;
|
||||
}
|
||||
free(hnpHead);
|
||||
hnpHead = NULL;
|
||||
HNP_LOGI("install hnp path[%s], dst path[%s]", srcPath, hnpDstPath.hnpProgramName, hnpDstPath.hnpVersionPath);
|
||||
HNP_LOGI("install hnp path[%s], dst path[%s]", srcPath, hnpDstPath.hnpVersionPath);
|
||||
count++;
|
||||
}
|
||||
closedir(dir);
|
||||
@ -314,10 +418,10 @@ int HnpCmdInstall(int argc, char *argv[])
|
||||
char dstPath[MAX_FILE_PATH_LEN];
|
||||
char basePath[MAX_FILE_PATH_LEN];
|
||||
unsigned long uid;
|
||||
Bool isForce = FALSE;
|
||||
bool isForce = false;
|
||||
int ret;
|
||||
|
||||
if (argc < HNP_INDEX_4) {
|
||||
if (argc < HNP_INDEX_5) {
|
||||
HNP_LOGE("hnp install args num[%u] unsuccess!", argc);
|
||||
return HNP_ERRNO_INSTALLER_ARGV_NUM_INVALID;
|
||||
}
|
||||
@ -341,18 +445,25 @@ int HnpCmdInstall(int argc, char *argv[])
|
||||
}
|
||||
|
||||
/* 获取参数是否需要强制覆盖 */
|
||||
if ((argc == HNP_INDEX_5) && (strcmp(argv[HNP_INDEX_4], "-f") == 0)) {
|
||||
isForce = TRUE;
|
||||
if ((argc == HNP_INDEX_6) && (strcmp(argv[HNP_INDEX_5], "-f") == 0)) {
|
||||
isForce = true;
|
||||
}
|
||||
|
||||
if (sprintf_s(basePath, MAX_FILE_PATH_LEN, "%shnp/", dstPath) < 0) {
|
||||
HNP_LOGE("hnp install base path sprintf unsuccess.");
|
||||
return HNP_ERRNO_INSTALLER_GET_HNP_PATH_FAILED;
|
||||
if (strcmp(argv[HNP_INDEX_4], "null") == 0) {
|
||||
if (sprintf_s(basePath, MAX_FILE_PATH_LEN, "%shnp_public/", dstPath) < 0) {
|
||||
HNP_LOGE("hnp install public base path sprintf unsuccess.");
|
||||
return HNP_ERRNO_INSTALLER_GET_HNP_PATH_FAILED;
|
||||
}
|
||||
} else {
|
||||
if (sprintf_s(basePath, MAX_FILE_PATH_LEN, "%shnp/%s/", dstPath, argv[HNP_INDEX_4]) < 0) {
|
||||
HNP_LOGE("hnp install private base path sprintf unsuccess.");
|
||||
return HNP_ERRNO_INSTALLER_GET_HNP_PATH_FAILED;
|
||||
}
|
||||
}
|
||||
|
||||
HNP_LOGI("\r\n hnp install start now! src path=%s, dst path=%s, is force=%d", argv[HNP_INDEX_3], dstPath, isForce);
|
||||
HNP_LOGI("hnp install start now! src path=%s, dst path=%s, is force=%d", argv[HNP_INDEX_3], basePath, isForce);
|
||||
ret = HnpDirReadAndInstall(srcPath, basePath, isForce);
|
||||
HNP_LOGI("\r\n hnp install end, ret=%d", ret);
|
||||
HNP_LOGI("hnp install end, ret=%d", ret);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@ -361,9 +472,10 @@ int HnpCmdUnInstall(int argc, char *argv[])
|
||||
unsigned long uid;
|
||||
char uninstallPath[MAX_FILE_PATH_LEN];
|
||||
char basePath[MAX_FILE_PATH_LEN];
|
||||
char pathTmp[MAX_FILE_PATH_LEN];
|
||||
int ret;
|
||||
|
||||
if (argc < HNP_INDEX_5) {
|
||||
if (argc < HNP_INDEX_6) {
|
||||
HNP_LOGE("hnp uninstall args num[%u] unsuccess!", argc);
|
||||
return HNP_ERRNO_UNINSTALLER_ARGV_NUM_INVALID;
|
||||
}
|
||||
@ -375,9 +487,19 @@ int HnpCmdUnInstall(int argc, char *argv[])
|
||||
}
|
||||
|
||||
/* 拼接卸载路径 */
|
||||
if (sprintf_s(uninstallPath, MAX_FILE_PATH_LEN, HNP_DEFAULT_INSTALL_ROOT_PATH"%lu/hnp/%s.org/%s_%s/", uid,
|
||||
argv[HNP_INDEX_3], argv[HNP_INDEX_3], argv[HNP_INDEX_4]) < 0) {
|
||||
HNP_LOGE("hnp uninstall path sprintf unsuccess, uid:%lu, program name[%s], version[%s]", uid,
|
||||
if (strcmp(argv[HNP_INDEX_5], "null") == 0) {
|
||||
ret = strcpy_s(pathTmp, MAX_FILE_PATH_LEN, "hnp_public");
|
||||
} else {
|
||||
ret = strcpy_s(pathTmp, MAX_FILE_PATH_LEN, argv[HNP_INDEX_5]);
|
||||
}
|
||||
if (ret != EOK) {
|
||||
HNP_LOGE("hnp uninstall path strcpy unsuccess.");
|
||||
return HNP_ERRNO_BASE_COPY_FAILED;
|
||||
}
|
||||
|
||||
if (sprintf_s(uninstallPath, MAX_FILE_PATH_LEN, HNP_DEFAULT_INSTALL_ROOT_PATH"%lu/%s/%s.org/%s_%s/",
|
||||
uid, pathTmp, argv[HNP_INDEX_3], argv[HNP_INDEX_3], argv[HNP_INDEX_4]) < 0) {
|
||||
HNP_LOGE("hnp uninstall path sprintf unsuccess, uid:%lu, program name[%s], version[%s]", uid,
|
||||
argv[HNP_INDEX_3], argv[HNP_INDEX_4]);
|
||||
return HNP_ERRNO_BASE_SPRINTF_FAILED;
|
||||
}
|
||||
@ -389,13 +511,13 @@ int HnpCmdUnInstall(int argc, char *argv[])
|
||||
}
|
||||
|
||||
/* 拼接基本路径 */
|
||||
if (sprintf_s(basePath, MAX_FILE_PATH_LEN, HNP_DEFAULT_INSTALL_ROOT_PATH"%lu/hnp/%s.org/", uid,
|
||||
if (sprintf_s(basePath, MAX_FILE_PATH_LEN, HNP_DEFAULT_INSTALL_ROOT_PATH"%lu/%s/%s.org/", uid, pathTmp,
|
||||
argv[HNP_INDEX_3]) < 0) {
|
||||
HNP_LOGE("hnp uninstall base path sprintf unsuccess, uid:%lu, program name[%s]", uid, argv[HNP_INDEX_3]);
|
||||
return HNP_ERRNO_BASE_SPRINTF_FAILED;
|
||||
}
|
||||
|
||||
return HnpUnInstall(basePath, argv[HNP_INDEX_3]);
|
||||
return HnpUnInstall(basePath, argv[HNP_INDEX_3], argv[HNP_INDEX_4], true);
|
||||
}
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
@ -35,6 +35,8 @@
|
||||
using namespace testing;
|
||||
using namespace testing::ext;
|
||||
|
||||
#define HNP_BASE_PATH "/data/app/el1/bundle/10000"
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
@ -77,9 +79,16 @@ void HnpPackWithoutBin(void)
|
||||
{
|
||||
EXPECT_EQ(mkdir("./hnp_sample", S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH), 0);
|
||||
EXPECT_EQ(mkdir("./hnp_out", S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH), 0);
|
||||
char* argv[] = {(char*)"hnpcli", (char*)"pack", (char*)"./hnp_sample", (char*)"./hnp_out", (char*)"-name",
|
||||
(char*)"sample", (char*)"-v", (char*)"1.1"};
|
||||
int argc = 8;
|
||||
char arg1[] = "hnpcli";
|
||||
char arg2[] = "pack";
|
||||
char arg3[] = "./hnp_sample";
|
||||
char arg4[] = "./hnp_out";
|
||||
char arg5[] = "-name";
|
||||
char arg6[] = "sample";
|
||||
char arg7[] = "-v";
|
||||
char arg8[] = "1.1";
|
||||
char* argv[] = {arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8};
|
||||
int argc = sizeof(argv) / sizeof(argv[0]);
|
||||
EXPECT_EQ(HnpCmdPack(argc, argv), 0);
|
||||
}
|
||||
|
||||
@ -98,9 +107,16 @@ void HnpPackWithBin(void)
|
||||
EXPECT_NE(fp, NULL);
|
||||
fclose(fp);
|
||||
EXPECT_EQ(mkdir("hnp_out", S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH), 0);
|
||||
char* argv[] = {(char*)"hnpcli", (char*)"pack", (char*)"./hnp_sample", (char*)"./hnp_out", (char*)"-name",
|
||||
(char*)"sample", (char*)"-v", (char*)"1.1"};
|
||||
int argc = 8;
|
||||
char arg1[] = "hnpcli";
|
||||
char arg2[] = "pack";
|
||||
char arg3[] = "./hnp_sample";
|
||||
char arg4[] = "./hnp_out";
|
||||
char arg5[] = "-name";
|
||||
char arg6[] = "sample";
|
||||
char arg7[] = "-v";
|
||||
char arg8[] = "1.1";
|
||||
char* argv[] = {arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8};
|
||||
int argc = sizeof(argv) / sizeof(argv[0]);
|
||||
EXPECT_EQ(HnpCmdPack(argc, argv), 0);
|
||||
}
|
||||
|
||||
@ -137,7 +153,7 @@ void HnpPackWithCfg(void)
|
||||
char* argv[] = {arg1, arg2, arg3, arg4, arg5, arg6};
|
||||
int argc = sizeof(argv) / sizeof(argv[0]);
|
||||
char cfg[] = "{\"type\":\"hnp-config\",\"name\":\"sample\",\"version\":\"1.1\",\"install\":"
|
||||
"{\"links\":[{\"source\":\"bin/out\",\"target\":\"out\"},{\"source\":\"bin/out2\","
|
||||
"{\"links\":[{\"source\":\"bin/out\",\"target\":\"outt\"},{\"source\":\"bin/out2\","
|
||||
"\"target\":\"out2\"}]}}";
|
||||
fp = fopen("./hnp.cfg", "w");
|
||||
EXPECT_EQ(fwrite(cfg, sizeof(char), strlen(cfg) + 1, fp), strlen(cfg) + 1);
|
||||
@ -159,14 +175,58 @@ void HnpPackWithCfgDelete(void)
|
||||
|
||||
void HnpInstall(void)
|
||||
{
|
||||
char* argv[] = {(char*)"hnp", (char*)"install", (char*)"10000", (char*)"./hnp_out", (char*)"-f"};
|
||||
EXPECT_EQ(HnpCmdInstall(5, argv), 0);
|
||||
char arg1[] = "hnp";
|
||||
char arg2[] = "install";
|
||||
char arg3[] = "10000";
|
||||
char arg4[] = "./hnp_out";
|
||||
char arg5[] = "null";
|
||||
char arg6[] = "-f";
|
||||
char* argv[] = {arg1, arg2, arg3, arg4, arg5, arg6};
|
||||
int argc = sizeof(argv) / sizeof(argv[0]);
|
||||
|
||||
EXPECT_EQ(HnpCmdInstall(argc, argv), 0);
|
||||
}
|
||||
|
||||
void HnpUnInstall(void)
|
||||
{
|
||||
char* argv[] = {(char*)"hnp", (char*)"install", (char*)"10000", (char*)"hnp_sample", (char*)"1.1"};
|
||||
EXPECT_EQ(HnpCmdUnInstall(5, argv), 0);
|
||||
char arg1[] = "hnp";
|
||||
char arg2[] = "uninstall";
|
||||
char arg3[] = "10000";
|
||||
char arg4[] = "hnp_sample";
|
||||
char arg5[] = "1.1";
|
||||
char arg6[] = "null";
|
||||
char* argv[] = {arg1, arg2, arg3, arg4, arg5, arg6};
|
||||
int argc = sizeof(argv) / sizeof(argv[0]);
|
||||
|
||||
EXPECT_EQ(HnpCmdUnInstall(argc, argv), 0);
|
||||
}
|
||||
|
||||
void HnpInstallPrivate(void)
|
||||
{
|
||||
char arg1[] = "hnp";
|
||||
char arg2[] = "uninstall";
|
||||
char arg3[] = "10000";
|
||||
char arg4[] = "./hnp_out";
|
||||
char arg5[] = "huawei";
|
||||
char arg6[] = "-f";
|
||||
char* argv[] = {arg1, arg2, arg3, arg4, arg5, arg6};
|
||||
int argc = sizeof(argv) / sizeof(argv[0]);
|
||||
|
||||
EXPECT_EQ(HnpCmdInstall(argc, argv), 0);
|
||||
}
|
||||
|
||||
void HnpUnInstallPrivate(void)
|
||||
{
|
||||
char arg1[] = "hnp";
|
||||
char arg2[] = "uninstall";
|
||||
char arg3[] = "10000";
|
||||
char arg4[] = "hnp_sample";
|
||||
char arg5[] = "1.1";
|
||||
char arg6[] = "huawei";
|
||||
char* argv[] = {arg1, arg2, arg3, arg4, arg5, arg6};
|
||||
int argc = sizeof(argv) / sizeof(argv[0]);
|
||||
|
||||
EXPECT_EQ(HnpCmdUnInstall(argc, argv), 0);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -186,9 +246,9 @@ HWTEST(HnpInstallerTest, Hnp_Install_001, TestSize.Level0)
|
||||
rmdir("hnp_sample/bin");
|
||||
rmdir("hnp_sample");
|
||||
rmdir("hnp_out");
|
||||
HnpDeleteFolder("/data/app/el1/bundle/10000");
|
||||
HnpDeleteFolder(HNP_BASE_PATH);
|
||||
|
||||
EXPECT_EQ(mkdir("/data/app/el1/bundle/10000", S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH), 0);
|
||||
EXPECT_EQ(mkdir(HNP_BASE_PATH, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH), 0);
|
||||
HnpPackWithBin();
|
||||
|
||||
char arg1[] = "hnp";
|
||||
@ -203,7 +263,8 @@ HWTEST(HnpInstallerTest, Hnp_Install_001, TestSize.Level0)
|
||||
{ // param uid is invalid
|
||||
char arg3[] = "asd1231";
|
||||
char arg4[] = "./hnp_out";
|
||||
char* argv[] = {arg1, arg2, arg3, arg4};
|
||||
char arg5[] = "null";
|
||||
char* argv[] = {arg1, arg2, arg3, arg4, arg5};
|
||||
int argc = sizeof(argv) / sizeof(argv[0]);
|
||||
|
||||
EXPECT_EQ(HnpCmdInstall(argc, argv), HNP_ERRNO_INSTALLER_ARGV_UID_INVALID);
|
||||
@ -211,7 +272,8 @@ HWTEST(HnpInstallerTest, Hnp_Install_001, TestSize.Level0)
|
||||
{ // src dir path is invalid
|
||||
char arg3[] = "10000";
|
||||
char arg4[] = "./hnp_in";
|
||||
char* argv[] = {arg1, arg2, arg3, arg4};
|
||||
char arg5[] = "null";
|
||||
char* argv[] = {arg1, arg2, arg3, arg4, arg5};
|
||||
int argc = sizeof(argv) / sizeof(argv[0]);
|
||||
|
||||
EXPECT_EQ(HnpCmdInstall(argc, argv), HNP_ERRNO_INSTALLER_GET_REALPATH_FAILED);
|
||||
@ -219,7 +281,8 @@ HWTEST(HnpInstallerTest, Hnp_Install_001, TestSize.Level0)
|
||||
{ // dst dir path is invalid
|
||||
char arg3[] = "10001";
|
||||
char arg4[] = "./hnp_out";
|
||||
char* argv[] = {arg1, arg2, arg3, arg4};
|
||||
char arg5[] = "null";
|
||||
char* argv[] = {arg1, arg2, arg3, arg4, arg5};
|
||||
int argc = sizeof(argv) / sizeof(argv[0]);
|
||||
|
||||
EXPECT_EQ(HnpCmdInstall(argc, argv), HNP_ERRNO_INSTALLER_GET_REALPATH_FAILED);
|
||||
@ -227,14 +290,15 @@ HWTEST(HnpInstallerTest, Hnp_Install_001, TestSize.Level0)
|
||||
{ // ok
|
||||
char arg3[] = "10000";
|
||||
char arg4[] = "./hnp_out";
|
||||
char* argv[] = {arg1, arg2, arg3, arg4};
|
||||
char arg5[] = "null";
|
||||
char* argv[] = {arg1, arg2, arg3, arg4, arg5};
|
||||
int argc = sizeof(argv) / sizeof(argv[0]);
|
||||
|
||||
EXPECT_EQ(HnpCmdInstall(argc, argv), 0);
|
||||
EXPECT_EQ(access("/data/app/el1/bundle/10000/hnp/bin/out", F_OK), 0);
|
||||
EXPECT_EQ(access(HNP_BASE_PATH"/hnp_public/bin/out", F_OK), 0);
|
||||
}
|
||||
|
||||
HnpDeleteFolder("/data/app/el1/bundle/10000");
|
||||
HnpDeleteFolder(HNP_BASE_PATH);
|
||||
HnpPackWithBinDelete();
|
||||
|
||||
GTEST_LOG_(INFO) << "Hnp_Installer_001 end";
|
||||
@ -251,7 +315,7 @@ HWTEST(HnpInstallerTest, Hnp_Install_002, TestSize.Level0)
|
||||
{
|
||||
GTEST_LOG_(INFO) << "Hnp_Installer_002 start";
|
||||
|
||||
EXPECT_EQ(mkdir("/data/app/el1/bundle/10000", S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH), 0);
|
||||
EXPECT_EQ(mkdir(HNP_BASE_PATH, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH), 0);
|
||||
HnpPackWithBin();
|
||||
|
||||
char arg1[] = "hnp";
|
||||
@ -260,7 +324,8 @@ HWTEST(HnpInstallerTest, Hnp_Install_002, TestSize.Level0)
|
||||
{ // dir exist but force is false
|
||||
char arg3[] = "10000";
|
||||
char arg4[] = "./hnp_out";
|
||||
char* argv[] = {arg1, arg2, arg3, arg4};
|
||||
char arg5[] = "null";
|
||||
char* argv[] = {arg1, arg2, arg3, arg4, arg5};
|
||||
int argc = sizeof(argv) / sizeof(argv[0]);
|
||||
|
||||
EXPECT_EQ(HnpCmdInstall(argc, argv), 0);
|
||||
@ -269,14 +334,15 @@ HWTEST(HnpInstallerTest, Hnp_Install_002, TestSize.Level0)
|
||||
{ //ok
|
||||
char arg3[] = "10000";
|
||||
char arg4[] = "./hnp_out";
|
||||
char arg5[] = "-f";
|
||||
char* argv[] = {arg1, arg2, arg3, arg4, arg5};
|
||||
char arg5[] = "null";
|
||||
char arg6[] = "-f";
|
||||
char* argv[] = {arg1, arg2, arg3, arg4, arg5, arg6};
|
||||
int argc = sizeof(argv) / sizeof(argv[0]);
|
||||
EXPECT_EQ(access("/data/app/el1/bundle/10000/hnp/bin/out", F_OK), 0);
|
||||
EXPECT_EQ(access(HNP_BASE_PATH"/hnp_public/bin/out", F_OK), 0);
|
||||
EXPECT_EQ(HnpCmdInstall(argc, argv), 0);
|
||||
}
|
||||
|
||||
HnpDeleteFolder("/data/app/el1/bundle/10000");
|
||||
HnpDeleteFolder(HNP_BASE_PATH);
|
||||
HnpPackWithBinDelete();
|
||||
|
||||
GTEST_LOG_(INFO) << "Hnp_Installer_002 end";
|
||||
@ -293,33 +359,37 @@ HWTEST(HnpInstallerTest, Hnp_Install_003, TestSize.Level0)
|
||||
{
|
||||
GTEST_LOG_(INFO) << "Hnp_Installer_003 start";
|
||||
|
||||
EXPECT_EQ(mkdir("/data/app/el1/bundle/10000", S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH), 0);
|
||||
|
||||
char arg1[] = "hnp";
|
||||
char arg2[] = "install";
|
||||
|
||||
{ // scr path bin not exist
|
||||
EXPECT_EQ(mkdir(HNP_BASE_PATH, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH), 0);
|
||||
HnpPackWithoutBin();
|
||||
char arg3[] = "10000";
|
||||
char arg4[] = "./hnp_out";
|
||||
char* argv[] = {arg1, arg2, arg3, arg4};
|
||||
int argc = sizeof(argv) / sizeof(argv[0]);
|
||||
|
||||
EXPECT_EQ(HnpCmdInstall(argc, argv), HNP_ERRNO_BASE_DIR_OPEN_FAILED);
|
||||
HnpPackWithoutBinDelete();
|
||||
}
|
||||
{ //ok
|
||||
HnpPackWithBin();
|
||||
char arg3[] = "10000";
|
||||
char arg4[] = "./hnp_out";
|
||||
char* argv[] = {arg1, arg2, arg3, arg4};
|
||||
char arg5[] = "null";
|
||||
char* argv[] = {arg1, arg2, arg3, arg4, arg5};
|
||||
int argc = sizeof(argv) / sizeof(argv[0]);
|
||||
|
||||
EXPECT_EQ(HnpCmdInstall(argc, argv), 0);
|
||||
EXPECT_EQ(access("/data/app/el1/bundle/10000/hnp/bin/out", F_OK), 0);
|
||||
EXPECT_EQ(access(HNP_BASE_PATH"/hnp_public/bin/out", F_OK), -1);
|
||||
HnpPackWithoutBinDelete();
|
||||
HnpDeleteFolder(HNP_BASE_PATH);
|
||||
}
|
||||
{ //ok
|
||||
EXPECT_EQ(mkdir(HNP_BASE_PATH, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH), 0);
|
||||
HnpPackWithBin();
|
||||
char arg3[] = "10000";
|
||||
char arg4[] = "./hnp_out";
|
||||
char arg5[] = "null";
|
||||
char* argv[] = {arg1, arg2, arg3, arg4, arg5};
|
||||
int argc = sizeof(argv) / sizeof(argv[0]);
|
||||
|
||||
EXPECT_EQ(HnpCmdInstall(argc, argv), 0);
|
||||
EXPECT_EQ(access(HNP_BASE_PATH"/hnp_public/bin/out", F_OK), 0);
|
||||
HnpPackWithBinDelete();
|
||||
}
|
||||
HnpDeleteFolder("/data/app/el1/bundle/10000");
|
||||
HnpDeleteFolder(HNP_BASE_PATH);
|
||||
|
||||
GTEST_LOG_(INFO) << "Hnp_Installer_003 end";
|
||||
}
|
||||
@ -335,7 +405,7 @@ HWTEST(HnpInstallerTest, Hnp_Install_004, TestSize.Level0)
|
||||
{
|
||||
GTEST_LOG_(INFO) << "Hnp_Installer_004 start";
|
||||
|
||||
EXPECT_EQ(mkdir("/data/app/el1/bundle/10000", S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH), 0);
|
||||
EXPECT_EQ(mkdir(HNP_BASE_PATH, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH), 0);
|
||||
HnpPackWithBin();
|
||||
|
||||
char arg1[] = "hnp";
|
||||
@ -349,8 +419,9 @@ HWTEST(HnpInstallerTest, Hnp_Install_004, TestSize.Level0)
|
||||
fclose(fp);
|
||||
char arg3[] = "10000";
|
||||
char arg4[] = "./hnp_out";
|
||||
char arg5[] = "-f";
|
||||
char* argv[] = {arg1, arg2, arg3, arg4, arg5};
|
||||
char arg5[] = "null";
|
||||
char arg6[] = "-f";
|
||||
char* argv[] = {arg1, arg2, arg3, arg4, arg5, arg6};
|
||||
int argc = sizeof(argv) / sizeof(argv[0]);
|
||||
EXPECT_EQ(HnpCmdInstall(argc, argv), HNP_ERRNO_BASE_FILE_READ_FAILED);
|
||||
remove("./hnp_out/example.zip");
|
||||
@ -363,8 +434,9 @@ HWTEST(HnpInstallerTest, Hnp_Install_004, TestSize.Level0)
|
||||
fclose(fp);
|
||||
char arg3[] = "10000";
|
||||
char arg4[] = "./hnp_out";
|
||||
char arg5[] = "-f";
|
||||
char* argv[] = {arg1, arg2, arg3, arg4, arg5};
|
||||
char arg5[] = "null";
|
||||
char arg6[] = "-f";
|
||||
char* argv[] = {arg1, arg2, arg3, arg4, arg5, arg6};
|
||||
int argc = sizeof(argv) / sizeof(argv[0]);
|
||||
EXPECT_EQ(HnpCmdInstall(argc, argv), HNP_ERRNO_BASE_MAGIC_CHECK_FAILED);
|
||||
remove("./hnp_out/example.zip");
|
||||
@ -372,14 +444,15 @@ HWTEST(HnpInstallerTest, Hnp_Install_004, TestSize.Level0)
|
||||
{ //ok
|
||||
char arg3[] = "10000";
|
||||
char arg4[] = "./hnp_out";
|
||||
char arg5[] = "-f";
|
||||
char* argv[] = {arg1, arg2, arg3, arg4, arg5};
|
||||
char arg5[] = "null";
|
||||
char arg6[] = "-f";
|
||||
char* argv[] = {arg1, arg2, arg3, arg4, arg5, arg6};
|
||||
int argc = sizeof(argv) / sizeof(argv[0]);
|
||||
EXPECT_EQ(HnpCmdInstall(argc, argv), 0);
|
||||
EXPECT_EQ(access("/data/app/el1/bundle/10000/hnp/bin/out", F_OK), 0);
|
||||
EXPECT_EQ(access(HNP_BASE_PATH"/hnp_public/bin/out", F_OK), 0);
|
||||
}
|
||||
|
||||
HnpDeleteFolder("/data/app/el1/bundle/10000");
|
||||
HnpDeleteFolder(HNP_BASE_PATH);
|
||||
HnpPackWithBinDelete();
|
||||
|
||||
GTEST_LOG_(INFO) << "Hnp_Installer_004 end";
|
||||
@ -396,7 +469,7 @@ HWTEST(HnpInstallerTest, Hnp_Install_005, TestSize.Level0)
|
||||
{
|
||||
GTEST_LOG_(INFO) << "Hnp_Installer_005 start";
|
||||
|
||||
EXPECT_EQ(mkdir("/data/app/el1/bundle/10000", S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH), 0);
|
||||
EXPECT_EQ(mkdir(HNP_BASE_PATH, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH), 0);
|
||||
HnpPackWithCfg();
|
||||
|
||||
char arg1[] = "hnp";
|
||||
@ -405,18 +478,54 @@ HWTEST(HnpInstallerTest, Hnp_Install_005, TestSize.Level0)
|
||||
{ //ok
|
||||
char arg3[] = "10000";
|
||||
char arg4[] = "./hnp_out";
|
||||
char arg5[] = "-f";
|
||||
char* argv[] = {arg1, arg2, arg3, arg4, arg5};
|
||||
char arg5[] = "null";
|
||||
char arg6[] = "-f";
|
||||
char* argv[] = {arg1, arg2, arg3, arg4, arg5, arg6};
|
||||
int argc = sizeof(argv) / sizeof(argv[0]);
|
||||
EXPECT_EQ(HnpCmdInstall(argc, argv), 0);
|
||||
EXPECT_EQ(access("/data/app/el1/bundle/10000/hnp/bin/out", F_OK), 0);
|
||||
EXPECT_EQ(access("/data/app/el1/bundle/10000/hnp/bin/out2", F_OK), 0);
|
||||
EXPECT_EQ(access(HNP_BASE_PATH"/hnp_public/bin/outt", F_OK), 0);
|
||||
EXPECT_EQ(access(HNP_BASE_PATH"/hnp_public/bin/out2", F_OK), 0);
|
||||
}
|
||||
|
||||
HnpDeleteFolder("/data/app/el1/bundle/10000");
|
||||
HnpDeleteFolder(HNP_BASE_PATH);
|
||||
HnpPackWithCfgDelete();
|
||||
|
||||
GTEST_LOG_(INFO) << "Hnp_Installer_004 end";
|
||||
GTEST_LOG_(INFO) << "Hnp_Installer_005 end";
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: Hnp_Install_006
|
||||
* @tc.desc: Verify private HnpCmdInstall succeed.
|
||||
* @tc.type: FUNC
|
||||
* @tc.require:issueI9BU5F
|
||||
* @tc.author:
|
||||
*/
|
||||
HWTEST(HnpInstallerTest, Hnp_Install_006, TestSize.Level0)
|
||||
{
|
||||
GTEST_LOG_(INFO) << "Hnp_Install_006 start";
|
||||
|
||||
EXPECT_EQ(mkdir(HNP_BASE_PATH, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH), 0);
|
||||
HnpPackWithCfg();
|
||||
|
||||
char arg1[] = "hnp";
|
||||
char arg2[] = "install";
|
||||
|
||||
{ //ok
|
||||
char arg3[] = "10000";
|
||||
char arg4[] = "./hnp_out";
|
||||
char arg5[] = "huawei";
|
||||
char arg6[] = "-f";
|
||||
char* argv[] = {arg1, arg2, arg3, arg4, arg5, arg6};
|
||||
int argc = sizeof(argv) / sizeof(argv[0]);
|
||||
EXPECT_EQ(HnpCmdInstall(argc, argv), 0);
|
||||
EXPECT_EQ(access(HNP_BASE_PATH"/hnp/huawei/bin/outt", F_OK), 0);
|
||||
EXPECT_EQ(access(HNP_BASE_PATH"/hnp/huawei/bin/out2", F_OK), 0);
|
||||
}
|
||||
|
||||
HnpDeleteFolder(HNP_BASE_PATH);
|
||||
HnpPackWithCfgDelete();
|
||||
|
||||
GTEST_LOG_(INFO) << "Hnp_Install_006 end";
|
||||
}
|
||||
|
||||
/**
|
||||
@ -430,7 +539,7 @@ HWTEST(HnpInstallerTest, Hnp_UnInstall_001, TestSize.Level0)
|
||||
{
|
||||
GTEST_LOG_(INFO) << "Hnp_UnInstall_001 start";
|
||||
|
||||
EXPECT_EQ(mkdir("/data/app/el1/bundle/10000", S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH), 0);
|
||||
EXPECT_EQ(mkdir(HNP_BASE_PATH, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH), 0);
|
||||
HnpPackWithBin();
|
||||
HnpInstall();
|
||||
|
||||
@ -447,7 +556,8 @@ HWTEST(HnpInstallerTest, Hnp_UnInstall_001, TestSize.Level0)
|
||||
char arg3[] = "asd1231";
|
||||
char arg4[] = "sample";
|
||||
char arg5[] = "1.1";
|
||||
char* argv[] = {arg1, arg2, arg3, arg4, arg5};
|
||||
char arg6[] = "null";
|
||||
char* argv[] = {arg1, arg2, arg3, arg4, arg5, arg6};
|
||||
int argc = sizeof(argv) / sizeof(argv[0]);
|
||||
|
||||
EXPECT_EQ(HnpCmdUnInstall(argc, argv), HNP_ERRNO_INSTALLER_ARGV_UID_INVALID);
|
||||
@ -456,7 +566,8 @@ HWTEST(HnpInstallerTest, Hnp_UnInstall_001, TestSize.Level0)
|
||||
char arg3[] = "10000";
|
||||
char arg4[] = "sample2";
|
||||
char arg5[] = "1.1";
|
||||
char* argv[] = {arg1, arg2, arg3, arg4, arg5};
|
||||
char arg6[] = "null";
|
||||
char* argv[] = {arg1, arg2, arg3, arg4, arg5, arg6};
|
||||
int argc = sizeof(argv) / sizeof(argv[0]);
|
||||
|
||||
EXPECT_EQ(HnpCmdUnInstall(argc, argv), HNP_ERRNO_UNINSTALLER_HNP_PATH_NOT_EXIST);
|
||||
@ -465,7 +576,8 @@ HWTEST(HnpInstallerTest, Hnp_UnInstall_001, TestSize.Level0)
|
||||
char arg3[] = "10001";
|
||||
char arg4[] = "sample";
|
||||
char arg5[] = "1.3";
|
||||
char* argv[] = {arg1, arg2, arg3, arg4, arg5};
|
||||
char arg6[] = "null";
|
||||
char* argv[] = {arg1, arg2, arg3, arg4, arg5, arg6};
|
||||
int argc = sizeof(argv) / sizeof(argv[0]);
|
||||
|
||||
EXPECT_EQ(HnpCmdUnInstall(argc, argv), HNP_ERRNO_UNINSTALLER_HNP_PATH_NOT_EXIST);
|
||||
@ -474,16 +586,51 @@ HWTEST(HnpInstallerTest, Hnp_UnInstall_001, TestSize.Level0)
|
||||
char arg3[] = "10000";
|
||||
char arg4[] = "sample";
|
||||
char arg5[] = "1.1";
|
||||
char* argv[] = {arg1, arg2, arg3, arg4, arg5};
|
||||
char arg6[] = "null";
|
||||
char* argv[] = {arg1, arg2, arg3, arg4, arg5, arg6};
|
||||
int argc = sizeof(argv) / sizeof(argv[0]);
|
||||
|
||||
EXPECT_EQ(HnpCmdUnInstall(argc, argv), 0);
|
||||
}
|
||||
|
||||
HnpDeleteFolder("/data/app/el1/bundle/10000");
|
||||
HnpDeleteFolder(HNP_BASE_PATH);
|
||||
HnpPackWithBinDelete();
|
||||
|
||||
GTEST_LOG_(INFO) << "Hnp_UnInstall_001 end";
|
||||
}
|
||||
|
||||
/**
|
||||
* @tc.name: Hnp_UnInstall_002
|
||||
* @tc.desc: Verify cfg pack HnpCmdUnInstall succeed.
|
||||
* @tc.type: FUNC
|
||||
* @tc.require:issueI9BU5F
|
||||
* @tc.author:
|
||||
*/
|
||||
HWTEST(HnpInstallerTest, Hnp_UnInstall_002, TestSize.Level0)
|
||||
{
|
||||
GTEST_LOG_(INFO) << "Hnp_UnInstall_002 start";
|
||||
|
||||
EXPECT_EQ(mkdir(HNP_BASE_PATH, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH), 0);
|
||||
HnpPackWithCfg();
|
||||
HnpInstallPrivate();
|
||||
|
||||
char arg1[] = "hnp";
|
||||
char arg2[] = "uninstall";
|
||||
{ // ok
|
||||
char arg3[] = "10000";
|
||||
char arg4[] = "sample";
|
||||
char arg5[] = "1.1";
|
||||
char arg6[] = "huawei";
|
||||
char* argv[] = {arg1, arg2, arg3, arg4, arg5, arg6};
|
||||
int argc = sizeof(argv) / sizeof(argv[0]);
|
||||
|
||||
EXPECT_EQ(HnpCmdUnInstall(argc, argv), 0);
|
||||
}
|
||||
|
||||
HnpDeleteFolder(HNP_BASE_PATH);
|
||||
HnpPackWithCfgDelete();
|
||||
|
||||
GTEST_LOG_(INFO) << "Hnp_UnInstall_002 end";
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user