Changes to attempt to silence bcc64x
[ACE_TAO.git] / ACE / tests / Missing_Svc_Conf_Test.cpp
blob960084f793388cd818d1e54bfbd23c25cc65d168
2 //=============================================================================
3 /**
4 * @file Missing_Svc_Conf_Test.cpp
6 * A test to ensure that service_config::open() returns -1 if it is
7 * fully defaulted, but no default svc.conf file exists. The first
8 * test verifies that open returns -1 with errno ENOENT. A second
9 * test ensures that service_config::open() returns 0 when any
10 * explicit directive is supplied by the command line, regardless
11 * of the existence of default svc.conf.
13 * Presently there is no svc.conf file in the tests directory and
14 * this test relies on that. It is assumed that this will stay
15 * true, since adding a default svc.conf file in this directory my
16 * impact other tests.
18 * @author Phil Mesnier <mesnier_p@ociweb.com>
20 //=============================================================================
22 #include "ace/Service_Config.h"
23 #include "ace/OS_NS_fcntl.h"
24 #include "ace/OS_NS_unistd.h"
25 #include "ace/Logging_Strategy.h"
27 #include "test_config.h"
29 int
30 run_main (int, ACE_TCHAR *[] )
32 ACE_START_TEST (ACE_TEXT ("Missing_Svc_Conf_Test"));
34 ACE_HANDLE h = ACE_OS::open (ACE_DEFAULT_SVC_CONF,O_RDONLY);
35 if (h != ACE_INVALID_HANDLE)
37 ACE_ERROR ((LM_ERROR,ACE_TEXT("svc.conf exists, test unable to run\n")));
38 ACE_OS::close(h);
39 return -1;
42 int argc = 1;
43 ACE_TCHAR *argv[] = {const_cast<ACE_TCHAR *>(ACE_TEXT("nosvc")),0,0,0 };
44 int failcount = 0;
45 int result = ACE_Service_Config::open(argc, argv);
46 if (result != -1 || errno != ENOENT)
48 ++failcount;
49 ACE_DEBUG ((LM_DEBUG,
50 ACE_TEXT("ERROR: did not get expected ENOENT, %p\n"),
51 ACE_TEXT("ACE_Service_Config::open")));
53 else
54 ACE_DEBUG ((LM_DEBUG,
55 ACE_TEXT("Success: defaulted Service_Config::open ")
56 ACE_TEXT("with missing file got expected ENOENT\n")));
58 result = ACE_Service_Config::close();
59 if (result != 0)
60 ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("%p\n"),
61 ACE_TEXT("Service_Config::close")));
63 argc = 3;
64 argv[1] = const_cast<ACE_TCHAR *>(ACE_TEXT("-S"));
65 argv[2] = const_cast<ACE_TCHAR *>(ACE_TEXT("dynamic Logger Service_Object *ACE:_make_ACE_Logging_Strategy() \"\""));
67 result = ACE_Service_Config::open(argc, argv);
68 if (result != 0)
70 ++failcount;
71 ACE_DEBUG ((LM_DEBUG,
72 ACE_TEXT("ERROR: missing svc.conf with ")
73 ACE_TEXT("command line directive, %p\n"),
74 ACE_TEXT("ACE_Service_Config::open")));
76 else
77 ACE_DEBUG ((LM_DEBUG,
78 ACE_TEXT("Success: Service_Config::open with command line ")
79 ACE_TEXT("directive ignored missing svc.conf\n")));
81 ACE_END_TEST;
82 return failcount;