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
This commit is contained in:
Mike Blumenkrantz 2018-07-09 13:31:20 -04:00 committed by Chris Michael
parent 695b44526c
commit 6ee58996e1
1 changed files with 21 additions and 6 deletions

View File

@ -305,8 +305,13 @@ EFL_START_TEST(ecore_test_ecore_file_operations)
fail_if(fd < 0);
fail_if(close(fd) != 0);
fail_if(ecore_file_can_read(src_file) != EINA_TRUE);
fail_if(ecore_file_can_write(src_file) != EINA_FALSE);
fail_if(ecore_file_can_exec(src_file) != EINA_FALSE);
#if defined(HAVE_GETUID) && defined(HAVE_GETEUID)
if (getuid() || geteuid())
#endif
{
fail_if(ecore_file_can_write(src_file) != EINA_FALSE);
fail_if(ecore_file_can_exec(src_file) != EINA_FALSE);
}
fail_if(ecore_file_cp(src_file, src_file) != EINA_FALSE);
fail_if(ecore_file_remove(src_file) != EINA_TRUE);
@ -316,9 +321,14 @@ EFL_START_TEST(ecore_test_ecore_file_operations)
fd = open(src_file, O_RDWR | O_BINARY | O_CREAT, 0200);
fail_if(fd < 0);
fail_if(close(fd) != 0);
fail_if(ecore_file_can_read(src_file) != EINA_FALSE);
fail_if(ecore_file_can_write(src_file) != EINA_TRUE);
#if defined(HAVE_GETUID) && defined(HAVE_GETEUID)
if (getuid() || geteuid())
#endif
{
fail_if(ecore_file_can_read(src_file) != EINA_FALSE);
}
fail_if(ecore_file_can_exec(src_file) != EINA_FALSE);
fail_if(ecore_file_can_write(src_file) != EINA_TRUE);
fail_if(ecore_file_remove(src_file) != EINA_TRUE);
src_file = get_tmp_file();
@ -327,8 +337,13 @@ EFL_START_TEST(ecore_test_ecore_file_operations)
fd = open(src_file, O_RDWR | O_BINARY | O_CREAT, 0100);
fail_if(fd < 0);
fail_if(close(fd) != 0);
fail_if(ecore_file_can_read(src_file) != EINA_FALSE);
fail_if(ecore_file_can_write(src_file) != EINA_FALSE);
#if defined(HAVE_GETUID) && defined(HAVE_GETEUID)
if (getuid() || geteuid())
#endif
{
fail_if(ecore_file_can_read(src_file) != EINA_FALSE);
fail_if(ecore_file_can_write(src_file) != EINA_FALSE);
}
fail_if(ecore_file_can_exec(src_file) != EINA_TRUE);
fail_if(ecore_file_remove(src_file) != EINA_TRUE);