2 //=============================================================================
4 * @file Capabilities_Test.cpp
6 * This is a test that makes sure the <ACE_Capabililties> class
9 * @author Arturo Montes <mitosys@colomsat.net.co>
11 //=============================================================================
14 #include "test_config.h"
15 #include "ace/OS_NS_fcntl.h"
16 #include "ace/OS_NS_unistd.h"
17 #include "ace/Capabilities.h"
19 static const ACE_TCHAR config
[] = ACE_TEXT ("Capabilities_Test.cfg");
24 ACE_Capabilities caps
;
25 if (caps
.getent (config
, ACE_TEXT ("Config")) == -1)
26 ACE_ERROR_RETURN ((LM_ERROR
,
27 ACE_TEXT ("Can't read %s\n"),
32 caps
.getval (ACE_TEXT ("bool"), b
);
34 ACE_TEXT ("bool = %d\n"),
38 caps
.getval (ACE_TEXT ("integer"), n
);
41 ACE_TEXT ("integer = %d\n"),
45 caps
.getval (ACE_TEXT ("string"), s
);
48 ACE_TEXT ("string = %s\n"),
54 run_main (int, ACE_TCHAR
*[])
56 ACE_START_TEST (ACE_TEXT ("Capabilities_Test"));
59 // --------------------------------------------------------
61 // --------------------------------------------------------
63 // A config file is created within the test so that the test is
64 // completely self contained.
66 const char file_contents
[] =
67 "Config|Esta entrada reservada para la configuracion,\n"
70 " string=000030,\n\n";
72 ACE_HANDLE fd
= ACE_OS::open (config
,
73 O_RDWR
| O_CREAT
| O_TRUNC
,
74 ACE_DEFAULT_FILE_PERMS
);
76 if (fd
== ACE_INVALID_HANDLE
)
77 ACE_ERROR_RETURN ((LM_ERROR
,
79 ACE_TEXT ("ACE_OS::open")),
83 if (ACE_OS::write (fd
, file_contents
, sizeof(file_contents
)) !=
84 (ssize_t
) sizeof(file_contents
))
86 ACE_OS::unlink (config
);
88 ACE_ERROR_RETURN ((LM_ERROR
,
90 ACE_TEXT ("ACE_OS::write")),
94 if (ACE_OS::close (fd
) != 0)
96 ACE_OS::unlink (config
);
97 ACE_ERROR_RETURN ((LM_ERROR
,
99 ACE_TEXT ("ACE_OS::close")),
102 // --------------------------------------------------------
105 int const result
= load_config ();
107 ACE_OS::unlink (config
);