message_initializer_2_unittest.cc 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. // Copyright (C) 2012 Internet Systems Consortium, Inc. ("ISC")
  2. //
  3. // Permission to use, copy, modify, and/or distribute this software for any
  4. // purpose with or without fee is hereby granted, provided that the above
  5. // copyright notice and this permission notice appear in all copies.
  6. //
  7. // THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
  8. // REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
  9. // AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
  10. // INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
  11. // LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
  12. // OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  13. // PERFORMANCE OF THIS SOFTWARE.
  14. #include <log/message_initializer.h>
  15. #include <gtest/gtest.h>
  16. #include <util/unittests/resource.h>
  17. using namespace isc::log;
  18. // Declare a set of messages to go into the global dictionary.
  19. namespace {
  20. const char* values[] = {
  21. "GLOBAL1", "global message one",
  22. "GLOBAL2", "global message two",
  23. NULL
  24. };
  25. }
  26. TEST(MessageInitializerTest2, MessageLoadTest) {
  27. // Load the maximum number of message arrays allowed. Some arrays may
  28. // already have been loaded because of static initialization from modules
  29. // in libraries linked against the test program, hence the reason for the
  30. // loop starting from the value returned by getPendingCount() instead of 0.
  31. for (size_t i = MessageInitializer::getPendingCount();
  32. i < MessageInitializer::MAX_MESSAGE_ARRAYS; ++i) {
  33. MessageInitializer initializer1(values);
  34. }
  35. // Note: Not all systems have EXPECT_DEATH. As it is a macro we can just
  36. // test for its presence and bypass the test if not available.
  37. #ifdef EXPECT_DEATH
  38. // Adding one more should take us over the limit.
  39. EXPECT_DEATH({
  40. isc::util::unittests::dontCreateCoreDumps();
  41. MessageInitializer initializer2(values);
  42. }, ".*");
  43. #endif
  44. }