Lines Matching defs:resCmd

132 void ParseCmdLine(const char *content, TestCmdLine *resCmd)
134 if (content == nullptr || resCmd == nullptr) {
140 (void)memset_s(resCmd, sizeof(TestCmdLine), 0, sizeof(TestCmdLine));
144 (void)memset_s(resCmd, sizeof(TestCmdLine), 0, sizeof(TestCmdLine));
147 int ret1 = strcpy_s(resCmd->name, MAX_CMD_NAME_LEN, cmd->name);
148 int ret2 = strcpy_s(resCmd->cmdContent, MAX_CMD_CONTENT_LEN, content + strlen(cmd->name));
150 (void)memset_s(resCmd, sizeof(TestCmdLine), 0, sizeof(TestCmdLine));
155 void DoCmd(const TestCmdLine *resCmd)
157 if (resCmd == nullptr) {
161 (void)GetMatchCmd(resCmd->name, &cmdIndex);
162 DoCmdByIndex(cmdIndex, resCmd->cmdContent, nullptr);
669 static void CheckCmd(const TestCmdLine *resCmd)
671 EXPECT_TRUE(strlen(resCmd->name) > 0);
672 EXPECT_TRUE(strlen(resCmd->cmdContent) > 0);
674 if (strcmp("start ", resCmd->name) == 0) {
675 for (size_t i = 0; i < strlen(resCmd->cmdContent); ++i) {
676 EXPECT_NE(' ', resCmd->cmdContent[i]); // no spaces in service name
678 } else if (strcmp("mkdir ", resCmd->name) == 0) {
679 for (size_t i = 0; i < strlen(resCmd->cmdContent); ++i) {
680 EXPECT_NE('.', resCmd->cmdContent[i]); // no dots in path string
682 } else if (strcmp("chmod ", resCmd->name) == 0) {
683 EXPECT_TRUE(strlen(resCmd->cmdContent) >= 6); // 0xxx x at least 6 characters
684 EXPECT_EQ('0', resCmd->cmdContent[0]);
685 EXPECT_EQ(' ', resCmd->cmdContent[4]); // 4 bytes, after 0xxx must be space
687 EXPECT_TRUE(resCmd->cmdContent[i] >= '0' && resCmd->cmdContent[i] <= '7');
689 for (size_t i = 5; i < strlen(resCmd->cmdContent); ++i) { // target starts from index 5
690 EXPECT_NE(' ', resCmd->cmdContent[i]); // no spaces allowed
692 } else if (strcmp("chown ", resCmd->name) == 0) {
693 EXPECT_TRUE(strlen(resCmd->cmdContent) >= 5); // x y z at least 5 characters
694 EXPECT_NE(' ', resCmd->cmdContent[0]); // should not start with space
695 EXPECT_NE(' ', resCmd->cmdContent[strlen(resCmd->cmdContent) - 1]); // should not end with space
698 for (size_t i = 1; i < strlen(resCmd->cmdContent); ++i) {
699 if (resCmd->cmdContent[i] != ' ') {
709 } else if (strcmp("mount ", resCmd->name) == 0) {
710 EXPECT_NE(' ', resCmd->cmdContent[0]); // should not start with space
711 } else if (strcmp("loadcfg ", resCmd->name) == 0) {
712 EXPECT_NE(' ', resCmd->cmdContent[0]); // should not start with space
713 } else if (strcmp("export ", resCmd->name) == 0) {
714 EXPECT_NE(' ', resCmd->cmdContent[0]); // should not start with space
715 } else if (strcmp("exec ", resCmd->name) == 0) {
716 EXPECT_NE(' ', resCmd->cmdContent[0]); // should not start with space
740 TestCmdLine resCmd;
741 (void)memset_s(&resCmd, sizeof(resCmd), 0, sizeof(resCmd));
742 ParseCmdLine(cmdLineStr, &resCmd);
743 CheckCmd(&resCmd);