summaryrefslogtreecommitdiff
path: root/ACE/tests/Missing_Svc_Conf_Test.cpp
diff options
context:
space:
mode:
authorPhil Mesnier <mesnier_p@ociweb.com>2010-08-20 13:32:02 +0000
committerPhil Mesnier <mesnier_p@ociweb.com>2010-08-20 13:32:02 +0000
commitc99310b44d8ce60ae5a7648a1450d936e4bafc2b (patch)
treeeb2a585ce88ddd2fa1e96b3b10a2df91be7c5586 /ACE/tests/Missing_Svc_Conf_Test.cpp
parent6984260a18b41e6b5e49d99caef66d6243c20eda (diff)
downloadATCD-c99310b44d8ce60ae5a7648a1450d936e4bafc2b.tar.gz
Fri Aug 20 13:29:22 UTC 2010 Phil Mesnier <mesnier_p@ociweb.com>
* ace/Service_Gestalt.cpp: One more shot at fixing the behavior of the service configurator in the face of missing defaulted svc.conf file. * tests/Missing_Svc_Conf_Test.cpp: * tests/run_test.lst: * tests/tests.mpc: Added a proper test to ensure changes to this behavior are caught in the future.
Diffstat (limited to 'ACE/tests/Missing_Svc_Conf_Test.cpp')
-rw-r--r--ACE/tests/Missing_Svc_Conf_Test.cpp62
1 files changed, 62 insertions, 0 deletions
diff --git a/ACE/tests/Missing_Svc_Conf_Test.cpp b/ACE/tests/Missing_Svc_Conf_Test.cpp
new file mode 100644
index 00000000000..11b7594d759
--- /dev/null
+++ b/ACE/tests/Missing_Svc_Conf_Test.cpp
@@ -0,0 +1,62 @@
+#include "test_config.h"
+#include "ace/Service_Config.h"
+#include "ace/OS_NS_fcntl.h"
+#include "ace/Logging_Strategy.h"
+
+//ACE_STATIC_SVC_REQUIRE (ACE_Logging_Strategy);
+
+int
+run_main (int , ACE_TCHAR ** )
+{
+ ACE_START_TEST (ACE_TEXT ("Missing_Svc_Conf_Test"));
+
+ ACE_HANDLE h = ACE_OS::open (ACE_DEFAULT_SVC_CONF,O_RDONLY);
+ if (h != ACE_INVALID_HANDLE)
+ {
+ ACE_ERROR ((LM_ERROR,ACE_TEXT("svc.conf exists, test unable to run\n")));
+ ACE_OS::close(h);
+ return -1;
+ }
+
+ int argc = 1;
+ ACE_TCHAR *argv[] = {const_cast<ACE_TCHAR *>(ACE_TEXT("nosvc")),0,0,0 };
+ int failcount = 0;
+ int result = ACE_Service_Config::open(argc, argv);
+ if (result != -1 || errno != ENOENT)
+ {
+ ++failcount;
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT("ERROR: did not get expected ENOENT, %p\n"),
+ ACE_TEXT("ACE_Service_Config::open")));
+ }
+ else
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT("Success: defaulted Service_Config::open ")
+ ACE_TEXT("with missing file got expected ENOENT\n")));
+
+ result = ACE_Service_Config::close();
+ if (result != 0)
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("%p\n"),
+ ACE_TEXT("Service_Config::close")));
+
+ argc = 3;
+ argv[1] = const_cast<ACE_TCHAR *>(ACE_TEXT("-S"));
+ argv[2] = const_cast<ACE_TCHAR *>(ACE_TEXT("dynamic Logger Service_Object *ACE:_make_ACE_Logging_Strategy() \"\""));
+
+ result = ACE_Service_Config::open(argc, argv);
+ if (result != 0)
+ {
+ ++failcount;
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT("ERROR: missing svc.conf with ")
+ ACE_TEXT("command line directive, %p\n"),
+ ACE_TEXT("ACE_Service_Config::open")));
+ }
+ else
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT("Success: Service_Config::open with command line ")
+ ACE_TEXT("directive ignored missing svc.conf\n")));
+
+ ACE_END_TEST;
+ return failcount;
+}