summaryrefslogtreecommitdiff
path: root/ACE/tests/Bug_3974_Regression_Test.cpp
blob: fe87c1b4258377089137c66a3479c7c7332e88c6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
/**
 * @file Bug_3974_Regression_Test.cpp
 *
 * Reproduces the problems reported in bug 3974
 *   http://bugzilla.dre.vanderbilt.edu/show_bug.cgi?id=3974
 */

#include "test_config.h"

#include "ace/Dev_Poll_Reactor.h"
#include "ace/Select_Reactor.h"
#include "ace/TP_Reactor.h"
#include "ace/WFMO_Reactor.h"
#include "ace/OS_NS_errno.h"

bool
testit (ACE_Reactor_Impl *ri)
{
  int ret = 0;
  ACE_Reactor r (ri);
  ACE_Time_Value one (1);
  r.end_reactor_event_loop ();
  if ((ret = r.handle_events (one)) != -1)
    {
      ACE_ERROR ((LM_ERROR, ACE_TEXT ("Return value %d should be -1\n"), ret));
      return false;
    }
  if (errno != ESHUTDOWN)
    {
      ACE_ERROR ((LM_ERROR,
                  ACE_TEXT ("errno %d should be %d (ESHUTDOWN)\n"),
                  errno, ESHUTDOWN));
      return false;
    }

  return true;
}

// Main function.

int
run_main (int, ACE_TCHAR *[])
{
  ACE_START_TEST (ACE_TEXT ("Bug_3974_Regression_Test"));
  int result = 0;

  ACE_Select_Reactor r1;
  if (!testit (&r1))
    {
      ACE_ERROR ((LM_ERROR, ACE_TEXT ("Select_Reactor failed\n")));
      result = 1;
    }

  ACE_TP_Reactor r2;
  if (!testit (&r2))
    {
      ACE_ERROR ((LM_ERROR, ACE_TEXT ("TP_Reactor failed\n")));
      result = 1;
    }

#ifdef ACE_WIN32
  ACE_WFMO_Reactor r3;
  if (!testit (&r3))
    {
      ACE_ERROR ((LM_ERROR, ACE_TEXT ("WFMO_Reactor failed\n")));
      result = 1;
    }
#endif /* ACE_WIN32 */

#if defined (ACE_HAS_EVENT_POLL) || defined (ACE_HAS_DEV_POLL)
  ACE_Dev_Poll_Reactor r4;
  if (!testit (&r4))
    {
      ACE_ERROR ((LM_ERROR, ACE_TEXT ("Dev_Poll_Reactor failed\n")));
      result = 1;
    }
#endif /* ACE_HAS_EVENT_POLL || ACE_HAS_DEV_POLL */

  ACE_END_TEST;
  return result;
}