summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Blumenkrantz <zmike@samsung.com>2018-07-09 13:31:20 -0400
committerChris Michael <cp.michael@samsung.com>2018-07-09 13:31:20 -0400
commit6ee58996e141bc061bb49c4d7aad0cb8b5869563 (patch)
tree19e095ce8694de8e80054866f8067a6e873b3159
parent695b44526c968787374fd421327422a6eea710a7 (diff)
tests/ecore: check uid on ecore-file tests
Summary: these tests will fail if run with root permission, so avoid checking them when run as root ref T7094 Reviewers: devilhorns Reviewed By: devilhorns Subscribers: cedric, #committers Tags: #efl Maniphest Tasks: T7094 Differential Revision: https://phab.enlightenment.org/D6534
-rw-r--r--src/tests/ecore/ecore_test_ecore_file.c27
1 files changed, 21 insertions, 6 deletions
diff --git a/src/tests/ecore/ecore_test_ecore_file.c b/src/tests/ecore/ecore_test_ecore_file.c
index fb23ffb15e..2f1648f793 100644
--- a/src/tests/ecore/ecore_test_ecore_file.c
+++ b/src/tests/ecore/ecore_test_ecore_file.c
@@ -305,8 +305,13 @@ EFL_START_TEST(ecore_test_ecore_file_operations)
305 fail_if(fd < 0); 305 fail_if(fd < 0);
306 fail_if(close(fd) != 0); 306 fail_if(close(fd) != 0);
307 fail_if(ecore_file_can_read(src_file) != EINA_TRUE); 307 fail_if(ecore_file_can_read(src_file) != EINA_TRUE);
308 fail_if(ecore_file_can_write(src_file) != EINA_FALSE); 308#if defined(HAVE_GETUID) && defined(HAVE_GETEUID)
309 fail_if(ecore_file_can_exec(src_file) != EINA_FALSE); 309 if (getuid() || geteuid())
310#endif
311 {
312 fail_if(ecore_file_can_write(src_file) != EINA_FALSE);
313 fail_if(ecore_file_can_exec(src_file) != EINA_FALSE);
314 }
310 fail_if(ecore_file_cp(src_file, src_file) != EINA_FALSE); 315 fail_if(ecore_file_cp(src_file, src_file) != EINA_FALSE);
311 fail_if(ecore_file_remove(src_file) != EINA_TRUE); 316 fail_if(ecore_file_remove(src_file) != EINA_TRUE);
312 317
@@ -316,9 +321,14 @@ EFL_START_TEST(ecore_test_ecore_file_operations)
316 fd = open(src_file, O_RDWR | O_BINARY | O_CREAT, 0200); 321 fd = open(src_file, O_RDWR | O_BINARY | O_CREAT, 0200);
317 fail_if(fd < 0); 322 fail_if(fd < 0);
318 fail_if(close(fd) != 0); 323 fail_if(close(fd) != 0);
319 fail_if(ecore_file_can_read(src_file) != EINA_FALSE); 324#if defined(HAVE_GETUID) && defined(HAVE_GETEUID)
320 fail_if(ecore_file_can_write(src_file) != EINA_TRUE); 325 if (getuid() || geteuid())
326#endif
327 {
328 fail_if(ecore_file_can_read(src_file) != EINA_FALSE);
329 }
321 fail_if(ecore_file_can_exec(src_file) != EINA_FALSE); 330 fail_if(ecore_file_can_exec(src_file) != EINA_FALSE);
331 fail_if(ecore_file_can_write(src_file) != EINA_TRUE);
322 fail_if(ecore_file_remove(src_file) != EINA_TRUE); 332 fail_if(ecore_file_remove(src_file) != EINA_TRUE);
323 333
324 src_file = get_tmp_file(); 334 src_file = get_tmp_file();
@@ -327,8 +337,13 @@ EFL_START_TEST(ecore_test_ecore_file_operations)
327 fd = open(src_file, O_RDWR | O_BINARY | O_CREAT, 0100); 337 fd = open(src_file, O_RDWR | O_BINARY | O_CREAT, 0100);
328 fail_if(fd < 0); 338 fail_if(fd < 0);
329 fail_if(close(fd) != 0); 339 fail_if(close(fd) != 0);
330 fail_if(ecore_file_can_read(src_file) != EINA_FALSE); 340#if defined(HAVE_GETUID) && defined(HAVE_GETEUID)
331 fail_if(ecore_file_can_write(src_file) != EINA_FALSE); 341 if (getuid() || geteuid())
342#endif
343 {
344 fail_if(ecore_file_can_read(src_file) != EINA_FALSE);
345 fail_if(ecore_file_can_write(src_file) != EINA_FALSE);
346 }
332 fail_if(ecore_file_can_exec(src_file) != EINA_TRUE); 347 fail_if(ecore_file_can_exec(src_file) != EINA_TRUE);
333 fail_if(ecore_file_remove(src_file) != EINA_TRUE); 348 fail_if(ecore_file_remove(src_file) != EINA_TRUE);
334 349