summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorschmidt <douglascraigschmidt@users.noreply.github.com>2006-06-19 13:17:37 +0000
committerschmidt <douglascraigschmidt@users.noreply.github.com>2006-06-19 13:17:37 +0000
commit2893580a945c9b8164c7cf0729030c5b31ca6b0f (patch)
tree8ebb65557dfcd01d02b5f7c45d23842083ccea4d
parent8dcb9f7e1a3d81534f035279d169409851bd7e61 (diff)
downloadATCD-2893580a945c9b8164c7cf0729030c5b31ca6b0f.tar.gz
ChangeLogTag:Mon
-rw-r--r--ChangeLog6
-rw-r--r--tests/Hash_Map_Manager_Test.cpp92
2 files changed, 98 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index 3a11033f591..3adae7331db 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,9 @@
+Mon Jun 19 13:14:54 UTC 2006 Douglas C. Schmidt <schmidt@dre.vanderbilt.edu>
+
+ * tests/Hash_Map_Manager_Test.cpp (test_two_allocators): Added a
+ test for the two allocator version of ACE_Hash_Map_Manager.
+ Thanks to Jarek for contributing this.
+
Mon Jun 19 02:55:48 UTC 2006 Douglas C. Schmidt <schmidt@dre.vanderbilt.edu>
* examples/Log_Msg/test_ostream.cpp (ACE_TMAIN): Enhanced the test to
diff --git a/tests/Hash_Map_Manager_Test.cpp b/tests/Hash_Map_Manager_Test.cpp
index ed22412a092..8345650fb46 100644
--- a/tests/Hash_Map_Manager_Test.cpp
+++ b/tests/Hash_Map_Manager_Test.cpp
@@ -91,6 +91,95 @@ static String_Table string_table[] =
}
};
+static
+int test_two_allocators ()
+{
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Testing both allocators\n")));
+ int status = 0;
+
+ // Number of entries in string_table above:
+ size_t chunks = 3;
+ size_t chunk_size = sizeof (HASH_STRING_MAP::ENTRY);
+
+ // Allocators:
+ ACE_Dynamic_Cached_Allocator<ACE_Null_Mutex> table_alloc (1 , chunk_size * chunks);
+ ACE_Dynamic_Cached_Allocator<ACE_Null_Mutex> table_alloc_small (1, chunk_size * chunks - 1);
+ ACE_Cached_Allocator<HASH_STRING_MAP::ENTRY, ACE_Null_Mutex> entry_alloc (chunks);
+
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Testing hash map manager with %d elements...\n"), chunks));
+
+ HASH_STRING_MAP hash;
+
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Opening hash map manager with "
+ "insufficient table allocator, should fail...\n")));
+ ACE_OS::last_error (0);
+ status = hash.open (chunks, &table_alloc_small, &entry_alloc);
+ if (status < 0)
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("OK, failed: %d (%s)\n"),
+ status, ACE_OS::strerror (ACE_OS::last_error ())));
+ else
+ ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("*** Something is wrong...\n")), -1);
+
+ status = hash.close ();
+
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Table allocator depth: %d.\n"),
+ table_alloc.pool_depth ()));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Entry allocator depth: %d.\n"),
+ entry_alloc.pool_depth ()));
+
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Opening hash map manager again, should succeed...\n")));
+ ACE_OS::last_error (0);
+ status = hash.open (chunks, &table_alloc, &entry_alloc);
+ if (status < 0)
+ ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("*** Something is wrong: %d (%s)\n"),
+ status, ACE_OS::strerror (ACE_OS::last_error ())), -1);
+ else
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("OK.\n")));
+
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Table allocator depth: %d\n"),
+ table_alloc.pool_depth ()));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Entry allocator depth: %d.\n"),
+ entry_alloc.pool_depth ()));
+
+ for (size_t i = 0; i < chunks; i++)
+ {
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("- Binding ('%s', '%s'), should succeed...\n"),
+ string_table[i].key_ , string_table[i].value_));
+ ACE_OS::last_error (0);
+ status = hash.bind (string_table[i].key_, string_table[i].value_);
+ if (status < 0)
+ ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("*** Something is wrong: %d (%s)\n"),
+ status, ACE_OS::strerror (ACE_OS::last_error ())), -1);
+ else
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("OK, entry allocator depth: %d\n"),
+ entry_alloc.pool_depth ()));
+ }
+
+ char *key = "key";
+ char *val = "value";
+
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("- Binding ('%s', '%s'), should fail...\n"),
+ key, val));
+ ACE_OS::last_error (0);
+ status = hash.bind (key, val);
+ if (status < 0)
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("OK, failed (%s).\n"),
+ ACE_OS::strerror (ACE_OS::last_error ())));
+ else
+ ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("*** Something is wrong: %d (%s)\n"),
+ status, ACE_OS::strerror (ACE_OS::last_error ())), -1);
+
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Closing hash map.\n")));
+ status = hash.close ();
+
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Table allocator depth: %d.\n"),
+ table_alloc.pool_depth ()));
+ ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Entry allocator depth: %d.\n"),
+ entry_alloc.pool_depth ()));
+
+ return 0;
+}
+
static int
run_test (void)
{
@@ -225,6 +314,9 @@ run_test (void)
string_table[i].key_), -1);
ace_test_allocator.dump ();
+
+ test_two_allocators();
+
return 0;
}