message_initializer_2_unittest.cc 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  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. #ifdef EXPECT_DEATH
  17. #include <testutils/resource.h>
  18. #endif /* EXPECT_DEATH */
  19. using namespace isc::log;
  20. // Declare a set of messages to go into the global dictionary.
  21. namespace {
  22. const char* values[] = {
  23. "GLOBAL1", "global message one",
  24. "GLOBAL2", "global message two",
  25. NULL
  26. };
  27. }
  28. TEST(MessageInitializerTest2, MessageLoadTest) {
  29. // Load the maximum number of message arrays allowed. Some arrays may
  30. // already have been loaded because of static initialization from modules
  31. // in libraries linked against the test program, hence the reason for the
  32. // loop starting from the value returned by getPendingCount() instead of 0.
  33. for (size_t i = MessageInitializer::getPendingCount();
  34. i < MessageInitializer::MAX_MESSAGE_ARRAYS; ++i) {
  35. MessageInitializer initializer1(values);
  36. }
  37. // Note: Not all systems have EXPECT_DEATH. As it is a macro we can just
  38. // test for its presence and bypass the test if not available.
  39. #ifdef EXPECT_DEATH
  40. // Adding one more should take us over the limit.
  41. EXPECT_DEATH({
  42. isc::testutils::dontCreateCoreDumps();
  43. MessageInitializer initializer2(values);
  44. }, ".*");
  45. #endif
  46. }