diff mbox

[v3,3/6] Add mechanism to tell FWTS what architecture is being tested

Message ID 1453163175-5801-4-git-send-email-al.stone@linaro.org
State New
Headers show

Commit Message

Al Stone Jan. 19, 2016, 12:26 a.m. UTC
In some cases, we will want to run FWTS on one architecture, but use it
test firmware tables that may be for another architecture.  For example,
we may want to test ACPI tables for arm64 machines on an x86 laptop.

Previous patches provided the fwts_architecture as a typedef, along with
some helper functions.  Here, we add in framework variables for the host
(the machine running FWTS) and the target (the arch of the tables being
tested) and then initialize them properly.

Further, we add the --arch=<name> parameter so that the user can specify
the target architecture.  By default, the target will be assumed to be
the same as the host.

Signed-off-by: Al Stone <al.stone@linaro.org>

---
 src/lib/include/fwts_framework.h |  3 +++
 src/lib/src/fwts_framework.c     | 25 +++++++++++++++++++++++++
 2 files changed, 28 insertions(+)

-- 
2.5.0
diff mbox

Patch

diff --git a/src/lib/include/fwts_framework.h b/src/lib/include/fwts_framework.h
index a35ed19..c9ea4bb 100644
--- a/src/lib/include/fwts_framework.h
+++ b/src/lib/include/fwts_framework.h
@@ -26,6 +26,7 @@ 
 
 typedef struct fwts_framework fwts_framework;
 
+#include "fwts_arch.h"
 #include "fwts_log.h"
 #include "fwts_list.h"
 #include "fwts_acpica_mode.h"
@@ -148,6 +149,8 @@  typedef struct fwts_framework {
 	fwts_acpica_mode acpica_mode;		/* ACPICA mode flags */
 	void *rsdp;				/* ACPI RSDP address */
 	fwts_pm_method pm_method;
+	fwts_architecture host_arch;		/* arch FWTS was built for */
+	fwts_architecture target_arch;		/* arch being tested */
 } fwts_framework;
 
 typedef struct {
diff --git a/src/lib/src/fwts_framework.c b/src/lib/src/fwts_framework.c
index fec444f..e3f03f6 100644
--- a/src/lib/src/fwts_framework.c
+++ b/src/lib/src/fwts_framework.c
@@ -127,6 +127,7 @@  static fwts_option fwts_framework_options[] = {
 	{ "acpitests",		"",   0, "Run general ACPI tests." },
 	{ "acpicompliance",	"",   0, "Run ACPI tests for spec compliance." },
 	{ "log-level",		"",   1, "Specify error level to report failed test messages," },
+	{ "arch",		"",   1, "Specify arch of the tables being tested (defaults to current host)." },
 	{ NULL, NULL, 0, NULL }
 };
 
@@ -1127,6 +1128,22 @@  static int fwts_framework_ll_parse(fwts_framework *fw, const char *arg)
 	return FWTS_ERROR;
 }
 
+/*
+ *  fwts_framework_an_parse()
+ *	parse arch (architecture) name option
+ */
+static int fwts_framework_an_parse(fwts_framework *fw, const char *arg)
+{
+	fw->target_arch = fwts_arch_get_arch(arg);
+	if (fw->target_arch == FWTS_ARCH_OTHER) {
+		fprintf(stderr, "--arch can be one of: %s\n",
+			fwts_arch_names());
+		return FWTS_ERROR;
+	}
+
+	return FWTS_OK;
+}
+
 int fwts_framework_options_handler(fwts_framework *fw, int argc, char * const argv[], int option_char, int long_index)
 {
 	FWTS_UNUSED(argc);
@@ -1280,6 +1297,10 @@  int fwts_framework_options_handler(fwts_framework *fw, int argc, char * const ar
 			if (fwts_framework_ll_parse(fw, optarg) != FWTS_OK)
 				return FWTS_ERROR;
 			break;
+		case 43: /* --arch */
+			if (fwts_framework_an_parse(fw, optarg) != FWTS_OK)
+				return FWTS_ERROR;
+			break;
 		}
 		break;
 	case 'a': /* --all */
@@ -1381,6 +1402,10 @@  int fwts_framework_args(const int argc, char **argv)
 	/* Set the power method to FWTS_PM_UNDEFINED before we parse arguments */
 	fw->pm_method = FWTS_PM_UNDEFINED;
 
+	/* Set host/target test architecture defaults */
+	fw->host_arch = fwts_arch_get_host();
+	fw->target_arch = fw->host_arch;
+
 	ret = fwts_args_add_options(fwts_framework_options,
 		fwts_framework_options_handler, NULL);
 	if (ret == FWTS_ERROR)