patch-testcode_testpolling_cpp 1.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061
  1. $OpenBSD: patch-testcode_testpolling_cpp,v 1.1 2013/12/24 13:57:18 sthen Exp $
  2. --- testcode/testpolling.cpp.orig Sun Jun 23 20:45:16 2013
  3. +++ testcode/testpolling.cpp Sat Dec 21 15:13:23 2013
  4. @@ -257,7 +257,9 @@ HRESULT CTestPolling::Test1()
  5. int fd;
  6. int count = 0;
  7. +#ifndef HAVE_ARC4RANDOM
  8. srand(100);
  9. +#endif
  10. ChkA(TestInit(10, 10));
  11. @@ -269,8 +271,11 @@ HRESULT CTestPolling::Test1()
  12. // one event at a time model
  13. for (int index = 0; index < 100; index++)
  14. {
  15. -
  16. +#ifdef HAVE_ARC4RANDOM
  17. + size_t item = arc4random_uniform(size);
  18. +#else
  19. size_t item = rand() % size;
  20. +#endif
  21. ChkA(WritePipe(&_pipes[item]));
  22. @@ -303,7 +308,9 @@ HRESULT CTestPolling::Test2()
  23. PollEvent event;
  24. const size_t c_maxSockets = 10;
  25. +#ifndef HAVE_ARC4RANDOM
  26. srand(100);
  27. +#endif
  28. ChkA(TestInit(c_maxSockets, 0));
  29. @@ -314,7 +321,11 @@ HRESULT CTestPolling::Test2()
  30. for (size_t index = 0; index < 1000; index++)
  31. {
  32. +#ifdef HAVE_ARC4RANDOM
  33. + int randresult = ::arc4random_uniform(4);
  34. +#else
  35. int randresult = ::rand() % 4;
  36. +#endif
  37. switch (randresult)
  38. {
  39. @@ -342,7 +353,11 @@ HRESULT CTestPolling::Test2()
  40. continue;
  41. }
  42. +#ifdef HAVE_ARC4RANDOM
  43. + itemindex = arc4random_uniform(size);
  44. +#else
  45. itemindex = rand() % size;
  46. +#endif
  47. ChkA(WritePipe(&_pipes[itemindex]));
  48. break;