File: test_utils.h

package info (click to toggle)
libtorrent 0.15.7-1
  • links: PTS, VCS
  • area: main
  • in suites: experimental
  • size: 5,152 kB
  • sloc: cpp: 35,007; sh: 4,488; ansic: 4,397; makefile: 575; xml: 163
file content (21 lines) | stat: -rw-r--r-- 336 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
#ifndef LIBTORRENT_TEST_UTILS_H
#define LIBTORRENT_TEST_UTILS_H

#include <functional>
#include <unistd.h>

inline bool
wait_for_true(std::function<bool ()> test_function) {
  int i = 100;

  do {
    if (test_function())
      return true;

    usleep(10 * 1000);
  } while (--i);

  return false;
}

#endif // LIBTORRENT_TEST_UTILS_H