mirror of
https://github.com/Ascend/ascend-docker-runtime.git
synced 2025-10-15 20:00:43 +08:00
Match-id-9a03c8fb0841907b57369eb478a91c38db559375
This commit is contained in:
@@ -1,5 +1,5 @@
|
|||||||
cmake_minimum_required(VERSION 2.26)
|
cmake_minimum_required(VERSION 2.26)
|
||||||
project(ascend_docker_cli C)
|
project(ascend-docker-cli C)
|
||||||
set(CMAKE_C_STANDARD 11)
|
set(CMAKE_C_STANDARD 11)
|
||||||
aux_source_directory(. SRC)
|
aux_source_directory(. SRC)
|
||||||
add_executable(ascend_docker_cli ${SRC})
|
add_executable(ascend-docker-cli ${SRC})
|
||||||
|
@@ -52,7 +52,7 @@ static inline bool IsCmdArgsValid(struct CmdArgs *args)
|
|||||||
return (args->devices != NULL) && (args->rootfs != NULL) && (args->pid > 0);
|
return (args->devices != NULL) && (args->rootfs != NULL) && (args->pid > 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
static void FreeCmdArgs(struct CmdArgs *args)
|
void FreeCmdArgs(struct CmdArgs *args)
|
||||||
{
|
{
|
||||||
if (args->devices != NULL) {
|
if (args->devices != NULL) {
|
||||||
free(args->devices);
|
free(args->devices);
|
||||||
@@ -67,19 +67,19 @@ static void FreeCmdArgs(struct CmdArgs *args)
|
|||||||
args->pid = -1;
|
args->pid = -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int GetNsPath(const int pid, const char *nsType, char *buf, size_t bufSize)
|
int GetNsPath(const int pid, const char *nsType, char *buf, size_t bufSize)
|
||||||
{
|
{
|
||||||
static const char *fmtStr = "/proc/%d/ns/%s";
|
static const char *fmtStr = "/proc/%d/ns/%s";
|
||||||
return snprintf(buf, bufSize, fmtStr, pid, nsType);
|
return snprintf(buf, bufSize, fmtStr, pid, nsType);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int GetSelfNsPath(const char *nsType, char *buf, size_t bufSize)
|
int GetSelfNsPath(const char *nsType, char *buf, size_t bufSize)
|
||||||
{
|
{
|
||||||
static const char *fmtStr = "/proc/self/ns/%s";
|
static const char *fmtStr = "/proc/self/ns/%s";
|
||||||
return snprintf(buf, bufSize, fmtStr, nsType);
|
return snprintf(buf, bufSize, fmtStr, nsType);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int EnterNsByFd(int fd, int nsType)
|
int EnterNsByFd(int fd, int nsType)
|
||||||
{
|
{
|
||||||
int ret = setns(fd, nsType);
|
int ret = setns(fd, nsType);
|
||||||
if (ret < 0) {
|
if (ret < 0) {
|
||||||
@@ -90,7 +90,7 @@ static int EnterNsByFd(int fd, int nsType)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int EnterNsByPath(const char *path, int nsType)
|
int EnterNsByPath(const char *path, int nsType)
|
||||||
{
|
{
|
||||||
int fd;
|
int fd;
|
||||||
int ret;
|
int ret;
|
||||||
@@ -111,14 +111,14 @@ static int EnterNsByPath(const char *path, int nsType)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static unsigned int GetNextSerialNum()
|
unsigned int GetNextSerialNum()
|
||||||
{
|
{
|
||||||
static unsigned int index = 0;
|
static unsigned int index = 0;
|
||||||
|
|
||||||
return index++;
|
return index++;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int MountDevice(const char *rootfs, const int serialNumber)
|
int MountDevice(const char *rootfs, const int serialNumber)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
char src[BUF_SIZE] = {0};
|
char src[BUF_SIZE] = {0};
|
||||||
@@ -154,7 +154,7 @@ static int MountDevice(const char *rootfs, const int serialNumber)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int DoDeviceMounting(const char *rootfs, const char *devicesList)
|
int DoDeviceMounting(const char *rootfs, const char *devicesList)
|
||||||
{
|
{
|
||||||
static const char *sep = ",";
|
static const char *sep = ",";
|
||||||
char list[BUF_SIZE] = {0};
|
char list[BUF_SIZE] = {0};
|
||||||
@@ -175,7 +175,7 @@ static int DoDeviceMounting(const char *rootfs, const char *devicesList)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int CheckDirExists(char *dir, int len)
|
int CheckDirExists(char *dir, int len)
|
||||||
{
|
{
|
||||||
if (len < 0) {
|
if (len < 0) {
|
||||||
fprintf(stderr, "length of path is %d\n", len);
|
fprintf(stderr, "length of path is %d\n", len);
|
||||||
@@ -192,7 +192,7 @@ static int CheckDirExists(char *dir, int len)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int GetParentPathStr(const char *path, int lenOfPath, char *parent)
|
int GetParentPathStr(const char *path, int lenOfPath, char *parent)
|
||||||
{
|
{
|
||||||
if (lenOfPath < 0) {
|
if (lenOfPath < 0) {
|
||||||
return -1;
|
return -1;
|
||||||
@@ -209,7 +209,7 @@ static int GetParentPathStr(const char *path, int lenOfPath, char *parent)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int MakeParentDir(char *path, mode_t mode)
|
int MakeParentDir(char *path, mode_t mode)
|
||||||
{
|
{
|
||||||
if (*path == '\0' || *path == '.') {
|
if (*path == '\0' || *path == '.') {
|
||||||
return 0;
|
return 0;
|
||||||
@@ -233,7 +233,7 @@ static int MakeParentDir(char *path, mode_t mode)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static int MountFiles(const char *rootfs, const char *file, unsigned long reMountRwFlag)
|
int MountFiles(const char *rootfs, const char *file, unsigned long reMountRwFlag)
|
||||||
{
|
{
|
||||||
char src[BUF_SIZE] = {0};
|
char src[BUF_SIZE] = {0};
|
||||||
char dst[BUF_SIZE] = {0};
|
char dst[BUF_SIZE] = {0};
|
||||||
@@ -287,7 +287,7 @@ static int MountFiles(const char *rootfs, const char *file, unsigned long reMoun
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int DoCtrlDeviceMounting(const char *rootfs)
|
int DoCtrlDeviceMounting(const char *rootfs)
|
||||||
{
|
{
|
||||||
/* device */
|
/* device */
|
||||||
unsigned long reMountRwFlag = MS_BIND | MS_REMOUNT | MS_RDONLY | MS_NOSUID | MS_NOEXEC;
|
unsigned long reMountRwFlag = MS_BIND | MS_REMOUNT | MS_RDONLY | MS_NOSUID | MS_NOEXEC;
|
||||||
@@ -309,7 +309,7 @@ static int DoCtrlDeviceMounting(const char *rootfs)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int DoMounting(const struct CmdArgs *args)
|
int DoMounting(const struct CmdArgs *args)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
@@ -412,7 +412,7 @@ char *GetCgroupRoot(char *line, const char *subSystem)
|
|||||||
return (rootDir);
|
return (rootDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int CatFileContent(char* buffer, int bufferSize, ParseFileLine fn, const char* filepath)
|
int CatFileContent(char* buffer, int bufferSize, ParseFileLine fn, const char* filepath)
|
||||||
{
|
{
|
||||||
FILE *fp;
|
FILE *fp;
|
||||||
char *line = NULL;
|
char *line = NULL;
|
||||||
@@ -440,7 +440,7 @@ static int CatFileContent(char* buffer, int bufferSize, ParseFileLine fn, const
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int SetupDeviceCgroup(FILE *cgroupAllow, const char *devPath)
|
int SetupDeviceCgroup(FILE *cgroupAllow, const char *devPath)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
struct stat devStat;
|
struct stat devStat;
|
||||||
@@ -460,7 +460,7 @@ static int SetupDeviceCgroup(FILE *cgroupAllow, const char *devPath)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int SetupDriverCgroup(FILE *cgroupAllow)
|
int SetupDriverCgroup(FILE *cgroupAllow)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
|
|
||||||
@@ -485,7 +485,7 @@ static int SetupDriverCgroup(FILE *cgroupAllow)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int GetCgroupPath(const struct CmdArgs *args, char *effPath, const size_t maxSize)
|
int GetCgroupPath(const struct CmdArgs *args, char *effPath, const size_t maxSize)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
char mountPath[BUF_SIZE] = {0x0};
|
char mountPath[BUF_SIZE] = {0x0};
|
||||||
@@ -608,7 +608,7 @@ static int DoPrepare(const struct CmdArgs *args, struct ParsedConfig *config)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
static int SetupMounts(struct CmdArgs *args)
|
int SetupMounts(struct CmdArgs *args)
|
||||||
{
|
{
|
||||||
int ret;
|
int ret;
|
||||||
struct ParsedConfig config;
|
struct ParsedConfig config;
|
||||||
@@ -653,13 +653,8 @@ static int SetupMounts(struct CmdArgs *args)
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef gtest
|
int Process(int argc, char **argv)
|
||||||
int _main(int argc, char **argv)
|
|
||||||
{
|
{
|
||||||
#else
|
|
||||||
int main(int argc, char **argv)
|
|
||||||
{
|
|
||||||
#endif
|
|
||||||
int c;
|
int c;
|
||||||
int optionIndex;
|
int optionIndex;
|
||||||
struct CmdArgs args = {
|
struct CmdArgs args = {
|
||||||
@@ -699,3 +694,12 @@ int main(int argc, char **argv)
|
|||||||
FreeCmdArgs(&args);
|
FreeCmdArgs(&args);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef gtest
|
||||||
|
int _main(int argc, char **argv) {
|
||||||
|
#else
|
||||||
|
int main(int argc, char **argv) {
|
||||||
|
#endif
|
||||||
|
int ret = Process(argc, argv);
|
||||||
|
return ret;
|
||||||
|
}
|
@@ -6,21 +6,122 @@
|
|||||||
#include <iostream>
|
#include <iostream>
|
||||||
#include "gtest/gtest.h"
|
#include "gtest/gtest.h"
|
||||||
#include "mockcpp/mockcpp.hpp"
|
#include "mockcpp/mockcpp.hpp"
|
||||||
|
#include <sys/mount.h>
|
||||||
|
|
||||||
using namespace std;
|
using namespace std;
|
||||||
using namespace testing;
|
using namespace testing;
|
||||||
|
|
||||||
extern "C" int IsStrEqual(const char *s1, const char *s2);
|
#define DAVINCI_MANAGER_PATH "/dev/davinci_manager"
|
||||||
|
#define BUF_SIZE 1024
|
||||||
|
typedef char *(*ParseFileLine)(char *, const char *);
|
||||||
|
extern "C" int IsStrEqual(const char *s1, const char *s2);
|
||||||
extern "C" int GetNsPath(const int pid, const char *nsType, char *buf, size_t bufSize);
|
extern "C" int GetNsPath(const int pid, const char *nsType, char *buf, size_t bufSize);
|
||||||
extern "C" int setns(int fd, int nstype);
|
extern "C" int setns(int fd, int nstype);
|
||||||
|
extern "C" int open(const char *path, int flags);
|
||||||
|
extern "C" int close(int fd);
|
||||||
|
extern "C" int stat(const char *file_name, struct stat *buf);
|
||||||
|
extern "C" int mount(const char *source, const char *target,
|
||||||
|
const char *filesystemtype, unsigned long mountflags, const void *data);
|
||||||
|
extern "C" int rmdir(const char *pathname);
|
||||||
extern "C" int EnterNsByFd(int fd, int nsType);
|
extern "C" int EnterNsByFd(int fd, int nsType);
|
||||||
|
extern "C" int StrHasPrefix(const char *str, const char *prefix);
|
||||||
|
extern "C" int GetNsPath(const int pid, const char *nsType, char *buf, size_t bufSize);
|
||||||
|
extern "C" int GetSelfNsPath(const char *nsType, char *buf, size_t bufSize);
|
||||||
|
extern "C" int EnterNsByPath(const char *path, int nsType);
|
||||||
|
extern "C" unsigned int GetNextSerialNum();
|
||||||
|
extern "C" int MountDevice(const char *rootfs, const int serialNumber);
|
||||||
|
extern "C" int DoDeviceMounting(const char *rootfs, const char *devicesList);
|
||||||
|
extern "C" int CheckDirExists(char *dir, int len);
|
||||||
|
extern "C" int GetParentPathStr(const char *path, int lenOfPath, char *parent);
|
||||||
|
extern "C" int MakeParentDir(char *path, mode_t mode);
|
||||||
|
extern "C" int MountFiles(const char *rootfs, const char *file, unsigned long reMountRwFlag);
|
||||||
|
extern "C" int DoCtrlDeviceMounting(const char *rootfs);
|
||||||
|
extern "C" char *GetCgroupMount(char *line, const char *subsys);
|
||||||
|
extern "C" char *GetCgroupRoot(char *line, const char *subSystem);
|
||||||
|
extern "C" int CatFileContent(char* buffer, int bufferSize, ParseFileLine fn, const char* filepath);
|
||||||
|
extern "C" int SetupDeviceCgroup(FILE *cgroupAllow, const char *devPath);
|
||||||
|
extern "C" int SetupDriverCgroup(FILE *cgroupAllow);
|
||||||
|
extern "C" int GetCgroupPath(const struct CmdArgs *args, char *effPath, const size_t maxSize);
|
||||||
|
extern "C" int SetupCgroup(struct CmdArgs *args, const char *cgroupPath);
|
||||||
|
extern "C" int SetupMounts(struct CmdArgs *args);
|
||||||
|
extern "C" void FreeCmdArgs(struct CmdArgs *args);
|
||||||
|
extern "C" int Process(int argc, char **argv);
|
||||||
|
|
||||||
|
struct CmdArgs {
|
||||||
|
char *devices;
|
||||||
|
char *rootfs;
|
||||||
|
int pid;
|
||||||
|
};
|
||||||
|
|
||||||
int stub_setns(int fd, int nstype)
|
int stub_setns(int fd, int nstype)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int Stub_EnterNsByFd_Success(int fd, int nsType)
|
||||||
{
|
{
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
class Test_Fhho : public Test {
|
int stub_open(const char *path, int flags)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int stub_mount_success(const char *source, const char *target,
|
||||||
|
const char *filesystemtype, unsigned long mountflags, const void *data)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int stub_MountDevice(const char *rootfs, const int serialNumber)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int stub_MountFiles_success(const char *rootfs, const char *file, unsigned long reMountRwFlag)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
int stub_CheckDirExists_fail(char *dir, int len)
|
||||||
|
{
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
int Stub_EnterNsByPath_Success(const char *path, int nsType)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int Stub_DoDeviceMounting_Success(const char *rootfs, const char *devicesList)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int Stub_DoCtrlDeviceMounting_Success(const char *rootfs)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int Stub_SetupCgroup_Success(struct CmdArgs *args, const char *cgroupPath)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int Stub_SetupMounts_Success(struct CmdArgs *args)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int Stub_SetupDriverCgroup_Fail(FILE *cgroupAllow)
|
||||||
|
{
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
class Test_Fhho : public Test
|
||||||
|
{
|
||||||
protected:
|
protected:
|
||||||
static void SetUpTestCase()
|
static void SetUpTestCase()
|
||||||
{
|
{
|
||||||
@@ -46,7 +147,6 @@ TEST_F(Test_Fhho, ClassEQ1)
|
|||||||
EXPECT_EQ(1, IsStrEqual("", ""));
|
EXPECT_EQ(1, IsStrEqual("", ""));
|
||||||
}
|
}
|
||||||
|
|
||||||
#if 0
|
|
||||||
TEST_F(Test_Fhho, ClassEQ2)
|
TEST_F(Test_Fhho, ClassEQ2)
|
||||||
{
|
{
|
||||||
int pid = 1;
|
int pid = 1;
|
||||||
@@ -54,10 +154,10 @@ TEST_F(Test_Fhho, ClassEQ2)
|
|||||||
char buf[100] = {0x0};
|
char buf[100] = {0x0};
|
||||||
int bufSize = 100;
|
int bufSize = 100;
|
||||||
int ret = GetNsPath(pid, nsType, buf, 100);
|
int ret = GetNsPath(pid, nsType, buf, 100);
|
||||||
EXPECT_EQ(1, ret);
|
EXPECT_LE(0, ret);
|
||||||
}
|
}
|
||||||
|
|
||||||
TEST_F(Test_Fhho, ClassEQ3)
|
TEST(EnterNsByFd, Status1)
|
||||||
{
|
{
|
||||||
int pid = 1;
|
int pid = 1;
|
||||||
int nsType = 1;
|
int nsType = 1;
|
||||||
@@ -65,6 +165,546 @@ TEST_F(Test_Fhho, ClassEQ3)
|
|||||||
.stubs()
|
.stubs()
|
||||||
.will(invoke(stub_setns));
|
.will(invoke(stub_setns));
|
||||||
int ret = EnterNsByFd(pid, nsType);
|
int ret = EnterNsByFd(pid, nsType);
|
||||||
EXPECT_EQ(1, ret);
|
GlobalMockObject::verify();
|
||||||
|
EXPECT_LE(0, ret);
|
||||||
}
|
}
|
||||||
#endif
|
|
||||||
|
TEST(EnterNsByFd, Status2)
|
||||||
|
{
|
||||||
|
int pid = 1;
|
||||||
|
int nsType = 1;
|
||||||
|
int ret = EnterNsByFd(pid, nsType);
|
||||||
|
EXPECT_LE(-1, ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(EnterNsByPath, Status1)
|
||||||
|
{
|
||||||
|
char containerNsPath[BUF_SIZE] = {0};
|
||||||
|
int nsType = 1;
|
||||||
|
MOCKER(open)
|
||||||
|
.stubs()
|
||||||
|
.will(invoke(stub_open));
|
||||||
|
int ret = EnterNsByPath(containerNsPath, nsType);
|
||||||
|
GlobalMockObject::verify();
|
||||||
|
EXPECT_LE(-1, ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(EnterNsByPath, Status2)
|
||||||
|
{
|
||||||
|
char containerNsPath[BUF_SIZE] = {0};
|
||||||
|
int nsType = 1;
|
||||||
|
int ret = EnterNsByPath(containerNsPath, nsType);
|
||||||
|
EXPECT_LE(-1, ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(Test_Fhho, StrHasPrefix)
|
||||||
|
{
|
||||||
|
EXPECT_EQ(1, StrHasPrefix("/home/user", "/home"));
|
||||||
|
EXPECT_EQ(0, StrHasPrefix("/home/user", "/heme"));
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(StrHasPrefix, status1)
|
||||||
|
{
|
||||||
|
EXPECT_EQ(1, StrHasPrefix("/home/user", "/home"));
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(StrHasPrefix, status2)
|
||||||
|
{
|
||||||
|
EXPECT_EQ(0, StrHasPrefix("/home/user", "/heme"));
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(Test_Fhho, GetNsPath)
|
||||||
|
{
|
||||||
|
char containerNsPath[BUF_SIZE] = {0};
|
||||||
|
int containerPid = 1;
|
||||||
|
EXPECT_LE(0, GetNsPath(containerPid,"mnt", containerNsPath, BUF_SIZE));
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(Test_Fhho, GetSelfNsPath)
|
||||||
|
{
|
||||||
|
char nsPath[BUF_SIZE] = {0};
|
||||||
|
EXPECT_LE(0, GetSelfNsPath("mnt", nsPath, BUF_SIZE));
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_F(Test_Fhho, GetNextSerialNum)
|
||||||
|
{
|
||||||
|
EXPECT_EQ(0, GetNextSerialNum());
|
||||||
|
EXPECT_EQ(1, GetNextSerialNum());
|
||||||
|
EXPECT_EQ(2, GetNextSerialNum());
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(MountDevice, Status1)
|
||||||
|
{
|
||||||
|
char *rootfs="/home";
|
||||||
|
MOCKER(mount).stubs().will(invoke(stub_mount_success));
|
||||||
|
int serialNumber = 0;
|
||||||
|
GlobalMockObject::verify();
|
||||||
|
EXPECT_EQ(-1, MountDevice(rootfs, serialNumber));
|
||||||
|
}
|
||||||
|
TEST(MountDevice, Status11)
|
||||||
|
{
|
||||||
|
char *rootfs="/home/notexists";
|
||||||
|
int serialNumber = 0;
|
||||||
|
EXPECT_EQ(-1, MountDevice(rootfs, serialNumber));
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(MountDevice, Status2)
|
||||||
|
{
|
||||||
|
char *rootfs="../testcase/data";
|
||||||
|
// char *rootfs="/home/zhouhongyu/DT/ascend-docker-cli/test/build/testcase/data";
|
||||||
|
int serialNumber = 0;
|
||||||
|
EXPECT_EQ(-1, MountDevice(rootfs, serialNumber));
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(DoDeviceMounting, Status1)
|
||||||
|
{
|
||||||
|
MOCKER(MountDevice)
|
||||||
|
.stubs()
|
||||||
|
.will(invoke(stub_MountDevice));
|
||||||
|
char *rootfs = "/home";
|
||||||
|
char *devicesList = "1,2";
|
||||||
|
int ret = DoDeviceMounting(rootfs, devicesList);
|
||||||
|
GlobalMockObject::verify();
|
||||||
|
EXPECT_EQ(0, ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(CheckDirExists, Status1)
|
||||||
|
{
|
||||||
|
char *dir = "/home";
|
||||||
|
int len = strlen(dir);
|
||||||
|
int ret = CheckDirExists(dir, len);
|
||||||
|
EXPECT_EQ(0, ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(GetParentPathStr, Status1)
|
||||||
|
{
|
||||||
|
char *path = "/usr/bin";
|
||||||
|
int lenOfPath = strlen(path);
|
||||||
|
char parent[BUF_SIZE] = {0};
|
||||||
|
int ret = GetParentPathStr(path, lenOfPath, parent);
|
||||||
|
EXPECT_EQ(0, ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(MakeParentDir, Status1)
|
||||||
|
{
|
||||||
|
char *path = "/home/test1/test2";
|
||||||
|
mode_t mode = 0755;
|
||||||
|
char parentDir[BUF_SIZE] = {0};
|
||||||
|
int ret = MakeParentDir(parentDir, mode);
|
||||||
|
EXPECT_EQ(0, ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(MakeParentDir, Status2)
|
||||||
|
{
|
||||||
|
char *pathData = "/home/zhouhongyu/DT/ascend-docker-cli/test/build/abc/abcd";
|
||||||
|
mode_t mode = 0755;
|
||||||
|
char *path = NULL;
|
||||||
|
path = strdup(pathData);
|
||||||
|
int ret = MakeParentDir(path, mode);
|
||||||
|
rmdir(path);
|
||||||
|
rmdir("/home/zhouhongyu/DT/ascend-docker-cli/test/build/abc/");
|
||||||
|
EXPECT_EQ(0, ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(MakeParentDir, Status3)
|
||||||
|
{
|
||||||
|
char *pathData = "/home/zhouhongyu/DT/ascend-docker-cli/test/build/abc/abcd";
|
||||||
|
mode_t mode = 0755;
|
||||||
|
char *path = NULL;
|
||||||
|
path = strdup(pathData);
|
||||||
|
int ret = MakeParentDir(path, mode);
|
||||||
|
ret = MakeParentDir(path, mode);
|
||||||
|
rmdir(path);
|
||||||
|
rmdir("/home/zhouhongyu/DT/ascend-docker-cli/test/build/abc/");
|
||||||
|
EXPECT_EQ(0, ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(MountFiles, Status1)
|
||||||
|
{
|
||||||
|
MOCKER(MountDevice)
|
||||||
|
.stubs()
|
||||||
|
.will(invoke(stub_MountDevice));
|
||||||
|
MOCKER(mount).stubs().will(invoke(stub_mount_success));
|
||||||
|
char *rootfs = "../testcase/data/dev";
|
||||||
|
unsigned long reMountRwFlag = MS_BIND | MS_REMOUNT | MS_RDONLY | MS_NOSUID | MS_NOEXEC;
|
||||||
|
int ret = MountFiles(rootfs, DAVINCI_MANAGER_PATH, reMountRwFlag);
|
||||||
|
umount("../testcase/data/dev" DAVINCI_MANAGER_PATH);
|
||||||
|
rmdir("../testcase/data/dev" DAVINCI_MANAGER_PATH);
|
||||||
|
GlobalMockObject::verify();
|
||||||
|
EXPECT_EQ(0, ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(MountFiles, Status11)
|
||||||
|
{
|
||||||
|
char *rootfs = "../testcase/data/dev";
|
||||||
|
unsigned long reMountRwFlag = MS_BIND | MS_REMOUNT | MS_RDONLY | MS_NOSUID | MS_NOEXEC;
|
||||||
|
int ret = MountFiles(rootfs, DAVINCI_MANAGER_PATH, reMountRwFlag);
|
||||||
|
umount("../testcase/data/dev" DAVINCI_MANAGER_PATH);
|
||||||
|
rmdir("../testcase/data/dev" DAVINCI_MANAGER_PATH);
|
||||||
|
EXPECT_EQ(-1, ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(MountFiles, Status2)
|
||||||
|
{
|
||||||
|
char *rootfsData = "/home/zhouhongyu/DT/ascend-docker-cli/test/testcase/data/dev";
|
||||||
|
char *rootfs = NULL;
|
||||||
|
rootfs = strdup(rootfsData);
|
||||||
|
unsigned long reMountRwFlag = MS_BIND | MS_REMOUNT;
|
||||||
|
int ret = MountFiles(rootfs, DAVINCI_MANAGER_PATH, reMountRwFlag);
|
||||||
|
umount("/home/zhouhongyu/DT/ascend-docker-cli/test/testcase/data/dev" DAVINCI_MANAGER_PATH);
|
||||||
|
rmdir("/home/zhouhongyu/DT/ascend-docker-cli/test/testcase/data/dev" DAVINCI_MANAGER_PATH);
|
||||||
|
EXPECT_EQ(-1, ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(MountFiles, Status3)
|
||||||
|
{
|
||||||
|
char *rootfsData = "/home/zhouhongyu/DT/ascend-docker-cli/test/testcase/data/usr";
|
||||||
|
char *rootfs = NULL;
|
||||||
|
rootfs = strdup(rootfsData);
|
||||||
|
unsigned long reMountRwFlag = MS_BIND | MS_REMOUNT;
|
||||||
|
int ret = MountFiles(rootfs, "/usr", reMountRwFlag);
|
||||||
|
umount("/home/zhouhongyu/DT/ascend-docker-cli/test/testcase/data/usr");
|
||||||
|
rmdir("/home/zhouhongyu/DT/ascend-docker-cli/test/testcase/data/usr");
|
||||||
|
EXPECT_EQ(-1, ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(MountFiles, Status4)
|
||||||
|
{
|
||||||
|
char *rootfsData = "/home/zhouhongyu/DT/ascend-docker-cli/test/testcase/data/usr";
|
||||||
|
char *rootfs = NULL;
|
||||||
|
rootfs = strdup(rootfsData);
|
||||||
|
unsigned long reMountRwFlag = MS_BIND | MS_REMOUNT;
|
||||||
|
int ret = MountFiles(rootfs, "/notexist1/notexist2", reMountRwFlag);
|
||||||
|
umount("/home/zhouhongyu/DT/ascend-docker-cli/test/testcase/data/usr");
|
||||||
|
rmdir("/home/zhouhongyu/DT/ascend-docker-cli/test/testcase/data/usr");
|
||||||
|
EXPECT_EQ(-1, ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(MountFiles, Status5)
|
||||||
|
{
|
||||||
|
char *rootfsData = "/home/zhouhongyu/DT/ascend-docker-cli/test/testcase/data/usr";
|
||||||
|
char *rootfs = NULL;
|
||||||
|
rootfs = strdup(rootfsData);
|
||||||
|
unsigned long reMountRwFlag = MS_BIND | MS_REMOUNT;
|
||||||
|
int ret = MountFiles(rootfs, "/notexist2", reMountRwFlag);
|
||||||
|
umount("/home/zhouhongyu/DT/ascend-docker-cli/test/testcase/data/usr");
|
||||||
|
rmdir("/home/zhouhongyu/DT/ascend-docker-cli/test/testcase/data/usr");
|
||||||
|
EXPECT_EQ(-1, ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(MountFiles, Status6)
|
||||||
|
{
|
||||||
|
MOCKER(CheckDirExists).stubs().will(invoke(stub_CheckDirExists_fail));
|
||||||
|
char *rootfsData = "/home/zhouhongyu/DT/ascend-docker-cli/test/testcase/data/usr1";
|
||||||
|
char *rootfs = NULL;
|
||||||
|
rootfs = strdup(rootfsData);
|
||||||
|
unsigned long reMountRwFlag = MS_BIND | MS_REMOUNT;
|
||||||
|
int ret = MountFiles(rootfs, "/usr", reMountRwFlag);
|
||||||
|
umount("/home/zhouhongyu/DT/ascend-docker-cli/test/testcase/data/usr");
|
||||||
|
rmdir("/home/zhouhongyu/DT/ascend-docker-cli/test/testcase/data/usr");
|
||||||
|
GlobalMockObject::verify();
|
||||||
|
EXPECT_EQ(-1, ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(DoCtrlDeviceMounting, Status1)
|
||||||
|
{
|
||||||
|
char *rootfs = "/home";
|
||||||
|
int ret = DoCtrlDeviceMounting(rootfs);
|
||||||
|
EXPECT_EQ(-1, ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(DoCtrlDeviceMounting, Status2)
|
||||||
|
{
|
||||||
|
MOCKER(MountFiles).stubs().will(invoke(stub_MountFiles_success));
|
||||||
|
char *rootfs = "/home";
|
||||||
|
int ret = DoCtrlDeviceMounting(rootfs);
|
||||||
|
GlobalMockObject::verify();
|
||||||
|
EXPECT_EQ(0, ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(GetCgroupMount, Status1)
|
||||||
|
{
|
||||||
|
char *lineData = "406 403 0:27 /docker/ba186404524744c189c6a03d2b66288a963a562a79b11005ae935104fc8c47b2 /sys/fs/cgroup/devices ro,nosuid,nodev,noexec,relatime master:15 - cgroup cgroup rw,devices";
|
||||||
|
char *line = NULL;
|
||||||
|
line = strdup(lineData);
|
||||||
|
char *subsys = "devices";
|
||||||
|
char *expectRes = "/sys/fs/cgroup/devices";
|
||||||
|
char *actualRes = GetCgroupMount(line, subsys);
|
||||||
|
EXPECT_EQ(0, strcmp(actualRes, expectRes));
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(GetCgroupRoot, Status1)
|
||||||
|
{
|
||||||
|
char *lineData = "3:devices:/docker/ba186404524744c189c6a03d2b66288a963a562a79b11005ae935104fc8c47b2";
|
||||||
|
char *line = NULL;
|
||||||
|
line = strdup(lineData);
|
||||||
|
char *subsys = "devices";
|
||||||
|
char *expectRes = "/docker/ba186404524744c189c6a03d2b66288a963a562a79b11005ae935104fc8c47b2";
|
||||||
|
char *actualRes = GetCgroupRoot(line, subsys);
|
||||||
|
EXPECT_EQ(0, strcmp(actualRes, expectRes));
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(CatFileContent, Status1)
|
||||||
|
{
|
||||||
|
char *mountPath= "./data/mountinfo.txt";
|
||||||
|
char mount[BUF_SIZE] = {0x0};
|
||||||
|
int ret = CatFileContent(mount, BUF_SIZE, GetCgroupMount, mountPath);
|
||||||
|
EXPECT_EQ(-1, ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(SetupDeviceCgroup, Status1)
|
||||||
|
{
|
||||||
|
char *cgroupPathData = "../testcase/data/devices.allow";
|
||||||
|
char *cgroupPath = NULL;
|
||||||
|
cgroupPath = strdup(cgroupPathData);
|
||||||
|
FILE *cgroupAllow = NULL;
|
||||||
|
cgroupAllow = fopen(cgroupPath, "a");
|
||||||
|
int ret = SetupDeviceCgroup(cgroupAllow, cgroupPath);
|
||||||
|
fclose(cgroupAllow);
|
||||||
|
EXPECT_EQ(0, ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(SetupDeviceCgroup, Status2)
|
||||||
|
{
|
||||||
|
char *cgroupPathData = "../testcase/data/devices1.allow";
|
||||||
|
char *cgroupPath = NULL;
|
||||||
|
cgroupPath = strdup(cgroupPathData);
|
||||||
|
FILE *cgroupAllow = NULL;
|
||||||
|
cgroupAllow = fopen(cgroupPath, "a");
|
||||||
|
int ret = SetupDeviceCgroup(cgroupAllow, cgroupPath);
|
||||||
|
fclose(cgroupAllow);
|
||||||
|
EXPECT_EQ(0, ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(SetupDriverCgroup, Status1)
|
||||||
|
{
|
||||||
|
char *cgroupPath = "../testcase/data/devices.allow";
|
||||||
|
FILE *cgroupAllow = NULL;
|
||||||
|
cgroupAllow = fopen(cgroupPath, "a");
|
||||||
|
int ret = SetupDriverCgroup(cgroupAllow);
|
||||||
|
fclose(cgroupAllow);
|
||||||
|
EXPECT_EQ(0, ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(SetupDriverCgroup, Status2)
|
||||||
|
{
|
||||||
|
char *cgroupPath = "../testcase/data/devices1.allow";
|
||||||
|
FILE *cgroupAllow = NULL;
|
||||||
|
cgroupAllow = fopen(cgroupPath, "a");
|
||||||
|
int ret = SetupDriverCgroup(cgroupAllow);
|
||||||
|
fclose(cgroupAllow);
|
||||||
|
EXPECT_EQ(0, ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(GetCgroupPath, Status1)
|
||||||
|
{
|
||||||
|
struct CmdArgs args = {
|
||||||
|
.devices = "1,2",
|
||||||
|
.rootfs = "/home",
|
||||||
|
.pid = 1
|
||||||
|
};
|
||||||
|
|
||||||
|
char cgroupPath[BUF_SIZE] = {0};
|
||||||
|
int ret = GetCgroupPath(&args, cgroupPath, BUF_SIZE);
|
||||||
|
EXPECT_EQ(0, ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(SetupCgroup, Status1)
|
||||||
|
{
|
||||||
|
struct CmdArgs args = {
|
||||||
|
.devices = "1,2",
|
||||||
|
.rootfs = "/home",
|
||||||
|
.pid = 1
|
||||||
|
};
|
||||||
|
|
||||||
|
char cgroupPath[BUF_SIZE] = {0};
|
||||||
|
int ret = SetupCgroup(&args, cgroupPath);
|
||||||
|
EXPECT_EQ(-1, ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(SetupCgroup, Status2)
|
||||||
|
{
|
||||||
|
struct CmdArgs args = {
|
||||||
|
.devices = "1,2",
|
||||||
|
.rootfs = "/home",
|
||||||
|
.pid = 1
|
||||||
|
};
|
||||||
|
char *cgroupPathData = "/home/zhouhongyu/DT/ascend-docker-cli/test/testcase/data/devices.allow";
|
||||||
|
char *cgroupPath = strdup(cgroupPathData);
|
||||||
|
int ret = SetupCgroup(&args, cgroupPath);
|
||||||
|
EXPECT_EQ(0, ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(SetupCgroup, Status3)
|
||||||
|
{
|
||||||
|
struct CmdArgs args = {
|
||||||
|
.devices = "1,2",
|
||||||
|
.rootfs = "/home",
|
||||||
|
.pid = 1
|
||||||
|
};
|
||||||
|
char *cgroupPathData = "/home/zhouhongyu/DT/ascend-docker-cli/test/testcase/";
|
||||||
|
char *cgroupPath = strdup(cgroupPathData);
|
||||||
|
int ret = SetupCgroup(&args, cgroupPath);
|
||||||
|
EXPECT_EQ(-1, ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(SetupCgroup, Status4)
|
||||||
|
{
|
||||||
|
MOCKER(SetupDriverCgroup)
|
||||||
|
.stubs()
|
||||||
|
.will(invoke(Stub_SetupDriverCgroup_Fail));
|
||||||
|
struct CmdArgs args = {
|
||||||
|
.devices = "1,2",
|
||||||
|
.rootfs = "/home",
|
||||||
|
.pid = 1
|
||||||
|
};
|
||||||
|
char *cgroupPathData = "/home/zhouhongyu/DT/ascend-docker-cli/test/testcase/";
|
||||||
|
char *cgroupPath = strdup(cgroupPathData);
|
||||||
|
int ret = SetupCgroup(&args, cgroupPath);
|
||||||
|
GlobalMockObject::verify();
|
||||||
|
EXPECT_EQ(-1, ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(SetupMounts, Status1)
|
||||||
|
{
|
||||||
|
struct CmdArgs args = {
|
||||||
|
.devices = "1,2",
|
||||||
|
.rootfs = "/home",
|
||||||
|
.pid = 1
|
||||||
|
};
|
||||||
|
int ret = SetupMounts(&args);
|
||||||
|
EXPECT_EQ(-1, ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(SetupMounts, Status2)
|
||||||
|
{
|
||||||
|
struct CmdArgs args = {
|
||||||
|
.devices = "1,2",
|
||||||
|
.rootfs = "/home",
|
||||||
|
.pid = 1
|
||||||
|
};
|
||||||
|
MOCKER(EnterNsByPath).stubs().will(invoke(Stub_EnterNsByPath_Success));
|
||||||
|
int ret = SetupMounts(&args);
|
||||||
|
GlobalMockObject::verify();
|
||||||
|
EXPECT_EQ(-1, ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(SetupMounts, Status3)
|
||||||
|
{
|
||||||
|
struct CmdArgs args = {
|
||||||
|
.devices = "1,2",
|
||||||
|
.rootfs = "/home",
|
||||||
|
.pid = 1
|
||||||
|
};
|
||||||
|
MOCKER(EnterNsByPath).stubs().will(invoke(Stub_EnterNsByPath_Success));
|
||||||
|
MOCKER(DoDeviceMounting).stubs().will(invoke(Stub_DoDeviceMounting_Success));
|
||||||
|
int ret = SetupMounts(&args);
|
||||||
|
GlobalMockObject::verify();
|
||||||
|
EXPECT_EQ(-1, ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(SetupMounts, Status4)
|
||||||
|
{
|
||||||
|
struct CmdArgs args = {
|
||||||
|
.devices = "1,2",
|
||||||
|
.rootfs = "/home",
|
||||||
|
.pid = 1
|
||||||
|
};
|
||||||
|
MOCKER(EnterNsByPath).stubs().will(invoke(Stub_EnterNsByPath_Success));
|
||||||
|
MOCKER(DoDeviceMounting).stubs().will(invoke(Stub_DoDeviceMounting_Success));
|
||||||
|
MOCKER(DoCtrlDeviceMounting).stubs().will(invoke(Stub_DoCtrlDeviceMounting_Success));
|
||||||
|
int ret = SetupMounts(&args);
|
||||||
|
GlobalMockObject::verify();
|
||||||
|
EXPECT_EQ(-1, ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(SetupMounts, Status5)
|
||||||
|
{
|
||||||
|
struct CmdArgs args = {
|
||||||
|
.devices = "1,2",
|
||||||
|
.rootfs = "/home",
|
||||||
|
.pid = 1
|
||||||
|
};
|
||||||
|
MOCKER(EnterNsByPath).stubs().will(invoke(Stub_EnterNsByPath_Success));
|
||||||
|
MOCKER(DoDeviceMounting).stubs().will(invoke(Stub_DoDeviceMounting_Success));
|
||||||
|
MOCKER(DoCtrlDeviceMounting).stubs().will(invoke(Stub_DoCtrlDeviceMounting_Success));
|
||||||
|
MOCKER(SetupCgroup).stubs().will(invoke(Stub_SetupCgroup_Success));
|
||||||
|
int ret = SetupMounts(&args);
|
||||||
|
GlobalMockObject::verify();
|
||||||
|
EXPECT_EQ(-1, ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(SetupMounts, Status6)
|
||||||
|
{
|
||||||
|
struct CmdArgs args = {
|
||||||
|
.devices = "1,2",
|
||||||
|
.rootfs = "/home",
|
||||||
|
.pid = 1
|
||||||
|
};
|
||||||
|
MOCKER(EnterNsByPath).stubs().will(invoke(Stub_EnterNsByPath_Success));
|
||||||
|
MOCKER(DoDeviceMounting).stubs().will(invoke(Stub_DoDeviceMounting_Success));
|
||||||
|
MOCKER(DoCtrlDeviceMounting).stubs().will(invoke(Stub_DoCtrlDeviceMounting_Success));
|
||||||
|
MOCKER(SetupCgroup).stubs().will(invoke(Stub_SetupCgroup_Success));
|
||||||
|
MOCKER(EnterNsByFd).stubs().will(invoke(Stub_EnterNsByFd_Success));
|
||||||
|
int ret = SetupMounts(&args);
|
||||||
|
GlobalMockObject::verify();
|
||||||
|
EXPECT_EQ(0, ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(FreeCmdArgs, Status1)
|
||||||
|
{
|
||||||
|
struct CmdArgs args = {
|
||||||
|
.devices = NULL,
|
||||||
|
.rootfs = NULL,
|
||||||
|
.pid = 1
|
||||||
|
};
|
||||||
|
FreeCmdArgs(&args);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(FreeCmdArgs, Status2)
|
||||||
|
{
|
||||||
|
struct CmdArgs args = {
|
||||||
|
.devices = NULL,
|
||||||
|
.rootfs = NULL,
|
||||||
|
.pid = 1
|
||||||
|
};
|
||||||
|
char *devlist = "1,2";
|
||||||
|
char *root = "/home";
|
||||||
|
args.devices = strdup(devlist);
|
||||||
|
args.rootfs = strdup(root);
|
||||||
|
FreeCmdArgs(&args);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(Process, Status1)
|
||||||
|
{
|
||||||
|
int argc = 0;
|
||||||
|
char **argv = NULL;
|
||||||
|
int ret = Process(argc, argv);
|
||||||
|
EXPECT_EQ(-1, ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(Process, Status2)
|
||||||
|
{
|
||||||
|
int argc = 7;
|
||||||
|
char *argvData[7] = {"ascend-docker-cli", "--devices", "1,2", "--pid", "123", "--rootfs", "/home"};
|
||||||
|
int ret = Process(argc, argvData);
|
||||||
|
EXPECT_EQ(-1, ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(Process, Status3)
|
||||||
|
{
|
||||||
|
int argc = 7;
|
||||||
|
char *argvData[7] = {"ascend-docker-cli", "--evices", "1,2", "--idd", "123", "--ootfs", "/home"};
|
||||||
|
int ret = Process(argc, argvData);
|
||||||
|
EXPECT_EQ(-1, ret);
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST(Process, Status4)
|
||||||
|
{
|
||||||
|
int argc = 7;
|
||||||
|
char *argvData[7] = {"ascend-docker-cli", "--evices", "1,2", "--idd", "123", "--ootfs", "/home"};
|
||||||
|
MOCKER(SetupMounts).stubs().will(invoke(Stub_SetupMounts_Success));
|
||||||
|
int ret = Process(argc, argvData);
|
||||||
|
GlobalMockObject::verify();
|
||||||
|
EXPECT_EQ(-1, ret);
|
||||||
|
}
|
Reference in New Issue
Block a user