summaryrefslogtreecommitdiff
path: root/tests/Pipe_Test.cpp
blob: b47a82a0dbc773d1f4e7c5b58cd9c8b87a79c4ba (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
// ============================================================================
//
// = LIBRARY
//    tests
// 
// = FILENAME
//    Pipe_Test.cpp
//
// = DESCRIPTION
//    Tests the construction of multiple pipes in a process.
//
// = AUTHOR
//    Irfan Pyarali
// 
// ============================================================================

#include "ace/Pipe.h"
#include "test_config.h"

void
open (ACE_Pipe &pipe, 
      const char *name, 
      int close_pipe = 1)
{
  if (pipe.open () == 0)
    ACE_DEBUG ((LM_DEBUG, "Pipe %s: successful open\n", name));
  else
    {
      ACE_DEBUG ((LM_DEBUG, "%p: UNSUCCESSFUL open for pipe %s\n", "pipe.open", name));
      if (pipe.read_handle () == ACE_INVALID_HANDLE)
	ACE_DEBUG ((LM_DEBUG, "Reader is invalid\n"));
      else
	ACE_DEBUG ((LM_DEBUG, "Reader is valid\n"));
      if (pipe.write_handle () == ACE_INVALID_HANDLE)
	ACE_DEBUG ((LM_DEBUG, "Writer is invalid\n"));
      else
	ACE_DEBUG ((LM_DEBUG, "Writer is valid\n"));

      ACE_OS::exit (-1);
    }     
  if (close_pipe)
    pipe.close ();
}

int 
main (int, char *argv[])
{
  ACE_START_TEST ("Pipe_Test.cpp");

  ACE_Pipe a, b, c, d, e, f, g, h, i, j;

  ::open (a, "a");
  ::open (b, "b");
  ::open (c, "c");
  ::open (d, "d");
  ::open (e, "e");
  ::open (f, "f");
  ::open (g, "g");
  ::open (h, "h");
  ::open (i, "i");
  ::open (j, "j");

  ACE_END_TEST;
  return 0;
}