summaryrefslogtreecommitdiffstats
path: root/meta-agl-bsp/recipes-support/ptest-runner/ptest-runner/0006-main.c-Add-option-e-to-exclude-certain-tests-for-exe.patch
blob: 7a4de868cb52fe9f207ab2b58a56969f1ff1f839 (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
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
From 49956f65bb53ea2a2c1b394e5e59ffdfcdcc490f Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?An=C3=ADbal=20Lim=C3=B3n?= <anibal.limon@linaro.org>
Date: Wed, 25 Apr 2018 11:55:03 -0500
Subject: [PATCH 6/7] main.c: Add option (-e) to exclude certain tests for
 execution
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

You can specify a set of ptests to be excluded, it will not fail
if some ptest excluded isn't found in the list of execution.

$ ./ptest-runner -e "hang glibc" -d tests/data

Signed-off-by: Aníbal Limón <anibal.limon@linaro.org>
---
 main.c  | 38 +++++++++++++++++++++++++++++++++++---
 utils.h |  1 +
 2 files changed, 36 insertions(+), 3 deletions(-)

diff --git a/main.c b/main.c
index 593aff1a1956..83600b7d1b31 100644
--- a/main.c
+++ b/main.c
@@ -19,6 +19,7 @@
  * 	Aníbal Limón <anibal.limon@intel.com>
  */
 
+#include <ctype.h>
 #include <limits.h>
 #include <unistd.h>
 #include <string.h>
@@ -42,8 +43,8 @@
 static inline void
 print_usage(FILE *stream, char *progname)
 {
-	fprintf(stream, "Usage: %s [-d directory] [-l list] [-t timeout] [-x xml-filename]"
-			" [-h] [ptest1 ptest2 ...]\n", progname);
+	fprintf(stream, "Usage: %s [-d directory] [-e exclude] [-l list] [-t timeout]"
+			" [-x xml-filename] [-h] [ptest1 ptest2 ...]\n", progname);
 }
 
 int
@@ -53,6 +54,8 @@ main(int argc, char *argv[])
 	int ptest_num = 0;
 	int i;
 	int rc;
+	int ptest_exclude_num = 0;
+	char *c, *tok;
 
 #ifdef MEMCHECK
 	mtrace();
@@ -62,18 +65,44 @@ main(int argc, char *argv[])
 	struct ptest_options opts;
 
 	opts.directory = strdup(DEFAULT_DIRECTORY);
+	opts.exclude = NULL;
 	opts.list = 0;
 	opts.timeout = DEFAULT_TIMEOUT;
 	opts.ptests = NULL;
 	opts.xml_filename = NULL;
 
-	while ((opt = getopt(argc, argv, "d:lt:x:h")) != -1) {
+	while ((opt = getopt(argc, argv, "d:e:lt:x:h")) != -1) {
 		switch (opt) {
 			case 'd':
 				free(opts.directory);
 				opts.directory = realpath(optarg, NULL);
 				CHECK_ALLOCATION(opts.directory, 1, 1);
 			break;
+			case 'e':
+				c = optarg;
+				ptest_exclude_num = 1;
+
+				while (*c) {
+					if (isspace(*c))
+						ptest_exclude_num++;
+					c++;
+				}
+
+
+				opts.exclude = malloc(ptest_exclude_num * sizeof(char));
+				CHECK_ALLOCATION(opts.exclude, 1, 1);
+
+				i = 0;
+				tok = strtok_r(optarg, " ", &c);
+				opts.exclude[i] = strdup(tok);
+				CHECK_ALLOCATION(opts.exclude[i], 1, 1);
+				i++;
+				while ((tok = strtok_r(NULL, " ", &c)) != NULL) {
+					opts.exclude[i] = strdup(tok);
+					CHECK_ALLOCATION(opts.exclude[i], 1, 1);
+					i++;
+				}
+			break;
 			case 'l':
 				opts.list = 1;
 			break;
@@ -134,6 +163,9 @@ main(int argc, char *argv[])
 		ptest_list_free_all(head);
 	}
 
+	for (i = 0; i < ptest_exclude_num; i++)
+		ptest_list_remove(run, opts.exclude[i], 1);
+
 	rc = run_ptests(run, opts, argv[0], stdout, stderr);
 
 	ptest_list_free_all(run);
diff --git a/utils.h b/utils.h
index 8fa20a8bf621..ee85163ddfff 100644
--- a/utils.h
+++ b/utils.h
@@ -32,6 +32,7 @@
 
 struct ptest_options {
 	char *directory;
+	char **exclude;
 	int list;
 	int timeout;
 	char **ptests;
-- 
2.11.0