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 Signed-off-by: Scott Murray <scott.murray@konsulko.com>
28 flags.h | 10 ++++++++++
30 utils.c | 17 ++++++++++++++++-
32 4 files changed, 35 insertions(+), 3 deletions(-)
33 create mode 100644 flags.h
35 diff --git a/flags.h b/flags.h
37 index 0000000..0dac223
41 +/* SPDX-License-Identifier: GPL-2.0 */
43 +/* Flag bit definitions */
48 +#define LAVA_SIGNAL_ENABLE (0x0001)
50 +#endif /* __FLAGS_H__ */
51 diff --git a/main.c b/main.c
52 index 31e4dd5..f12d6d6 100644
61 #ifndef DEFAULT_DIRECTORY
62 #define DEFAULT_DIRECTORY "/usr/lib"
63 @@ -130,8 +131,9 @@ main(int argc, char *argv[])
64 opts.timeout = DEFAULT_TIMEOUT;
66 opts.xml_filename = NULL;
69 - while ((opt = getopt(argc, argv, "d:e:lt:x:h")) != -1) {
70 + while ((opt = getopt(argc, argv, "d:e:lt:x:Lh")) != -1) {
74 @@ -156,6 +158,11 @@ main(int argc, char *argv[])
75 opts.xml_filename = strdup(optarg);
76 CHECK_ALLOCATION(opts.xml_filename, 1, 1);
79 + // set LAVA signal mode
80 + opts.flags |= LAVA_SIGNAL_ENABLE;
81 + fprintf(stdout, "LAVA_SIGNAL_ENABLE == %d\n", opts.flags);
84 print_usage(stdout, argv[0]);
86 diff --git a/utils.c b/utils.c
87 index 59b8b77..30423c4 100644
92 #include "ptest_list.h"
96 #define GET_STIME_BUF_SIZE 1024
97 #define WAIT_CHILD_BUF_MAX_SIZE 1024
98 @@ -425,6 +426,7 @@ run_ptests(struct ptest_list *head, const struct ptest_options opts,
101 char *ptest_dir = strdup(p->run_ptest);
102 + char *ptest = strdup(p->ptest);
103 if (ptest_dir == NULL) {
106 @@ -477,7 +479,10 @@ run_ptests(struct ptest_list *head, const struct ptest_options opts,
107 fprintf(fp, "ERROR: setpgid() failed, %s\n", strerror(errno));
110 - time_t start_time= time(NULL);
111 + if (opts.flags & LAVA_SIGNAL_ENABLE) {
112 + fprintf(stdout, "<LAVA_SIGNAL_STARTTC %s>\n", ptest);
114 + time_t start_time = time(NULL);
115 fprintf(fp, "%s\n", get_stime(stime, GET_STIME_BUF_SIZE, start_time));
116 fprintf(fp, "BEGIN: %s\n", ptest_dir);
118 @@ -594,6 +599,16 @@ run_ptests(struct ptest_list *head, const struct ptest_options opts,
120 fprintf(fp, "END: %s\n", ptest_dir);
121 fprintf(fp, "%s\n", get_stime(stime, GET_STIME_BUF_SIZE, end_time));
122 + if (opts.flags & LAVA_SIGNAL_ENABLE) {
123 + char result[5]; // pass\0, fail\0, skip\0
126 + sprintf(result, "fail");
128 + sprintf(result, "pass");
129 + fprintf(stdout, "<LAVA_SIGNAL_ENDTC %s>\n", ptest);
130 + fprintf(stdout, "<LAVA_SIGNAL_TESTCASE TEST_CASE_ID=%s RESULT=%s>\n", ptest, result);
134 do_close(&pipefd_stdout[PIPE_READ]);
135 diff --git a/utils.h b/utils.h
136 index 04fc666..ad702d8 100644
139 @@ -42,9 +42,9 @@ struct ptest_options {
140 unsigned int timeout;
143 + unsigned int flags;
147 extern void check_allocation1(void *, size_t, char *, int, int);
148 extern struct ptest_list *get_available_ptests(const char *);
149 extern int print_ptests(struct ptest_list *, FILE *);