提交 3494a968 编写于 作者: L leon

Fix coding style

上级 97d8bd8b
...@@ -22,8 +22,6 @@ extern "C" { ...@@ -22,8 +22,6 @@ extern "C" {
#endif #endif
#endif #endif
#include <stddef.h>
struct ListNode { struct ListNode {
struct ListNode *next; struct ListNode *next;
struct ListNode *prev; struct ListNode *prev;
......
...@@ -20,6 +20,13 @@ ...@@ -20,6 +20,13 @@
#include <string.h> #include <string.h>
#include <errno.h> #include <errno.h>
#define DEFAULT_RW_MODE 0666
#define DEFAULT_NO_AUTHORITY_MODE 0600
#define DEVICE_ID_THIRD 3
#define DEVICE_ID_EIGHTH 8
#define DEVICE_ID_NINTH 9
#define DEVICE_ID_ELEVNTH 11
void MountBasicFs() void MountBasicFs()
{ {
if (mount("tmpfs", "/dev", "tmpfs", MS_NOSUID, "mode=0755") != 0) { if (mount("tmpfs", "/dev", "tmpfs", MS_NOSUID, "mode=0755") != 0) {
...@@ -35,17 +42,17 @@ void MountBasicFs() ...@@ -35,17 +42,17 @@ void MountBasicFs()
void CreateDeviceNode() void CreateDeviceNode()
{ {
if (mknod("/dev/kmsg", S_IFCHR | 0600, makedev(1, 11)) != 0) { if (mknod("/dev/kmsg", S_IFCHR | DEFAULT_NO_AUTHORITY_MODE, makedev(1, DEVICE_ID_ELEVNTH)) != 0) {
printf("Create /dev/kmsg device node failed. %s\n", strerror(errno)); printf("Create /dev/kmsg device node failed. %s\n", strerror(errno));
} }
if (mknod("/dev/null", S_IFCHR | 0666, makedev(1, 3)) != 0) { if (mknod("/dev/null", S_IFCHR | DEFAULT_RW_MODE, makedev(1, DEVICE_ID_THIRD)) != 0) {
printf("Create /dev/null device node failed. %s\n", strerror(errno)); printf("Create /dev/null device node failed. %s\n", strerror(errno));
} }
if (mknod("/dev/random", S_IFCHR | 0666, makedev(1, 8)) != 0) { if (mknod("/dev/random", S_IFCHR | DEFAULT_RW_MODE, makedev(1, DEVICE_ID_EIGHTH)) != 0) {
printf("Create /dev/random device node failed. %s\n", strerror(errno)); printf("Create /dev/random device node failed. %s\n", strerror(errno));
} }
if (mknod("/dev/urandom", S_IFCHR | 0666, makedev(1, 9)) != 0) { if (mknod("/dev/urandom", S_IFCHR | DEFAULT_RW_MODE, makedev(1, DEVICE_ID_NINTH)) != 0) {
printf("Create /dev/urandom device node failed. %s\n", strerror(errno)); printf("Create /dev/urandom device node failed. %s\n", strerror(errno));
} }
} }
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
*/ */
#include "init_adapter.h" #include "init_adapter.h"
#include <errno.h> #include <errno.h>
#include <stdio.h> #include <stdio.h>
#include <unistd.h> #include <unistd.h>
......
...@@ -14,7 +14,6 @@ ...@@ -14,7 +14,6 @@
*/ */
#include "init_cmds.h" #include "init_cmds.h"
#include <ctype.h> #include <ctype.h>
#include <errno.h> #include <errno.h>
#include <stdbool.h> #include <stdbool.h>
...@@ -40,6 +39,7 @@ ...@@ -40,6 +39,7 @@
#define LOADCFG_BUF_SIZE 128 // loadcfg, max buffer for one cmdline #define LOADCFG_BUF_SIZE 128 // loadcfg, max buffer for one cmdline
#define LOADCFG_MAX_FILE_LEN 51200 // loadcfg, max file size is 50K #define LOADCFG_MAX_FILE_LEN 51200 // loadcfg, max file size is 50K
#define LOADCFG_MAX_LOOP 20 // loadcfg, to prevent to be trapped in infite loop #define LOADCFG_MAX_LOOP 20 // loadcfg, to prevent to be trapped in infite loop
#define OCTAL_TYPE 8 //8 means octal to decimal
static const char *g_supportCfg[] = { static const char *g_supportCfg[] = {
"/patch/fstab.cfg", "/patch/fstab.cfg",
}; };
...@@ -119,7 +119,7 @@ static void DoChmod(const char* cmdContent) ...@@ -119,7 +119,7 @@ static void DoChmod(const char* cmdContent)
} }
const char* pathBeginStr = cmdContent + MODE_LEN + 1; // after space const char* pathBeginStr = cmdContent + MODE_LEN + 1; // after space
mode_t mode = strtoul(cmdContent, NULL, 8); // 8 means octal to decimal mode_t mode = strtoul(cmdContent, NULL, OCTAL_TYPE);
if (mode == 0) { if (mode == 0) {
printf("[Init] DoChmod, strtoul failed for %s, er %d.\n", cmdContent, errno); printf("[Init] DoChmod, strtoul failed for %s, er %d.\n", cmdContent, errno);
return; return;
...@@ -321,17 +321,51 @@ static void DoMount(const char* cmdContent) ...@@ -321,17 +321,51 @@ static void DoMount(const char* cmdContent)
} }
#ifndef OHOS_LITE #ifndef OHOS_LITE
#define OPTIONS_SIZE (128u)
static void DoInsmodInternal(const char *fileName, char *secondPtr, char *restPtr, int flags)
{
int fd = -1;
char options[OPTIONS_SIZE] = {0};
if (flags == 0) { // '-f' option
if (restPtr != NULL && secondPtr != NULL) { // Reset arugments, combine then all.
if (snprintf_s(options, sizeof(options), OPTIONS_SIZE -1, "%s %s", secondPtr, restPtr) == -1) {
goto out;
}
} else {
if (strncpy_s(options, OPTIONS_SIZE - 1, secondPtr, strlen(secondPtr)) != 0) {
goto out;
}
}
} else { // Only restPtr is option
if (restPtr != NULL) {
strncpy_s(options, OPTIONS_SIZE - 1, restPtr, strlen(restPtr));
}
}
fd = open(fileName, O_RDONLY | O_NOFOLLOW | O_CLOEXEC);
if (fd < 0) {
printf("[Init] failed to open %s: %d\n", fileName, errno);
goto out;
}
int rc = syscall(__NR_finit_module, fd, options, flags);
if (rc == -1) {
printf("[Init] finit_module for %s failed: %d\n", fileName, errno);
}
out:
if (fd > 0) {
close(fd);
}
return;
}
// format insmod <ko name> [-f] [options] // format insmod <ko name> [-f] [options]
static void DoInsmod(const char *cmdContent) static void DoInsmod(const char *cmdContent)
{ {
#define OPTIONS_SIZE (128u)
char *p = NULL; char *p = NULL;
char *line = NULL;
char *restPtr = NULL; char *restPtr = NULL;
char *fileName = NULL; char *fileName = NULL;
char *line = NULL;
int flags = 0; int flags = 0;
int fd = -1;
char options[OPTIONS_SIZE] = {0};
size_t count = strlen(cmdContent); size_t count = strlen(cmdContent);
if (count > OPTIONS_SIZE) { if (count > OPTIONS_SIZE) {
...@@ -342,16 +376,15 @@ static void DoInsmod(const char *cmdContent) ...@@ -342,16 +376,15 @@ static void DoInsmod(const char *cmdContent)
printf("[Init] Allocate memory failed.\n"); printf("[Init] Allocate memory failed.\n");
return; return;
} }
if (memcpy_s(line, count, cmdContent, count) != EOK) { if (memcpy_s(line, count, cmdContent, count) != EOK) {
printf("[Init] memcpy failed\n"); printf("[Init] memcpy failed\n");
return;
} }
line[count] = '\0'; line[count] = '\0';
do { do {
if ((p = strtok_r(line, " ", &restPtr)) == NULL) { if ((p = strtok_r(line, " ", &restPtr)) == NULL) {
printf("[Init] debug, cannot get filename\n"); printf("[Init] debug, cannot get filename\n");
free(line);
return; return;
} }
fileName = p; fileName = p;
...@@ -363,44 +396,13 @@ static void DoInsmod(const char *cmdContent) ...@@ -363,44 +396,13 @@ static void DoInsmod(const char *cmdContent)
flags = MODULE_INIT_IGNORE_VERMAGIC | MODULE_INIT_IGNORE_MODVERSIONS; flags = MODULE_INIT_IGNORE_VERMAGIC | MODULE_INIT_IGNORE_MODVERSIONS;
} }
} while (0); } while (0);
DoInsmodInternal(fileName, p, restPtr, flags);
if (flags != 0) { // '-f' option
p = restPtr; // grab all rest of contents.
} else { // no '-f' option, should combine p and resetPtr
if (p != NULL) {
if (restPtr != NULL) {
if (snprintf_s(options, sizeof(options), OPTIONS_SIZE -1, "%s %s", p, restPtr) == -1) {
goto out;
return;
}
} else {
if (strncpy_s(options, OPTIONS_SIZE - 1, p, strlen(p)) != 0) {
goto out;
return;
}
}
}
}
// Open ko files
fd = open(fileName, O_RDONLY | O_NOFOLLOW | O_CLOEXEC);
if (fd < 0) {
printf("[Init] failed to open %s: %d\n", fileName, errno);
goto out;
}
int rc = syscall(__NR_finit_module, fd, options, flags);
if (rc == -1) {
printf("[Init] finit_module for %s failed: %d\n", fileName, errno);
}
out:
if (fd > 0) {
close(fd);
}
if (line != NULL) { if (line != NULL) {
free(line); free(line);
} }
return;
} }
#endif #endif // OHOS_LITE
static bool CheckValidCfg(const char *path) static bool CheckValidCfg(const char *path)
{ {
...@@ -488,13 +490,11 @@ void DoCmd(const CmdLine* curCmd) ...@@ -488,13 +490,11 @@ void DoCmd(const CmdLine* curCmd)
DoMount(curCmd->cmdContent); DoMount(curCmd->cmdContent);
} else if (strncmp(curCmd->name, "loadcfg ", strlen("loadcfg ")) == 0) { } else if (strncmp(curCmd->name, "loadcfg ", strlen("loadcfg ")) == 0) {
DoLoadCfg(curCmd->cmdContent); DoLoadCfg(curCmd->cmdContent);
}
#ifndef OHOS_LITE #ifndef OHOS_LITE
else if (strncmp(curCmd->name, "insmod ", strlen("insmod ")) == 0) { } else if (strncmp(curCmd->name, "insmod ", strlen("insmod ")) == 0) {
DoInsmod(curCmd->cmdContent); DoInsmod(curCmd->cmdContent);
}
#endif #endif
else { } else {
printf("[Init] DoCmd, unknown cmd name %s.\n", curCmd->name); printf("[Init] DoCmd, unknown cmd name %s.\n", curCmd->name);
} }
} }
......
...@@ -31,8 +31,57 @@ ...@@ -31,8 +31,57 @@
#include "list.h" #include "list.h"
#include "securec.h" #include "securec.h"
#define LINK_NUMBER 4
#define DEFAULT_DIR_MODE 0755
#define DEV_DRM 3
#define DEV_ONCRPC 6
#define DEV_ADSP 4
#define DEV_INPUT 5
#define DEV_MTD 3
#define DEV_SOUND 5
#define DEV_MISC 4
#define DEV_DEFAULT 4
#define DEV_PLAT_FORM 9
#define DEV_USB 4
#define DEV_GRAPHICS 8
#define EVENT_ACTION 7
#define EVENT_DEVPATH 8
#define EVENT_SYSTEM 10
#define EVENT_FIRMWARE 9
#define EVENT_MAJOR 6
#define EVENT_MINOR 6
#define EVENT_PARTN 6
#define EVENT_PART_NAME 9
#define EVENT_DEV_NAME 8
#define EVENT_BLOCK 5
#define EVENT_PLAT_FORM 8
#define TRIGGER_ADDR_SIZE 4
#define BASE_BUFFER_SIZE 1024
#define MAX_BUFFER 256
#define EVENT_MAX_BUFFER 1026
#define MAX_DEV_PATH 96
#define MINORS_GROUPS 128
#define SYS_LINK_NUMBER 2
#define MAX_DEVICE_LEN 64
#define DEFAULT_MODE 0000
#define DEVICE_SKIP 5
#define HANDLE_DEVICE_USB 3
#define DEFAULT_NO_AUTHORITY_MODE 0600
int g_ueventFD = -1; int g_ueventFD = -1;
#define CHECK_RESULT_DONE(ret, do, another) \
if (ret) { \
do; \
} else { \
another; \
}
#define CHECK_RETURN(ret, statement) \
if (!(ret)) { \
statement; \
}
struct Uevent { struct Uevent {
const char *action; const char *action;
const char *path; const char *path;
...@@ -71,7 +120,7 @@ static void DoTrigger(DIR *dir) ...@@ -71,7 +120,7 @@ static void DoTrigger(DIR *dir)
int dfd = dirfd(dir); int dfd = dirfd(dir);
int fd = openat(dfd, "uevent", O_WRONLY); int fd = openat(dfd, "uevent", O_WRONLY);
if (fd >= 0) { if (fd >= 0) {
write(fd, "add\n", 4); write(fd, "add\n", TRIGGER_ADDR_SIZE);
close(fd); close(fd);
HandleUevent(); HandleUevent();
} }
...@@ -114,7 +163,7 @@ static void RetriggerUevent() ...@@ -114,7 +163,7 @@ static void RetriggerUevent()
Trigger("/sys/class"); Trigger("/sys/class");
Trigger("/sys/block"); Trigger("/sys/block");
Trigger("/sys/devices"); Trigger("/sys/devices");
int fd = open(TRIGGER, O_WRONLY | O_CREAT | O_CLOEXEC, 0000); int fd = open(TRIGGER, O_WRONLY | O_CREAT | O_CLOEXEC, DEFAULT_MODE);
if (fd > 0) { if (fd > 0) {
close(fd); close(fd);
} }
...@@ -124,7 +173,7 @@ static void RetriggerUevent() ...@@ -124,7 +173,7 @@ static void RetriggerUevent()
static void UeventSockInit() static void UeventSockInit()
{ {
struct sockaddr_nl addr; struct sockaddr_nl addr;
int buffSize = 256 * 1024; int buffSize = MAX_BUFFER * BASE_BUFFER_SIZE;
int on = 1; int on = 1;
if (memset_s(&addr, sizeof(addr), 0, sizeof(addr)) != 0) { if (memset_s(&addr, sizeof(addr), 0, sizeof(addr)) != 0) {
...@@ -211,32 +260,32 @@ static void ParseUevent(const char *buf, struct Uevent *event) ...@@ -211,32 +260,32 @@ static void ParseUevent(const char *buf, struct Uevent *event)
{ {
InitUevent(event); InitUevent(event);
while (*buf) { while (*buf) {
if (strncmp(buf, "ACTION=", 7) == 0) { if (strncmp(buf, "ACTION=", EVENT_ACTION) == 0) {
buf += 7; buf += EVENT_ACTION;
event->action = buf; event->action = buf;
} else if (strncmp(buf, "DEVPATH=", 8) == 0) { } else if (strncmp(buf, "DEVPATH=", EVENT_DEVPATH) == 0) {
buf += 8; buf += EVENT_DEVPATH;
event->path = buf; event->path = buf;
} else if (strncmp(buf, "SUBSYSTEM=", 10) == 0) { } else if (strncmp(buf, "SUBSYSTEM=", EVENT_SYSTEM) == 0) {
buf += 10; buf += EVENT_SYSTEM;
event->subsystem = buf; event->subsystem = buf;
} else if (strncmp(buf, "FIRMWARE=", 9) == 0) { } else if (strncmp(buf, "FIRMWARE=", EVENT_FIRMWARE) == 0) {
buf += 9; buf += EVENT_FIRMWARE;
event->firmware = buf; event->firmware = buf;
} else if (strncmp(buf, "MAJOR=", 6) == 0) { } else if (strncmp(buf, "MAJOR=", EVENT_MAJOR) == 0) {
buf += 6; buf += EVENT_MAJOR;
event->major = atoi(buf); event->major = atoi(buf);
} else if (strncmp(buf, "MINOR=", 6) == 0) { } else if (strncmp(buf, "MINOR=", EVENT_MINOR) == 0) {
buf += 6; buf += EVENT_MINOR;
event->minor = atoi(buf); event->minor = atoi(buf);
} else if (strncmp(buf, "PARTN=", 6) == 0) { } else if (strncmp(buf, "PARTN=", EVENT_PARTN) == 0) {
buf += 6; buf += EVENT_PARTN;
event->partitionNum = atoi(buf); event->partitionNum = atoi(buf);
} else if (strncmp(buf, "PARTNAME=", 9) == 0) { } else if (strncmp(buf, "PARTNAME=", EVENT_PART_NAME) == 0) {
buf += 9; buf += EVENT_PART_NAME;
event->partitionName = buf; event->partitionName = buf;
} else if (strncmp(buf, "DEVNAME=", 8) == 0) { } else if (strncmp(buf, "DEVNAME=", EVENT_DEV_NAME) == 0) {
buf += 8; buf += EVENT_DEV_NAME;
event->deviceName = buf; event->deviceName = buf;
} }
// Drop reset. // Drop reset.
...@@ -293,24 +342,17 @@ static char **ParsePlatformBlockDevice(const struct Uevent *uevent) ...@@ -293,24 +342,17 @@ static char **ParsePlatformBlockDevice(const struct Uevent *uevent)
const char *device; const char *device;
char *slash = NULL; char *slash = NULL;
const char *type; const char *type;
char linkPath[256]; char linkPath[MAX_BUFFER];
int linkNum = 0; int linkNum = 0;
char *p = NULL; char *p = NULL;
struct PlatformNode *pDev = FindPlatformDevice(uevent->path); struct PlatformNode *pDev = FindPlatformDevice(uevent->path);
if (pDev) { CHECK_RESULT_DONE(pDev, device = pDev->name; type = "platform", printf("Non platform device.\n"); return NULL);
device = pDev->name; char **links = malloc(sizeof(char *) * LINK_NUMBER);
type = "platform";
} else {
printf("Non platform device.\n");
return NULL;
}
char **links = malloc(sizeof(char *) * 4);
if (!links) { if (!links) {
return NULL; return NULL;
} }
if (memset_s(links, sizeof(char *) * 4, 0, sizeof(char *) * 4) != 0) { if (memset_s(links, sizeof(char *) * LINK_NUMBER, 0, sizeof(char *) * LINK_NUMBER) != 0) {
return NULL; return NULL;
} }
printf("found %s device %s\n", type, device); printf("found %s device %s\n", type, device);
...@@ -351,7 +393,7 @@ static void MakeDevice(const char *devpath, const char *path, int block, int maj ...@@ -351,7 +393,7 @@ static void MakeDevice(const char *devpath, const char *path, int block, int maj
/* Only for super user */ /* Only for super user */
gid_t gid = 0; gid_t gid = 0;
dev_t dev; dev_t dev;
mode_t mode = 0600; mode_t mode = DEFAULT_NO_AUTHORITY_MODE;
mode |= (block ? S_IFBLK : S_IFCHR); mode |= (block ? S_IFBLK : S_IFCHR);
dev = makedev(major, minor); dev = makedev(major, minor);
setegid(gid); setegid(gid);
...@@ -402,7 +444,7 @@ int MkdirRecursive(const char *pathName, mode_t mode) ...@@ -402,7 +444,7 @@ int MkdirRecursive(const char *pathName, mode_t mode)
void RemoveLink(const char *oldpath, const char *newpath) void RemoveLink(const char *oldpath, const char *newpath)
{ {
char path[256]; char path[MAX_BUFFER];
ssize_t ret = readlink(newpath, path, sizeof(path) - 1); ssize_t ret = readlink(newpath, path, sizeof(path) - 1);
if (ret <= 0) { if (ret <= 0) {
return; return;
...@@ -415,7 +457,7 @@ void RemoveLink(const char *oldpath, const char *newpath) ...@@ -415,7 +457,7 @@ void RemoveLink(const char *oldpath, const char *newpath)
static void MakeLink(const char *oldPath, const char *newPath) static void MakeLink(const char *oldPath, const char *newPath)
{ {
char buf[256]; char buf[MAX_BUFFER];
char *slash = strrchr(newPath, '/'); char *slash = strrchr(newPath, '/');
if (!slash) { if (!slash) {
return; return;
...@@ -428,7 +470,7 @@ static void MakeLink(const char *oldPath, const char *newPath) ...@@ -428,7 +470,7 @@ static void MakeLink(const char *oldPath, const char *newPath)
return; return;
} }
buf[width] = 0; buf[width] = 0;
int ret = MkdirRecursive(buf, 0755); int ret = MkdirRecursive(buf, DEFAULT_DIR_MODE);
if (ret) { if (ret) {
printf("Failed to create directory %s: %s (%d)\n", buf, strerror(errno), errno); printf("Failed to create directory %s: %s (%d)\n", buf, strerror(errno), errno);
} }
...@@ -438,12 +480,11 @@ static void MakeLink(const char *oldPath, const char *newPath) ...@@ -438,12 +480,11 @@ static void MakeLink(const char *oldPath, const char *newPath)
} }
} }
static void HandleDevice(const char *action, const char *devpath, const char *path, int block, int major, static void HandleDevice(struct Uevent *event, const char *devpath, int block, char **links)
int minor, char **links)
{ {
int i; int i;
if (!strcmp(action, "add")) { if (!strcmp(event->action, "add")) {
MakeDevice(devpath, path, block, major, minor); MakeDevice(devpath, event->path, block, event->major, event->minor);
if (links) { if (links) {
for (i = 0; links[i]; i++) { for (i = 0; links[i]; i++) {
MakeLink(devpath, links[i]); MakeLink(devpath, links[i]);
...@@ -451,7 +492,7 @@ static void HandleDevice(const char *action, const char *devpath, const char *pa ...@@ -451,7 +492,7 @@ static void HandleDevice(const char *action, const char *devpath, const char *pa
} }
} }
if (!strcmp(action, "remove")) { if (!strcmp(event->action, "remove")) {
if (links) { if (links) {
for (i = 0; links[i]; i++) { for (i = 0; links[i]; i++) {
RemoveLink(devpath, links[i]); RemoveLink(devpath, links[i]);
...@@ -471,7 +512,7 @@ static void HandleDevice(const char *action, const char *devpath, const char *pa ...@@ -471,7 +512,7 @@ static void HandleDevice(const char *action, const char *devpath, const char *pa
static void HandleBlockDevice(struct Uevent *event) static void HandleBlockDevice(struct Uevent *event)
{ {
const char *base = "/dev/block"; const char *base = "/dev/block";
char devpath[96]; char devpath[MAX_DEV_PATH];
char **links = NULL; char **links = NULL;
if (event->major < 0 || event->minor < 0) { if (event->major < 0 || event->minor < 0) {
...@@ -482,17 +523,17 @@ static void HandleBlockDevice(struct Uevent *event) ...@@ -482,17 +523,17 @@ static void HandleBlockDevice(struct Uevent *event)
return; return;
} }
name++; name++;
if (strlen(name) > 64) { // too long if (strlen(name) > MAX_DEVICE_LEN) { // too long
return; return;
} }
if (snprintf_s(devpath, sizeof(devpath), sizeof(devpath), "%s/%s", base, name) == -1) { if (snprintf_s(devpath, sizeof(devpath), sizeof(devpath), "%s/%s", base, name) == -1) {
return; return;
} }
MakeDir(base, 0755); MakeDir(base, DEFAULT_DIR_MODE);
if (!strncmp(event->path, "/devices/", 9)) { if (!strncmp(event->path, "/devices/", DEV_PLAT_FORM)) {
links = ParsePlatformBlockDevice(event); links = ParsePlatformBlockDevice(event);
} }
HandleDevice(event->action, devpath, event->path, 1, event->major, event->minor, links); HandleDevice(event, devpath, 1, links);
} }
static void AddPlatformDevice(const char *path) static void AddPlatformDevice(const char *path)
...@@ -500,10 +541,10 @@ static void AddPlatformDevice(const char *path) ...@@ -500,10 +541,10 @@ static void AddPlatformDevice(const char *path)
size_t pathLen = strlen(path); size_t pathLen = strlen(path);
const char *name = path; const char *name = path;
if (!strncmp(path, "/devices/", 9)) { if (!strncmp(path, "/devices/", DEV_PLAT_FORM)) {
name += 9; name += DEV_PLAT_FORM;
if (!strncmp(name, "platform/", 9)) { if (!strncmp(name, "platform/", DEV_PLAT_FORM)) {
name += 9; name += DEV_PLAT_FORM;
} }
} }
printf("adding platform device %s (%s)\n", name, path); printf("adding platform device %s (%s)\n", name, path);
...@@ -567,15 +608,11 @@ static char **GetCharacterDeviceSymlinks(const struct Uevent *uevent) ...@@ -567,15 +608,11 @@ static char **GetCharacterDeviceSymlinks(const struct Uevent *uevent)
int width; int width;
struct PlatformNode *pDev = FindPlatformDevice(uevent->path); struct PlatformNode *pDev = FindPlatformDevice(uevent->path);
if (!pDev) { CHECK_RETURN(pDev, return NULL);
return NULL;
}
char **links = malloc(sizeof(char *) * 2); char **links = malloc(sizeof(char *) * SYS_LINK_NUMBER);
if (!links) { CHECK_RETURN(links, return NULL);
return NULL; if (memset_s(links, sizeof(char *) * SYS_LINK_NUMBER, 0, sizeof(char *) * SYS_LINK_NUMBER) != 0) {
}
if (memset_s(links, sizeof(char *) * 2, 0, sizeof(char *) * 2) != 0) {
return NULL; return NULL;
} }
...@@ -585,11 +622,19 @@ static char **GetCharacterDeviceSymlinks(const struct Uevent *uevent) ...@@ -585,11 +622,19 @@ static char **GetCharacterDeviceSymlinks(const struct Uevent *uevent)
goto err; goto err;
} }
if (!strncmp(parent, "/usb", 4)) { if (!strncmp(parent, "/usb", DEV_USB)) {
/* skip root hub name and device. use device interface */ /* skip root hub name and device. use device interface */
while (*++parent && *parent != '/') {} while (*++parent) {
if (*parent == '/') {
break;
}
}
if (*parent) { if (*parent) {
while (*++parent && *parent != '/') {} while (*++parent) {
if (*parent == '/') {
break;
}
}
} }
if (!*parent) { if (!*parent) {
goto err; goto err;
...@@ -608,7 +653,7 @@ static char **GetCharacterDeviceSymlinks(const struct Uevent *uevent) ...@@ -608,7 +653,7 @@ static char **GetCharacterDeviceSymlinks(const struct Uevent *uevent)
} else { } else {
links[linkNum] = NULL; links[linkNum] = NULL;
} }
mkdir("/dev/usb", 0755); mkdir("/dev/usb", DEFAULT_DIR_MODE);
} else { } else {
goto err; goto err;
} }
...@@ -618,97 +663,106 @@ err: ...@@ -618,97 +663,106 @@ err:
return NULL; return NULL;
} }
static int HandleUsbDevice(const struct Uevent *event, char *devpath, int len)
{
if (event->deviceName) {
/*
* create device node provided by kernel if present
* see drivers/base/core.c
*/
char *p = devpath;
if (snprintf_s(devpath, len, len, "/dev/%s", event->deviceName) == -1) {
return -1;
}
/* skip leading /dev/ */
p += DEVICE_SKIP;
/* build directories */
while (*p) {
if (*p == '/') {
*p = 0;
MakeDir(devpath, DEFAULT_DIR_MODE);
*p = '/';
}
p++;
}
} else {
/* This imitates the file system that would be created
* if we were using devfs instead.
* Minors are broken up into groups of 128, starting at "001"
*/
int busId = event->minor / MINORS_GROUPS + 1;
int deviceId = event->minor % MINORS_GROUPS + 1;
/* build directories */
MakeDir("/dev/bus", DEFAULT_DIR_MODE);
MakeDir("/dev/bus/usb", DEFAULT_DIR_MODE);
if (snprintf_s(devpath, len, len, "/dev/bus/usb/%03d", busId) == -1) {
return -1;
}
MakeDir(devpath, DEFAULT_DIR_MODE);
if (snprintf_s(devpath, len, len, "/dev/bus/usb/%03d/%03d", busId,
deviceId) == -1) {
return -1;
}
}
return 0;
}
static void HandleDeviceEvent(struct Uevent *event, char *devpath, int len, const char *base, const char *name)
{
char **links = NULL;
links = GetCharacterDeviceSymlinks(event);
if (!devpath[0]) {
if (snprintf_s(devpath, len, len, "%s%s", base, name) == -1) {
printf("[Init] snprintf_s err \n");
return;
}
}
HandleDevice(event, devpath, 0, links);
return;
}
static void HandleGenericDevice(struct Uevent *event) static void HandleGenericDevice(struct Uevent *event)
{ {
char *base = NULL; char *base = NULL;
char devpath[96] = {0}; char devpath[MAX_DEV_PATH] = {0};
char **links = NULL; const char *name = ParseDeviceName(event, MAX_DEVICE_LEN);
const char *name = ParseDeviceName(event, 64);
if (!name) { if (!name) {
return; return;
} }
if (!strncmp(event->subsystem, "usb", 3)) { if (!strncmp(event->subsystem, "usb", HANDLE_DEVICE_USB)) {
if (!strcmp(event->subsystem, "usb")) { if (!strcmp(event->subsystem, "usb")) {
if (event->deviceName) { if (HandleUsbDevice(event, devpath, MAX_DEV_PATH) == -1) {
/* return;
* create device node provided by kernel if present
* see drivers/base/core.c
*/
char *p = devpath;
if (snprintf_s(devpath, sizeof(devpath), sizeof(devpath), "/dev/%s", event->deviceName) == -1) {
return;
}
/* skip leading /dev/ */
p += 5;
/* build directories */
while (*p) {
if (*p == '/') {
*p = 0;
MakeDir(devpath, 0755);
*p = '/';
}
p++;
}
} else {
/* This imitates the file system that would be created
* if we were using devfs instead.
* Minors are broken up into groups of 128, starting at "001"
*/
int busId = event->minor / 128 + 1;
int deviceId = event->minor % 128 + 1;
/* build directories */
MakeDir("/dev/bus", 0755);
MakeDir("/dev/bus/usb", 0755);
if (snprintf_s(devpath, sizeof(devpath), sizeof(devpath), "/dev/bus/usb/%03d", busId) == -1) {
return;
}
MakeDir(devpath, 0755);
if (snprintf_s(devpath, sizeof(devpath), sizeof(devpath), "/dev/bus/usb/%03d/%03d", busId,
deviceId) == -1) {
return;
}
} }
} else { } else {
/* ignore other USB events */ /* ignore other USB events */
return; return;
} }
} else if (!strncmp(event->subsystem, "graphics", 8)) { } else if (!strncmp(event->subsystem, "graphics", DEV_GRAPHICS)) {
base = "/dev/graphics/"; base = "/dev/graphics/";
MakeDir(base, 0755); MakeDir(base, DEFAULT_DIR_MODE);
} else if (!strncmp(event->subsystem, "drm", 3)) { } else if (!strncmp(event->subsystem, "drm", DEV_DRM)) {
base = "/dev/dri/"; base = "/dev/dri/";
MakeDir(base, 0755); MakeDir(base, DEFAULT_DIR_MODE);
} else if (!strncmp(event->subsystem, "oncrpc", 6)) { } else if (!strncmp(event->subsystem, "oncrpc", DEV_ONCRPC)) {
base = "/dev/oncrpc/"; base = "/dev/oncrpc/";
MakeDir(base, 0755); MakeDir(base, DEFAULT_DIR_MODE);
} else if (!strncmp(event->subsystem, "adsp", 4)) { } else if (!strncmp(event->subsystem, "adsp", DEV_ADSP)) {
base = "/dev/adsp/"; base = "/dev/adsp/";
MakeDir(base, 0755); MakeDir(base, DEFAULT_DIR_MODE);
} else if (!strncmp(event->subsystem, "input", 5)) { } else if (!strncmp(event->subsystem, "input", DEV_INPUT)) {
base = "/dev/input/"; base = "/dev/input/";
MakeDir(base, 0755); MakeDir(base, DEFAULT_DIR_MODE);
} else if (!strncmp(event->subsystem, "mtd", 3)) { } else if (!strncmp(event->subsystem, "mtd", DEV_MTD)) {
base = "/dev/mtd/"; base = "/dev/mtd/";
MakeDir(base, 0755); MakeDir(base, DEFAULT_DIR_MODE);
} else if (!strncmp(event->subsystem, "sound", 5)) { } else if (!strncmp(event->subsystem, "sound", DEV_SOUND)) {
base = "/dev/snd/"; base = "/dev/snd/";
MakeDir(base, 0755); MakeDir(base, DEFAULT_DIR_MODE);
} else if (!strncmp(event->subsystem, "misc", 4) && !strncmp(name, "log_", 4)) {
base = "/dev/log/";
MakeDir(base, 0755);
name += 4;
} else { } else {
base = "/dev/"; base = "/dev/";
} }
links = GetCharacterDeviceSymlinks(event); HandleDeviceEvent(event, devpath, MAX_DEV_PATH, base, name);
if (!devpath[0]) { return;
if (snprintf_s(devpath, sizeof(devpath), sizeof(devpath), "%s%s", base, name) == -1) {
return;
}
}
HandleDevice(event->action, devpath, event->path, 0,
event->major, event->minor, links);
} }
static void HandleDeviceUevent(struct Uevent *event) static void HandleDeviceUevent(struct Uevent *event)
...@@ -716,9 +770,9 @@ static void HandleDeviceUevent(struct Uevent *event) ...@@ -716,9 +770,9 @@ static void HandleDeviceUevent(struct Uevent *event)
if (strcmp(event->action, "add") == 0 || strcmp(event->action, "change") == 0) { if (strcmp(event->action, "add") == 0 || strcmp(event->action, "change") == 0) {
/* Do nothing for now */ /* Do nothing for now */
} }
if (strncmp(event->subsystem, "block", 5) == 0) { if (strncmp(event->subsystem, "block", EVENT_BLOCK) == 0) {
HandleBlockDevice(event); HandleBlockDevice(event);
} else if (strncmp(event->subsystem, "platform", 8) == 0) { } else if (strncmp(event->subsystem, "platform", EVENT_PLAT_FORM) == 0) {
HandlePlatformDevice(event); HandlePlatformDevice(event);
} else { } else {
HandleGenericDevice(event); HandleGenericDevice(event);
...@@ -727,11 +781,11 @@ static void HandleDeviceUevent(struct Uevent *event) ...@@ -727,11 +781,11 @@ static void HandleDeviceUevent(struct Uevent *event)
static void HandleUevent() static void HandleUevent()
{ {
char buf[1024 + 2]; char buf[EVENT_MAX_BUFFER];
int ret; int ret;
struct Uevent event; struct Uevent event;
while ((ret = ReadUevent(g_ueventFD, buf, 1024)) > 0) { while ((ret = ReadUevent(g_ueventFD, buf, BASE_BUFFER_SIZE)) > 0) {
if (ret >= 1024) { if (ret >= BASE_BUFFER_SIZE) {
continue; continue;
} }
buf[ret] = '\0'; buf[ret] = '\0';
...@@ -760,7 +814,7 @@ void UeventInit() ...@@ -760,7 +814,7 @@ void UeventInit()
return; return;
} }
int main(int argc, char **argv) int main(const int argc, const char **argv)
{ {
printf("Uevent demo starting...\n"); printf("Uevent demo starting...\n");
UeventInit(); UeventInit();
......
...@@ -135,7 +135,7 @@ public: ...@@ -135,7 +135,7 @@ public:
** @tc.type: FUNC ** @tc.type: FUNC
** @tc.require: AR000F733F ** @tc.require: AR000F733F
**/ **/
HWTEST_F(StartupInitUTest, cmdFuncParseCmdTest_001, TestSize.Level1) HWTEST_F(StartupInitUTest, cmdFuncParseCmdTest_001, TestSize.Level0)
{ {
// do not crash // do not crash
ParseCmdLine(nullptr, nullptr); ParseCmdLine(nullptr, nullptr);
...@@ -147,7 +147,7 @@ HWTEST_F(StartupInitUTest, cmdFuncParseCmdTest_001, TestSize.Level1) ...@@ -147,7 +147,7 @@ HWTEST_F(StartupInitUTest, cmdFuncParseCmdTest_001, TestSize.Level1)
** @tc.type: FUNC ** @tc.type: FUNC
** @tc.require: AR000F733F ** @tc.require: AR000F733F
**/ **/
HWTEST_F(StartupInitUTest, cmdFuncParseCmdTest_002, TestSize.Level1) HWTEST_F(StartupInitUTest, cmdFuncParseCmdTest_002, TestSize.Level0)
{ {
CmdLine curCmdLine; CmdLine curCmdLine;
memset_s(&curCmdLine, sizeof(curCmdLine), 0, sizeof(curCmdLine)); memset_s(&curCmdLine, sizeof(curCmdLine), 0, sizeof(curCmdLine));
...@@ -175,7 +175,7 @@ HWTEST_F(StartupInitUTest, cmdFuncParseCmdTest_002, TestSize.Level1) ...@@ -175,7 +175,7 @@ HWTEST_F(StartupInitUTest, cmdFuncParseCmdTest_002, TestSize.Level1)
** @tc.type: FUNC ** @tc.type: FUNC
** @tc.require: AR000F733F ** @tc.require: AR000F733F
**/ **/
HWTEST_F(StartupInitUTest, cmdFuncParseCmdTest_003, TestSize.Level1) HWTEST_F(StartupInitUTest, cmdFuncParseCmdTest_003, TestSize.Level0)
{ {
CmdLine curCmdLine; CmdLine curCmdLine;
memset_s(&curCmdLine, sizeof(curCmdLine), 0, sizeof(curCmdLine)); memset_s(&curCmdLine, sizeof(curCmdLine), 0, sizeof(curCmdLine));
...@@ -193,7 +193,7 @@ HWTEST_F(StartupInitUTest, cmdFuncParseCmdTest_003, TestSize.Level1) ...@@ -193,7 +193,7 @@ HWTEST_F(StartupInitUTest, cmdFuncParseCmdTest_003, TestSize.Level1)
** @tc.type: FUNC ** @tc.type: FUNC
** @tc.require: AR000F733F ** @tc.require: AR000F733F
**/ **/
HWTEST_F(StartupInitUTest, cmdFuncParseCmdTest_004, TestSize.Level1) HWTEST_F(StartupInitUTest, cmdFuncParseCmdTest_004, TestSize.Level0)
{ {
CmdLine curCmdLine; CmdLine curCmdLine;
memset_s(&curCmdLine, sizeof(curCmdLine), 0, sizeof(curCmdLine)); memset_s(&curCmdLine, sizeof(curCmdLine), 0, sizeof(curCmdLine));
...@@ -234,7 +234,7 @@ HWTEST_F(StartupInitUTest, cmdFuncParseCmdTest_004, TestSize.Level1) ...@@ -234,7 +234,7 @@ HWTEST_F(StartupInitUTest, cmdFuncParseCmdTest_004, TestSize.Level1)
** @tc.type: FUNC ** @tc.type: FUNC
** @tc.require: AR000F733E ** @tc.require: AR000F733E
**/ **/
HWTEST_F(StartupInitUTest, cmdFuncParseCmdTest_005, TestSize.Level1) HWTEST_F(StartupInitUTest, cmdFuncParseCmdTest_005, TestSize.Level0)
{ {
CmdLine curCmdLine; CmdLine curCmdLine;
memset_s(&curCmdLine, sizeof(curCmdLine), 0, sizeof(curCmdLine)); memset_s(&curCmdLine, sizeof(curCmdLine), 0, sizeof(curCmdLine));
...@@ -266,7 +266,7 @@ HWTEST_F(StartupInitUTest, cmdFuncParseCmdTest_005, TestSize.Level1) ...@@ -266,7 +266,7 @@ HWTEST_F(StartupInitUTest, cmdFuncParseCmdTest_005, TestSize.Level1)
** @tc.type: FUNC ** @tc.type: FUNC
** @tc.require: AR000F733E ** @tc.require: AR000F733E
**/ **/
HWTEST_F(StartupInitUTest, cmdFuncDoCmdTest_001, TestSize.Level1) HWTEST_F(StartupInitUTest, cmdFuncDoCmdTest_001, TestSize.Level0)
{ {
// do not crash here // do not crash here
DoCmd(nullptr); DoCmd(nullptr);
...@@ -278,7 +278,7 @@ HWTEST_F(StartupInitUTest, cmdFuncDoCmdTest_001, TestSize.Level1) ...@@ -278,7 +278,7 @@ HWTEST_F(StartupInitUTest, cmdFuncDoCmdTest_001, TestSize.Level1)
** @tc.type: FUNC ** @tc.type: FUNC
** @tc.require: AR000F733E ** @tc.require: AR000F733E
**/ **/
HWTEST_F(StartupInitUTest, cmdFuncDoCmdTest_002, TestSize.Level1) HWTEST_F(StartupInitUTest, cmdFuncDoCmdTest_002, TestSize.Level0)
{ {
CmdLine curCmdLine; CmdLine curCmdLine;
memset_s(&curCmdLine, sizeof(curCmdLine), 0, sizeof(curCmdLine)); memset_s(&curCmdLine, sizeof(curCmdLine), 0, sizeof(curCmdLine));
...@@ -297,7 +297,7 @@ HWTEST_F(StartupInitUTest, cmdFuncDoCmdTest_002, TestSize.Level1) ...@@ -297,7 +297,7 @@ HWTEST_F(StartupInitUTest, cmdFuncDoCmdTest_002, TestSize.Level1)
** @tc.type: FUNC ** @tc.type: FUNC
** @tc.require: AR000F733E ** @tc.require: AR000F733E
**/ **/
HWTEST_F(StartupInitUTest, cmdFuncDoCmdTest_003, TestSize.Level1) HWTEST_F(StartupInitUTest, cmdFuncDoCmdTest_003, TestSize.Level0)
{ {
CmdLine curCmdLine; CmdLine curCmdLine;
memset_s(&curCmdLine, sizeof(curCmdLine), 0, sizeof(curCmdLine)); memset_s(&curCmdLine, sizeof(curCmdLine), 0, sizeof(curCmdLine));
...@@ -341,7 +341,7 @@ HWTEST_F(StartupInitUTest, cmdFuncDoCmdTest_003, TestSize.Level1) ...@@ -341,7 +341,7 @@ HWTEST_F(StartupInitUTest, cmdFuncDoCmdTest_003, TestSize.Level1)
** @tc.type: FUNC ** @tc.type: FUNC
** @tc.require: AR000F732P ** @tc.require: AR000F732P
**/ **/
HWTEST_F(StartupInitUTest, cmdFuncDoCmdTest_004, TestSize.Level1) HWTEST_F(StartupInitUTest, cmdFuncDoCmdTest_004, TestSize.Level0)
{ {
CmdLine curCmdLine; CmdLine curCmdLine;
memset_s(&curCmdLine, sizeof(curCmdLine), 0, sizeof(curCmdLine)); memset_s(&curCmdLine, sizeof(curCmdLine), 0, sizeof(curCmdLine));
...@@ -393,7 +393,7 @@ HWTEST_F(StartupInitUTest, cmdFuncDoCmdTest_004, TestSize.Level1) ...@@ -393,7 +393,7 @@ HWTEST_F(StartupInitUTest, cmdFuncDoCmdTest_004, TestSize.Level1)
** @tc.type: FUNC ** @tc.type: FUNC
** @tc.require: AR000F732P ** @tc.require: AR000F732P
**/ **/
HWTEST_F(StartupInitUTest, cmdFuncDoCmdTest_005, TestSize.Level1) HWTEST_F(StartupInitUTest, cmdFuncDoCmdTest_005, TestSize.Level0)
{ {
CmdLine curCmdLine; CmdLine curCmdLine;
memset_s(&curCmdLine, sizeof(curCmdLine), 0, sizeof(curCmdLine)); memset_s(&curCmdLine, sizeof(curCmdLine), 0, sizeof(curCmdLine));
...@@ -434,7 +434,7 @@ HWTEST_F(StartupInitUTest, cmdFuncDoCmdTest_005, TestSize.Level1) ...@@ -434,7 +434,7 @@ HWTEST_F(StartupInitUTest, cmdFuncDoCmdTest_005, TestSize.Level1)
** @tc.type: FUNC ** @tc.type: FUNC
** @tc.require: AR000F732P ** @tc.require: AR000F732P
**/ **/
HWTEST_F(StartupInitUTest, cmdFuncDoCmdTest_006, TestSize.Level1) HWTEST_F(StartupInitUTest, cmdFuncDoCmdTest_006, TestSize.Level0)
{ {
CmdLine curCmdLine; CmdLine curCmdLine;
...@@ -499,7 +499,7 @@ HWTEST_F(StartupInitUTest, cmdFuncDoCmdTest_006, TestSize.Level1) ...@@ -499,7 +499,7 @@ HWTEST_F(StartupInitUTest, cmdFuncDoCmdTest_006, TestSize.Level1)
** @tc.type: FUNC ** @tc.type: FUNC
** @tc.require: AR000F733F ** @tc.require: AR000F733F
**/ **/
HWTEST_F(StartupInitUTest, cfgCheckStat_001, TestSize.Level1) HWTEST_F(StartupInitUTest, cfgCheckStat_001, TestSize.Level0)
{ {
struct stat fileStat = {0}; struct stat fileStat = {0};
EXPECT_EQ(0, stat(CFG_FILE.c_str(), &fileStat)); EXPECT_EQ(0, stat(CFG_FILE.c_str(), &fileStat));
...@@ -764,7 +764,7 @@ static void CheckJobs(const cJSON* fileRoot) ...@@ -764,7 +764,7 @@ static void CheckJobs(const cJSON* fileRoot)
** @tc.type: FUNC ** @tc.type: FUNC
** @tc.require: AR000F733F ** @tc.require: AR000F733F
**/ **/
HWTEST_F(StartupInitUTest, cfgCheckContent_001, TestSize.Level1) HWTEST_F(StartupInitUTest, cfgCheckContent_001, TestSize.Level0)
{ {
char* fileBuf = ReadFileToBuf(); char* fileBuf = ReadFileToBuf();
if (fileBuf == nullptr) { if (fileBuf == nullptr) {
...@@ -814,7 +814,7 @@ static void CreateIllegalCfg() ...@@ -814,7 +814,7 @@ static void CreateIllegalCfg()
* @tc.type: FUNC * @tc.type: FUNC
* @tc.require: AR000F861Q * @tc.require: AR000F861Q
*/ */
HWTEST_F(StartupInitUTest, cmdFuncDoLoadCfgTest_001, TestSize.Level1) HWTEST_F(StartupInitUTest, cmdFuncDoLoadCfgTest_001, TestSize.Level0)
{ {
CmdLine curCmdLine; CmdLine curCmdLine;
memset_s(&curCmdLine, sizeof(curCmdLine), 0, sizeof(curCmdLine)); memset_s(&curCmdLine, sizeof(curCmdLine), 0, sizeof(curCmdLine));
...@@ -830,7 +830,7 @@ HWTEST_F(StartupInitUTest, cmdFuncDoLoadCfgTest_001, TestSize.Level1) ...@@ -830,7 +830,7 @@ HWTEST_F(StartupInitUTest, cmdFuncDoLoadCfgTest_001, TestSize.Level1)
* @tc.type: FUNC * @tc.type: FUNC
* @tc.require: AR000F861Q * @tc.require: AR000F861Q
*/ */
HWTEST_F(StartupInitUTest, cmdFuncDoLoadCfgTest_002, TestSize.Level1) HWTEST_F(StartupInitUTest, cmdFuncDoLoadCfgTest_002, TestSize.Level0)
{ {
CmdLine curCmdLine; CmdLine curCmdLine;
std::string cmdStr = "loadcfg "; std::string cmdStr = "loadcfg ";
...@@ -868,7 +868,7 @@ HWTEST_F(StartupInitUTest, cmdFuncDoLoadCfgTest_002, TestSize.Level1) ...@@ -868,7 +868,7 @@ HWTEST_F(StartupInitUTest, cmdFuncDoLoadCfgTest_002, TestSize.Level1)
* @tc.type: FUNC * @tc.type: FUNC
* @tc.require: AR000F861Q * @tc.require: AR000F861Q
*/ */
HWTEST_F(StartupInitUTest, cmdFuncDoLoadCfgTest_003, TestSize.Level1) HWTEST_F(StartupInitUTest, cmdFuncDoLoadCfgTest_003, TestSize.Level0)
{ {
CmdLine curCmdLine; CmdLine curCmdLine;
std::string cmdStr = "loadcfg "; std::string cmdStr = "loadcfg ";
...@@ -916,7 +916,7 @@ HWTEST_F(StartupInitUTest, cmdFuncDoLoadCfgTest_003, TestSize.Level1) ...@@ -916,7 +916,7 @@ HWTEST_F(StartupInitUTest, cmdFuncDoLoadCfgTest_003, TestSize.Level1)
* @tc.type: FUNC * @tc.type: FUNC
* @tc.require: AR000F733F * @tc.require: AR000F733F
*/ */
HWTEST_F(StartupInitUTest, cmdJobTest_001, TestSize.Level1) HWTEST_F(StartupInitUTest, cmdJobTest_001, TestSize.Level0)
{ {
// functions do not crash // functions do not crash
ParseAllJobs(nullptr); ParseAllJobs(nullptr);
...@@ -938,7 +938,7 @@ HWTEST_F(StartupInitUTest, cmdJobTest_001, TestSize.Level1) ...@@ -938,7 +938,7 @@ HWTEST_F(StartupInitUTest, cmdJobTest_001, TestSize.Level1)
* @tc.type: FUNC * @tc.type: FUNC
* @tc.require: AR000F733F * @tc.require: AR000F733F
*/ */
HWTEST_F(StartupInitUTest, cmdJobTest_002, TestSize.Level1) HWTEST_F(StartupInitUTest, cmdJobTest_002, TestSize.Level0)
{ {
std::string cfgJson = "{\"jobs\":[{\"name\":\"pre-init\",\"cmds\":[\"mkdir " + std::string cfgJson = "{\"jobs\":[{\"name\":\"pre-init\",\"cmds\":[\"mkdir " +
PRE_INIT_DIR + "\"]},{\"name\":\"init\",\"cmds\":[\"mkdir " + INIT_DIR + PRE_INIT_DIR + "\"]},{\"name\":\"init\",\"cmds\":[\"mkdir " + INIT_DIR +
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册