Return-Path: Received: by yocto-www.yoctoproject.org (Postfix, from userid 118) id C0FEEE00D94; Thu, 28 Sep 2017 19:10:43 -0700 (PDT) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on yocto-www.yoctoproject.org X-Spam-Level: X-Spam-Status: No, score=-4.2 required=5.0 tests=BAYES_00,RCVD_IN_DNSWL_MED autolearn=ham version=3.3.1 X-Spam-HAM-Report: * -2.3 RCVD_IN_DNSWL_MED RBL: Sender listed at http://www.dnswl.org/, * medium trust * [147.11.146.13 listed in list.dnswl.org] * -1.9 BAYES_00 BODY: Bayes spam probability is 0 to 1% * [score: 0.0000] Received: from mail1.windriver.com (mail1.windriver.com [147.11.146.13]) by yocto-www.yoctoproject.org (Postfix) with ESMTP id C9A1EE00D91 for ; Thu, 28 Sep 2017 19:10:42 -0700 (PDT) Received: from ALA-HCA.corp.ad.wrs.com (ala-hca.corp.ad.wrs.com [147.11.189.40]) by mail1.windriver.com (8.15.2/8.15.1) with ESMTPS id v8T2AgKE012205 (version=TLSv1 cipher=AES128-SHA bits=128 verify=FAIL); Thu, 28 Sep 2017 19:10:42 -0700 (PDT) Received: from pek-lpd-ccm2.wrs.com (128.224.179.210) by ALA-HCA.corp.ad.wrs.com (147.11.189.50) with Microsoft SMTP Server id 14.3.361.1; Thu, 28 Sep 2017 19:10:41 -0700 From: Jiwei Sun To: Date: Fri, 29 Sep 2017 10:09:40 +0800 Message-ID: <1506650980-87720-8-git-send-email-jiwei.sun@windriver.com> X-Mailer: git-send-email 1.8.3.1 In-Reply-To: <1506650980-87720-1-git-send-email-jiwei.sun@windriver.com> References: <1506650980-87720-1-git-send-email-jiwei.sun@windriver.com> MIME-Version: 1.0 X-Mailman-Approved-At: Fri, 29 Sep 2017 08:40:16 -0700 Cc: anibal.limon@linux.intel.com Subject: [ptest-runner 8/8] Added to XML X-BeenThere: yocto@yoctoproject.org X-Mailman-Version: 2.1.13 Precedence: list List-Id: Discussion of all things Yocto Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 29 Sep 2017 02:10:43 -0000 Content-Type: text/plain Signed-off-by: Jiwei Sun --- tests/data/reference.xml | 3 ++- tests/utils.c | 4 ++-- utils.c | 49 +++++++++++++++++++++++++++++++++--------------- utils.h | 2 +- 4 files changed, 39 insertions(+), 19 deletions(-) diff --git a/tests/data/reference.xml b/tests/data/reference.xml index a23b44b..0dea38c 100644 --- a/tests/data/reference.xml +++ b/tests/data/reference.xml @@ -4,6 +4,7 @@ - ERROR + STDOUT ERROR + STDERR diff --git a/tests/utils.c b/tests/utils.c index bb799f4..230116a 100644 --- a/tests/utils.c +++ b/tests/utils.c @@ -262,9 +262,9 @@ START_TEST(test_xml_pass) ck_assert(xp != NULL); entry.ptest = "test1"; entry.run_ptest = "run-ptest"; - xml_add_case(xp, 0, &entry, ""); + xml_add_case(xp, 0, &entry, "", ""); entry.ptest = "test2"; - xml_add_case(xp, 1, &entry, "ERROR"); + xml_add_case(xp, 1, &entry, "STDOUT ERROR", "STDERR"); xml_finish(xp); FILE *fp, *fr; diff --git a/utils.c b/utils.c index 54ef89d..0f712f9 100644 --- a/utils.c +++ b/utils.c @@ -295,7 +295,8 @@ wait_child(const char *ptest_dir, int timeout, int *fds, FILE **fps, - char *buf) + char *bufout, + char *buferr) { struct pollfd pfds[2]; time_t sentinel; @@ -319,13 +320,13 @@ wait_child(const char *ptest_dir, ssize_t n; if (pfds[0].revents != 0) { - while ((n = read(fds[0], buf, WAIT_CHILD_BUF_MAX_SIZE)) > 0) - fwrite(buf, n, 1, fps[0]); + while ((n = read(fds[0], bufout, WAIT_CHILD_BUF_MAX_SIZE)) > 0) + fwrite(bufout, n, 1, fps[0]); } if (pfds[1].revents != 0) { - while ((n = read(fds[1], buf, WAIT_CHILD_BUF_MAX_SIZE)) > 0) - fwrite(buf, n, 1, fps[1]); + while ((n = read(fds[1], buferr, WAIT_CHILD_BUF_MAX_SIZE)) > 0) + fwrite(buferr, n, 1, fps[1]); } sentinel = time(NULL); @@ -454,13 +455,15 @@ run_ptests(struct ptest_list *head, const struct ptest_options opts, int status; int fds[2]; fds[0] = pipefd_stdout[0]; fds[1] = pipefd_stderr[0]; FILE *fps[2]; fps[0] = fp; fps[1] = fp_stderr; - char buf[WAIT_CHILD_BUF_MAX_SIZE]; + char bufout[WAIT_CHILD_BUF_MAX_SIZE]; + char buferr[WAIT_CHILD_BUF_MAX_SIZE]; // fprintf(fp, "%s\n", get_stime(stime, GET_STIME_BUF_SIZE)); fprintf(fp, "BEGIN: %s\n", ptest_dir); status = wait_child(ptest_dir, p->run_ptest, child, - opts.timeout, fds, fps, buf); + opts.timeout, fds, fps, bufout, + buferr); if (status) rc += 1; @@ -468,7 +471,8 @@ run_ptests(struct ptest_list *head, const struct ptest_options opts, xml_add_case(xh, status, (struct ptest_entry *)p, - buf); + bufout, + buferr); // fprintf(fp, "%s\n", get_stime(stime, GET_STIME_BUF_SIZE)); /* Let non-master gracefully terminate */ @@ -502,14 +506,18 @@ run_ptests(struct ptest_list *head, const struct ptest_options opts, int status; int fds[2]; fds[0] = pipefd_stdout[0]; fds[1] = pipefd_stderr[0]; FILE *fps[2]; fps[0] = fp; fps[1] = fp_stderr; - char buf[WAIT_CHILD_BUF_MAX_SIZE]; + char bufout[WAIT_CHILD_BUF_MAX_SIZE]; + char buferr[WAIT_CHILD_BUF_MAX_SIZE]; + + memset(bufout, 0, sizeof(bufout)); + memset(buferr, 0, sizeof(buferr)); - memset(buf, 0, sizeof(buf)); fprintf(fp, "%s\n", get_stime(stime, GET_STIME_BUF_SIZE)); fprintf(fp, "BEGIN: %s\n", ptest_dir); status = wait_child(ptest_dir, p->run_ptest, child, - opts.timeout, fds, fps, buf); + opts.timeout, fds, fps, bufout, + buferr); if (status) rc += 1; @@ -517,7 +525,8 @@ run_ptests(struct ptest_list *head, const struct ptest_options opts, xml_add_case(xh, status, (struct ptest_entry *)p, - buf); + bufout, + buferr); fprintf(fp, "END: %s\n", ptest_dir); fprintf(fp, "%s\n", get_stime(stime, GET_STIME_BUF_SIZE)); @@ -556,7 +565,11 @@ xml_create(int test_count, char *xml_filename) } void -xml_add_case(FILE *xh, int status, struct ptest_entry *ptest, char *buf) +xml_add_case(FILE *xh, + int status, + struct ptest_entry *ptest, + char *bufout, + char *buferr) { struct flock lock; int fd; @@ -577,11 +590,14 @@ xml_add_case(FILE *xh, int status, struct ptest_entry *ptest, char *buf) "\n" \ "\t\t%s" \ "\n" \ + "\t\t%s" \ + "\n" \ "\t\n", ptest->ptest, basename(bname), status, - buf); + bufout, + buferr); } else { fprintf(xh, "\t\n" \ @@ -590,11 +606,14 @@ xml_add_case(FILE *xh, int status, struct ptest_entry *ptest, char *buf) "\n" \ "\t\t%s" \ "\n" \ + "\t\t%s" \ + "\n" \ "\t\n", ptest->ptest, basename(bname), status, - buf); + bufout, + buferr); } } else { diff --git a/utils.h b/utils.h index 70e2abe..8f2e5b4 100644 --- a/utils.h +++ b/utils.h @@ -48,7 +48,7 @@ extern int run_ptests(struct ptest_list *, const struct ptest_options, const char *, FILE *, FILE *); extern FILE *xml_create(int, char *); -extern void xml_add_case(FILE *, int, struct ptest_entry *, char *); +extern void xml_add_case(FILE *, int, struct ptest_entry *, char *, char *); extern void xml_finish(FILE *); #endif -- 1.8.3.1