Merge lp:~michihenning/thumbnailer/snap into lp:thumbnailer/devel
- snap
- Merge into devel
Status: | Merged |
---|---|
Approved by: | James Henstridge |
Approved revision: | 377 |
Merged at revision: | 370 |
Proposed branch: | lp:~michihenning/thumbnailer/snap |
Merge into: | lp:thumbnailer/devel |
Diff against target: |
833 lines (+228/-124) 25 files modified
CMakeLists.txt (+5/-0) doc/libthumbnailer-qt/examples/qt_example_test.cpp (+3/-3) include/internal/env_vars.h (+22/-6) man/thumbnailer-service.1 (+1/-1) snapcraft.yaml (+4/-0) src/CMakeLists.txt (+1/-0) src/env_vars.cpp (+148/-0) src/file_io.cpp (+1/-1) src/imageextractor.cpp (+1/-4) src/service/inactivityhandler.cpp (+1/-39) src/settings.cpp (+2/-19) src/thumbnailer.cpp (+2/-2) src/ubuntuserverdownloader.cpp (+2/-13) tests/dbus/dbus_test.cpp (+7/-7) tests/download/download_test.cpp (+1/-1) tests/file_io/file_io_test.cpp (+1/-1) tests/image-provider/image-provider_test.cpp (+1/-2) tests/libthumbnailer-qt/libthumbnailer-qt_test.cpp (+3/-3) tests/qml/qml_test.cpp (+1/-1) tests/settings/settings_test.cpp (+3/-3) tests/slow-vs-thumb/slow-vs-thumb_test.cpp (+1/-1) tests/stress/stress_test.cpp (+4/-4) tests/thumbnailer-admin/thumbnailer-admin_test.cpp (+3/-3) tests/thumbnailer/thumbnailer_test.cpp (+8/-8) tests/utils/artserver.cpp (+2/-2) |
To merge this branch: | bzr merge lp:~michihenning/thumbnailer/snap |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
James Henstridge | Approve | ||
unity-api-1-bot | continuous-integration | Approve | |
Review via email: mp+316060@code.launchpad.net |
Commit message
Adjust paths when running in a snap. Decision whether to adjust paths is now made at compile time. Also consolidated all the environment variable accesses into an EnvVar helper class.
Added home interface to service and admin tool for the time being. This allows local thumbnailing to work (but the apparmor credentials check is currently not doing the right thing).
videos don't thumbnail yet because we are not bundling the gstreamer codecs, I suspect.
Description of the change
Adjust paths when running in a snap.
unity-api-1-bot (unity-api-1-bot) wrote : | # |
unity-api-1-bot (unity-api-1-bot) wrote : | # |
PASSED: Continuous integration, rev:374
https:/
Executed test runs:
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
Click here to trigger a rebuild:
https:/
unity-api-1-bot (unity-api-1-bot) wrote : | # |
PASSED: Continuous integration, rev:375
https:/
Executed test runs:
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
Click here to trigger a rebuild:
https:/
- 376. By Michi Henning
-
Added home interface to enable thumbnailing local files.
Also add this to the thumbnailer-admin command, because it is a royal
pain not to be able to use it for local media files.
unity-api-1-bot (unity-api-1-bot) wrote : | # |
PASSED: Continuous integration, rev:376
https:/
Executed test runs:
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
Click here to trigger a rebuild:
https:/
James Henstridge (jamesh) wrote : | # |
I've noted a few small issues as inline comments.
- 377. By Michi Henning
-
Review comments from James.
Michi Henning (michihenning) wrote : | # |
Thanks for that! I think I've addressed all the issues. Tests pass for normal and -DSNAP_BUILD.
unity-api-1-bot (unity-api-1-bot) wrote : | # |
PASSED: Continuous integration, rev:377
https:/
Executed test runs:
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
Click here to trigger a rebuild:
https:/
James Henstridge (jamesh) wrote : | # |
Looks close enough. I expected you to call the cmake option SNAP_BUILD, since that's the variable you were already using (and setting in snapcraft.yaml). That can be addressed with a future MP though.
Preview Diff
1 | === modified file 'CMakeLists.txt' | |||
2 | --- CMakeLists.txt 2017-01-16 05:12:01 +0000 | |||
3 | +++ CMakeLists.txt 2017-02-03 07:36:24 +0000 | |||
4 | @@ -47,6 +47,11 @@ | |||
5 | 47 | 47 | ||
6 | 48 | add_definitions(-DQT_NO_KEYWORDS) | 48 | add_definitions(-DQT_NO_KEYWORDS) |
7 | 49 | 49 | ||
8 | 50 | option(SnapBuild "Build for snap release") | ||
9 | 51 | if(${SnapBuild} OR "${SNAP_BUILD}") | ||
10 | 52 | add_definitions(-DSNAP_BUILD=1) | ||
11 | 53 | endif() | ||
12 | 54 | |||
13 | 50 | include(GNUInstallDirs) | 55 | include(GNUInstallDirs) |
14 | 51 | 56 | ||
15 | 52 | # libthumbnailer-qt version | 57 | # libthumbnailer-qt version |
16 | 53 | 58 | ||
17 | === modified file 'doc/libthumbnailer-qt/examples/qt_example_test.cpp' | |||
18 | --- doc/libthumbnailer-qt/examples/qt_example_test.cpp 2017-01-17 04:13:01 +0000 | |||
19 | +++ doc/libthumbnailer-qt/examples/qt_example_test.cpp 2017-02-03 07:36:24 +0000 | |||
20 | @@ -146,7 +146,7 @@ | |||
21 | 146 | setenv("XDG_CACHE_HOME", (tempdir->path() + "/cache").toUtf8().data(), true); | 146 | setenv("XDG_CACHE_HOME", (tempdir->path() + "/cache").toUtf8().data(), true); |
22 | 147 | 147 | ||
23 | 148 | // set 3 seconds as max idle time | 148 | // set 3 seconds as max idle time |
25 | 149 | setenv(unity::thumbnailer::internal::MAX_IDLE, "1000", true); | 149 | setenv(unity::thumbnailer::internal::EnvVars::MAX_IDLE, "1000", true); |
26 | 150 | 150 | ||
27 | 151 | dbus_.reset(new DBusServer()); | 151 | dbus_.reset(new DBusServer()); |
28 | 152 | } | 152 | } |
29 | @@ -155,7 +155,7 @@ | |||
30 | 155 | { | 155 | { |
31 | 156 | dbus_.reset(); | 156 | dbus_.reset(); |
32 | 157 | 157 | ||
34 | 158 | unsetenv(unity::thumbnailer::internal::MAX_IDLE); | 158 | unsetenv(unity::thumbnailer::internal::EnvVars::MAX_IDLE); |
35 | 159 | unsetenv("XDG_CACHE_HOME"); | 159 | unsetenv("XDG_CACHE_HOME"); |
36 | 160 | tempdir.reset(); | 160 | tempdir.reset(); |
37 | 161 | } | 161 | } |
38 | @@ -192,7 +192,7 @@ | |||
39 | 192 | QCoreApplication app(argc, argv); | 192 | QCoreApplication app(argc, argv); |
40 | 193 | setenv("GSETTINGS_BACKEND", "memory", true); | 193 | setenv("GSETTINGS_BACKEND", "memory", true); |
41 | 194 | setenv("GSETTINGS_SCHEMA_DIR", GSETTINGS_SCHEMA_DIR, true); | 194 | setenv("GSETTINGS_SCHEMA_DIR", GSETTINGS_SCHEMA_DIR, true); |
43 | 195 | setenv(unity::thumbnailer::internal::UTIL_DIR, TESTBINDIR "/../src/vs-thumb", true); | 195 | setenv(unity::thumbnailer::internal::EnvVars::UTIL_DIR, TESTBINDIR "/../src/vs-thumb", true); |
44 | 196 | ::testing::InitGoogleTest(&argc, argv); | 196 | ::testing::InitGoogleTest(&argc, argv); |
45 | 197 | return RUN_ALL_TESTS(); | 197 | return RUN_ALL_TESTS(); |
46 | 198 | } | 198 | } |
47 | 199 | 199 | ||
48 | === modified file 'include/internal/env_vars.h' | |||
49 | --- include/internal/env_vars.h 2015-12-14 04:43:11 +0000 | |||
50 | +++ include/internal/env_vars.h 2017-02-03 07:36:24 +0000 | |||
51 | @@ -18,8 +18,9 @@ | |||
52 | 18 | 18 | ||
53 | 19 | #pragma once | 19 | #pragma once |
54 | 20 | 20 | ||
57 | 21 | #include <map> | 21 | #include <internal/config.h> |
58 | 22 | #include <string> | 22 | |
59 | 23 | #include <QString> | ||
60 | 23 | 24 | ||
61 | 24 | namespace unity | 25 | namespace unity |
62 | 25 | { | 26 | { |
63 | @@ -30,10 +31,25 @@ | |||
64 | 30 | namespace internal | 31 | namespace internal |
65 | 31 | { | 32 | { |
66 | 32 | 33 | ||
71 | 33 | constexpr char const* MAX_IDLE = "THUMBNAILER_MAX_IDLE"; | 34 | struct EnvVars |
72 | 34 | constexpr char const* UBUNTU_SERVER_URL = "THUMBNAILER_UBUNTU_SERVER_URL"; | 35 | { |
73 | 35 | constexpr char const* UTIL_DIR = "THUMBNAILER_UTIL_DIR"; | 36 | static int get_max_idle(); |
74 | 36 | constexpr char const* LOG_LEVEL = "THUMBNAILER_LOG_LEVEL"; | 37 | static QString get_ubuntu_server_url(); |
75 | 38 | static QString get_util_dir(); | ||
76 | 39 | static int get_log_level(); | ||
77 | 40 | static std::string get_cache_dir(); | ||
78 | 41 | |||
79 | 42 | static constexpr char const* MAX_IDLE = "THUMBNAILER_MAX_IDLE"; | ||
80 | 43 | static constexpr int DFLT_MAX_IDLE = 30000; | ||
81 | 44 | |||
82 | 45 | static constexpr char const* UBUNTU_SERVER_URL = "THUMBNAILER_UBUNTU_SERVER_URL"; | ||
83 | 46 | static constexpr char const* DFLT_UBUNTU_SERVER_URL = "https://dash.ubuntu.com"; | ||
84 | 47 | |||
85 | 48 | static constexpr char const* UTIL_DIR = "THUMBNAILER_UTIL_DIR"; | ||
86 | 49 | static constexpr char const* DFLT_UTIL_DIR = SHARE_PRIV_ABS; | ||
87 | 50 | |||
88 | 51 | static constexpr char const* LOG_LEVEL = "THUMBNAILER_LOG_LEVEL"; | ||
89 | 52 | }; | ||
90 | 37 | 53 | ||
91 | 38 | } // namespace internal | 54 | } // namespace internal |
92 | 39 | 55 | ||
93 | 40 | 56 | ||
94 | === modified file 'man/thumbnailer-service.1' | |||
95 | --- man/thumbnailer-service.1 2016-04-07 01:18:31 +0000 | |||
96 | +++ man/thumbnailer-service.1 2017-02-03 07:36:24 +0000 | |||
97 | @@ -55,7 +55,7 @@ | |||
98 | 55 | .B THUMBNAILER_UTIL_DIR | 55 | .B THUMBNAILER_UTIL_DIR |
99 | 56 | The directory in which to look for the \fBvs\-thumb\fP executable, which is used | 56 | The directory in which to look for the \fBvs\-thumb\fP executable, which is used |
100 | 57 | to extract images from streaming media. If not set, the program is expected to be in | 57 | to extract images from streaming media. If not set, the program is expected to be in |
102 | 58 | \fB/usr/lib/\fP\fI<arch>\fP\fB/thumbnailer\fP. | 58 | \fB$/usr/lib/\fP\fI<arch>\fP\fB/thumbnailer\fP. |
103 | 59 | .TP | 59 | .TP |
104 | 60 | .B THUMBNAILER_MAX_IDLE | 60 | .B THUMBNAILER_MAX_IDLE |
105 | 61 | The service exits once it has been idle for the number of milliseconds specified by this variable. If not set, | 61 | The service exits once it has been idle for the number of milliseconds specified by this variable. If not set, |
106 | 62 | 62 | ||
107 | === modified file 'snapcraft.yaml' | |||
108 | --- snapcraft.yaml 2017-01-30 03:00:30 +0000 | |||
109 | +++ snapcraft.yaml 2017-02-03 07:36:24 +0000 | |||
110 | @@ -44,6 +44,7 @@ | |||
111 | 44 | # See https://bugs.launchpad.net/snappy/+bug/1600154 | 44 | # See https://bugs.launchpad.net/snappy/+bug/1600154 |
112 | 45 | # For now, the service uses default settings because it's gsettings lookups fail. | 45 | # For now, the service uses default settings because it's gsettings lookups fail. |
113 | 46 | - gsettings | 46 | - gsettings |
114 | 47 | - home | ||
115 | 47 | slots: | 48 | slots: |
116 | 48 | - thumbnailer | 49 | - thumbnailer |
117 | 49 | thumbnailer-admin: | 50 | thumbnailer-admin: |
118 | @@ -51,10 +52,13 @@ | |||
119 | 51 | plugs: | 52 | plugs: |
120 | 52 | - platform | 53 | - platform |
121 | 53 | - thumbnails | 54 | - thumbnails |
122 | 55 | - home | ||
123 | 54 | 56 | ||
124 | 55 | parts: | 57 | parts: |
125 | 56 | thumbnailer: | 58 | thumbnailer: |
126 | 57 | plugin: cmake | 59 | plugin: cmake |
127 | 60 | configflags: | ||
128 | 61 | - -DSNAP_BUILD=1 | ||
129 | 58 | source: . | 62 | source: . |
130 | 59 | after: | 63 | after: |
131 | 60 | - desktop-ubuntu-app-platform | 64 | - desktop-ubuntu-app-platform |
132 | 61 | 65 | ||
133 | === modified file 'src/CMakeLists.txt' | |||
134 | --- src/CMakeLists.txt 2016-02-14 23:42:00 +0000 | |||
135 | +++ src/CMakeLists.txt 2017-02-03 07:36:24 +0000 | |||
136 | @@ -18,6 +18,7 @@ | |||
137 | 18 | artdownloader.cpp | 18 | artdownloader.cpp |
138 | 19 | backoff_adjuster.cpp | 19 | backoff_adjuster.cpp |
139 | 20 | check_access.cpp | 20 | check_access.cpp |
140 | 21 | env_vars.cpp | ||
141 | 21 | file_io.cpp | 22 | file_io.cpp |
142 | 22 | file_lock.cpp | 23 | file_lock.cpp |
143 | 23 | image.cpp | 24 | image.cpp |
144 | 24 | 25 | ||
145 | === added file 'src/env_vars.cpp' | |||
146 | --- src/env_vars.cpp 1970-01-01 00:00:00 +0000 | |||
147 | +++ src/env_vars.cpp 2017-02-03 07:36:24 +0000 | |||
148 | @@ -0,0 +1,148 @@ | |||
149 | 1 | /* | ||
150 | 2 | * Copyright (C) 2017 Canonical Ltd. | ||
151 | 3 | * | ||
152 | 4 | * This program is free software: you can redistribute it and/or modify | ||
153 | 5 | * it under the terms of the GNU General Public License version 3 as | ||
154 | 6 | * published by the Free Software Foundation. | ||
155 | 7 | * | ||
156 | 8 | * This program is distributed in the hope that it will be useful, | ||
157 | 9 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
158 | 10 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
159 | 11 | * GNU General Public License for more details. | ||
160 | 12 | * | ||
161 | 13 | * You should have received a copy of the GNU General Public License | ||
162 | 14 | * along with this program. If not, see <http://www.gnu.org/licenses/>. | ||
163 | 15 | * | ||
164 | 16 | * Authored by: Michi Henning <michi.henning@canonical.com> | ||
165 | 17 | */ | ||
166 | 18 | |||
167 | 19 | #include <internal/env_vars.h> | ||
168 | 20 | |||
169 | 21 | #include <internal/config.h> | ||
170 | 22 | |||
171 | 23 | #pragma GCC diagnostic push | ||
172 | 24 | #pragma GCC diagnostic ignored "-Wold-style-cast" | ||
173 | 25 | #include <glib.h> | ||
174 | 26 | #pragma GCC diagnostic pop | ||
175 | 27 | #include <QDebug> | ||
176 | 28 | #include <sstream> | ||
177 | 29 | |||
178 | 30 | using namespace std; | ||
179 | 31 | |||
180 | 32 | namespace unity | ||
181 | 33 | { | ||
182 | 34 | |||
183 | 35 | namespace thumbnailer | ||
184 | 36 | { | ||
185 | 37 | |||
186 | 38 | namespace internal | ||
187 | 39 | { | ||
188 | 40 | |||
189 | 41 | int EnvVars::get_max_idle() | ||
190 | 42 | { | ||
191 | 43 | char const* c_idle_time = getenv(MAX_IDLE); | ||
192 | 44 | if (c_idle_time) | ||
193 | 45 | { | ||
194 | 46 | std::string str_idle_time(c_idle_time); | ||
195 | 47 | try | ||
196 | 48 | { | ||
197 | 49 | int env_value = std::stoi(str_idle_time); | ||
198 | 50 | if (env_value < 1000) | ||
199 | 51 | { | ||
200 | 52 | std::ostringstream s; | ||
201 | 53 | s << "Value for env variable THUMBNAILER_MAX_IDLE \"" << env_value << "\" must be >= 1000."; | ||
202 | 54 | throw std::invalid_argument(s.str()); | ||
203 | 55 | } | ||
204 | 56 | return env_value; | ||
205 | 57 | } | ||
206 | 58 | catch (std::exception& e) | ||
207 | 59 | { | ||
208 | 60 | std::ostringstream s; | ||
209 | 61 | s << "Value for env variable THUMBNAILER_MAX_IDLE \"" << str_idle_time << "\" must be >= 1000."; | ||
210 | 62 | throw std::invalid_argument(s.str()); | ||
211 | 63 | } | ||
212 | 64 | } | ||
213 | 65 | return DFLT_MAX_IDLE; | ||
214 | 66 | } | ||
215 | 67 | |||
216 | 68 | QString EnvVars::get_ubuntu_server_url() | ||
217 | 69 | { | ||
218 | 70 | char const* override_url = getenv(UBUNTU_SERVER_URL); | ||
219 | 71 | if (override_url && *override_url) | ||
220 | 72 | { | ||
221 | 73 | return override_url; | ||
222 | 74 | } | ||
223 | 75 | return DFLT_UBUNTU_SERVER_URL; | ||
224 | 76 | } | ||
225 | 77 | |||
226 | 78 | QString EnvVars::get_util_dir() | ||
227 | 79 | { | ||
228 | 80 | char const* utildir = getenv(UTIL_DIR); | ||
229 | 81 | if (utildir && *utildir) | ||
230 | 82 | { | ||
231 | 83 | return utildir; | ||
232 | 84 | } | ||
233 | 85 | |||
234 | 86 | #ifdef SNAP_BUILD | ||
235 | 87 | char const* snapdir = getenv("SNAP"); | ||
236 | 88 | if (!snapdir || !*snapdir) | ||
237 | 89 | { | ||
238 | 90 | throw std::runtime_error("Environment variable SNAP is not set or empty."); | ||
239 | 91 | } | ||
240 | 92 | return QString(snapdir) + "/" + SHARE_PRIV_ABS; | ||
241 | 93 | #else | ||
242 | 94 | return SHARE_PRIV_ABS; | ||
243 | 95 | #endif | ||
244 | 96 | } | ||
245 | 97 | |||
246 | 98 | int EnvVars::get_log_level() | ||
247 | 99 | { | ||
248 | 100 | char const* level = getenv(LOG_LEVEL); | ||
249 | 101 | if (level && *level) | ||
250 | 102 | { | ||
251 | 103 | int l; | ||
252 | 104 | try | ||
253 | 105 | { | ||
254 | 106 | l = std::stoi(level); | ||
255 | 107 | } | ||
256 | 108 | catch (std::exception const& e) | ||
257 | 109 | { | ||
258 | 110 | qCritical() << "Environment variable" << LOG_LEVEL << "has invalid setting:" << level | ||
259 | 111 | << "(expected value in range 0..2) - variable ignored"; | ||
260 | 112 | return -1; | ||
261 | 113 | } | ||
262 | 114 | if (l < 0 || l > 2) | ||
263 | 115 | { | ||
264 | 116 | qCritical() << "Environment variable" << LOG_LEVEL << "has invalid setting:" << level | ||
265 | 117 | << "(expected value in range 0..2) - variable ignored"; | ||
266 | 118 | return -1; | ||
267 | 119 | } | ||
268 | 120 | return l; | ||
269 | 121 | } | ||
270 | 122 | return -1; | ||
271 | 123 | } | ||
272 | 124 | |||
273 | 125 | string EnvVars::get_cache_dir() | ||
274 | 126 | { | ||
275 | 127 | string cache_dir = g_get_user_cache_dir(); // Always returns something, even HOME and XDG_CACHE_HOME are not set. | ||
276 | 128 | |||
277 | 129 | #ifdef SNAP_BUILD | ||
278 | 130 | // When running in a snap, g_get_user_cache_dir() returns $SNAP_USER_DATA (not shared among snap versions), | ||
279 | 131 | // but we want $SNAP_USER_COMMON, which is shared. PersistentCache automatically deals with versioning | ||
280 | 132 | // changes in the database, so reverting to a snap with an earlier DB schema is safe. | ||
281 | 133 | char const* user_common = getenv("SNAP_USER_COMMON"); | ||
282 | 134 | if (user_common && *user_common) | ||
283 | 135 | { | ||
284 | 136 | return user_common; | ||
285 | 137 | } | ||
286 | 138 | setenv("SNAP_USER_COMMON", cache_dir.c_str(), 1); | ||
287 | 139 | #endif | ||
288 | 140 | |||
289 | 141 | return cache_dir; | ||
290 | 142 | } | ||
291 | 143 | |||
292 | 144 | } // namespace internal | ||
293 | 145 | |||
294 | 146 | } // namespace thumbnailer | ||
295 | 147 | |||
296 | 148 | } // namespace unity | ||
297 | 0 | 149 | ||
298 | === modified file 'src/file_io.cpp' | |||
299 | --- src/file_io.cpp 2015-12-02 12:48:12 +0000 | |||
300 | +++ src/file_io.cpp 2017-02-03 07:36:24 +0000 | |||
301 | @@ -90,7 +90,7 @@ | |||
302 | 90 | int fd = mkstemp(&tmp_path[0]); | 90 | int fd = mkstemp(&tmp_path[0]); |
303 | 91 | if (fd == -1) | 91 | if (fd == -1) |
304 | 92 | { | 92 | { |
306 | 93 | string s = string("write_file(): mkstemp() failed for " + tmp_path + ": ") + safe_strerror(errno); | 93 | string s = string("write_file(): cannot create temp file in " + dir.native() + ": ") + safe_strerror(errno); |
307 | 94 | throw runtime_error(s); | 94 | throw runtime_error(s); |
308 | 95 | } | 95 | } |
309 | 96 | 96 | ||
310 | 97 | 97 | ||
311 | === modified file 'src/imageextractor.cpp' | |||
312 | --- src/imageextractor.cpp 2016-03-18 22:49:32 +0000 | |||
313 | +++ src/imageextractor.cpp 2017-02-03 07:36:24 +0000 | |||
314 | @@ -20,7 +20,6 @@ | |||
315 | 20 | 20 | ||
316 | 21 | #include <internal/imageextractor.h> | 21 | #include <internal/imageextractor.h> |
317 | 22 | 22 | ||
318 | 23 | #include <internal/config.h> | ||
319 | 24 | #include <internal/env_vars.h> | 23 | #include <internal/env_vars.h> |
320 | 25 | #include <internal/safe_strerror.h> | 24 | #include <internal/safe_strerror.h> |
321 | 26 | 25 | ||
322 | @@ -102,9 +101,7 @@ | |||
323 | 102 | { | 101 | { |
324 | 103 | // Gstreamer video pipelines are unstable so we need to run an | 102 | // Gstreamer video pipelines are unstable so we need to run an |
325 | 104 | // external helper executable. | 103 | // external helper executable. |
329 | 105 | char* utildir = getenv(UTIL_DIR); | 104 | exe_path_ = EnvVars::get_util_dir() + "/vs-thumb"; |
327 | 106 | exe_path_ = utildir ? utildir : SHARE_PRIV_ABS; | ||
328 | 107 | exe_path_ += QLatin1String("/vs-thumb"); | ||
330 | 108 | QUrl in_url = QUrl::fromLocalFile(filename_.c_str()); | 105 | QUrl in_url = QUrl::fromLocalFile(filename_.c_str()); |
331 | 109 | QUrl out_url; | 106 | QUrl out_url; |
332 | 110 | out_url.setScheme("fd"); | 107 | out_url.setScheme("fd"); |
333 | 111 | 108 | ||
334 | === modified file 'src/service/inactivityhandler.cpp' | |||
335 | --- src/service/inactivityhandler.cpp 2015-12-12 02:06:41 +0000 | |||
336 | +++ src/service/inactivityhandler.cpp 2017-02-03 07:36:24 +0000 | |||
337 | @@ -28,44 +28,6 @@ | |||
338 | 28 | #include <sstream> | 28 | #include <sstream> |
339 | 29 | #include <string> | 29 | #include <string> |
340 | 30 | 30 | ||
341 | 31 | const int MAX_INACTIVITY_TIME = 30000; // max inactivity time before exiting the app, in milliseconds | ||
342 | 32 | |||
343 | 33 | namespace | ||
344 | 34 | { | ||
345 | 35 | |||
346 | 36 | int get_env_inactivity_time(int default_value) | ||
347 | 37 | { | ||
348 | 38 | using namespace unity::thumbnailer::internal; | ||
349 | 39 | |||
350 | 40 | char const* c_idle_time = getenv(MAX_IDLE); | ||
351 | 41 | if (c_idle_time) | ||
352 | 42 | { | ||
353 | 43 | std::string str_idle_time(c_idle_time); | ||
354 | 44 | try | ||
355 | 45 | { | ||
356 | 46 | int env_value = std::stoi(str_idle_time); | ||
357 | 47 | if (env_value < 1000) | ||
358 | 48 | { | ||
359 | 49 | std::ostringstream s; | ||
360 | 50 | s << "InactivityHandler::InactivityHandler(): Value for env variable THUMBNAILER_MAX_IDLE \"" | ||
361 | 51 | << env_value << "\" must be >= 1000."; | ||
362 | 52 | throw std::invalid_argument(s.str()); | ||
363 | 53 | } | ||
364 | 54 | return env_value; | ||
365 | 55 | } | ||
366 | 56 | catch (std::exception& e) | ||
367 | 57 | { | ||
368 | 58 | std::ostringstream s; | ||
369 | 59 | s << "InactivityHandler::InactivityHandler(): Value for env variable THUMBNAILER_MAX_IDLE \"" | ||
370 | 60 | << str_idle_time << "\" must be >= 1000."; | ||
371 | 61 | throw std::invalid_argument(s.str()); | ||
372 | 62 | } | ||
373 | 63 | } | ||
374 | 64 | return default_value; | ||
375 | 65 | } | ||
376 | 66 | |||
377 | 67 | } // namespace | ||
378 | 68 | |||
379 | 69 | namespace unity | 31 | namespace unity |
380 | 70 | { | 32 | { |
381 | 71 | 33 | ||
382 | @@ -81,7 +43,7 @@ | |||
383 | 81 | { | 43 | { |
384 | 82 | assert(timer_func); | 44 | assert(timer_func); |
385 | 83 | connect(&timer_, &QTimer::timeout, this, &InactivityHandler::timer_expired); | 45 | connect(&timer_, &QTimer::timeout, this, &InactivityHandler::timer_expired); |
387 | 84 | timer_.setInterval(get_env_inactivity_time(MAX_INACTIVITY_TIME)); | 46 | timer_.setInterval(internal::EnvVars::get_max_idle()); |
388 | 85 | } | 47 | } |
389 | 86 | 48 | ||
390 | 87 | InactivityHandler::~InactivityHandler() | 49 | InactivityHandler::~InactivityHandler() |
391 | 88 | 50 | ||
392 | === modified file 'src/settings.cpp' | |||
393 | --- src/settings.cpp 2016-01-11 07:33:57 +0000 | |||
394 | +++ src/settings.cpp 2017-02-03 07:36:24 +0000 | |||
395 | @@ -139,26 +139,9 @@ | |||
396 | 139 | using namespace unity::thumbnailer::internal; | 139 | using namespace unity::thumbnailer::internal; |
397 | 140 | 140 | ||
398 | 141 | int log_level = get_positive_or_zero_int("log-level", LOG_LEVEL_DEFAULT); | 141 | int log_level = get_positive_or_zero_int("log-level", LOG_LEVEL_DEFAULT); |
401 | 142 | char const* level = getenv(LOG_LEVEL); | 142 | int l = EnvVars::get_log_level(); |
402 | 143 | if (level && *level) | 143 | if (l != -1) |
403 | 144 | { | 144 | { |
404 | 145 | int l; | ||
405 | 146 | try | ||
406 | 147 | { | ||
407 | 148 | l = std::stoi(level); | ||
408 | 149 | } | ||
409 | 150 | catch (std::exception const& e) | ||
410 | 151 | { | ||
411 | 152 | qCritical() << "Environment variable" << LOG_LEVEL << "has invalid setting:" << level | ||
412 | 153 | << "(expected value in range 0..2) - variable ignored"; | ||
413 | 154 | return log_level; | ||
414 | 155 | } | ||
415 | 156 | if (l < 0 || l > 2) | ||
416 | 157 | { | ||
417 | 158 | qCritical() << "Environment variable" << LOG_LEVEL << "has invalid setting:" << level | ||
418 | 159 | << "(expected value in range 0..2) - variable ignored"; | ||
419 | 160 | return log_level; | ||
420 | 161 | } | ||
421 | 162 | log_level = l; | 145 | log_level = l; |
422 | 163 | } | 146 | } |
423 | 164 | return log_level; | 147 | return log_level; |
424 | 165 | 148 | ||
425 | === modified file 'src/thumbnailer.cpp' | |||
426 | --- src/thumbnailer.cpp 2017-01-30 08:24:44 +0000 | |||
427 | +++ src/thumbnailer.cpp 2017-02-03 07:36:24 +0000 | |||
428 | @@ -23,6 +23,7 @@ | |||
429 | 23 | #include <internal/artreply.h> | 23 | #include <internal/artreply.h> |
430 | 24 | #include <internal/cachehelper.h> | 24 | #include <internal/cachehelper.h> |
431 | 25 | #include <internal/check_access.h> | 25 | #include <internal/check_access.h> |
432 | 26 | #include <internal/env_vars.h> | ||
433 | 26 | #include <internal/image.h> | 27 | #include <internal/image.h> |
434 | 27 | #include <internal/imageextractor.h> | 28 | #include <internal/imageextractor.h> |
435 | 28 | #include <internal/local_album_art.h> | 29 | #include <internal/local_album_art.h> |
436 | @@ -744,8 +745,7 @@ | |||
437 | 744 | Thumbnailer::Thumbnailer() | 745 | Thumbnailer::Thumbnailer() |
438 | 745 | : downloader_(new UbuntuServerDownloader()) | 746 | : downloader_(new UbuntuServerDownloader()) |
439 | 746 | { | 747 | { |
442 | 747 | string xdg_base = g_get_user_cache_dir(); // Always returns something, even HOME and XDG_CACHE_HOME are not set. | 748 | string cache_dir = EnvVars::get_cache_dir() + "/unity-thumbnailer"; |
441 | 748 | string cache_dir = xdg_base + "/unity-thumbnailer"; | ||
443 | 749 | make_directories(cache_dir, 0700); | 749 | make_directories(cache_dir, 0700); |
444 | 750 | 750 | ||
445 | 751 | try | 751 | try |
446 | 752 | 752 | ||
447 | === modified file 'src/ubuntuserverdownloader.cpp' | |||
448 | --- src/ubuntuserverdownloader.cpp 2016-01-05 07:00:49 +0000 | |||
449 | +++ src/ubuntuserverdownloader.cpp 2017-02-03 07:36:24 +0000 | |||
450 | @@ -99,17 +99,6 @@ | |||
451 | 99 | return key; | 99 | return key; |
452 | 100 | } | 100 | } |
453 | 101 | 101 | ||
454 | 102 | char const* server_url() | ||
455 | 103 | { | ||
456 | 104 | char const* server_url = DFLT_SERVER_URL; | ||
457 | 105 | char const* override_url = getenv(thumbnailer::internal::UBUNTU_SERVER_URL); | ||
458 | 106 | if (override_url && *override_url) | ||
459 | 107 | { | ||
460 | 108 | server_url = override_url; | ||
461 | 109 | } | ||
462 | 110 | return server_url; | ||
463 | 111 | } | ||
464 | 112 | |||
465 | 113 | } // namespace | 102 | } // namespace |
466 | 114 | 103 | ||
467 | 115 | class UbuntuServerArtReply : public ArtReply | 104 | class UbuntuServerArtReply : public ArtReply |
468 | @@ -279,7 +268,7 @@ | |||
469 | 279 | QString const& album, | 268 | QString const& album, |
470 | 280 | chrono::milliseconds timeout) | 269 | chrono::milliseconds timeout) |
471 | 281 | { | 270 | { |
473 | 282 | auto url = make_art_url(server_url(), ALBUM_ART_BASE_URL, artist, album, api_key_); | 271 | auto url = make_art_url(EnvVars::get_ubuntu_server_url(), ALBUM_ART_BASE_URL, artist, album, api_key_); |
474 | 283 | return download_url(url, timeout); | 272 | return download_url(url, timeout); |
475 | 284 | } | 273 | } |
476 | 285 | 274 | ||
477 | @@ -287,7 +276,7 @@ | |||
478 | 287 | QString const& album, | 276 | QString const& album, |
479 | 288 | chrono::milliseconds timeout) | 277 | chrono::milliseconds timeout) |
480 | 289 | { | 278 | { |
482 | 290 | auto url = make_art_url(server_url(), ARTIST_ART_BASE_URL, artist, album, api_key_); | 279 | auto url = make_art_url(EnvVars::get_ubuntu_server_url(), ARTIST_ART_BASE_URL, artist, album, api_key_); |
483 | 291 | return download_url(url, timeout); | 280 | return download_url(url, timeout); |
484 | 292 | } | 281 | } |
485 | 293 | 282 | ||
486 | 294 | 283 | ||
487 | === modified file 'tests/dbus/dbus_test.cpp' | |||
488 | --- tests/dbus/dbus_test.cpp 2017-01-17 04:13:01 +0000 | |||
489 | +++ tests/dbus/dbus_test.cpp 2017-02-03 07:36:24 +0000 | |||
490 | @@ -74,8 +74,8 @@ | |||
491 | 74 | tempdir.reset(new QTemporaryDir(TESTBINDIR "/dbus-test.XXXXXX")); | 74 | tempdir.reset(new QTemporaryDir(TESTBINDIR "/dbus-test.XXXXXX")); |
492 | 75 | setenv("XDG_CACHE_HOME", (tempdir->path() + "/cache").toUtf8().data(), true); | 75 | setenv("XDG_CACHE_HOME", (tempdir->path() + "/cache").toUtf8().data(), true); |
493 | 76 | 76 | ||
496 | 77 | setenv(MAX_IDLE, "1000", true); | 77 | setenv(EnvVars::MAX_IDLE, "1000", true); |
497 | 78 | setenv(LOG_LEVEL, "2", true); // For coverage | 78 | setenv(EnvVars::LOG_LEVEL, "2", true); // For coverage |
498 | 79 | 79 | ||
499 | 80 | dbus_.reset(new DBusServer()); | 80 | dbus_.reset(new DBusServer()); |
500 | 81 | } | 81 | } |
501 | @@ -90,7 +90,7 @@ | |||
502 | 90 | dbus_.reset(); | 90 | dbus_.reset(); |
503 | 91 | art_server_.reset(); | 91 | art_server_.reset(); |
504 | 92 | 92 | ||
506 | 93 | unsetenv(MAX_IDLE); | 93 | unsetenv(EnvVars::MAX_IDLE); |
507 | 94 | unsetenv("XDG_CACHE_HOME"); | 94 | unsetenv("XDG_CACHE_HOME"); |
508 | 95 | tempdir.reset(); | 95 | tempdir.reset(); |
509 | 96 | } | 96 | } |
510 | @@ -318,7 +318,7 @@ | |||
511 | 318 | QTemporaryDir tempdir(TESTBINDIR "/dbus-test.XXXXXX"); | 318 | QTemporaryDir tempdir(TESTBINDIR "/dbus-test.XXXXXX"); |
512 | 319 | setenv("XDG_CACHE_HOME", (tempdir.path() + "/cache").toUtf8().data(), true); | 319 | setenv("XDG_CACHE_HOME", (tempdir.path() + "/cache").toUtf8().data(), true); |
513 | 320 | 320 | ||
515 | 321 | EnvVarGuard ev_guard(MAX_IDLE, "bad_value"); | 321 | EnvVarGuard ev_guard(EnvVars::MAX_IDLE, "bad_value"); |
516 | 322 | try | 322 | try |
517 | 323 | { | 323 | { |
518 | 324 | unique_ptr<DBusServer> dbus(new DBusServer()); | 324 | unique_ptr<DBusServer> dbus(new DBusServer()); |
519 | @@ -341,7 +341,7 @@ | |||
520 | 341 | QTemporaryDir tempdir(TESTBINDIR "/dbus-test.XXXXXX"); | 341 | QTemporaryDir tempdir(TESTBINDIR "/dbus-test.XXXXXX"); |
521 | 342 | setenv("XDG_CACHE_HOME", (tempdir.path() + "/cache").toUtf8().data(), true); | 342 | setenv("XDG_CACHE_HOME", (tempdir.path() + "/cache").toUtf8().data(), true); |
522 | 343 | 343 | ||
524 | 344 | EnvVarGuard ev_guard(MAX_IDLE, "999"); | 344 | EnvVarGuard ev_guard(EnvVars::MAX_IDLE, "999"); |
525 | 345 | try | 345 | try |
526 | 346 | { | 346 | { |
527 | 347 | unique_ptr<DBusServer> dbus(new DBusServer()); | 347 | unique_ptr<DBusServer> dbus(new DBusServer()); |
528 | @@ -359,7 +359,7 @@ | |||
529 | 359 | QTemporaryDir tempdir(TESTBINDIR "/dbus-test.XXXXXX"); | 359 | QTemporaryDir tempdir(TESTBINDIR "/dbus-test.XXXXXX"); |
530 | 360 | setenv("XDG_CACHE_HOME", (tempdir.path() + "/cache").toUtf8().data(), true); | 360 | setenv("XDG_CACHE_HOME", (tempdir.path() + "/cache").toUtf8().data(), true); |
531 | 361 | 361 | ||
533 | 362 | EnvVarGuard ev_guard(MAX_IDLE, nullptr); | 362 | EnvVarGuard ev_guard(EnvVars::MAX_IDLE, nullptr); |
534 | 363 | unique_ptr<DBusServer> dbus(new DBusServer()); // For coverage with default timeout. | 363 | unique_ptr<DBusServer> dbus(new DBusServer()); // For coverage with default timeout. |
535 | 364 | } | 364 | } |
536 | 365 | 365 | ||
537 | @@ -623,7 +623,7 @@ | |||
538 | 623 | 623 | ||
539 | 624 | setenv("GSETTINGS_BACKEND", "memory", true); | 624 | setenv("GSETTINGS_BACKEND", "memory", true); |
540 | 625 | setenv("GSETTINGS_SCHEMA_DIR", GSETTINGS_SCHEMA_DIR, true); | 625 | setenv("GSETTINGS_SCHEMA_DIR", GSETTINGS_SCHEMA_DIR, true); |
542 | 626 | setenv(UTIL_DIR, TESTBINDIR "/../src/vs-thumb", true); | 626 | setenv(EnvVars::UTIL_DIR, TESTBINDIR "/../src/vs-thumb", true); |
543 | 627 | ::testing::InitGoogleTest(&argc, argv); | 627 | ::testing::InitGoogleTest(&argc, argv); |
544 | 628 | return RUN_ALL_TESTS(); | 628 | return RUN_ALL_TESTS(); |
545 | 629 | } | 629 | } |
546 | 630 | 630 | ||
547 | === modified file 'tests/download/download_test.cpp' | |||
548 | --- tests/download/download_test.cpp 2017-01-17 04:13:01 +0000 | |||
549 | +++ tests/download/download_test.cpp 2017-02-03 07:36:24 +0000 | |||
550 | @@ -234,7 +234,7 @@ | |||
551 | 234 | QCoreApplication qt_app(argc, argv); | 234 | QCoreApplication qt_app(argc, argv); |
552 | 235 | setenv("GSETTINGS_BACKEND", "memory", true); | 235 | setenv("GSETTINGS_BACKEND", "memory", true); |
553 | 236 | setenv("GSETTINGS_SCHEMA_DIR", GSETTINGS_SCHEMA_DIR, true); | 236 | setenv("GSETTINGS_SCHEMA_DIR", GSETTINGS_SCHEMA_DIR, true); |
555 | 237 | setenv(UBUNTU_SERVER_URL, "http://127.0.0.1", true); | 237 | setenv(EnvVars::UBUNTU_SERVER_URL, "http://127.0.0.1", true); |
556 | 238 | ::testing::InitGoogleTest(&argc, argv); | 238 | ::testing::InitGoogleTest(&argc, argv); |
557 | 239 | return RUN_ALL_TESTS(); | 239 | return RUN_ALL_TESTS(); |
558 | 240 | } | 240 | } |
559 | 241 | 241 | ||
560 | === modified file 'tests/file_io/file_io_test.cpp' | |||
561 | --- tests/file_io/file_io_test.cpp 2017-01-17 04:13:01 +0000 | |||
562 | +++ tests/file_io/file_io_test.cpp 2017-02-03 07:36:24 +0000 | |||
563 | @@ -113,7 +113,7 @@ | |||
564 | 113 | { | 113 | { |
565 | 114 | chmod(dir.c_str(), 0700); | 114 | chmod(dir.c_str(), 0700); |
566 | 115 | string msg = e.what(); | 115 | string msg = e.what(); |
568 | 116 | EXPECT_TRUE(boost::starts_with(msg, "write_file(): mkstemp() failed for ")) << msg; | 116 | EXPECT_TRUE(boost::starts_with(msg, "write_file(): cannot create temp file in ")) << msg; |
569 | 117 | } | 117 | } |
570 | 118 | 118 | ||
571 | 119 | try | 119 | try |
572 | 120 | 120 | ||
573 | === modified file 'tests/image-provider/image-provider_test.cpp' | |||
574 | --- tests/image-provider/image-provider_test.cpp 2017-01-17 04:13:01 +0000 | |||
575 | +++ tests/image-provider/image-provider_test.cpp 2017-02-03 07:36:24 +0000 | |||
576 | @@ -40,7 +40,6 @@ | |||
577 | 40 | 40 | ||
578 | 41 | using namespace std; | 41 | using namespace std; |
579 | 42 | using namespace unity::thumbnailer::qml; | 42 | using namespace unity::thumbnailer::qml; |
580 | 43 | using unity::thumbnailer::internal::UTIL_DIR; | ||
581 | 44 | using unity::thumbnailer::qt::Thumbnailer; | 43 | using unity::thumbnailer::qt::Thumbnailer; |
582 | 45 | 44 | ||
583 | 46 | class ProviderTest : public ::testing::Test | 45 | class ProviderTest : public ::testing::Test |
584 | @@ -214,7 +213,7 @@ | |||
585 | 214 | QGuiApplication app(argc, argv); | 213 | QGuiApplication app(argc, argv); |
586 | 215 | setenv("GSETTINGS_BACKEND", "memory", true); | 214 | setenv("GSETTINGS_BACKEND", "memory", true); |
587 | 216 | setenv("GSETTINGS_SCHEMA_DIR", GSETTINGS_SCHEMA_DIR, true); | 215 | setenv("GSETTINGS_SCHEMA_DIR", GSETTINGS_SCHEMA_DIR, true); |
589 | 217 | setenv(UTIL_DIR, TESTBINDIR "/../src/vs-thumb", true); | 216 | setenv(unity::thumbnailer::internal::EnvVars::UTIL_DIR, TESTBINDIR "/../src/vs-thumb", true); |
590 | 218 | ::testing::InitGoogleTest(&argc, argv); | 217 | ::testing::InitGoogleTest(&argc, argv); |
591 | 219 | return RUN_ALL_TESTS(); | 218 | return RUN_ALL_TESTS(); |
592 | 220 | } | 219 | } |
593 | 221 | 220 | ||
594 | === modified file 'tests/libthumbnailer-qt/libthumbnailer-qt_test.cpp' | |||
595 | --- tests/libthumbnailer-qt/libthumbnailer-qt_test.cpp 2017-01-17 04:13:01 +0000 | |||
596 | +++ tests/libthumbnailer-qt/libthumbnailer-qt_test.cpp 2017-02-03 07:36:24 +0000 | |||
597 | @@ -82,7 +82,7 @@ | |||
598 | 82 | tempdir.reset(new QTemporaryDir(TESTBINDIR "/libthumbnailer-qt.XXXXXX")); | 82 | tempdir.reset(new QTemporaryDir(TESTBINDIR "/libthumbnailer-qt.XXXXXX")); |
599 | 83 | setenv("XDG_CACHE_HOME", (tempdir->path() + "/cache").toUtf8().data(), true); | 83 | setenv("XDG_CACHE_HOME", (tempdir->path() + "/cache").toUtf8().data(), true); |
600 | 84 | 84 | ||
602 | 85 | setenv(MAX_IDLE, "10000", true); | 85 | setenv(EnvVars::MAX_IDLE, "10000", true); |
603 | 86 | 86 | ||
604 | 87 | dbus_.reset(new DBusServer()); | 87 | dbus_.reset(new DBusServer()); |
605 | 88 | } | 88 | } |
606 | @@ -97,7 +97,7 @@ | |||
607 | 97 | dbus_.reset(); | 97 | dbus_.reset(); |
608 | 98 | art_server_.reset(); | 98 | art_server_.reset(); |
609 | 99 | 99 | ||
611 | 100 | unsetenv(MAX_IDLE); | 100 | unsetenv(EnvVars::MAX_IDLE); |
612 | 101 | unsetenv("XDG_CACHE_HOME"); | 101 | unsetenv("XDG_CACHE_HOME"); |
613 | 102 | tempdir.reset(); | 102 | tempdir.reset(); |
614 | 103 | } | 103 | } |
615 | @@ -794,7 +794,7 @@ | |||
616 | 794 | 794 | ||
617 | 795 | setenv("GSETTINGS_BACKEND", "memory", true); | 795 | setenv("GSETTINGS_BACKEND", "memory", true); |
618 | 796 | setenv("GSETTINGS_SCHEMA_DIR", GSETTINGS_SCHEMA_DIR, true); | 796 | setenv("GSETTINGS_SCHEMA_DIR", GSETTINGS_SCHEMA_DIR, true); |
620 | 797 | setenv(UTIL_DIR, TESTBINDIR "/../src/vs-thumb", true); | 797 | setenv(EnvVars::UTIL_DIR, TESTBINDIR "/../src/vs-thumb", true); |
621 | 798 | 798 | ||
622 | 799 | // Turn on trace so we get coverage on those parts of the code. | 799 | // Turn on trace so we get coverage on those parts of the code. |
623 | 800 | gobj_ptr<GSettings> gsettings(g_settings_new("com.canonical.Unity.Thumbnailer")); | 800 | gobj_ptr<GSettings> gsettings(g_settings_new("com.canonical.Unity.Thumbnailer")); |
624 | 801 | 801 | ||
625 | === modified file 'tests/qml/qml_test.cpp' | |||
626 | --- tests/qml/qml_test.cpp 2016-09-26 00:30:42 +0000 | |||
627 | +++ tests/qml/qml_test.cpp 2017-02-03 07:36:24 +0000 | |||
628 | @@ -78,7 +78,7 @@ | |||
629 | 78 | 78 | ||
630 | 79 | setenv("GSETTINGS_BACKEND", "memory", true); | 79 | setenv("GSETTINGS_BACKEND", "memory", true); |
631 | 80 | setenv("GSETTINGS_SCHEMA_DIR", GSETTINGS_SCHEMA_DIR, true); | 80 | setenv("GSETTINGS_SCHEMA_DIR", GSETTINGS_SCHEMA_DIR, true); |
633 | 81 | setenv(unity::thumbnailer::internal::UTIL_DIR, TESTBINDIR "/../src/vs-thumb", true); | 81 | setenv(unity::thumbnailer::internal::EnvVars::UTIL_DIR, TESTBINDIR "/../src/vs-thumb", true); |
634 | 82 | qmlRegisterSingletonType("testconfig", 1, 0, "Config", make_test_config); | 82 | qmlRegisterSingletonType("testconfig", 1, 0, "Config", make_test_config); |
635 | 83 | qmlProtectModule("testconfig", 1); | 83 | qmlProtectModule("testconfig", 1); |
636 | 84 | 84 | ||
637 | 85 | 85 | ||
638 | === modified file 'tests/settings/settings_test.cpp' | |||
639 | --- tests/settings/settings_test.cpp 2017-01-17 04:13:01 +0000 | |||
640 | +++ tests/settings/settings_test.cpp 2017-02-03 07:36:24 +0000 | |||
641 | @@ -188,7 +188,7 @@ | |||
642 | 188 | 188 | ||
643 | 189 | TEST(Settings, log_level_env_override) | 189 | TEST(Settings, log_level_env_override) |
644 | 190 | { | 190 | { |
646 | 191 | EnvVarGuard ev_guard(LOG_LEVEL, "0"); | 191 | EnvVarGuard ev_guard(EnvVars::LOG_LEVEL, "0"); |
647 | 192 | 192 | ||
648 | 193 | Settings settings; | 193 | Settings settings; |
649 | 194 | EXPECT_EQ(0, settings.log_level()); | 194 | EXPECT_EQ(0, settings.log_level()); |
650 | @@ -196,7 +196,7 @@ | |||
651 | 196 | 196 | ||
652 | 197 | TEST(Settings, log_level_env_bad_setting) | 197 | TEST(Settings, log_level_env_bad_setting) |
653 | 198 | { | 198 | { |
655 | 199 | EnvVarGuard ev_guard(LOG_LEVEL, "abc"); | 199 | EnvVarGuard ev_guard(EnvVars::LOG_LEVEL, "abc"); |
656 | 200 | 200 | ||
657 | 201 | Settings settings; | 201 | Settings settings; |
658 | 202 | EXPECT_EQ(1, settings.log_level()); | 202 | EXPECT_EQ(1, settings.log_level()); |
659 | @@ -204,7 +204,7 @@ | |||
660 | 204 | 204 | ||
661 | 205 | TEST(Settings, log_level_out_of_range) | 205 | TEST(Settings, log_level_out_of_range) |
662 | 206 | { | 206 | { |
664 | 207 | EnvVarGuard ev_guard(LOG_LEVEL, "3"); | 207 | EnvVarGuard ev_guard(EnvVars::LOG_LEVEL, "3"); |
665 | 208 | 208 | ||
666 | 209 | Settings settings; | 209 | Settings settings; |
667 | 210 | EXPECT_EQ(1, settings.log_level()); | 210 | EXPECT_EQ(1, settings.log_level()); |
668 | 211 | 211 | ||
669 | === modified file 'tests/slow-vs-thumb/slow-vs-thumb_test.cpp' | |||
670 | --- tests/slow-vs-thumb/slow-vs-thumb_test.cpp 2017-01-17 04:13:01 +0000 | |||
671 | +++ tests/slow-vs-thumb/slow-vs-thumb_test.cpp 2017-02-03 07:36:24 +0000 | |||
672 | @@ -82,7 +82,7 @@ | |||
673 | 82 | QCoreApplication app(argc, argv); | 82 | QCoreApplication app(argc, argv); |
674 | 83 | 83 | ||
675 | 84 | // Run fake vs-thumb that does nothing for 20 seconds. | 84 | // Run fake vs-thumb that does nothing for 20 seconds. |
677 | 85 | setenv(UTIL_DIR, TESTSRCDIR "/slow-vs-thumb/slow", true); | 85 | setenv(EnvVars::UTIL_DIR, TESTSRCDIR "/slow-vs-thumb/slow", true); |
678 | 86 | ::testing::InitGoogleTest(&argc, argv); | 86 | ::testing::InitGoogleTest(&argc, argv); |
679 | 87 | return RUN_ALL_TESTS(); | 87 | return RUN_ALL_TESTS(); |
680 | 88 | } | 88 | } |
681 | 89 | 89 | ||
682 | === modified file 'tests/stress/stress_test.cpp' | |||
683 | --- tests/stress/stress_test.cpp 2017-01-17 04:13:01 +0000 | |||
684 | +++ tests/stress/stress_test.cpp 2017-02-03 07:36:24 +0000 | |||
685 | @@ -163,7 +163,7 @@ | |||
686 | 163 | tempdir.reset(new QTemporaryDir(TESTBINDIR "/stress-test.XXXXXX")); | 163 | tempdir.reset(new QTemporaryDir(TESTBINDIR "/stress-test.XXXXXX")); |
687 | 164 | setenv("XDG_CACHE_HOME", (tempdir->path() + "/cache").toUtf8().data(), true); | 164 | setenv("XDG_CACHE_HOME", (tempdir->path() + "/cache").toUtf8().data(), true); |
688 | 165 | 165 | ||
690 | 166 | setenv(MAX_IDLE, "30000", true); | 166 | setenv(EnvVars::MAX_IDLE, "30000", true); |
691 | 167 | 167 | ||
692 | 168 | dbus_.reset(new DBusServer()); | 168 | dbus_.reset(new DBusServer()); |
693 | 169 | thumbnailer_.reset(new unity::thumbnailer::qt::Thumbnailer(dbus_->connection())); | 169 | thumbnailer_.reset(new unity::thumbnailer::qt::Thumbnailer(dbus_->connection())); |
694 | @@ -224,7 +224,7 @@ | |||
695 | 224 | dbus_.reset(); | 224 | dbus_.reset(); |
696 | 225 | art_server_.reset(); | 225 | art_server_.reset(); |
697 | 226 | 226 | ||
699 | 227 | unsetenv(MAX_IDLE); | 227 | unsetenv(EnvVars::MAX_IDLE); |
700 | 228 | unsetenv("XDG_CACHE_HOME"); | 228 | unsetenv("XDG_CACHE_HOME"); |
701 | 229 | tempdir.reset(); | 229 | tempdir.reset(); |
702 | 230 | 230 | ||
703 | @@ -612,8 +612,8 @@ | |||
704 | 612 | #endif | 612 | #endif |
705 | 613 | setenv("GSETTINGS_BACKEND", "memory", true); | 613 | setenv("GSETTINGS_BACKEND", "memory", true); |
706 | 614 | setenv("GSETTINGS_SCHEMA_DIR", GSETTINGS_SCHEMA_DIR, true); | 614 | setenv("GSETTINGS_SCHEMA_DIR", GSETTINGS_SCHEMA_DIR, true); |
709 | 615 | setenv(UTIL_DIR, TESTBINDIR "/../src/vs-thumb", true); | 615 | setenv(EnvVars::UTIL_DIR, TESTBINDIR "/../src/vs-thumb", true); |
710 | 616 | setenv(LOG_LEVEL, "0", true); | 616 | setenv(EnvVars::LOG_LEVEL, "0", true); |
711 | 617 | ::testing::InitGoogleTest(&argc, argv); | 617 | ::testing::InitGoogleTest(&argc, argv); |
712 | 618 | return RUN_ALL_TESTS(); | 618 | return RUN_ALL_TESTS(); |
713 | 619 | } | 619 | } |
714 | 620 | 620 | ||
715 | === modified file 'tests/thumbnailer-admin/thumbnailer-admin_test.cpp' | |||
716 | --- tests/thumbnailer-admin/thumbnailer-admin_test.cpp 2017-01-17 04:13:01 +0000 | |||
717 | +++ tests/thumbnailer-admin/thumbnailer-admin_test.cpp 2017-02-03 07:36:24 +0000 | |||
718 | @@ -48,7 +48,7 @@ | |||
719 | 48 | ASSERT_NE(-1, chdir(temp_dir().c_str())); | 48 | ASSERT_NE(-1, chdir(temp_dir().c_str())); |
720 | 49 | setenv("XDG_CACHE_HOME", qPrintable(tempdir->path() + "/cache"), true); | 49 | setenv("XDG_CACHE_HOME", qPrintable(tempdir->path() + "/cache"), true); |
721 | 50 | 50 | ||
723 | 51 | setenv(MAX_IDLE, "3000", true); | 51 | setenv(EnvVars::MAX_IDLE, "3000", true); |
724 | 52 | 52 | ||
725 | 53 | dbus_.reset(new DBusServer()); | 53 | dbus_.reset(new DBusServer()); |
726 | 54 | } | 54 | } |
727 | @@ -62,7 +62,7 @@ | |||
728 | 62 | { | 62 | { |
729 | 63 | dbus_.reset(); | 63 | dbus_.reset(); |
730 | 64 | 64 | ||
732 | 65 | unsetenv(MAX_IDLE); | 65 | unsetenv(EnvVars::MAX_IDLE); |
733 | 66 | unsetenv("XDG_CACHE_HOME"); | 66 | unsetenv("XDG_CACHE_HOME"); |
734 | 67 | tempdir.reset(); | 67 | tempdir.reset(); |
735 | 68 | } | 68 | } |
736 | @@ -723,7 +723,7 @@ | |||
737 | 723 | { | 723 | { |
738 | 724 | QCoreApplication app(argc, argv); | 724 | QCoreApplication app(argc, argv); |
739 | 725 | 725 | ||
741 | 726 | setenv(UTIL_DIR, TESTBINDIR "/../src/vs-thumb", true); | 726 | setenv(EnvVars::UTIL_DIR, TESTBINDIR "/../src/vs-thumb", true); |
742 | 727 | setenv("LC_ALL", "C", true); | 727 | setenv("LC_ALL", "C", true); |
743 | 728 | ::testing::InitGoogleTest(&argc, argv); | 728 | ::testing::InitGoogleTest(&argc, argv); |
744 | 729 | return RUN_ALL_TESTS(); | 729 | return RUN_ALL_TESTS(); |
745 | 730 | 730 | ||
746 | === modified file 'tests/thumbnailer/thumbnailer_test.cpp' | |||
747 | --- tests/thumbnailer/thumbnailer_test.cpp 2017-01-17 04:13:01 +0000 | |||
748 | +++ tests/thumbnailer/thumbnailer_test.cpp 2017-02-03 07:36:24 +0000 | |||
749 | @@ -447,7 +447,7 @@ | |||
750 | 447 | TEST_F(ThumbnailerTest, vs_thumb_exec_failure) | 447 | TEST_F(ThumbnailerTest, vs_thumb_exec_failure) |
751 | 448 | { | 448 | { |
752 | 449 | // Cause vs-thumb exec failure. | 449 | // Cause vs-thumb exec failure. |
754 | 450 | EnvVarGuard ev_guard(UTIL_DIR, "no_such_directory"); | 450 | EnvVarGuard ev_guard(EnvVars::UTIL_DIR, "no_such_directory"); |
755 | 451 | 451 | ||
756 | 452 | Thumbnailer tn; | 452 | Thumbnailer tn; |
757 | 453 | 453 | ||
758 | @@ -468,7 +468,7 @@ | |||
759 | 468 | TEST_F(ThumbnailerTest, vs_thumb_exit_1) | 468 | TEST_F(ThumbnailerTest, vs_thumb_exit_1) |
760 | 469 | { | 469 | { |
761 | 470 | // Run fake vs-thumb that exits with status 1 | 470 | // Run fake vs-thumb that exits with status 1 |
763 | 471 | EnvVarGuard ev_guard(UTIL_DIR, TESTSRCDIR "/thumbnailer/vs-thumb-exit-1"); | 471 | EnvVarGuard ev_guard(EnvVars::UTIL_DIR, TESTSRCDIR "/thumbnailer/vs-thumb-exit-1"); |
764 | 472 | 472 | ||
765 | 473 | Thumbnailer tn; | 473 | Thumbnailer tn; |
766 | 474 | 474 | ||
767 | @@ -489,7 +489,7 @@ | |||
768 | 489 | TEST_F(ThumbnailerTest, vs_thumb_exit_2) | 489 | TEST_F(ThumbnailerTest, vs_thumb_exit_2) |
769 | 490 | { | 490 | { |
770 | 491 | // Run fake vs-thumb that exits with status 2 | 491 | // Run fake vs-thumb that exits with status 2 |
772 | 492 | EnvVarGuard ev_guard(UTIL_DIR, TESTSRCDIR "/thumbnailer/vs-thumb-exit-2"); | 492 | EnvVarGuard ev_guard(EnvVars::UTIL_DIR, TESTSRCDIR "/thumbnailer/vs-thumb-exit-2"); |
773 | 493 | 493 | ||
774 | 494 | Thumbnailer tn; | 494 | Thumbnailer tn; |
775 | 495 | 495 | ||
776 | @@ -510,7 +510,7 @@ | |||
777 | 510 | TEST_F(ThumbnailerTest, vs_thumb_exit_99) | 510 | TEST_F(ThumbnailerTest, vs_thumb_exit_99) |
778 | 511 | { | 511 | { |
779 | 512 | // Run fake vs-thumb that exits with status 99 | 512 | // Run fake vs-thumb that exits with status 99 |
781 | 513 | EnvVarGuard ev_guard(UTIL_DIR, TESTSRCDIR "/thumbnailer/vs-thumb-exit-99"); | 513 | EnvVarGuard ev_guard(EnvVars::UTIL_DIR, TESTSRCDIR "/thumbnailer/vs-thumb-exit-99"); |
782 | 514 | 514 | ||
783 | 515 | Thumbnailer tn; | 515 | Thumbnailer tn; |
784 | 516 | 516 | ||
785 | @@ -531,7 +531,7 @@ | |||
786 | 531 | TEST_F(ThumbnailerTest, vs_thumb_crash) | 531 | TEST_F(ThumbnailerTest, vs_thumb_crash) |
787 | 532 | { | 532 | { |
788 | 533 | // Run fake vs-thumb that kills itself with SIGTERM | 533 | // Run fake vs-thumb that kills itself with SIGTERM |
790 | 534 | EnvVarGuard ev_guard(UTIL_DIR, TESTSRCDIR "/thumbnailer/vs-thumb-crash"); | 534 | EnvVarGuard ev_guard(EnvVars::UTIL_DIR, TESTSRCDIR "/thumbnailer/vs-thumb-crash"); |
791 | 535 | 535 | ||
792 | 536 | Thumbnailer tn; | 536 | Thumbnailer tn; |
793 | 537 | 537 | ||
794 | @@ -1011,7 +1011,7 @@ | |||
795 | 1011 | TEST_F(RemoteServer, dead_server) | 1011 | TEST_F(RemoteServer, dead_server) |
796 | 1012 | { | 1012 | { |
797 | 1013 | // Dead server won't reply. | 1013 | // Dead server won't reply. |
799 | 1014 | EnvVarGuard ev_guard(UBUNTU_SERVER_URL, "http://deadserver.invalid"); | 1014 | EnvVarGuard ev_guard(EnvVars::UBUNTU_SERVER_URL, "http://deadserver.invalid"); |
800 | 1015 | 1015 | ||
801 | 1016 | Thumbnailer tn; | 1016 | Thumbnailer tn; |
802 | 1017 | 1017 | ||
803 | @@ -1032,8 +1032,8 @@ | |||
804 | 1032 | QCoreApplication app(argc, argv); | 1032 | QCoreApplication app(argc, argv); |
805 | 1033 | setenv("GSETTINGS_BACKEND", "memory", true); | 1033 | setenv("GSETTINGS_BACKEND", "memory", true); |
806 | 1034 | setenv("GSETTINGS_SCHEMA_DIR", GSETTINGS_SCHEMA_DIR, true); | 1034 | setenv("GSETTINGS_SCHEMA_DIR", GSETTINGS_SCHEMA_DIR, true); |
809 | 1035 | setenv(UTIL_DIR, TESTBINDIR "/../src/vs-thumb", true); | 1035 | setenv(EnvVars::UTIL_DIR, TESTBINDIR "/../src/vs-thumb", true); |
810 | 1036 | setenv(UBUNTU_SERVER_URL, "http://127.0.0.1", true); | 1036 | setenv(EnvVars::UBUNTU_SERVER_URL, "http://127.0.0.1", true); |
811 | 1037 | ::testing::InitGoogleTest(&argc, argv); | 1037 | ::testing::InitGoogleTest(&argc, argv); |
812 | 1038 | return RUN_ALL_TESTS(); | 1038 | return RUN_ALL_TESTS(); |
813 | 1039 | } | 1039 | } |
814 | 1040 | 1040 | ||
815 | === modified file 'tests/utils/artserver.cpp' | |||
816 | --- tests/utils/artserver.cpp 2016-01-11 08:20:51 +0000 | |||
817 | +++ tests/utils/artserver.cpp 2017-02-03 07:36:24 +0000 | |||
818 | @@ -79,7 +79,7 @@ | |||
819 | 79 | { | 79 | { |
820 | 80 | qCritical() << "Failed to terminate fake art server"; | 80 | qCritical() << "Failed to terminate fake art server"; |
821 | 81 | } | 81 | } |
823 | 82 | unsetenv(unity::thumbnailer::internal::UBUNTU_SERVER_URL); | 82 | unsetenv(unity::thumbnailer::internal::EnvVars::UBUNTU_SERVER_URL); |
824 | 83 | } | 83 | } |
825 | 84 | 84 | ||
826 | 85 | std::string const& ArtServer::server_url() const | 85 | std::string const& ArtServer::server_url() const |
827 | @@ -108,5 +108,5 @@ | |||
828 | 108 | 108 | ||
829 | 109 | void ArtServer::update_env() | 109 | void ArtServer::update_env() |
830 | 110 | { | 110 | { |
832 | 111 | setenv(unity::thumbnailer::internal::UBUNTU_SERVER_URL, server_url().c_str(), true); | 111 | setenv(unity::thumbnailer::internal::EnvVars::UBUNTU_SERVER_URL, server_url().c_str(), true); |
833 | 112 | } | 112 | } |
PASSED: Continuous integration, rev:373 /jenkins. canonical. com/unity- api-1/job/ lp-thumbnailer- ci/22/ /jenkins. canonical. com/unity- api-1/job/ build/1577 /jenkins. canonical. com/unity- api-1/job/ build-0- fetch/1584 /jenkins. canonical. com/unity- api-1/job/ build-2- binpkg/ arch=amd64, release= xenial+ overlay/ 1362 /jenkins. canonical. com/unity- api-1/job/ build-2- binpkg/ arch=amd64, release= xenial+ overlay/ 1362/artifact/ output/ *zip*/output. zip /jenkins. canonical. com/unity- api-1/job/ build-2- binpkg/ arch=amd64, release= zesty/1362 /jenkins. canonical. com/unity- api-1/job/ build-2- binpkg/ arch=amd64, release= zesty/1362/ artifact/ output/ *zip*/output. zip /jenkins. canonical. com/unity- api-1/job/ build-2- binpkg/ arch=armhf, release= xenial+ overlay/ 1362 /jenkins. canonical. com/unity- api-1/job/ build-2- binpkg/ arch=armhf, release= xenial+ overlay/ 1362/artifact/ output/ *zip*/output. zip /jenkins. canonical. com/unity- api-1/job/ build-2- binpkg/ arch=armhf, release= zesty/1362 /jenkins. canonical. com/unity- api-1/job/ build-2- binpkg/ arch=armhf, release= zesty/1362/ artifact/ output/ *zip*/output. zip /jenkins. canonical. com/unity- api-1/job/ build-2- binpkg/ arch=i386, release= xenial+ overlay/ 1362 /jenkins. canonical. com/unity- api-1/job/ build-2- binpkg/ arch=i386, release= xenial+ overlay/ 1362/artifact/ output/ *zip*/output. zip /jenkins. canonical. com/unity- api-1/job/ build-2- binpkg/ arch=i386, release= zesty/1362 /jenkins. canonical. com/unity- api-1/job/ build-2- binpkg/ arch=i386, release= zesty/1362/ artifact/ output/ *zip*/output. zip
https:/
Executed test runs:
SUCCESS: https:/
SUCCESS: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
SUCCESS: https:/
deb: https:/
Click here to trigger a rebuild: /jenkins. canonical. com/unity- api-1/job/ lp-thumbnailer- ci/22/rebuild
https:/