summaryrefslogtreecommitdiff
path: root/test/ares-test-init.cc
diff options
context:
space:
mode:
authorYu Jiung <jiung.yu@samsung.com>2016-11-09 02:24:14 (GMT)
committerYu Jiung <jiung.yu@samsung.com>2016-11-09 02:24:20 (GMT)
commit04b1a8c051547b221a3bdd74d68ab02df3e3f752 (patch)
tree68d564a70d38771969fc9f946fb16792e8d4f7f7 /test/ares-test-init.cc
parentf57d349bba373ddb713a249cb2866198346ae011 (diff)
parent8e609b5f488d486a9e066ed494218d966f489938 (diff)
downloadc-ares-04b1a8c051547b221a3bdd74d68ab02df3e3f752.zip
c-ares-04b1a8c051547b221a3bdd74d68ab02df3e3f752.tar.gz
c-ares-04b1a8c051547b221a3bdd74d68ab02df3e3f752.tar.bz2
Merge branch 'upstream' into tizenrefs/changes/27/96427/1
Change-Id: If7b14a6bca2079b3cc58a0432a9eb05a41ea5ceb
Diffstat (limited to 'test/ares-test-init.cc')
-rw-r--r--test/ares-test-init.cc59
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"},