/* vim:expandtab:shiftwidth=2:tabstop=2:smarttab:
- *
- * uTest
*
- * Copyright (C) 2011 Data Differential, http://datadifferential.com/
- * All rights reserved.
+ * Data Differential YATL (i.e. libtest) library
+ *
+ * Copyright (C) 2012 Data Differential, http://datadifferential.com/
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are
#include <unistd.h>
#include <string>
+#include <signal.h>
+
+#include <libtest/dream.h>
namespace libtest {
uint32_t this_wait;
uint32_t retry;
+ if (filename.empty())
+ {
+ _successful= false;
+ return;
+ }
+
+ for (waited= 0, retry= 1; ; retry++, waited+= this_wait)
+ {
+ if (access(filename.c_str(), R_OK) == 0)
+ {
+ _successful= true;
+ break;
+ }
+ else if (waited >= timeout)
+ {
+ break;
+ }
+
+ this_wait= retry * retry / 3 + 1;
+ libtest::dream(0, this_wait * 10000000);
+ }
+ }
+
+ Wait(const pid_t &_pid_arg, uint32_t timeout= 6) :
+ _successful(false)
+ {
+ uint32_t waited;
+ uint32_t this_wait;
+ uint32_t retry;
+
for (waited= 0, retry= 1; ; retry++, waited+= this_wait)
{
- if ((not access(filename.c_str(), R_OK)) or (waited >= timeout))
+ if (kill(_pid_arg, 0) == 0)
{
_successful= true;
break;
}
+ else if (waited >= timeout)
+ {
+ break;
+ }
this_wait= retry * retry / 3 + 1;
- sleep(this_wait);
+ libtest::dream(0, this_wait * 10000000);
}
}