diff options
Diffstat (limited to 'test/ares-test-init.cc')
-rw-r--r-- | test/ares-test-init.cc | 59 |
1 files changed, 57 insertions, 2 deletions
diff --git a/test/ares-test-init.cc b/test/ares-test-init.cc index c9c6089..66570ac 100644 --- a/test/ares-test-init.cc +++ b/test/ares-test-init.cc @@ -354,6 +354,26 @@ CONTAINED_TEST_F(LibraryTest, ContainerChannelInit, return HasFailure(); } +CONTAINED_TEST_F(LibraryTest, ContainerSortlistOptionInit, + "myhostname", "mydomainname.org", filelist) { + ares_channel channel = nullptr; + struct ares_options opts = {0}; + int optmask = 0; + optmask |= ARES_OPT_SORTLIST; + opts.nsort = 0; + // Explicitly specifying an empty sortlist in the options should override the + // environment. + EXPECT_EQ(ARES_SUCCESS, ares_init_options(&channel, &opts, optmask)); + ares_save_options(channel, &opts, &optmask); + EXPECT_EQ(0, opts.nsort); + EXPECT_EQ(nullptr, opts.sortlist); + EXPECT_EQ(ARES_OPT_SORTLIST, (optmask & ARES_OPT_SORTLIST)); + ares_destroy_options(&opts); + + ares_destroy(channel); + return HasFailure(); +} + NameContentList fullresolv = { {"/etc/resolv.conf", " nameserver 1.2.3.4 \n" "search first.com second.com\n" @@ -431,8 +451,8 @@ CONTAINED_TEST_F(LibraryTest, ContainerResolvConfNotReadable, "myhostname", "mydomainname.org", filelist) { ares_channel channel = nullptr; MakeUnreadable hide("/etc/resolv.conf"); - // Unavailable /etc/resolv.conf fails initialization. - EXPECT_EQ(ARES_EFILE, ares_init(&channel)); + // Unavailable /etc/resolv.conf falls back to defaults + EXPECT_EQ(ARES_SUCCESS, ares_init(&channel)); return HasFailure(); } CONTAINED_TEST_F(LibraryTest, ContainerNsswitchConfNotReadable, @@ -470,6 +490,41 @@ CONTAINED_TEST_F(LibraryTest, ContainerSvcConfNotReadable, return HasFailure(); } +NameContentList rotateenv = { + {"/etc/resolv.conf", "nameserver 1.2.3.4\n" + "search first.com second.com\n" + "options rotate\n"}}; +CONTAINED_TEST_F(LibraryTest, ContainerRotateInit, + "myhostname", "mydomainname.org", rotateenv) { + ares_channel channel = nullptr; + EXPECT_EQ(ARES_SUCCESS, ares_init(&channel)); + + struct ares_options opts; + int optmask = 0; + ares_save_options(channel, &opts, &optmask); + EXPECT_EQ(ARES_OPT_ROTATE, (optmask & ARES_OPT_ROTATE)); + ares_destroy_options(&opts); + + ares_destroy(channel); + return HasFailure(); +} + +CONTAINED_TEST_F(LibraryTest, ContainerRotateOverride, + "myhostname", "mydomainname.org", rotateenv) { + ares_channel channel = nullptr; + struct ares_options opts = {0}; + int optmask = ARES_OPT_NOROTATE; + EXPECT_EQ(ARES_SUCCESS, ares_init_options(&channel, &opts, optmask)); + + optmask = 0; + ares_save_options(channel, &opts, &optmask); + EXPECT_EQ(ARES_OPT_NOROTATE, (optmask & ARES_OPT_NOROTATE)); + ares_destroy_options(&opts); + + ares_destroy(channel); + return HasFailure(); +} + NameContentList multiresolv = { {"/etc/resolv.conf", " nameserver 1::2 ; ;;\n" " domain first.com\n"}, |