#include <stdio.h> #include <sys/types.h> #include <sys/stat.h> #include <fcntl.h> #define Max_ PATH 2048 #define TMP_RUN_PATH "/tmp/run" #define Wait_timeout_max 10000U//10 s Econds #define TEST_NAME "test_name"//parameter NAME #define RET_FALSE 0 #define Ret_t
RUE 1 bool i_test_wait (const svpchar* name, SVPUint32 timeout) {bool Service_ready = Ret_false;
Char Service_registry[max_path] = {0};
snprintf (Service_registry, MAX_PATH, "%s/service/registry/%s", Tmp_run_path, name);
if (Timeout > Wait_timeout_max) timeout = Wait_timeout_max;
int try_time = TIMEOUT/50;
while (try_time--) {if (svpfile::fileexist (service_registry) = = Ret_false) {sleep (50);
Continue
} Service_ready = Ret_true;
Break
return service_ready; }
/**************************** Source: Access (Pfilepath, F_OK);
* int m_hfile =-1;
* m_hfile = open (Pfilepath, o_creat);
* Close (M_hfile);
* Remove (filename); *************************************/