meta-agl-profile-telematics: recipes-core: systemd: change canbus systemd match regex
[AGL/meta-agl.git] / meta-agl-bsp / recipes-support / ptest-runner / ptest-runner / 0006-main.c-Add-option-e-to-exclude-certain-tests-for-exe.patch
1 From 49956f65bb53ea2a2c1b394e5e59ffdfcdcc490f Mon Sep 17 00:00:00 2001
2 From: =?UTF-8?q?An=C3=ADbal=20Lim=C3=B3n?= <anibal.limon@linaro.org>
3 Date: Wed, 25 Apr 2018 11:55:03 -0500
4 Subject: [PATCH 6/7] main.c: Add option (-e) to exclude certain tests for
5  execution
6 MIME-Version: 1.0
7 Content-Type: text/plain; charset=UTF-8
8 Content-Transfer-Encoding: 8bit
9
10 You can specify a set of ptests to be excluded, it will not fail
11 if some ptest excluded isn't found in the list of execution.
12
13 $ ./ptest-runner -e "hang glibc" -d tests/data
14
15 Signed-off-by: Aníbal Limón <anibal.limon@linaro.org>
16 ---
17  main.c  | 38 +++++++++++++++++++++++++++++++++++---
18  utils.h |  1 +
19  2 files changed, 36 insertions(+), 3 deletions(-)
20
21 diff --git a/main.c b/main.c
22 index 593aff1a1956..83600b7d1b31 100644
23 --- a/main.c
24 +++ b/main.c
25 @@ -19,6 +19,7 @@
26   *     Aníbal Limón <anibal.limon@intel.com>
27   */
28  
29 +#include <ctype.h>
30  #include <limits.h>
31  #include <unistd.h>
32  #include <string.h>
33 @@ -42,8 +43,8 @@
34  static inline void
35  print_usage(FILE *stream, char *progname)
36  {
37 -       fprintf(stream, "Usage: %s [-d directory] [-l list] [-t timeout] [-x xml-filename]"
38 -                       " [-h] [ptest1 ptest2 ...]\n", progname);
39 +       fprintf(stream, "Usage: %s [-d directory] [-e exclude] [-l list] [-t timeout]"
40 +                       " [-x xml-filename] [-h] [ptest1 ptest2 ...]\n", progname);
41  }
42  
43  int
44 @@ -53,6 +54,8 @@ main(int argc, char *argv[])
45         int ptest_num = 0;
46         int i;
47         int rc;
48 +       int ptest_exclude_num = 0;
49 +       char *c, *tok;
50  
51  #ifdef MEMCHECK
52         mtrace();
53 @@ -62,18 +65,44 @@ main(int argc, char *argv[])
54         struct ptest_options opts;
55  
56         opts.directory = strdup(DEFAULT_DIRECTORY);
57 +       opts.exclude = NULL;
58         opts.list = 0;
59         opts.timeout = DEFAULT_TIMEOUT;
60         opts.ptests = NULL;
61         opts.xml_filename = NULL;
62  
63 -       while ((opt = getopt(argc, argv, "d:lt:x:h")) != -1) {
64 +       while ((opt = getopt(argc, argv, "d:e:lt:x:h")) != -1) {
65                 switch (opt) {
66                         case 'd':
67                                 free(opts.directory);
68                                 opts.directory = realpath(optarg, NULL);
69                                 CHECK_ALLOCATION(opts.directory, 1, 1);
70                         break;
71 +                       case 'e':
72 +                               c = optarg;
73 +                               ptest_exclude_num = 1;
74 +
75 +                               while (*c) {
76 +                                       if (isspace(*c))
77 +                                               ptest_exclude_num++;
78 +                                       c++;
79 +                               }
80 +
81 +
82 +                               opts.exclude = malloc(ptest_exclude_num * sizeof(char));
83 +                               CHECK_ALLOCATION(opts.exclude, 1, 1);
84 +
85 +                               i = 0;
86 +                               tok = strtok_r(optarg, " ", &c);
87 +                               opts.exclude[i] = strdup(tok);
88 +                               CHECK_ALLOCATION(opts.exclude[i], 1, 1);
89 +                               i++;
90 +                               while ((tok = strtok_r(NULL, " ", &c)) != NULL) {
91 +                                       opts.exclude[i] = strdup(tok);
92 +                                       CHECK_ALLOCATION(opts.exclude[i], 1, 1);
93 +                                       i++;
94 +                               }
95 +                       break;
96                         case 'l':
97                                 opts.list = 1;
98                         break;
99 @@ -134,6 +163,9 @@ main(int argc, char *argv[])
100                 ptest_list_free_all(head);
101         }
102  
103 +       for (i = 0; i < ptest_exclude_num; i++)
104 +               ptest_list_remove(run, opts.exclude[i], 1);
105 +
106         rc = run_ptests(run, opts, argv[0], stdout, stderr);
107  
108         ptest_list_free_all(run);
109 diff --git a/utils.h b/utils.h
110 index 8fa20a8bf621..ee85163ddfff 100644
111 --- a/utils.h
112 +++ b/utils.h
113 @@ -32,6 +32,7 @@
114  
115  struct ptest_options {
116         char *directory;
117 +       char **exclude;
118         int list;
119         int timeout;
120         char **ptests;
121 -- 
122 2.11.0
123