2 //=============================================================================
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
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"
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")));
43 ACE_TCHAR
*argv
[] = {const_cast<ACE_TCHAR
*>(ACE_TEXT("nosvc")),0,0,0 };
45 int result
= ACE_Service_Config::open(argc
, argv
);
46 if (result
!= -1 || errno
!= ENOENT
)
50 ACE_TEXT("ERROR: did not get expected ENOENT, %p\n"),
51 ACE_TEXT("ACE_Service_Config::open")));
55 ACE_TEXT("Success: defaulted Service_Config::open ")
56 ACE_TEXT("with missing file got expected ENOENT\n")));
58 result
= ACE_Service_Config::close();
60 ACE_DEBUG ((LM_DEBUG
, ACE_TEXT ("%p\n"),
61 ACE_TEXT("Service_Config::close")));
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
);
72 ACE_TEXT("ERROR: missing svc.conf with ")
73 ACE_TEXT("command line directive, %p\n"),
74 ACE_TEXT("ACE_Service_Config::open")));
78 ACE_TEXT("Success: Service_Config::open with command line ")
79 ACE_TEXT("directive ignored missing svc.conf\n")));