[yocto] [ptest-runner 8/8] Added <system-err></system-err> to XML

Joshua Lock joshua.g.lock at linux.intel.com
Tue Oct 3 08:31:25 PDT 2017


Is this an evolution of the change in 6/8? Can it be squashed in with 
that patch?

Thanks,

Joshua

On 29/09/17 03:09, Jiwei Sun wrote:
> Signed-off-by: Jiwei Sun <jiwei.sun at windriver.com>
> ---
>   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 @@
>   	</testcase>
>   	<testcase classname='test2' name='run-ptest'>
>   		<failure type='exit_code' message='run-ptest exited with code: 1'></failure>
> -		<system-out>ERROR</system-out>
> +		<system-out>STDOUT ERROR</system-out>
> +		<system-err>STDERR</system-err>
>   	</testcase>
>   </testsuite>
> 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)
>   				"</failure>\n"				\
>   				"\t\t<system-out>%s"			\
>   				"</system-out>\n"			\
> +				"\t\t<system-err>%s"			\
> +				"</system-err>\n"			\
>   				"\t</testcase>\n",
>   				ptest->ptest,
>   				basename(bname),
>   				status,
> -				buf);
> +				bufout,
> +				buferr);
>   		}
>   		else {
>   			fprintf(xh, "\t<testcase classname='%s' name='%s'>\n" \
> @@ -590,11 +606,14 @@ xml_add_case(FILE *xh, int status, struct ptest_entry *ptest, char *buf)
>   				"</failure>\n"				\
>   				"\t\t<system-out>%s"			\
>   				"</system-out>\n"			\
> +				"\t\t<system-err>%s"			\
> +				"</system-err>\n"			\
>   				"\t</testcase>\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
> 



More information about the yocto mailing list