1 From bdcbb0e78bbffe45719d0a27954544120f37442a 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 Upstream-Status: Pending
22 Signed-off-by: Tim Orling <timothy.t.orling@linux.intel.com>
23 [updated for ptest-runner 2.3.2]
24 [updated for ptest-runner 2.4.1]
25 [updated for ptest-runner 2.4.2]
26 [updated for ptest-runner 2.4.4]
27 Signed-off-by: Scott Murray <scott.murray@konsulko.com>
29 flags.h | 10 ++++++++++
31 utils.c | 20 +++++++++++++++++++-
33 4 files changed, 38 insertions(+), 3 deletions(-)
34 create mode 100644 flags.h
36 diff --git a/flags.h b/flags.h
38 index 0000000..0dac223
42 +/* SPDX-License-Identifier: GPL-2.0 */
44 +/* Flag bit definitions */
49 +#define LAVA_SIGNAL_ENABLE (0x0001)
51 +#endif /* __FLAGS_H__ */
52 diff --git a/main.c b/main.c
53 index 31e4dd5..f12d6d6 100644
62 #ifndef DEFAULT_DIRECTORY
63 #define DEFAULT_DIRECTORY "/usr/lib"
64 @@ -130,8 +131,9 @@ main(int argc, char *argv[])
65 opts.timeout = DEFAULT_TIMEOUT;
67 opts.xml_filename = NULL;
70 - while ((opt = getopt(argc, argv, "d:e:lt:x:h")) != -1) {
71 + while ((opt = getopt(argc, argv, "d:e:lt:x:Lh")) != -1) {
75 @@ -156,6 +158,11 @@ main(int argc, char *argv[])
76 opts.xml_filename = strdup(optarg);
77 CHECK_ALLOCATION(opts.xml_filename, 1, 1);
80 + // set LAVA signal mode
81 + opts.flags |= LAVA_SIGNAL_ENABLE;
82 + fprintf(stdout, "LAVA_SIGNAL_ENABLE == %d\n", opts.flags);
85 print_usage(stdout, argv[0]);
87 diff --git a/utils.c b/utils.c
88 index 6cf7705..f6a3a2a 100644
93 #include "ptest_list.h"
97 #define GET_STIME_BUF_SIZE 1024
98 #define WAIT_CHILD_BUF_MAX_SIZE 1024
99 @@ -369,6 +370,9 @@ run_ptests(struct ptest_list *head, const struct ptest_options opts,
100 strcpy(ptest_dir, p->run_ptest);
103 + char *ptest = strdup(p->ptest);
104 + CHECK_ALLOCATION(ptest, 1, 1);
106 if (pipe2(pipefd_stdout, 0) == -1) {
107 fprintf(fp, "ERROR: pipe2() failed with: %s.\n", strerror(errno));
109 @@ -425,7 +429,10 @@ run_ptests(struct ptest_list *head, const struct ptest_options opts,
110 do_close(&pipefd_stdout[PIPE_WRITE]);
111 do_close(&pipefd_stderr[PIPE_WRITE]);
113 - time_t start_time= time(NULL);
114 + if (opts.flags & LAVA_SIGNAL_ENABLE) {
115 + fprintf(stdout, "<LAVA_SIGNAL_STARTTC %s>\n", ptest);
117 + time_t start_time = time(NULL);
118 fprintf(fp, "%s\n", get_stime(stime, GET_STIME_BUF_SIZE, start_time));
119 fprintf(fp, "BEGIN: %s\n", ptest_dir);
121 @@ -542,6 +549,16 @@ run_ptests(struct ptest_list *head, const struct ptest_options opts,
123 fprintf(fp, "END: %s\n", ptest_dir);
124 fprintf(fp, "%s\n", get_stime(stime, GET_STIME_BUF_SIZE, end_time));
125 + if (opts.flags & LAVA_SIGNAL_ENABLE) {
126 + char result[5]; // pass\0, fail\0, skip\0
129 + sprintf(result, "fail");
131 + sprintf(result, "pass");
132 + fprintf(stdout, "<LAVA_SIGNAL_ENDTC %s>\n", ptest);
133 + fprintf(stdout, "<LAVA_SIGNAL_TESTCASE TEST_CASE_ID=%s RESULT=%s>\n", ptest, result);
138 @@ -556,6 +573,7 @@ ptest_list_fail2:
139 do_close(&pipefd_stdout[PIPE_WRITE]);
146 diff --git a/utils.h b/utils.h
147 index 04fc666..ad702d8 100644
150 @@ -42,9 +42,9 @@ struct ptest_options {
151 unsigned int timeout;
154 + unsigned int flags;
158 extern void check_allocation1(void *, size_t, char *, int, int);
159 extern struct ptest_list *get_available_ptests(const char *);
160 extern int print_ptests(struct ptest_list *, FILE *);