]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
test-misc_hh: Add test for getCarbonHostname
authorAki Tuomi <cmouse@cmouse.fi>
Tue, 21 Jul 2020 19:04:56 +0000 (22:04 +0300)
committerOtto Moerbeek <otto.moerbeek@open-xchange.com>
Fri, 31 Jul 2020 08:09:42 +0000 (10:09 +0200)
(cherry picked from commit f19c0ed44619382b41119c8fb3136a3eb11790b8)

pdns/test-misc_hh.cc

index 1522850c3089a332a697415f52cee61c1efdc55c..01c4c3fb4e38f6aeaba49390ab4c2359a303d15f 100644 (file)
@@ -202,5 +202,19 @@ BOOST_AUTO_TEST_CASE(test_rfc1982LessThan) {
   BOOST_CHECK(rfc1982check<uint64_t>(UINT64_MAX/2, UINT64_MAX-10));
 }
 
+BOOST_AUTO_TEST_CASE(test_getCarbonHostName)
+{
+  char buffer[4096];
+
+  BOOST_CHECK_EQUAL(gethostname(buffer, sizeof buffer), 0);
+  std::string my_hostname(buffer);
+  boost::replace_all(my_hostname, ".", "_");
+
+  std::string hostname = getCarbonHostName();
+  // ensure it matches what we get
+  BOOST_CHECK_EQUAL(my_hostname, hostname);
+  BOOST_CHECK_EQUAL(my_hostname.size(), hostname.size());
+}
+
 BOOST_AUTO_TEST_SUITE_END()