summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorWander Lairson Costa <wander.lairson@gmail.com>2020-06-24 13:32:12 +0000
committerStefan Schmidt <s.schmidt@samsung.com>2020-06-26 15:37:44 +0200
commit0e61c08c2b38eaf88f0d8078fbba41e63e1f00cf (patch)
tree6cda0b1af8f1470a69de97f02991b9a75c61c2d3
parent6ab86d50523c75e06948f9fe62ec6dfac96750b4 (diff)
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
-rw-r--r--src/tests/eina/eina_test_file.c24
1 files changed, 23 insertions, 1 deletions
diff --git a/src/tests/eina/eina_test_file.c b/src/tests/eina/eina_test_file.c
index 0ed1c93d75..bcaff19e40 100644
--- a/src/tests/eina/eina_test_file.c
+++ b/src/tests/eina/eina_test_file.c
@@ -490,7 +490,29 @@ static void *
490_eina_test_file_thread(void *data EINA_UNUSED, Eina_Thread t EINA_UNUSED) 490_eina_test_file_thread(void *data EINA_UNUSED, Eina_Thread t EINA_UNUSED)
491{ 491{
492#ifdef _WIN32 492#ifdef _WIN32
493 const char *filename = "cmd.exe"; 493 char filename[MAX_PATH];
494 size_t len;
495 const char test_file[] = "cmd.exe";
496
497 fail_if(!GetSystemDirectoryA(filename, MAX_PATH));
498
499 len = strlen(filename);
500
501 /*
502 * Check the buffer size.
503 * The system path length + path separator + length of the test_file + null terminator
504 * Must fit in MAX_PATH.
505 */
506 fail_if(MAX_PATH < len + 1 + sizeof(test_file));
507
508 // append trailing directory separator if there isn't one
509 if (filename[len - 1] != '\\' && filename[len - 1] != '/')
510 {
511 filename[len] = '\\';
512 filename[len + 1] = '\0';
513 }
514
515 strncat(filename, test_file, MAX_PATH - len - 2);
494#else 516#else
495 const char *filename = "/bin/sh"; 517 const char *filename = "/bin/sh";
496#endif 518#endif