Merge lp:~michihenning/storage-framework/fix-test-dir into lp:storage-framework/devel
- fix-test-dir
- Merge into devel
Status: | Merged |
---|---|
Approved by: | James Henstridge |
Approved revision: | 114 |
Merged at revision: | 117 |
Proposed branch: | lp:~michihenning/storage-framework/fix-test-dir |
Merge into: | lp:storage-framework/devel |
Diff against target: |
550 lines (+92/-89) 1 file modified
tests/local-provider/local-provider_test.cpp (+92/-89) |
To merge this branch: | bzr merge lp:~michihenning/storage-framework/fix-test-dir |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
unity-api-1-bot | continuous-integration | Approve | |
James Henstridge | Approve | ||
Review via email: mp+320141@code.launchpad.net |
Commit message
Use temporary dir for local provider test.
Description of the change
Use temporary dir for local provider test.
unity-api-1-bot (unity-api-1-bot) wrote : | # |
PASSED: Continuous integration, rev:114
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:/
Preview Diff
1 | === modified file 'tests/local-provider/local-provider_test.cpp' |
2 | --- tests/local-provider/local-provider_test.cpp 2017-03-17 04:59:44 +0000 |
3 | +++ tests/local-provider/local-provider_test.cpp 2017-03-17 07:08:22 +0000 |
4 | @@ -48,15 +48,14 @@ |
5 | return chrono::system_clock::now().time_since_epoch() / chrono::nanoseconds(1); |
6 | } |
7 | |
8 | -string const ROOT_DIR = TEST_DIR "/data"; |
9 | - |
10 | class LocalProviderTest : public ProviderFixture |
11 | { |
12 | protected: |
13 | void SetUp() override |
14 | { |
15 | - boost::filesystem::remove_all(ROOT_DIR); |
16 | - boost::filesystem::create_directory(ROOT_DIR); |
17 | + tmp_dir_.reset(new QTemporaryDir(TEST_DIR "/data.XXXXXX")); |
18 | + ASSERT_TRUE(tmp_dir_->isValid()); |
19 | + setenv("SF_LOCAL_PROVIDER_ROOT", ROOT_DIR().c_str(), true); |
20 | |
21 | ProviderFixture::SetUp(); |
22 | runtime_.reset(new qt::Runtime(connection())); |
23 | @@ -67,8 +66,19 @@ |
24 | { |
25 | runtime_.reset(); |
26 | ProviderFixture::TearDown(); |
27 | - } |
28 | - |
29 | + if (HasFailure()) |
30 | + { |
31 | + tmp_dir_->setAutoRemove(false); |
32 | + } |
33 | + tmp_dir_.reset(); |
34 | + } |
35 | + |
36 | + std::string ROOT_DIR() const |
37 | + { |
38 | + return tmp_dir_->path().toStdString(); |
39 | + } |
40 | + |
41 | + std::unique_ptr<QTemporaryDir> tmp_dir_; |
42 | unique_ptr<qt::Runtime> runtime_; |
43 | qt::Account acc_; |
44 | }; |
45 | @@ -238,7 +248,7 @@ |
46 | auto root = items[0]; |
47 | EXPECT_TRUE(root.isValid()); |
48 | EXPECT_EQ(Item::Type::Root, root.type()); |
49 | - EXPECT_EQ(ROOT_DIR, root.itemId().toStdString()); |
50 | + EXPECT_EQ(ROOT_DIR(), root.itemId().toStdString()); |
51 | EXPECT_EQ("/", root.name()); |
52 | EXPECT_EQ("", root.etag()); |
53 | EXPECT_EQ(QList<QString>(), root.parentIds()); |
54 | @@ -279,10 +289,10 @@ |
55 | ASSERT_EQ(ItemJob::Finished, job->status()) << job->error().errorString().toStdString(); |
56 | |
57 | Item child = job->item(); |
58 | - EXPECT_EQ(ROOT_DIR + "/child", child.itemId().toStdString()); |
59 | + EXPECT_EQ(ROOT_DIR() + "/child", child.itemId().toStdString()); |
60 | EXPECT_EQ("child", child.name().toStdString()); |
61 | ASSERT_EQ(1, child.parentIds().size()); |
62 | - EXPECT_EQ(ROOT_DIR, child.parentIds().at(0).toStdString()); |
63 | + EXPECT_EQ(ROOT_DIR(), child.parentIds().at(0).toStdString()); |
64 | EXPECT_EQ("", child.etag()); |
65 | EXPECT_EQ(Item::Type::Folder, child.type()); |
66 | EXPECT_EQ(5, child.metadata().size()); |
67 | @@ -295,18 +305,18 @@ |
68 | job.reset(root.createFolder("child")); |
69 | wait(job.get()); |
70 | ASSERT_EQ(ItemJob::Error, job->status()) << job->error().errorString().toStdString(); |
71 | - EXPECT_EQ(string("Exists: create_folder(): \"") + ROOT_DIR + "/child\" exists already", |
72 | + EXPECT_EQ(string("Exists: create_folder(): \"") + ROOT_DIR() + "/child\" exists already", |
73 | job->error().errorString().toStdString()); |
74 | |
75 | // Again, without write permission on the root dir, to get coverage for a filesystem_error in invoke_async(). |
76 | - ASSERT_EQ(0, ::rmdir((ROOT_DIR + "/child").c_str())); |
77 | - ASSERT_EQ(0, ::chmod(ROOT_DIR.c_str(), 0555)); |
78 | + ASSERT_EQ(0, ::rmdir((ROOT_DIR() + "/child").c_str())); |
79 | + ASSERT_EQ(0, ::chmod(ROOT_DIR().c_str(), 0555)); |
80 | job.reset(root.createFolder("child")); |
81 | wait(job.get()); |
82 | - ::chmod(ROOT_DIR.c_str(), 0755); |
83 | + ::chmod(ROOT_DIR().c_str(), 0755); |
84 | ASSERT_EQ(ItemJob::Error, job->status()) << job->error().errorString().toStdString(); |
85 | - EXPECT_EQ(string("PermissionDenied: create_folder(): \"") + ROOT_DIR |
86 | - + "/child\": boost::filesystem::create_directory: Permission denied: \"" + ROOT_DIR + "/child\"", |
87 | + EXPECT_EQ(string("PermissionDenied: create_folder(): \"") + ROOT_DIR() |
88 | + + "/child\": boost::filesystem::create_directory: Permission denied: \"" + ROOT_DIR() + "/child\"", |
89 | job->error().errorString().toStdString()); |
90 | } |
91 | } |
92 | @@ -353,7 +363,7 @@ |
93 | // Client-side API does not allow us to try to delete the root, so we talk to the provider directly. |
94 | auto p = make_shared<LocalProvider>(); |
95 | |
96 | - auto fut = p->delete_item(ROOT_DIR, provider::Context()); |
97 | + auto fut = p->delete_item(ROOT_DIR(), provider::Context()); |
98 | try |
99 | { |
100 | fut.get(); |
101 | @@ -371,21 +381,21 @@ |
102 | // so we talk to the provider directly. |
103 | auto p = make_shared<LocalProvider>(); |
104 | |
105 | - auto fut = p->metadata(ROOT_DIR, {}, provider::Context()); |
106 | + auto fut = p->metadata(ROOT_DIR(), {}, provider::Context()); |
107 | auto item = fut.get(); |
108 | EXPECT_EQ(5, item.metadata.size()); |
109 | |
110 | // Again, to get coverage for the "not file or folder" case in make_item(). |
111 | - ASSERT_EQ(0, mknod((ROOT_DIR + "/pipe").c_str(), S_IFIFO | 06666, 0)); |
112 | + ASSERT_EQ(0, mknod((ROOT_DIR() + "/pipe").c_str(), S_IFIFO | 06666, 0)); |
113 | try |
114 | { |
115 | - auto fut = p->metadata(ROOT_DIR + "/pipe", {}, provider::Context()); |
116 | + auto fut = p->metadata(ROOT_DIR() + "/pipe", {}, provider::Context()); |
117 | fut.get(); |
118 | FAIL(); |
119 | } |
120 | catch (provider::NotExistsException const& e) |
121 | { |
122 | - EXPECT_EQ(string("NotExistsException: metadata(): \"") + ROOT_DIR + "/pipe\" is neither a file nor a folder", |
123 | + EXPECT_EQ(string("NotExistsException: metadata(): \"") + ROOT_DIR() + "/pipe\" is neither a file nor a folder", |
124 | e.what()); |
125 | } |
126 | } |
127 | @@ -408,22 +418,22 @@ |
128 | ASSERT_EQ(1, items.size()); |
129 | auto child = items.at(0); |
130 | |
131 | - EXPECT_EQ(ROOT_DIR + "/child", child.itemId().toStdString()); |
132 | + EXPECT_EQ(ROOT_DIR() + "/child", child.itemId().toStdString()); |
133 | EXPECT_EQ("child", child.name().toStdString()); |
134 | ASSERT_EQ(1, child.parentIds().size()); |
135 | - EXPECT_EQ(ROOT_DIR, child.parentIds().at(0).toStdString()); |
136 | + EXPECT_EQ(ROOT_DIR(), child.parentIds().at(0).toStdString()); |
137 | EXPECT_EQ("", child.etag()); |
138 | EXPECT_EQ(Item::Type::Folder, child.type()); |
139 | EXPECT_EQ(5, child.metadata().size()); |
140 | |
141 | // Remove the child again and try the lookup once more. |
142 | - ASSERT_EQ(0, rmdir((ROOT_DIR + "/child").c_str())); |
143 | + ASSERT_EQ(0, rmdir((ROOT_DIR() + "/child").c_str())); |
144 | |
145 | job.reset(root.lookup("child")); |
146 | wait(job.get()); |
147 | EXPECT_EQ(ItemJob::Error, job->status()); |
148 | - EXPECT_EQ(string("NotExists: lookup(): \"") + ROOT_DIR + "/child\": boost::filesystem::canonical: " |
149 | - + "No such file or directory: \"" + ROOT_DIR + "/child\"", |
150 | + EXPECT_EQ(string("NotExists: lookup(): \"") + ROOT_DIR() + "/child\": boost::filesystem::canonical: " |
151 | + + "No such file or directory: \"" + ROOT_DIR() + "/child\"", |
152 | job->error().errorString().toStdString()); |
153 | } |
154 | |
155 | @@ -441,10 +451,10 @@ |
156 | } |
157 | |
158 | // Make a weird item that will be ignored (for coverage). |
159 | - ASSERT_EQ(0, mknod((ROOT_DIR + "/pipe").c_str(), S_IFIFO | 06666, 0)); |
160 | + ASSERT_EQ(0, mknod((ROOT_DIR() + "/pipe").c_str(), S_IFIFO | 06666, 0)); |
161 | |
162 | // Make a file that starts with the temp file prefix (for coverage). |
163 | - int fd = creat((ROOT_DIR + "/.storage-framework").c_str(), 0755); |
164 | + int fd = creat((ROOT_DIR() + "/.storage-framework").c_str(), 0755); |
165 | ASSERT_GT(fd, 0); |
166 | close(fd); |
167 | |
168 | @@ -453,28 +463,28 @@ |
169 | ASSERT_EQ(1, items.size()); |
170 | auto child = items.at(0); |
171 | |
172 | - EXPECT_EQ(ROOT_DIR + "/child", child.itemId().toStdString()); |
173 | + EXPECT_EQ(ROOT_DIR() + "/child", child.itemId().toStdString()); |
174 | EXPECT_EQ("child", child.name().toStdString()); |
175 | ASSERT_EQ(1, child.parentIds().size()); |
176 | - EXPECT_EQ(ROOT_DIR, child.parentIds().at(0).toStdString()); |
177 | + EXPECT_EQ(ROOT_DIR(), child.parentIds().at(0).toStdString()); |
178 | EXPECT_EQ("", child.etag()); |
179 | EXPECT_EQ(Item::Type::Folder, child.type()); |
180 | EXPECT_EQ(5, child.metadata().size()); |
181 | } |
182 | |
183 | -void make_hierarchy() |
184 | +void make_hierarchy(string const& root_dir) |
185 | { |
186 | // Make a small tree so we have something to test with for move() and copy(). |
187 | - ASSERT_EQ(0, mkdir((ROOT_DIR + "/a").c_str(), 0755)); |
188 | - ASSERT_EQ(0, mkdir((ROOT_DIR + "/a/b").c_str(), 0755)); |
189 | - string cmd = string("echo hello >") + ROOT_DIR + "/hello"; |
190 | - ASSERT_EQ(0, system(cmd.c_str())); |
191 | - cmd = string("echo text >") + ROOT_DIR + "/a/foo.txt"; |
192 | - ASSERT_EQ(0, system(cmd.c_str())); |
193 | - ASSERT_EQ(0, mknod((ROOT_DIR + "/a/pipe").c_str(), S_IFIFO | 06666, 0)); |
194 | - ASSERT_EQ(0, mkdir((ROOT_DIR + "/a/.storage-framework-").c_str(), 0755)); |
195 | - ASSERT_EQ(0, mkdir((ROOT_DIR + "/a/b/.storage-framework-").c_str(), 0755)); |
196 | - ASSERT_EQ(0, mknod((ROOT_DIR + "/a/b/pipe").c_str(), S_IFIFO | 06666, 0)); |
197 | + ASSERT_EQ(0, mkdir((root_dir + "/a").c_str(), 0755)); |
198 | + ASSERT_EQ(0, mkdir((root_dir + "/a/b").c_str(), 0755)); |
199 | + string cmd = string("echo hello >") + root_dir + "/hello"; |
200 | + ASSERT_EQ(0, system(cmd.c_str())); |
201 | + cmd = string("echo text >") + root_dir + "/a/foo.txt"; |
202 | + ASSERT_EQ(0, system(cmd.c_str())); |
203 | + ASSERT_EQ(0, mknod((root_dir + "/a/pipe").c_str(), S_IFIFO | 06666, 0)); |
204 | + ASSERT_EQ(0, mkdir((root_dir + "/a/.storage-framework-").c_str(), 0755)); |
205 | + ASSERT_EQ(0, mkdir((root_dir + "/a/b/.storage-framework-").c_str(), 0755)); |
206 | + ASSERT_EQ(0, mknod((root_dir + "/a/b/pipe").c_str(), S_IFIFO | 06666, 0)); |
207 | } |
208 | |
209 | TEST_F(LocalProviderTest, move) |
210 | @@ -485,7 +495,7 @@ |
211 | |
212 | auto start_time = nanosecs_now(); |
213 | |
214 | - make_hierarchy(); |
215 | + make_hierarchy(ROOT_DIR()); |
216 | |
217 | auto root = get_root(acc_); |
218 | |
219 | @@ -505,7 +515,7 @@ |
220 | // Check metadata. |
221 | EXPECT_EQ("hello", hello.name()); |
222 | ASSERT_EQ(1, hello.parentIds().size()); |
223 | - EXPECT_EQ(ROOT_DIR, hello.parentIds().at(0).toStdString()); |
224 | + EXPECT_EQ(ROOT_DIR(), hello.parentIds().at(0).toStdString()); |
225 | EXPECT_EQ(Item::Type::File, hello.type()); |
226 | |
227 | ASSERT_EQ(6, hello.metadata().size()); |
228 | @@ -547,7 +557,7 @@ |
229 | world = job->item(); |
230 | } |
231 | EXPECT_FALSE(boost::filesystem::exists(hello.itemId().toStdString())); |
232 | - EXPECT_EQ(ROOT_DIR + "/world", world.itemId().toStdString()); |
233 | + EXPECT_EQ(ROOT_DIR() + "/world", world.itemId().toStdString()); |
234 | |
235 | ASSERT_EQ(0, stat(world.itemId().toStdString().c_str(), &st)); |
236 | auto new_ino = st.st_ino; |
237 | @@ -557,7 +567,7 @@ |
238 | unique_ptr<ItemJob> job(world.move(root, "a")); |
239 | wait(job.get()); |
240 | ASSERT_EQ(ItemJob::Error, job->status()) << job->error().errorString().toStdString(); |
241 | - EXPECT_EQ(string("Exists: move(): \"") + ROOT_DIR + "/a\" exists already", |
242 | + EXPECT_EQ(string("Exists: move(): \"") + ROOT_DIR() + "/a\" exists already", |
243 | job->error().errorString().toStdString()); |
244 | } |
245 | |
246 | @@ -567,7 +577,7 @@ |
247 | |
248 | set_provider(unique_ptr<provider::ProviderBase>(new LocalProvider)); |
249 | |
250 | - make_hierarchy(); |
251 | + make_hierarchy(ROOT_DIR()); |
252 | |
253 | auto root = get_root(acc_); |
254 | |
255 | @@ -593,7 +603,7 @@ |
256 | world = job->item(); |
257 | } |
258 | EXPECT_TRUE(boost::filesystem::exists(hello.itemId().toStdString())); |
259 | - EXPECT_EQ(ROOT_DIR + "/world", world.itemId().toStdString()); |
260 | + EXPECT_EQ(ROOT_DIR() + "/world", world.itemId().toStdString()); |
261 | |
262 | ASSERT_EQ(0, stat(world.itemId().toStdString().c_str(), &st)); |
263 | auto new_ino = st.st_ino; |
264 | @@ -607,7 +617,7 @@ |
265 | |
266 | set_provider(unique_ptr<provider::ProviderBase>(new LocalProvider)); |
267 | |
268 | - make_hierarchy(); |
269 | + make_hierarchy(ROOT_DIR()); |
270 | |
271 | auto root = get_root(acc_); |
272 | |
273 | @@ -632,19 +642,19 @@ |
274 | |
275 | // Check that we only copied regular files and directories, but not a pipe or anything starting with |
276 | // the temp file prefix. |
277 | - EXPECT_TRUE(exists(ROOT_DIR + "/c/b")); |
278 | - EXPECT_TRUE(exists(ROOT_DIR + "/c/foo.txt")); |
279 | - EXPECT_FALSE(exists(ROOT_DIR + "/c/pipe")); |
280 | - EXPECT_FALSE(exists(ROOT_DIR + "/c/storage-framework-")); |
281 | - EXPECT_FALSE(exists(ROOT_DIR + "/c/b/pipe")); |
282 | - EXPECT_FALSE(exists(ROOT_DIR + "/c/b/storage-framework-")); |
283 | + EXPECT_TRUE(exists(ROOT_DIR() + "/c/b")); |
284 | + EXPECT_TRUE(exists(ROOT_DIR() + "/c/foo.txt")); |
285 | + EXPECT_FALSE(exists(ROOT_DIR() + "/c/pipe")); |
286 | + EXPECT_FALSE(exists(ROOT_DIR() + "/c/storage-framework-")); |
287 | + EXPECT_FALSE(exists(ROOT_DIR() + "/c/b/pipe")); |
288 | + EXPECT_FALSE(exists(ROOT_DIR() + "/c/b/storage-framework-")); |
289 | |
290 | // Copy c -> a. This must fail because a exists. |
291 | { |
292 | unique_ptr<ItemJob> job(c.copy(root, "a")); |
293 | wait(job.get()); |
294 | ASSERT_EQ(ItemJob::Error, job->status()) << job->error().errorString().toStdString(); |
295 | - EXPECT_EQ(string("Exists: copy(): \"") + ROOT_DIR + "/a\" exists already", |
296 | + EXPECT_EQ(string("Exists: copy(): \"") + ROOT_DIR() + "/a\" exists already", |
297 | job->error().errorString().toStdString()); |
298 | } |
299 | } |
300 | @@ -662,7 +672,7 @@ |
301 | { |
302 | large_contents += file_contents; |
303 | } |
304 | - string const full_path = ROOT_DIR + "/foo.txt"; |
305 | + string const full_path = ROOT_DIR() + "/foo.txt"; |
306 | { |
307 | int fd = open(full_path.c_str(), O_WRONLY | O_CREAT | O_EXCL, 0644); |
308 | ASSERT_GT(fd, 0); |
309 | @@ -706,7 +716,7 @@ |
310 | set_provider(unique_ptr<provider::ProviderBase>(new LocalProvider)); |
311 | |
312 | int const segments = 10000; |
313 | - string const full_path = ROOT_DIR + "/foo.txt"; |
314 | + string const full_path = ROOT_DIR() + "/foo.txt"; |
315 | { |
316 | int fd = open(full_path.c_str(), O_WRONLY | O_CREAT | O_EXCL, 0644); |
317 | ASSERT_GT(fd, 0); |
318 | @@ -751,7 +761,7 @@ |
319 | |
320 | set_provider(unique_ptr<provider::ProviderBase>(new LocalProvider)); |
321 | |
322 | - string const full_path = ROOT_DIR + "/foo.txt"; |
323 | + string const full_path = ROOT_DIR() + "/foo.txt"; |
324 | string cmd = string("echo hello >") + full_path; |
325 | ASSERT_EQ(0, system(cmd.c_str())); |
326 | |
327 | @@ -784,7 +794,7 @@ |
328 | |
329 | auto p = make_shared<LocalProvider>(); |
330 | |
331 | - string const dir = ROOT_DIR + "/dir"; |
332 | + string const dir = ROOT_DIR() + "/dir"; |
333 | ASSERT_EQ(0, mkdir(dir.c_str(), 0755)); |
334 | |
335 | try |
336 | @@ -804,7 +814,7 @@ |
337 | |
338 | set_provider(unique_ptr<provider::ProviderBase>(new LocalProvider)); |
339 | |
340 | - string const full_path = ROOT_DIR + "/foo.txt"; |
341 | + string const full_path = ROOT_DIR() + "/foo.txt"; |
342 | string cmd = string("echo hello >") + full_path; |
343 | ASSERT_EQ(0, system(cmd.c_str())); |
344 | |
345 | @@ -838,7 +848,7 @@ |
346 | |
347 | try |
348 | { |
349 | - LocalDownloadJob(p, ROOT_DIR + "/no_such_file", "some_etag"); |
350 | + LocalDownloadJob(p, ROOT_DIR() + "/no_such_file", "some_etag"); |
351 | FAIL(); |
352 | } |
353 | catch (provider::NotExistsException const&) |
354 | @@ -852,7 +862,7 @@ |
355 | |
356 | set_provider(unique_ptr<provider::ProviderBase>(new LocalProvider)); |
357 | |
358 | - auto full_path = ROOT_DIR + "/foo.txt"; |
359 | + auto full_path = ROOT_DIR() + "/foo.txt"; |
360 | auto cmd = string("echo hello >") + full_path; |
361 | ASSERT_EQ(0, system(cmd.c_str())); |
362 | |
363 | @@ -899,7 +909,7 @@ |
364 | |
365 | set_provider(unique_ptr<provider::ProviderBase>(new LocalProvider)); |
366 | |
367 | - auto full_path = ROOT_DIR + "/foo.txt"; |
368 | + auto full_path = ROOT_DIR() + "/foo.txt"; |
369 | auto cmd = string("echo hello >") + full_path; |
370 | ASSERT_EQ(0, system(cmd.c_str())); |
371 | |
372 | @@ -938,7 +948,7 @@ |
373 | |
374 | set_provider(unique_ptr<provider::ProviderBase>(new LocalProvider)); |
375 | |
376 | - auto full_path = ROOT_DIR + "/foo.txt"; |
377 | + auto full_path = ROOT_DIR() + "/foo.txt"; |
378 | auto cmd = string("echo hello >") + full_path; |
379 | ASSERT_EQ(0, system(cmd.c_str())); |
380 | |
381 | @@ -983,7 +993,7 @@ |
382 | |
383 | set_provider(unique_ptr<provider::ProviderBase>(new LocalProvider)); |
384 | |
385 | - auto full_path = ROOT_DIR + "/foo.txt"; |
386 | + auto full_path = ROOT_DIR() + "/foo.txt"; |
387 | auto cmd = string("echo hello >") + full_path; |
388 | ASSERT_EQ(0, system(cmd.c_str())); |
389 | |
390 | @@ -1012,7 +1022,7 @@ |
391 | |
392 | set_provider(unique_ptr<provider::ProviderBase>(new LocalProvider)); |
393 | |
394 | - auto full_path = ROOT_DIR + "/foo.txt"; |
395 | + auto full_path = ROOT_DIR() + "/foo.txt"; |
396 | auto cmd = string("echo hello >") + full_path; |
397 | ASSERT_EQ(0, system(cmd.c_str())); |
398 | |
399 | @@ -1061,7 +1071,7 @@ |
400 | |
401 | set_provider(unique_ptr<provider::ProviderBase>(new LocalProvider)); |
402 | |
403 | - auto full_path = ROOT_DIR + "/foo.txt"; |
404 | + auto full_path = ROOT_DIR() + "/foo.txt"; |
405 | auto cmd = string("echo hello >") + full_path; |
406 | ASSERT_EQ(0, system(cmd.c_str())); |
407 | |
408 | @@ -1101,7 +1111,7 @@ |
409 | |
410 | set_provider(unique_ptr<provider::ProviderBase>(new LocalProvider)); |
411 | |
412 | - auto full_path = ROOT_DIR + "/foo.txt"; |
413 | + auto full_path = ROOT_DIR() + "/foo.txt"; |
414 | auto cmd = string("echo hello >") + full_path; |
415 | ASSERT_EQ(0, system(cmd.c_str())); |
416 | |
417 | @@ -1145,7 +1155,7 @@ |
418 | |
419 | set_provider(unique_ptr<provider::ProviderBase>(new LocalProvider)); |
420 | |
421 | - auto full_path = ROOT_DIR + "/foo.txt"; |
422 | + auto full_path = ROOT_DIR() + "/foo.txt"; |
423 | auto cmd = string("echo hello >") + full_path; |
424 | ASSERT_EQ(0, system(cmd.c_str())); |
425 | |
426 | @@ -1190,7 +1200,7 @@ |
427 | |
428 | auto p = make_shared<LocalProvider>(); |
429 | |
430 | - string const dir = ROOT_DIR + "/dir"; |
431 | + string const dir = ROOT_DIR() + "/dir"; |
432 | ASSERT_EQ(0, mkdir(dir.c_str(), 0755)); |
433 | |
434 | try |
435 | @@ -1210,21 +1220,21 @@ |
436 | |
437 | auto p = make_shared<LocalProvider>(); |
438 | |
439 | - ASSERT_EQ(0, chmod(ROOT_DIR.c_str(), 0644)); |
440 | + ASSERT_EQ(0, chmod(ROOT_DIR().c_str(), 0644)); |
441 | |
442 | try |
443 | { |
444 | - LocalUploadJob(p, ROOT_DIR, "name", 0, true); |
445 | - chmod(ROOT_DIR.c_str(), 0755); |
446 | + LocalUploadJob(p, ROOT_DIR(), "name", 0, true); |
447 | + chmod(ROOT_DIR().c_str(), 0755); |
448 | FAIL(); |
449 | } |
450 | catch (provider::ResourceException const& e) |
451 | { |
452 | - EXPECT_EQ(string("ResourceException: create_file(): cannot create temp file \"") + ROOT_DIR |
453 | + EXPECT_EQ(string("ResourceException: create_file(): cannot create temp file \"") + ROOT_DIR() |
454 | + "/.storage-framework-%%%%-%%%%-%%%%-%%%%\": Invalid argument", |
455 | e.what()); |
456 | } |
457 | - chmod(ROOT_DIR.c_str(), 0755); |
458 | + chmod(ROOT_DIR().c_str(), 0755); |
459 | } |
460 | |
461 | TEST_F(LocalProviderTest, sanitize) |
462 | @@ -1235,7 +1245,7 @@ |
463 | |
464 | try |
465 | { |
466 | - LocalUploadJob(p, ROOT_DIR, "a/b", 0, true); |
467 | + LocalUploadJob(p, ROOT_DIR(), "a/b", 0, true); |
468 | FAIL(); |
469 | } |
470 | catch (provider::InvalidArgumentException const& e) |
471 | @@ -1245,7 +1255,7 @@ |
472 | |
473 | try |
474 | { |
475 | - LocalUploadJob(p, ROOT_DIR, "..", 0, true); |
476 | + LocalUploadJob(p, ROOT_DIR(), "..", 0, true); |
477 | FAIL(); |
478 | } |
479 | catch (provider::InvalidArgumentException const& e) |
480 | @@ -1255,7 +1265,7 @@ |
481 | |
482 | try |
483 | { |
484 | - LocalUploadJob(p, ROOT_DIR, ".storage-framework", 0, true); |
485 | + LocalUploadJob(p, ROOT_DIR(), ".storage-framework", 0, true); |
486 | FAIL(); |
487 | } |
488 | catch (provider::InvalidArgumentException const& e) |
489 | @@ -1273,12 +1283,12 @@ |
490 | |
491 | try |
492 | { |
493 | - LocalUploadJob(p, ROOT_DIR + "/..", "a", 0, true); |
494 | + LocalUploadJob(p, ROOT_DIR() + "/..", "a", 0, true); |
495 | FAIL(); |
496 | } |
497 | catch (provider::InvalidArgumentException const& e) |
498 | { |
499 | - EXPECT_EQ(string("InvalidArgumentException: create_file(): invalid id: \"") + ROOT_DIR + "/..\"", e.what()); |
500 | + EXPECT_EQ(string("InvalidArgumentException: create_file(): invalid id: \"") + ROOT_DIR() + "/..\"", e.what()); |
501 | } |
502 | |
503 | try |
504 | @@ -1337,7 +1347,7 @@ |
505 | |
506 | set_provider(unique_ptr<provider::ProviderBase>(new LocalProvider)); |
507 | |
508 | - auto full_path = ROOT_DIR + "/foo.txt"; |
509 | + auto full_path = ROOT_DIR() + "/foo.txt"; |
510 | auto cmd = string("echo hello >") + full_path; |
511 | ASSERT_EQ(0, system(cmd.c_str())); |
512 | |
513 | @@ -1380,7 +1390,7 @@ |
514 | |
515 | set_provider(unique_ptr<provider::ProviderBase>(new LocalProvider)); |
516 | |
517 | - auto full_path = ROOT_DIR + "/foo.txt"; |
518 | + auto full_path = ROOT_DIR() + "/foo.txt"; |
519 | auto cmd = string("echo hello >") + full_path; |
520 | ASSERT_EQ(0, system(cmd.c_str())); |
521 | |
522 | @@ -1406,7 +1416,7 @@ |
523 | |
524 | auto root = get_root(acc_); |
525 | int const segments = 50; |
526 | - string full_path = ROOT_DIR + "/foo.txt"; |
527 | + string full_path = ROOT_DIR() + "/foo.txt"; |
528 | unique_ptr<Uploader> uploader(root.createFile("foo.txt", Item::ErrorIfConflict, |
529 | file_contents.size() * segments, "text/plain")); |
530 | |
531 | @@ -1445,7 +1455,6 @@ |
532 | int main(int argc, char** argv) |
533 | { |
534 | setenv("LANG", "C", true); |
535 | - setenv("SF_LOCAL_PROVIDER_ROOT", ROOT_DIR.c_str(), true); |
536 | |
537 | // Test test fixture repeatedly creates and tears down the dbus connection. |
538 | // The provider calls g_file_new_for_path() which talks to the GVfs backend |
539 | @@ -1463,11 +1472,5 @@ |
540 | QCoreApplication::sendPostedEvents(); |
541 | QCoreApplication::processEvents(); |
542 | |
543 | - if (rc == 0) |
544 | - { |
545 | - boost::system::error_code ec; |
546 | - boost::filesystem::remove_all(ROOT_DIR, ec); |
547 | - } |
548 | - |
549 | return rc; |
550 | } |
Looks good.