1 From edb252e5dae20869081a22e1e18cde4336c7b31c 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] 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>
25 flags.h | 10 ++++++++++
27 utils.c | 14 ++++++++++++++
29 4 files changed, 33 insertions(+), 2 deletions(-)
30 create mode 100644 flags.h
32 diff --git a/flags.h b/flags.h
34 index 0000000..0dac223
38 +/* SPDX-License-Identifier: GPL-2.0 */
40 +/* Flag bit definitions */
45 +#define LAVA_SIGNAL_ENABLE (0x0001)
47 +#endif /* __FLAGS_H__ */
48 diff --git a/main.c b/main.c
49 index e3a1b69..4807183 100644
58 #ifndef DEFAULT_DIRECTORY
59 #define DEFAULT_DIRECTORY "/usr/lib"
60 @@ -110,8 +111,9 @@ main(int argc, char *argv[])
61 opts.timeout = DEFAULT_TIMEOUT;
63 opts.xml_filename = NULL;
66 - while ((opt = getopt(argc, argv, "d:e:lt:x:h")) != -1) {
67 + while ((opt = getopt(argc, argv, "d:e:lt:x:Lh")) != -1) {
71 @@ -136,6 +138,11 @@ main(int argc, char *argv[])
72 opts.xml_filename = strdup(optarg);
73 CHECK_ALLOCATION(opts.xml_filename, 1, 1);
76 + // set LAVA signal mode
77 + opts.flags |= LAVA_SIGNAL_ENABLE;
78 + fprintf(stdout, "LAVA_SIGNAL_ENABLE == %d\n", opts.flags);
81 print_usage(stdout, argv[0]);
83 diff --git a/utils.c b/utils.c
84 index a4e190e..29f40f3 100644
89 #include "ptest_list.h"
93 #define GET_STIME_BUF_SIZE 1024
94 #define WAIT_CHILD_POLL_TIMEOUT_MS 200
95 @@ -442,6 +443,7 @@ run_ptests(struct ptest_list *head, const struct ptest_options opts,
97 PTEST_LIST_ITERATE_START(head, p)
98 char *ptest_dir = strdup(p->run_ptest);
99 + char *ptest = strdup(p->ptest);
100 if (ptest_dir == NULL) {
103 @@ -480,11 +482,15 @@ run_ptests(struct ptest_list *head, const struct ptest_options opts,
105 int fds[2]; fds[0] = pipefd_stdout[0]; fds[1] = pipefd_stderr[0];
106 FILE *fps[2]; fps[0] = fp; fps[1] = fp_stderr;
107 + char result[5]; // pass\0, fail\0, skip\0
109 if (setpgid(child, pgid) == -1) {
110 fprintf(fp, "ERROR: setpgid() failed, %s\n", strerror(errno));
113 + if (opts.flags & LAVA_SIGNAL_ENABLE) {
114 + fprintf(stdout, "<LAVA_SIGNAL_STARTTC %s>\n", ptest);
117 fprintf(fp, "%s\n", get_stime(stime, GET_STIME_BUF_SIZE, sttime));
118 fprintf(fp, "BEGIN: %s\n", ptest_dir);
119 @@ -506,6 +512,14 @@ run_ptests(struct ptest_list *head, const struct ptest_options opts,
121 fprintf(fp, "END: %s\n", ptest_dir);
122 fprintf(fp, "%s\n", get_stime(stime, GET_STIME_BUF_SIZE, entime));
123 + if (opts.flags & LAVA_SIGNAL_ENABLE) {
125 + sprintf(result, "fail");
127 + sprintf(result, "pass");
128 + fprintf(stdout, "<LAVA_SIGNAL_ENDTC %s>\n", ptest);
129 + fprintf(stdout, "<LAVA_SIGNAL_TESTCASE TEST_CASE_ID=%s RESULT=%s>\n", ptest, result);
132 PTEST_LIST_ITERATE_END
133 fprintf(fp, "STOP: %s\n", progname);
134 diff --git a/utils.h b/utils.h
135 index 39832e6..8137bd6 100644
138 @@ -41,9 +41,9 @@ struct ptest_options {
142 + unsigned int flags;
146 extern void check_allocation1(void *, size_t, char *, int, int);
147 extern struct ptest_list *get_available_ptests(const char *);
148 extern int print_ptests(struct ptest_list *, FILE *);