summaryrefslogtreecommitdiffstats
path: root/meta-agl-bsp/recipes-support/ptest-runner/ptest-runner/0003-Add-support-to-avoid-load-run-twice-a-run_ptest-scri.patch
blob: 47957333d6049d8ed76cec4573485c24194f686a (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
124
125
126
127
128
129
130
131
132
133
134
135
136
137
From 0e566f65fa31eaa5208d4a17413c7a4aad7eade5 Mon Sep 17 00:00:00 2001
From: =?UTF-8?q?An=C3=ADbal=20Lim=C3=B3n?= <anibal.limon@linaro.org>
Date: Thu, 7 Dec 2017 17:42:45 -0600
Subject: [PATCH 3/7] Add support to avoid load/run twice a run_ptest script
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit

In some ptest packages exists symlink in the ptest directory causing
to load/run twice the same ptest,

For example in perl5:

/usr/lib/perl -> /usr/lib/perl5

Signed-off-by: Aníbal Limón <anibal.limon@linaro.org>
---
 ptest_list.c       | 40 ++++++++++++++++++++++++++++++++++++++++
 ptest_list.h       |  3 +++
 tests/data/python3 |  1 +
 tests/utils.c      |  1 +
 utils.c            |  6 ++++++
 5 files changed, 51 insertions(+)
 create mode 120000 tests/data/python3

diff --git a/ptest_list.c b/ptest_list.c
index 2e1aa305752d..3e393d5fabe2 100644
--- a/ptest_list.c
+++ b/ptest_list.c
@@ -110,6 +110,46 @@ ptest_list_search(struct ptest_list *head, char *ptest)
 	return q;
 }
 
+
+struct ptest_list *
+ptest_list_search_by_file(struct ptest_list *head, char *run_ptest, struct stat st_buf)
+{
+	struct ptest_list *q = NULL;
+	struct ptest_list *p;
+	struct stat st_buf_p;
+
+	VALIDATE_PTR_RNULL(head);
+	VALIDATE_PTR_RNULL(run_ptest);
+
+	for (p = head; p != NULL; p = p->next) {
+		if (p->ptest == NULL) 
+			continue;
+
+		if (stat(p->run_ptest, &st_buf_p) == -1)
+			continue;
+
+		if (strcmp(p->run_ptest, run_ptest) == 0) {
+			q = p;
+			break;
+		}
+
+		/* *
+		 * In some ptest packages exists symlink in the ptest directory
+		 * causing to load/run twice the same ptest, 
+		 *
+		 * For example in perl5:
+		 * /usr/lib/perl -> /usr/lib/perl5
+		 * */
+		if (st_buf.st_dev == st_buf_p.st_dev &&
+		    st_buf.st_ino == st_buf_p.st_ino) {
+			q = p;
+			break;
+		}
+	}
+
+	return q;
+}
+
 struct ptest_list *
 ptest_list_add(struct ptest_list *head, char *ptest, char *run_ptest)
 {
diff --git a/ptest_list.h b/ptest_list.h
index 8b394853c25b..03d75390a51d 100644
--- a/ptest_list.h
+++ b/ptest_list.h
@@ -28,6 +28,8 @@
 #define PTEST_LIST_ITERATE_START(head, p) for (p = head->next; p != NULL; p = p->next) { 
 #define PTEST_LIST_ITERATE_END }
 
+#include <sys/stat.h>
+
 struct ptest_list {
 	char *ptest;
 	char *run_ptest;
@@ -42,6 +44,7 @@ extern int ptest_list_free_all(struct ptest_list *);
 
 extern int ptest_list_length(struct ptest_list *);
 extern struct ptest_list *ptest_list_search(struct ptest_list *, char *);
+extern struct ptest_list *ptest_list_search_by_file(struct ptest_list *, char *, struct stat);
 extern struct ptest_list *ptest_list_add(struct ptest_list *, char *, char *);
 extern struct ptest_list *ptest_list_remove(struct ptest_list *, char *, int);
 
diff --git a/tests/data/python3 b/tests/data/python3
new file mode 120000
index 000000000000..d8654aa0e2f2
--- /dev/null
+++ b/tests/data/python3
@@ -0,0 +1 @@
+python
\ No newline at end of file
diff --git a/tests/utils.c b/tests/utils.c
index ecf3e8af9a81..cf093793c4f2 100644
--- a/tests/utils.c
+++ b/tests/utils.c
@@ -48,6 +48,7 @@ static int ptests_found_length = 6;
 static char *ptests_not_found[] = {
 	"busybox",
 	"perl",
+	"python3",
 	NULL,
 };
 
diff --git a/utils.c b/utils.c
index 933ecedf57e8..ed2eff7900c1 100644
--- a/utils.c
+++ b/utils.c
@@ -143,6 +143,12 @@ get_available_ptests(const char *dir)
 				continue;
 			}
 
+			if (ptest_list_search_by_file(head, run_ptest, st_buf)) {
+				free(run_ptest);
+				free(d_name);
+				continue;
+			}
+
 			struct ptest_list *p = ptest_list_add(head,
 				d_name, run_ptest);
 			CHECK_ALLOCATION(p, sizeof(struct ptest_list *), 0);
-- 
2.11.0