Fix eina file thread test on Windows

On windows, we try to open the "cmd.exe" file, but without the full path
the test fails unless it runs from the system directory.

We now use the full path to test the eina_file_open function.

Reviewed-by: Stefan Schmidt <stefan@datenfreihafen.org>
Reviewed-by: Vincent Torri <vincent.torri@gmail.com>
Reviewed-by: João Paulo Taylor Ienczak Zanette <joao.tiz@expertisesolutions.com.br>
Differential Revision: https://phab.enlightenment.org/D12021
This commit is contained in:
Wander Lairson Costa 2020-06-24 13:32:12 +00:00 committed by Stefan Schmidt
parent 6ab86d5052
commit 0e61c08c2b
1 changed files with 23 additions and 1 deletions

View File

@ -490,7 +490,29 @@ static void *
_eina_test_file_thread(void *data EINA_UNUSED, Eina_Thread t EINA_UNUSED)
{
#ifdef _WIN32
const char *filename = "cmd.exe";
char filename[MAX_PATH];
size_t len;
const char test_file[] = "cmd.exe";
fail_if(!GetSystemDirectoryA(filename, MAX_PATH));
len = strlen(filename);
/*
* Check the buffer size.
* The system path length + path separator + length of the test_file + null terminator
* Must fit in MAX_PATH.
*/
fail_if(MAX_PATH < len + 1 + sizeof(test_file));
// append trailing directory separator if there isn't one
if (filename[len - 1] != '\\' && filename[len - 1] != '/')
{
filename[len] = '\\';
filename[len + 1] = '\0';
}
strncat(filename, test_file, MAX_PATH - len - 2);
#else
const char *filename = "/bin/sh";
#endif