summaryrefslogtreecommitdiffstats
path: root/lib/xaapiv1/config.go
blob: b1c5fecba4c9c3c2db09354051188024ed0207d8 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
/*
 * Copyright (C) 2017-2018 "IoT.bzh"
 * Author Sebastien Douheret <sebastien@iot.bzh>
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package xaapiv1

// APIConfig parameters (json format) of /config command
type APIConfig struct {
	Servers []ServerCfg `json:"servers"`

	// Not exposed outside in JSON
	Version       string `json:"-"`
	APIVersion    string `json:"-"`
	VersionGitTag string `json:"-"`
}

// ServerCfg .
type ServerCfg struct {
	ID         string `json:"id"`
	URL        string `json:"url"`
	APIURL     string `json:"apiUrl"`
	PartialURL string `json:"partialUrl"`
	ConnRetry  int    `json:"connRetry"`
	Connected  bool   `json:"connected"`
	Disabled   bool   `json:"disabled"`
}
.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */ }
From edb252e5dae20869081a22e1e18cde4336c7b31c Mon Sep 17 00:00:00 2001
From: Tim Orling <timothy.t.orling@linux.intel.com>
Date: Mon, 15 Oct 2018 18:30:42 -0700
Subject: [PATCH] Initial LAVA support

Linaro Automated Validation Architecture (LAVA) launches a test suite
on the target but thereafter only observes stdout.

LAVA knows that a test case has started or ended based on signals
emitted to stdout:
(setup)
<LAVA_SIGNAL_STARTTC test_case_name>
(teardown)
<LAVA_SIGNAL_ENDTC test_case_name>
<LAVA_SIGNAL_TESTCASE TEST_CASE_ID=test_case_name RESULT=pass|fail \
  [[ MEASUREMENT=numeric_measurement ][ UNITS=units_string]]>

It is valid to have a measurement without units, but not units without a measurement.

Signed-off-by: Tim Orling <timothy.t.orling@linux.intel.com>
[updated for ptest-runner 2.3.2]
Signed-off-by: Scott Murray <scott.murray@konsulko.com>

---
 flags.h | 10 ++++++++++
 main.c  |  9 ++++++++-
 utils.c | 14 ++++++++++++++
 utils.h |  2 +-
 4 files changed, 33 insertions(+), 2 deletions(-)
 create mode 100644 flags.h

diff --git a/flags.h b/flags.h
new file mode 100644
index 0000000..0dac223
--- /dev/null
+++ b/flags.h
@@ -0,0 +1,10 @@
+/* SPDX-License-Identifier: GPL-2.0 */
+
+/* Flag bit definitions */
+
+#ifndef __FLAGS_H__
+#define __FLAGS_H__
+
+#define LAVA_SIGNAL_ENABLE	(0x0001)
+
+#endif				/* __FLAGS_H__ */
diff --git a/main.c b/main.c
index e3a1b69..4807183 100644
--- a/main.c
+++ b/main.c
@@ -38,6 +38,7 @@
 #endif
 
 #include "utils.h"
+#include "flags.h"
 
 #ifndef DEFAULT_DIRECTORY
 #define DEFAULT_DIRECTORY "/usr/lib"
@@ -110,8 +111,9 @@ main(int argc, char *argv[])
 	opts.timeout = DEFAULT_TIMEOUT;
 	opts.ptests = NULL;
 	opts.xml_filename = NULL;
+	opts.flags = 0;
 
-	while ((opt = getopt(argc, argv, "d:e:lt:x:h")) != -1) {
+	while ((opt = getopt(argc, argv, "d:e:lt:x:Lh")) != -1) {
 		switch (opt) {
 			case 'd':
 				free(opts.dirs[0]);
@@ -136,6 +138,11 @@ main(int argc, char *argv[])
 				opts.xml_filename = strdup(optarg);
 				CHECK_ALLOCATION(opts.xml_filename, 1, 1);
 			break;
+			case 'L':
+				// set LAVA signal mode
+				opts.flags |= LAVA_SIGNAL_ENABLE;
+				fprintf(stdout, "LAVA_SIGNAL_ENABLE == %d\n", opts.flags);
+			break;
 			default:
 				print_usage(stdout, argv[0]);
 				exit(1);
diff --git a/utils.c b/utils.c
index a4e190e..29f40f3 100644
--- a/utils.c
+++ b/utils.c
@@ -47,6 +47,7 @@
 
 #include "ptest_list.h"
 #include "utils.h"
+#include "flags.h"
 
 #define GET_STIME_BUF_SIZE 1024
 #define WAIT_CHILD_POLL_TIMEOUT_MS 200
@@ -442,6 +443,7 @@ run_ptests(struct ptest_list *head, const struct ptest_options opts,
 		}
 		PTEST_LIST_ITERATE_START(head, p)
 			char *ptest_dir = strdup(p->run_ptest);
+			char *ptest = strdup(p->ptest);
 			if (ptest_dir == NULL) {
 				rc = -1;
 				break;
@@ -480,11 +482,15 @@ run_ptests(struct ptest_list *head, const struct ptest_options opts,
 				int status;
 				int fds[2]; fds[0] = pipefd_stdout[0]; fds[1] = pipefd_stderr[0];
 				FILE *fps[2]; fps[0] = fp; fps[1] = fp_stderr;
+				char result[5]; // pass\0, fail\0, skip\0
 
 				if (setpgid(child, pgid) == -1) {
 					fprintf(fp, "ERROR: setpgid() failed, %s\n", strerror(errno));
 				}
 
+				if (opts.flags & LAVA_SIGNAL_ENABLE) {
+					fprintf(stdout, "<LAVA_SIGNAL_STARTTC %s>\n", ptest);
+				}
 				sttime = time(NULL);
 				fprintf(fp, "%s\n", get_stime(stime, GET_STIME_BUF_SIZE, sttime));
 				fprintf(fp, "BEGIN: %s\n", ptest_dir);
@@ -506,6 +512,14 @@ run_ptests(struct ptest_list *head, const struct ptest_options opts,
 
 				fprintf(fp, "END: %s\n", ptest_dir);
 				fprintf(fp, "%s\n", get_stime(stime, GET_STIME_BUF_SIZE, entime));
+				if (opts.flags & LAVA_SIGNAL_ENABLE) {
+					if (status)
+						sprintf(result, "fail");
+					else
+						sprintf(result, "pass");
+					fprintf(stdout, "<LAVA_SIGNAL_ENDTC %s>\n", ptest);
+					fprintf(stdout, "<LAVA_SIGNAL_TESTCASE TEST_CASE_ID=%s RESULT=%s>\n", ptest, result);
+				}
 			}
 		PTEST_LIST_ITERATE_END
 		fprintf(fp, "STOP: %s\n", progname);
diff --git a/utils.h b/utils.h
index 39832e6..8137bd6 100644
--- a/utils.h
+++ b/utils.h
@@ -41,9 +41,9 @@ struct ptest_options {
 	int timeout;
 	char **ptests;
 	char *xml_filename;
+	unsigned int flags;
 };
 
-
 extern void check_allocation1(void *, size_t, char *, int, int);
 extern struct ptest_list *get_available_ptests(const char *);
 extern int print_ptests(struct ptest_list *, FILE *);