diff options
Diffstat (limited to 'tests/Svc_Handler_Test.cpp')
-rw-r--r-- | tests/Svc_Handler_Test.cpp | 43 |
1 files changed, 18 insertions, 25 deletions
diff --git a/tests/Svc_Handler_Test.cpp b/tests/Svc_Handler_Test.cpp index a6c4b64a3ae..4505059c324 100644 --- a/tests/Svc_Handler_Test.cpp +++ b/tests/Svc_Handler_Test.cpp @@ -10,8 +10,7 @@ // // = DESCRIPTION // This tests illustrates the "buffering" strategy of the -// <ACE_Buffered_Svc_Handler>. This test also illustrates how the -// <ACE_FILE_IO> classes work. +// <ACE_Buffered_Svc_Handler>. // // = AUTHORS // Douglas C. Schmidt <schmidt@cs.wustl.edu> @@ -29,7 +28,7 @@ typedef ACE_Buffered_Svc_Handler <ACE_FILE_STREAM, ACE_NULL_SYNCH> SVC_HANDLER; static void run_test (SVC_HANDLER &svc_handler, - size_t iterations) + size_t iterations) { // Create a whole slew of message blocks and pass them to the // <svc_handler>. @@ -92,7 +91,8 @@ main (int argc, ACE_TCHAR *argv[]) ACE_FILE_Addr file (ACE_sap_any_cast (ACE_FILE_Addr &)); // Open up the temp file. - if (connector.connect (file_io, file) == -1) + if (connector.connect (file_io, + file) == -1) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("connect failed for %p\n"), file.get_path_name ()), @@ -103,6 +103,16 @@ main (int argc, ACE_TCHAR *argv[]) # define TEST_CAN_UNLINK_IN_ADVANCE #endif +#if defined(TEST_CAN_UNLINK_IN_ADVANCE) + // Unlink this file right away so that it is automatically removed + // when the process exits. + if (file_io.unlink () == -1) + ACE_ERROR_RETURN ((LM_ERROR, + ACE_TEXT ("unlink failed for %p\n"), + file.get_path_name ()), + 1); +#endif + // Create the service handler and assign it <file_io> as its data // sink. SVC_HANDLER svc_handler (0, @@ -115,32 +125,15 @@ main (int argc, ACE_TCHAR *argv[]) // Run the test. run_test (svc_handler, iterations); - file_io.close (); - - // Open up the temp file. - if (connector.connect (file_io, file) == -1) - ACE_ERROR_RETURN ((LM_ERROR, - ACE_TEXT ("connect failed for %p\n"), - file.get_path_name ()), - 1); - char buf[17]; - ACE_LOG_MSG->clr_flags (ACE_Log_Msg::VERBOSE_LITE); - - ACE_FILE_Info info; - file_io.get_info (info); - ACE_DEBUG ((LM_DEBUG, "file size = %d\n", info.size_)); - - for (ssize_t n_bytes; (n_bytes = file_io.recv (buf, sizeof buf)) > 0; ) - ACE_DEBUG ((LM_DEBUG, "%*s", n_bytes, buf)); - - ACE_DEBUG ((LM_DEBUG, "\n")); - - file_io.close (); +#if !defined(TEST_CAN_UNLINK_IN_ADVANCE) + file_io.close(); if (file_io.unlink () == -1) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("unlink failed for %p\n"), file.get_path_name ()), 1); +#endif + } ACE_END_TEST; |