diff options
3 files changed, 207 insertions, 1 deletions
diff --git a/meta/recipes-devtools/cmake/cmake-native_3.28.3.bb b/meta/recipes-devtools/cmake/cmake-native_3.28.3.bb index 546d117156..376da3254b 100644 --- a/meta/recipes-devtools/cmake/cmake-native_3.28.3.bb +++ b/meta/recipes-devtools/cmake/cmake-native_3.28.3.bb | |||
@@ -51,7 +51,7 @@ do_compile() { | |||
51 | do_install() { | 51 | do_install() { |
52 | oe_runmake 'DESTDIR=${D}' install | 52 | oe_runmake 'DESTDIR=${D}' install |
53 | 53 | ||
54 | # The following codes are here because eSDK needs to provide compatibilty | 54 | # The following codes are here because eSDK needs to provide compatibility |
55 | # for SDK. That is, eSDK could also be used like traditional SDK. | 55 | # for SDK. That is, eSDK could also be used like traditional SDK. |
56 | mkdir -p ${D}${datadir}/cmake | 56 | mkdir -p ${D}${datadir}/cmake |
57 | install -m 644 ${WORKDIR}/OEToolchainConfig.cmake ${D}${datadir}/cmake/ | 57 | install -m 644 ${WORKDIR}/OEToolchainConfig.cmake ${D}${datadir}/cmake/ |
diff --git a/meta/recipes-devtools/cmake/cmake/0001-ctest-Allow-arbitrary-characters-in-test-names-of-CT.patch b/meta/recipes-devtools/cmake/cmake/0001-ctest-Allow-arbitrary-characters-in-test-names-of-CT.patch new file mode 100644 index 0000000000..77c1d6378d --- /dev/null +++ b/meta/recipes-devtools/cmake/cmake/0001-ctest-Allow-arbitrary-characters-in-test-names-of-CT.patch | |||
@@ -0,0 +1,205 @@ | |||
1 | From 49576cf1df618609be4aa1000749ad087c143df0 Mon Sep 17 00:00:00 2001 | ||
2 | From: John Drouhard <john@drouhard.dev> | ||
3 | Date: Thu, 9 Jan 2025 20:34:42 -0600 | ||
4 | Subject: [PATCH] ctest: Allow arbitrary characters in test names of | ||
5 | CTestCostData.txt | ||
6 | |||
7 | This changes the way lines in CTestCostData.txt are parsed to allow for | ||
8 | spaces in the test name. | ||
9 | |||
10 | It does so by looking for space characters from the end; and once two | ||
11 | have been found, assumes everything from the beginning up to that | ||
12 | second-to-last-space is the test name. | ||
13 | |||
14 | Additionally, parsing the file should be much more efficient since there | ||
15 | is no string or vector heap allocation per line. The std::string used by | ||
16 | the parse function to convert the int and float should be within most | ||
17 | standard libraries' small string optimization. | ||
18 | |||
19 | Fixes: #26594 | ||
20 | |||
21 | Upstream-Status: Backport [4.0.0, 040da7d83216ace59710407e8ce35d5fd38e1340] | ||
22 | Signed-off-by: Moritz Haase <Moritz.Haase@bmw.de> | ||
23 | --- | ||
24 | Source/CTest/cmCTestMultiProcessHandler.cxx | 80 +++++++++++++++------ | ||
25 | Source/CTest/cmCTestMultiProcessHandler.h | 3 +- | ||
26 | Tests/CTestTestScheduler/CMakeLists.txt | 4 +- | ||
27 | 3 files changed, 64 insertions(+), 23 deletions(-) | ||
28 | |||
29 | diff --git a/Source/CTest/cmCTestMultiProcessHandler.cxx b/Source/CTest/cmCTestMultiProcessHandler.cxx | ||
30 | index ca07a081eafced40697d82b08c0e2a504939fc4d..59a101454b84367d219e79a01ff72702df0dfa7f 100644 | ||
31 | --- a/Source/CTest/cmCTestMultiProcessHandler.cxx | ||
32 | +++ b/Source/CTest/cmCTestMultiProcessHandler.cxx | ||
33 | @@ -20,6 +20,7 @@ | ||
34 | |||
35 | #include <cm/memory> | ||
36 | #include <cm/optional> | ||
37 | +#include <cm/string_view> | ||
38 | #include <cmext/algorithm> | ||
39 | |||
40 | #include <cm3p/json/value.h> | ||
41 | @@ -43,6 +44,51 @@ | ||
42 | #include "cmUVSignalHackRAII.h" // IWYU pragma: keep | ||
43 | #include "cmWorkingDirectory.h" | ||
44 | |||
45 | +namespace { | ||
46 | + | ||
47 | +struct CostEntry | ||
48 | +{ | ||
49 | + cm::string_view name; | ||
50 | + int prevRuns; | ||
51 | + float cost; | ||
52 | +}; | ||
53 | + | ||
54 | +cm::optional<CostEntry> splitCostLine(cm::string_view line) | ||
55 | +{ | ||
56 | + std::string part; | ||
57 | + cm::string_view::size_type pos1 = line.size(); | ||
58 | + cm::string_view::size_type pos2 = line.find_last_of(' ', pos1); | ||
59 | + auto findNext = [line, &part, &pos1, &pos2]() -> bool { | ||
60 | + if (pos2 != cm::string_view::npos) { | ||
61 | + cm::string_view sub = line.substr(pos2 + 1, pos1 - pos2 - 1); | ||
62 | + part.assign(sub.begin(), sub.end()); | ||
63 | + pos1 = pos2; | ||
64 | + if (pos1 > 0) { | ||
65 | + pos2 = line.find_last_of(' ', pos1 - 1); | ||
66 | + } | ||
67 | + return true; | ||
68 | + } | ||
69 | + return false; | ||
70 | + }; | ||
71 | + | ||
72 | + // parse the cost | ||
73 | + if (!findNext()) { | ||
74 | + return cm::nullopt; | ||
75 | + } | ||
76 | + float cost = static_cast<float>(atof(part.c_str())); | ||
77 | + | ||
78 | + // parse the previous runs | ||
79 | + if (!findNext()) { | ||
80 | + return cm::nullopt; | ||
81 | + } | ||
82 | + int prev = atoi(part.c_str()); | ||
83 | + | ||
84 | + // from start to the last found space is the name | ||
85 | + return CostEntry{ line.substr(0, pos1), prev, cost }; | ||
86 | +} | ||
87 | + | ||
88 | +} | ||
89 | + | ||
90 | namespace cmsys { | ||
91 | class RegularExpression; | ||
92 | } | ||
93 | @@ -697,24 +743,21 @@ void cmCTestMultiProcessHandler::UpdateCostData() | ||
94 | if (line == "---") { | ||
95 | break; | ||
96 | } | ||
97 | - std::vector<std::string> parts = cmSystemTools::SplitString(line, ' '); | ||
98 | // Format: <name> <previous_runs> <avg_cost> | ||
99 | - if (parts.size() < 3) { | ||
100 | + cm::optional<CostEntry> entry = splitCostLine(line); | ||
101 | + if (!entry) { | ||
102 | break; | ||
103 | } | ||
104 | |||
105 | - std::string name = parts[0]; | ||
106 | - int prev = atoi(parts[1].c_str()); | ||
107 | - float cost = static_cast<float>(atof(parts[2].c_str())); | ||
108 | - | ||
109 | - int index = this->SearchByName(name); | ||
110 | + int index = this->SearchByName(entry->name); | ||
111 | if (index == -1) { | ||
112 | // This test is not in memory. We just rewrite the entry | ||
113 | - fout << name << " " << prev << " " << cost << "\n"; | ||
114 | + fout << entry->name << " " << entry->prevRuns << " " << entry->cost | ||
115 | + << "\n"; | ||
116 | } else { | ||
117 | // Update with our new average cost | ||
118 | - fout << name << " " << this->Properties[index]->PreviousRuns << " " | ||
119 | - << this->Properties[index]->Cost << "\n"; | ||
120 | + fout << entry->name << " " << this->Properties[index]->PreviousRuns | ||
121 | + << " " << this->Properties[index]->Cost << "\n"; | ||
122 | temp.erase(index); | ||
123 | } | ||
124 | } | ||
125 | @@ -750,28 +793,25 @@ void cmCTestMultiProcessHandler::ReadCostData() | ||
126 | break; | ||
127 | } | ||
128 | |||
129 | - std::vector<std::string> parts = cmSystemTools::SplitString(line, ' '); | ||
130 | + // Format: <name> <previous_runs> <avg_cost> | ||
131 | + cm::optional<CostEntry> entry = splitCostLine(line); | ||
132 | |||
133 | // Probably an older version of the file, will be fixed next run | ||
134 | - if (parts.size() < 3) { | ||
135 | + if (!entry) { | ||
136 | fin.close(); | ||
137 | return; | ||
138 | } | ||
139 | |||
140 | - std::string name = parts[0]; | ||
141 | - int prev = atoi(parts[1].c_str()); | ||
142 | - float cost = static_cast<float>(atof(parts[2].c_str())); | ||
143 | - | ||
144 | - int index = this->SearchByName(name); | ||
145 | + int index = this->SearchByName(entry->name); | ||
146 | if (index == -1) { | ||
147 | continue; | ||
148 | } | ||
149 | |||
150 | - this->Properties[index]->PreviousRuns = prev; | ||
151 | + this->Properties[index]->PreviousRuns = entry->prevRuns; | ||
152 | // When not running in parallel mode, don't use cost data | ||
153 | if (this->ParallelLevel > 1 && this->Properties[index] && | ||
154 | this->Properties[index]->Cost == 0) { | ||
155 | - this->Properties[index]->Cost = cost; | ||
156 | + this->Properties[index]->Cost = entry->cost; | ||
157 | } | ||
158 | } | ||
159 | // Next part of the file is the failed tests | ||
160 | @@ -784,7 +824,7 @@ void cmCTestMultiProcessHandler::ReadCostData() | ||
161 | } | ||
162 | } | ||
163 | |||
164 | -int cmCTestMultiProcessHandler::SearchByName(std::string const& name) | ||
165 | +int cmCTestMultiProcessHandler::SearchByName(cm::string_view name) | ||
166 | { | ||
167 | int index = -1; | ||
168 | |||
169 | diff --git a/Source/CTest/cmCTestMultiProcessHandler.h b/Source/CTest/cmCTestMultiProcessHandler.h | ||
170 | index 3b4e9c59ad1871168d8528be0586831e2416ae36..8d33dabcf0d9fc6e11459105c65eadaa1de33e42 100644 | ||
171 | --- a/Source/CTest/cmCTestMultiProcessHandler.h | ||
172 | +++ b/Source/CTest/cmCTestMultiProcessHandler.h | ||
173 | @@ -12,6 +12,7 @@ | ||
174 | #include <vector> | ||
175 | |||
176 | #include <cm/optional> | ||
177 | +#include <cm/string_view> | ||
178 | |||
179 | #include <cm3p/uv.h> | ||
180 | |||
181 | @@ -113,7 +114,7 @@ protected: | ||
182 | void UpdateCostData(); | ||
183 | void ReadCostData(); | ||
184 | // Return index of a test based on its name | ||
185 | - int SearchByName(std::string const& name); | ||
186 | + int SearchByName(cm::string_view name); | ||
187 | |||
188 | void CreateTestCostList(); | ||
189 | |||
190 | diff --git a/Tests/CTestTestScheduler/CMakeLists.txt b/Tests/CTestTestScheduler/CMakeLists.txt | ||
191 | index 91d565d4020aafda6d49462cd8616d168d5844b6..daf6ce2b23d8c048334ae1047759130b246dccef 100644 | ||
192 | --- a/Tests/CTestTestScheduler/CMakeLists.txt | ||
193 | +++ b/Tests/CTestTestScheduler/CMakeLists.txt | ||
194 | @@ -1,9 +1,9 @@ | ||
195 | -cmake_minimum_required (VERSION 3.5) | ||
196 | +cmake_minimum_required(VERSION 3.19) | ||
197 | project (CTestTestScheduler) | ||
198 | include (CTest) | ||
199 | |||
200 | add_executable (Sleep sleep.c) | ||
201 | |||
202 | foreach (time RANGE 1 4) | ||
203 | - add_test (TestSleep${time} Sleep ${time}) | ||
204 | + add_test ("TestSleep ${time}" Sleep ${time}) | ||
205 | endforeach () | ||
diff --git a/meta/recipes-devtools/cmake/cmake_3.28.3.bb b/meta/recipes-devtools/cmake/cmake_3.28.3.bb index 6a9a3266df..63d483801a 100644 --- a/meta/recipes-devtools/cmake/cmake_3.28.3.bb +++ b/meta/recipes-devtools/cmake/cmake_3.28.3.bb | |||
@@ -5,6 +5,7 @@ inherit cmake bash-completion | |||
5 | DEPENDS += "curl expat zlib libarchive xz ncurses bzip2" | 5 | DEPENDS += "curl expat zlib libarchive xz ncurses bzip2" |
6 | 6 | ||
7 | SRC_URI:append:class-nativesdk = " \ | 7 | SRC_URI:append:class-nativesdk = " \ |
8 | file://0001-ctest-Allow-arbitrary-characters-in-test-names-of-CT.patch \ | ||
8 | file://OEToolchainConfig.cmake \ | 9 | file://OEToolchainConfig.cmake \ |
9 | file://SDKToolchainConfig.cmake.template \ | 10 | file://SDKToolchainConfig.cmake.template \ |
10 | file://cmake-setup.py \ | 11 | file://cmake-setup.py \ |