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>
22 flags.h | 10 ++++++++++
24 utils.c | 15 +++++++++++++++
26 4 files changed, 34 insertions(+), 2 deletions(-)
27 create mode 100644 flags.h
29 diff --git a/flags.h b/flags.h
31 index 000000000000..0dac2234e0b4
35 +/* SPDX-License-Identifier: GPL-2.0 */
37 +/* Flag bit definitions */
42 +#define LAVA_SIGNAL_ENABLE (0x0001)
44 +#endif /* __FLAGS_H__ */
45 diff --git a/main.c b/main.c
46 index 83600b7d1b31..92ced6926c3d 100644
55 #define DEFAULT_DIRECTORY "/usr/lib"
56 #define DEFAULT_TIMEOUT 300
57 @@ -70,8 +71,9 @@ main(int argc, char *argv[])
58 opts.timeout = DEFAULT_TIMEOUT;
60 opts.xml_filename = NULL;
63 - while ((opt = getopt(argc, argv, "d:e:lt:x:h")) != -1) {
64 + while ((opt = getopt(argc, argv, "d:e:lt:x:Lh")) != -1) {
68 @@ -118,6 +120,11 @@ main(int argc, char *argv[])
69 opts.xml_filename = strdup(optarg);
70 CHECK_ALLOCATION(opts.xml_filename, 1, 1);
73 + // set LAVA signal mode
74 + opts.flags |= LAVA_SIGNAL_ENABLE;
75 + fprintf(stdout, "LAVA_SIGNAL_ENABLE == %d\n", opts.flags);
78 print_usage(stdout, argv[0]);
80 diff --git a/utils.c b/utils.c
81 index ed2eff7900c1..0fd1da6aec92 100644
86 #include "ptest_list.h"
90 #define GET_STIME_BUF_SIZE 1024
91 #define WAIT_CHILD_POLL_TIMEOUT_MS 200
92 @@ -358,6 +359,7 @@ run_ptests(struct ptest_list *head, const struct ptest_options opts,
93 fprintf(fp, "START: %s\n", progname);
94 PTEST_LIST_ITERATE_START(head, p);
95 char *ptest_dir = strdup(p->run_ptest);
96 + char *ptest = strdup(p->ptest);
97 if (ptest_dir == NULL) {
100 @@ -376,6 +378,11 @@ run_ptests(struct ptest_list *head, const struct ptest_options opts,
101 int fds[2]; fds[0] = pipefd_stdout[0]; fds[1] = pipefd_stderr[0];
102 FILE *fps[2]; fps[0] = fp; fps[1] = fp_stderr;
104 + char result[5]; // pass\0, fail\0, skip\0
106 + if (opts.flags & LAVA_SIGNAL_ENABLE) {
107 + fprintf(stdout, "<LAVA_SIGNAL_STARTTC %s>\n", ptest);
109 fprintf(fp, "%s\n", get_stime(stime, GET_STIME_BUF_SIZE));
110 fprintf(fp, "BEGIN: %s\n", ptest_dir);
112 @@ -389,6 +396,14 @@ run_ptests(struct ptest_list *head, const struct ptest_options opts,
114 fprintf(fp, "END: %s\n", ptest_dir);
115 fprintf(fp, "%s\n", get_stime(stime, GET_STIME_BUF_SIZE));
116 + if (opts.flags & LAVA_SIGNAL_ENABLE) {
118 + sprintf(result, "fail");
120 + sprintf(result, "pass");
121 + fprintf(stdout, "<LAVA_SIGNAL_ENDTC %s>\n", ptest);
122 + fprintf(stdout, "<LAVA_SIGNAL_TESTCASE TEST_CASE_ID=%s RESULT=%s>\n", ptest, result);
125 PTEST_LIST_ITERATE_END;
126 fprintf(fp, "STOP: %s\n", progname);
127 diff --git a/utils.h b/utils.h
128 index ee85163ddfff..06d4c100d151 100644
131 @@ -37,9 +37,9 @@ struct ptest_options {
135 + unsigned int flags;
139 extern void check_allocation1(void *, size_t, char *, int, int);
140 extern struct ptest_list *get_available_ptests(const char *);
141 extern int print_ptests(struct ptest_list *, FILE *);