1 From 11b29ce444610a07067a89b38e9e85c2162bbf67 Mon Sep 17 00:00:00 2001
2 From: Tim Orling <timothy.t.orling@linux.intel.com>
3 Date: Mon, 15 Oct 2018 18:30:42 -0700
4 Subject: [PATCH 7/7] [WIP] Initial LAVA support
6 Linaro Automated Validation Architecture (LAVA) launches a test suite
7 on the target but thereafter only observes stdout.
9 LAVA knows that a test case has started or ended based on signals
12 <LAVA_SIGNAL_STARTTC test_case_name>
14 <LAVA_SIGNAL_ENDTC test_case_name>
15 <LAVA_SIGNAL_TESTCASE TEST_CASE_ID=test_case_name RESULT=pass|fail \
16 [[ MEASUREMENT=numeric_measurement ][ UNITS=units_string]]>
18 It is valid to have a measurement without units, but not units without a measurement.
20 Signed-off-by: Tim Orling <timothy.t.orling@linux.intel.com>
21 [updated for ptest-runner 2.3.2]
22 Signed-off-by: Scott Murray <scott.murray@konsulko.com>
24 diff --git a/flags.h b/flags.h
26 index 0000000..0dac223
30 +/* SPDX-License-Identifier: GPL-2.0 */
32 +/* Flag bit definitions */
37 +#define LAVA_SIGNAL_ENABLE (0x0001)
39 +#endif /* __FLAGS_H__ */
40 diff --git a/main.c b/main.c
41 index 01d60f7..165370f 100644
50 #ifndef DEFAULT_DIRECTORY
51 #define DEFAULT_DIRECTORY "/usr/lib"
52 @@ -74,8 +75,9 @@ main(int argc, char *argv[])
53 opts.timeout = DEFAULT_TIMEOUT;
55 opts.xml_filename = NULL;
58 - while ((opt = getopt(argc, argv, "d:e:lt:x:h")) != -1) {
59 + while ((opt = getopt(argc, argv, "d:e:lt:x:Lh")) != -1) {
63 @@ -122,6 +124,11 @@ main(int argc, char *argv[])
64 opts.xml_filename = strdup(optarg);
65 CHECK_ALLOCATION(opts.xml_filename, 1, 1);
68 + // set LAVA signal mode
69 + opts.flags |= LAVA_SIGNAL_ENABLE;
70 + fprintf(stdout, "LAVA_SIGNAL_ENABLE == %d\n", opts.flags);
73 print_usage(stdout, argv[0]);
75 diff --git a/utils.c b/utils.c
76 index a8ba190..19f9efa 100644
81 #include "ptest_list.h"
85 #define GET_STIME_BUF_SIZE 1024
86 #define WAIT_CHILD_POLL_TIMEOUT_MS 200
87 @@ -439,6 +440,7 @@ run_ptests(struct ptest_list *head, const struct ptest_options opts,
88 fprintf(fp, "START: %s\n", progname);
89 PTEST_LIST_ITERATE_START(head, p)
90 char *ptest_dir = strdup(p->run_ptest);
91 + char *ptest = strdup(p->ptest);
92 if (ptest_dir == NULL) {
95 @@ -480,11 +482,15 @@ run_ptests(struct ptest_list *head, const struct ptest_options opts,
97 int fds[2]; fds[0] = pipefd_stdout[0]; fds[1] = pipefd_stderr[0];
98 FILE *fps[2]; fps[0] = fp; fps[1] = fp_stderr;
99 + char result[5]; // pass\0, fail\0, skip\0
101 if (setpgid(child, pgid) == -1) {
102 fprintf(fp, "ERROR: setpgid() failed, %s\n", strerror(errno));
105 + if (opts.flags & LAVA_SIGNAL_ENABLE) {
106 + fprintf(stdout, "<LAVA_SIGNAL_STARTTC %s>\n", ptest);
109 fprintf(fp, "%s\n", get_stime(stime, GET_STIME_BUF_SIZE, sttime));
110 fprintf(fp, "BEGIN: %s\n", ptest_dir);
111 @@ -506,6 +512,14 @@ run_ptests(struct ptest_list *head, const struct ptest_options opts,
113 fprintf(fp, "END: %s\n", ptest_dir);
114 fprintf(fp, "%s\n", get_stime(stime, GET_STIME_BUF_SIZE, entime));
115 + if (opts.flags & LAVA_SIGNAL_ENABLE) {
117 + sprintf(result, "fail");
119 + sprintf(result, "pass");
120 + fprintf(stdout, "<LAVA_SIGNAL_ENDTC %s>\n", ptest);
121 + fprintf(stdout, "<LAVA_SIGNAL_TESTCASE TEST_CASE_ID=%s RESULT=%s>\n", ptest, result);
124 PTEST_LIST_ITERATE_END
125 fprintf(fp, "STOP: %s\n", progname);
126 diff --git a/utils.h b/utils.h
127 index aa53707..df11e24 100644
130 @@ -39,9 +39,9 @@ struct ptest_options {
134 + unsigned int flags;
138 extern void check_allocation1(void *, size_t, char *, int, int);
139 extern struct ptest_list *get_available_ptests(const char *);
140 extern int print_ptests(struct ptest_list *, FILE *);