瀏覽代碼

test: fix test issue.

Nick Peng 2 年之前
父節點
當前提交
33ee73cbf2

+ 8 - 32
test/cases/test-address.cc

@@ -49,14 +49,11 @@ TEST_F(Address, soa)
 
 	server.Start(R"""(bind [::]:60053
 server 127.0.0.1:61053
-log-num 0
-log-console yes
-log-level debug
 speed-check-mode none
 address /a.com/#4
 address /b.com/#6
 address /c.com/#
-cache-persist no)""");
+)""");
 	smartdns::Client client;
 	ASSERT_TRUE(client.Query("a.com A", 60053));
 	std::cout << client.GetResult() << std::endl;
@@ -135,13 +132,10 @@ TEST_F(Address, ip)
 
 	server.Start(R"""(bind [::]:60053
 server 127.0.0.1:61053
-log-num 0
-log-console yes
-log-level debug
 speed-check-mode none
 address /a.com/10.10.10.10
 address /a.com/64:ff9b::1010:1010
-cache-persist no)""");
+)""");
 	smartdns::Client client;
 	ASSERT_TRUE(client.Query("a.com A", 60053));
 	std::cout << client.GetResult() << std::endl;
@@ -180,13 +174,10 @@ TEST_F(Address, multiaddress)
 
 	server.Start(R"""(bind [::]:60053
 server 127.0.0.1:61053
-log-num 0
-log-console yes
-log-level debug
 speed-check-mode none
 address /a.com/10.10.10.10,11.11.11.11,22.22.22.22
 address /a.com/64:ff9b::1010:1010,64:ff9b::1111:1111,64:ff9b::2222:2222
-cache-persist no)""");
+)""");
 	smartdns::Client client;
 	ASSERT_TRUE(client.Query("a.com A", 60053));
 	std::cout << client.GetResult() << std::endl;
@@ -271,13 +262,10 @@ TEST_F(Address, soa_sub_ip)
 
 	server.Start(R"""(bind [::]:60053
 server 127.0.0.1:61053
-log-num 0
-log-console yes
-log-level debug
 speed-check-mode none
 address /a.com/192.168.1.1
 address /com/#
-cache-persist no)""");
+)""");
 	smartdns::Client client;
 	ASSERT_TRUE(client.Query("a.com A", 60053));
 	std::cout << client.GetResult() << std::endl;
@@ -317,12 +305,9 @@ TEST_F(Address, set_ipv4_query_ipv6)
 
 	server.Start(R"""(bind [::]:60053
 server 127.0.0.1:61053
-log-num 0
-log-console yes
-log-level debug
 speed-check-mode none
 address /a.com/192.168.1.1
-cache-persist no)""");
+)""");
 	smartdns::Client client;
 	ASSERT_TRUE(client.Query("a.com A", 60053));
 	std::cout << client.GetResult() << std::endl;
@@ -357,12 +342,9 @@ TEST_F(Address, set_ipv6_query_ipv4)
 
 	server.Start(R"""(bind [::]:60053
 server 127.0.0.1:61053
-log-num 0
-log-console yes
-log-level debug
 speed-check-mode none
 address /a.com/64:ff9b::1010:1010
-cache-persist no)""");
+)""");
 	smartdns::Client client;
 	ASSERT_TRUE(client.Query("a.com A", 60053));
 	std::cout << client.GetResult() << std::endl;
@@ -397,14 +379,11 @@ TEST_F(Address, set_ipv4_allow_ipv6)
 
 	server.Start(R"""(bind [::]:60053
 server 127.0.0.1:61053
-log-num 0
-log-console yes
-log-level debug
 speed-check-mode none
 address /a.com/192.168.1.1
 address /b.a.com/-6
 address /com/#
-cache-persist no)""");
+)""");
 	smartdns::Client client;
 	ASSERT_TRUE(client.Query("a.com A", 60053));
 	std::cout << client.GetResult() << std::endl;
@@ -458,14 +437,11 @@ TEST_F(Address, set_both_ipv4_ipv6)
 
 	server.Start(R"""(bind [::]:60053
 server 127.0.0.1:61053
-log-num 0
-log-console yes
-log-level debug
 speed-check-mode none
 address /a.com/192.168.1.1
 address /b.a.com/64:ff9b::1010:1010
 address /com/#
-cache-persist no)""");
+)""");
 	smartdns::Client client;
 	ASSERT_TRUE(client.Query("a.com A", 60053));
 	std::cout << client.GetResult() << std::endl;

+ 10 - 40
test/cases/test-bind.cc

@@ -39,16 +39,10 @@ TEST(Bind, tls)
 
 	server.Start(R"""(bind [::]:61053
 server-tls 127.0.0.1:60053 -no-check-certificate
-log-num 0
-log-console yes
-log-level debug
-cache-persist no)""");
+)""");
 	server_wrap.Start(R"""(bind-tls [::]:60053
 address /example.com/1.2.3.4
-log-num 0
-log-console yes
-log-level debug
-cache-persist no)""");
+)""");
 	smartdns::Client client;
 	ASSERT_TRUE(client.Query("example.com", 61053));
 	ASSERT_EQ(client.GetAnswerNum(), 1);
@@ -69,16 +63,10 @@ TEST(Bind, https)
 
 	server.Start(R"""(bind [::]:61053
 server https://127.0.0.1:60053 -no-check-certificate
-log-num 0
-log-console yes
-log-level debug
-cache-persist no)""");
+)""");
 	server_wrap.Start(R"""(bind-https [::]:60053
 address /example.com/1.2.3.4
-log-num 0
-log-console yes
-log-level debug
-cache-persist no)""");
+)""");
 	smartdns::Client client;
 	ASSERT_TRUE(client.Query("example.com", 61053));
 	ASSERT_EQ(client.GetAnswerNum(), 1);
@@ -103,10 +91,7 @@ TEST(Bind, udp_tcp)
 bind [::]:60053
 bind-tcp [::]:60053
 server 127.0.0.1:61053
-log-num 0
-log-console yes
-log-level debug
-cache-persist no)""");
+)""");
 	smartdns::Client client;
 	ASSERT_TRUE(client.Query("a.com +tcp", 60053));
 	std::cout << client.GetResult() << std::endl;
@@ -141,10 +126,7 @@ bind [::]:60053 -group self
 server 127.0.0.1:61053 -group self
 bind [::]:61053 -group upstream  
 server 127.0.0.1:62053 -group upstream
-log-num 0
-log-console yes
-log-level info
-cache-persist no)""");
+)""");
 	smartdns::Client client;
 
 	ASSERT_TRUE(client.Query("a.com", 60053));
@@ -174,10 +156,7 @@ TEST(Bind, nocache)
 bind [::]:60053 --no-cache
 bind-tcp [::]:60053
 server 127.0.0.1:61053
-log-num 0
-log-console yes
-log-level debug
-cache-persist no)""");
+)""");
 	smartdns::Client client;
 	ASSERT_TRUE(client.Query("a.com", 60053));
 	std::cout << client.GetResult() << std::endl;
@@ -213,10 +192,7 @@ TEST(Bind, device)
 	server.Start(R"""(
 bind [::]:60053@lo
 server 127.0.0.1:62053
-log-num 0
-log-console yes
-log-level info
-cache-persist no)""");
+)""");
 	smartdns::Client client;
 
 	ASSERT_TRUE(client.Query("a.com", 60053));
@@ -244,10 +220,8 @@ TEST(Bind, malformed_packet)
 	server.Start(R"""(
 bind [::]:60053@lo
 server 127.0.0.1:62053
-log-num 0
-log-console yes
 log-level info
-cache-persist no)""");
+)""");
 
 	int sockfd = socket(AF_INET, SOCK_DGRAM, 0);
 	ASSERT_NE(sockfd, -1);
@@ -283,7 +257,6 @@ cache-persist no)""");
 	EXPECT_EQ(client.GetAnswer()[0].GetData(), "1.2.3.4");
 }
 
-
 TEST(Bind, group)
 {
 	smartdns::MockServer server_upstream;
@@ -324,10 +297,7 @@ bind [::]:60253 -group g2
 server 127.0.0.1:61053
 server 127.0.0.1:62053 -group g1 -exclude-default-group
 server 127.0.0.1:63053 -group g2 -exclude-default-group
-log-num 0
-log-console yes
-log-level debug
-cache-persist no)""");
+)""");
 	smartdns::Client client;
 	ASSERT_TRUE(client.Query("a.com", 60053));
 	std::cout << client.GetResult() << std::endl;

+ 1 - 4
test/cases/test-bootstrap.cc

@@ -56,10 +56,7 @@ TEST_F(BootStrap, bootstrap)
 	server.Start(R"""(bind [::]:60053
 server udp://127.0.0.1:62053 -bootstrap-dns
 server udp://example.com:61053
-log-num 0
-log-console yes
-log-level debug
-cache-persist no)""");
+)""");
 	smartdns::Client client;
 	usleep(2500000);
 	ASSERT_TRUE(client.Query("a.com", 60053));

+ 7 - 32
test/cases/test-cache.cc

@@ -65,14 +65,11 @@ TEST_F(Cache, min)
 
 	server.Start(R"""(bind [::]:60053
 server 127.0.0.1:61053
-log-num 0
 cache-size 1
 rr-ttl-min 1
 speed-check-mode none
 response-mode fastest-response
-log-console yes
-log-level debug
-cache-persist no)""");
+)""");
 	smartdns::Client client;
 	ASSERT_TRUE(client.Query("a.com", 60053));
 	std::cout << client.GetResult() << std::endl;
@@ -110,15 +107,12 @@ TEST_F(Cache, max_reply_ttl)
 
 	server.Start(R"""(bind [::]:60053
 server 127.0.0.1:61053
-log-num 0
 cache-size 1
 rr-ttl-min 600
 rr-ttl-reply-max 5
 speed-check-mode none
 response-mode fastest-response
-log-console yes
-log-level debug
-cache-persist no)""");
+)""");
 	smartdns::Client client;
 	ASSERT_TRUE(client.Query("a.com", 60053));
 	std::cout << client.GetResult() << std::endl;
@@ -166,13 +160,10 @@ TEST_F(Cache, max_reply_ttl_expired)
 
 	server.Start(R"""(bind [::]:60053
 server 127.0.0.1:61053
-log-num 0
 cache-size 1
 rr-ttl-min 600
 rr-ttl-reply-max 6
-log-console yes
-log-level debug
-cache-persist no)""");
+)""");
 	smartdns::Client client;
 	ASSERT_TRUE(client.Query("a.com", 60053));
 	std::cout << client.GetResult() << std::endl;
@@ -234,14 +225,10 @@ bind [::]:60153 -group g1
 server 127.0.0.1:61053
 server 127.0.0.1:62053 -group g1 -exclude-default-group
 server 127.0.0.1:63053 -group g2
-log-num 0
 prefetch-domain yes
 rr-ttl-max 2
 serve-expired no
-log-console yes
-log-level debug
-srv-record-selection no
-cache-persist no)""");
+)""");
 	smartdns::Client client;
 	ASSERT_TRUE(client.Query("a.com", 60053));
 	std::cout << client.GetResult() << std::endl;
@@ -303,14 +290,11 @@ TEST_F(Cache, nocache)
 
 	server.Start(R"""(bind [::]:60053
 server 127.0.0.1:61053
-log-num 0
 cache-size 100
 rr-ttl-min 600
 rr-ttl-reply-max 5
-log-console yes
-log-level debug
 domain-rules /a.com/ --no-cache
-cache-persist no)""");
+)""");
 	smartdns::Client client;
 	ASSERT_TRUE(client.Query("a.com", 60053));
 	std::cout << client.GetResult() << std::endl;
@@ -337,9 +321,6 @@ TEST_F(Cache, save_file)
 	std::string conf = R"""(
 bind [::]:60053@lo
 server 127.0.0.1:62053
-log-num 0
-log-console yes
-log-level debug
 cache-persist yes
 dualstack-ip-selection no
 )""";
@@ -390,9 +371,6 @@ TEST_F(Cache, corrupt_file)
 	std::string conf = R"""(
 bind [::]:60053@lo
 server 127.0.0.1:62053
-log-num 0
-log-console yes
-log-level debug
 dualstack-ip-selection no
 cache-persist yes
 )""";
@@ -479,11 +457,8 @@ TEST_F(Cache, cname)
 
 	server.Start(R"""(bind [::]:60053
 server 127.0.0.1:61053
-log-num 0
 cache-size 100
-log-console yes
-log-level debug
-cache-persist no)""");
+)""");
 	smartdns::Client client;
 	ASSERT_TRUE(client.Query("a.com A", 60053));
 	std::cout << client.GetResult() << std::endl;
@@ -501,6 +476,6 @@ cache-persist no)""");
 	ASSERT_EQ(client.GetAnswerNum(), 1);
 	EXPECT_EQ(client.GetStatus(), "NOERROR");
 	EXPECT_EQ(client.GetAnswer()[0].GetName(), "cname.a.com");
-	EXPECT_GE(client.GetAnswer()[0].GetTTL(), 3);
+	EXPECT_GE(client.GetAnswer()[0].GetTTL(), 590);
 	EXPECT_EQ(client.GetAnswer()[0].GetData(), "1.2.3.4");
 }

+ 4 - 16
test/cases/test-cname.cc

@@ -50,10 +50,7 @@ cname /b.com/c.com
 cname /c.com/d.com
 cname /d.com/e.com
 server 127.0.0.1:61053
-log-num 0
-log-console yes
-log-level debug
-cache-persist no)""");
+)""");
 	smartdns::Client client;
 	ASSERT_TRUE(client.Query("a.com", 60053));
 	std::cout << client.GetResult() << std::endl;
@@ -86,10 +83,7 @@ TEST_F(Cname, subdomain1)
 	server.Start(R"""(bind [::]:60053
 cname /a.com/s.a.com
 server 127.0.0.1:61053
-log-num 0
-log-console yes
-log-level debug
-cache-persist no)""");
+)""");
 	smartdns::Client client;
 	ASSERT_TRUE(client.Query("a.com", 60053));
 	std::cout << client.GetResult() << std::endl;
@@ -123,10 +117,7 @@ TEST_F(Cname, subdomain2)
 cname /a.com/s.a.com
 cname /s.a.com/a.s.a.com
 server 127.0.0.1:61053
-log-num 0
-log-console yes
-log-level debug
-cache-persist no)""");
+)""");
 	smartdns::Client client;
 	ASSERT_TRUE(client.Query("a.com", 60053));
 	std::cout << client.GetResult() << std::endl;
@@ -160,10 +151,7 @@ TEST_F(Cname, loop)
 cname /a.com/c.a.com
 cname /c.a.com/s.a.com
 server 127.0.0.1:61053
-log-num 0
-log-console yes
-log-level debug
-cache-persist no)""");
+)""");
 	smartdns::Client client;
 	ASSERT_TRUE(client.Query("a.com", 60053));
 	std::cout << client.GetResult() << std::endl;

+ 6 - 14
test/cases/test-ddns.cc

@@ -36,17 +36,13 @@ TEST_F(DDNS, smartdns)
 	smartdns::MockServer server_upstream;
 	smartdns::Server server;
 
-	server_upstream.Start("udp://0.0.0.0:61053", [&](struct smartdns::ServerRequestContext *request) {
-		return smartdns::SERVER_REQUEST_SOA;
-	});
+	server_upstream.Start("udp://0.0.0.0:61053",
+						  [&](struct smartdns::ServerRequestContext *request) { return smartdns::SERVER_REQUEST_SOA; });
 
 	server.Start(R"""(bind [::]:60053
 server 127.0.0.1:61053
-log-num 0
-log-console yes
 dualstack-ip-selection no
-log-level debug
-cache-persist no)""");
+)""");
 	smartdns::Client client;
 	ASSERT_TRUE(client.Query("smartdns A", 60053));
 	std::cout << client.GetResult() << std::endl;
@@ -72,19 +68,15 @@ TEST_F(DDNS, ddns)
 	smartdns::MockServer server_upstream;
 	smartdns::Server server;
 
-	server_upstream.Start("udp://0.0.0.0:61053", [&](struct smartdns::ServerRequestContext *request) {
-		return smartdns::SERVER_REQUEST_SOA;
-	});
+	server_upstream.Start("udp://0.0.0.0:61053",
+						  [&](struct smartdns::ServerRequestContext *request) { return smartdns::SERVER_REQUEST_SOA; });
 
 	server.Start(R"""(bind [::]:60053
 server 127.0.0.1:61053
-log-num 0
 ddns-domain test.ddns.com
 ddns-domain test.ddns.org
-log-console yes
 dualstack-ip-selection no
-log-level debug
-cache-persist no)""");
+)""");
 	smartdns::Client client;
 	ASSERT_TRUE(client.Query("test.ddns.com A", 60053));
 	std::cout << client.GetResult() << std::endl;

+ 2 - 8
test/cases/test-discard-block-ip.cc

@@ -53,10 +53,7 @@ TEST(DiscardBlockIP, first_ping)
 	server.Start(R"""(bind [::]:60053
 server 127.0.0.1:61053
 server 127.0.0.1:62053
-log-num 0
-log-console yes
-log-level debug
-cache-persist no)""");
+)""");
 	smartdns::Client client;
 	ASSERT_TRUE(client.Query("a.com", 60053));
 	std::cout << client.GetResult() << std::endl;
@@ -91,11 +88,8 @@ TEST(DiscardBlockIP, first_response)
 	server.Start(R"""(bind [::]:60053
 server 127.0.0.1:61053
 server 127.0.0.1:62053
-log-num 0
-log-console yes
-log-level debug
 response-mode fastest-response
-cache-persist no)""");
+)""");
 	smartdns::Client client;
 	ASSERT_TRUE(client.Query("a.com", 60053));
 	std::cout << client.GetResult() << std::endl;

+ 1 - 4
test/cases/test-dns64.cc

@@ -46,12 +46,9 @@ TEST_F(DNS64, no_dualstack)
 
 	server.Start(R"""(bind [::]:60053
 server 127.0.0.1:61053
-log-num 0
 dns64 64:ff9b::/96
-log-console yes
 dualstack-ip-selection no
-log-level debug
-cache-persist no)""");
+)""");
 	smartdns::Client client;
 	ASSERT_TRUE(client.Query("a.com AAAA", 60053));
 	std::cout << client.GetResult() << std::endl;

+ 1 - 4
test/cases/test-domain-rule.cc

@@ -54,10 +54,7 @@ TEST_F(DomainRule, bogus_nxdomain)
 	server.Start(R"""(bind [::]:60053
 server udp://127.0.0.1:61053 -blacklist-ip
 bogus-nxdomain 10.0.0.0/8
-log-num 0
-log-console yes
-log-level debug
-cache-persist no)""");
+)""");
 	smartdns::Client client;
 	ASSERT_TRUE(client.Query("a.com", 60053));
 	std::cout << client.GetResult() << std::endl;

+ 0 - 4
test/cases/test-domain-set.cc

@@ -41,10 +41,6 @@ TEST_F(DomainSet, set_add)
 	std::string config = "domain-set -name test-set -file " + file_set.GetPath() + "\n";
 	config += R"""(bind [::]:60053
 server 127.0.0.1:61053
-log-num 0
-log-console yes
-log-level info
-cache-persist no
 domain-rules /domain-set:test-set/ -c none --dualstack-ip-selection no -a 9.9.9.9
 )""";
 

+ 5 - 20
test/cases/test-dualstack.cc

@@ -56,11 +56,8 @@ TEST_F(DualStack, ipv4_prefer)
 
 	server.Start(R"""(bind [::]:60053
 server 127.0.0.1:61053
-log-num 0
-log-console yes
 speed-check-mode ping
-log-level debug
-cache-persist no)""");
+)""");
 	smartdns::Client client;
 	ASSERT_TRUE(client.Query("a.com AAAA", 60053));
 	std::cout << client.GetResult() << std::endl;
@@ -107,12 +104,9 @@ TEST_F(DualStack, ipv6_prefer_allow_force_AAAA)
 
 	server.Start(R"""(bind [::]:60053
 server 127.0.0.1:61053
-log-num 0
-log-console yes
 speed-check-mode ping
 dualstack-ip-allow-force-AAAA yes
-log-level debug
-cache-persist no)""");
+)""");
 	smartdns::Client client;
 	ASSERT_TRUE(client.Query("a.com A", 60053));
 	std::cout << client.GetResult() << std::endl;
@@ -159,12 +153,9 @@ TEST_F(DualStack, ipv6_prefer_without_ipv4)
 
 	server.Start(R"""(bind [::]:60053
 server 127.0.0.1:61053
-log-num 0
-log-console yes
 speed-check-mode ping
 dualstack-ip-allow-force-AAAA yes
-log-level debug
-cache-persist no)""");
+)""");
 	smartdns::Client client;
 	ASSERT_TRUE(client.Query("a.com A", 60053));
 	std::cout << client.GetResult() << std::endl;
@@ -210,11 +201,8 @@ TEST_F(DualStack, ipv6_no_speed)
 
 	server.Start(R"""(bind [::]:60053
 server 127.0.0.1:61053
-log-num 0
-log-console yes
 speed-check-mode ping
-log-level debug
-cache-persist no)""");
+)""");
 	smartdns::Client client;
 	ASSERT_TRUE(client.Query("a.com A", 60053));
 	std::cout << client.GetResult() << std::endl;
@@ -259,12 +247,9 @@ TEST_F(DualStack, ipv4_no_response)
 
 	server.Start(R"""(bind [::]:60053
 server 127.0.0.1:61053
-log-num 0
-log-console yes
 dualstack-ip-selection yes
 speed-check-mode ping
-log-level debug
-cache-persist no)""");
+)""");
 	smartdns::Client client;
 	ASSERT_TRUE(client.Query("a.com A", 60053));
 	std::cout << client.GetResult() << std::endl;

+ 1 - 4
test/cases/test-idna.cc

@@ -49,13 +49,10 @@ TEST_F(IDNA, match)
 
 	server.Start(R"""(bind [::]:60053
 server 127.0.0.1:61053
-log-num 0
-log-console yes
-log-level debug
 speed-check-mode none
 address /中国.com/10.10.10.10
 address /中国.com/64:ff9b::1010:1010
-cache-persist no)""");
+)""");
 	smartdns::Client client;
 	ASSERT_TRUE(client.Query("xn--fiqs8s.com A", 60053));
 	std::cout << client.GetResult() << std::endl;

+ 4 - 16
test/cases/test-ip-alias.cc

@@ -74,14 +74,11 @@ TEST(IPAlias, map_multiip_nospeed_check)
 
 	server.Start(R"""(bind [::]:60053
 server 127.0.0.1:61053
-log-num 0
-log-console yes
-log-level debug
 dualstack-ip-selection no
 speed-check-mode none
 ip-alias 1.2.3.0/24 10.10.10.10,12.12.12.12,13.13.13.13,15.15.15.15
 ip-alias 0102::/16 FFFF::0001,FFFF::0002,FFFF::0003,FFFF::0004
-cache-persist no)""");
+)""");
 	smartdns::Client client;
 	ASSERT_TRUE(client.Query("a.com", 60053));
 	std::cout << client.GetResult() << std::endl;
@@ -148,16 +145,13 @@ TEST(IPAlias, map_single_ip_nospeed_check)
 
 	server.Start(R"""(bind [::]:60053
 server 127.0.0.1:61053
-log-num 0
-log-console yes
-log-level debug
 dualstack-ip-selection no
 speed-check-mode none
 ip-alias 1.2.3.4 10.10.10.10
 ip-alias 5.6.7.8/32 11.11.11.11
 ip-alias 0102:0304:0500:: ffff::1
 ip-alias 0506:0708:0900:: ffff::2
-cache-persist no)""");
+)""");
 	smartdns::Client client;
 	ASSERT_TRUE(client.Query("a.com", 60053));
 	std::cout << client.GetResult() << std::endl;
@@ -222,15 +216,12 @@ TEST(IPAlias, mapip_withspeed_check)
 
 	server.Start(R"""(bind [::]:60053
 server 127.0.0.1:61053
-log-num 0
-log-console yes
-log-level debug
 dualstack-ip-selection no
 ip-alias 1.2.3.4 10.10.10.10
 ip-alias 5.6.7.8/32 11.11.11.11
 ip-alias 0102::/16 ffff::1
 ip-alias 0506::/16 ffff::2
-cache-persist no)""");
+)""");
 	smartdns::Client client;
 	ASSERT_TRUE(client.Query("a.com", 60053));
 	std::cout << client.GetResult() << std::endl;
@@ -291,16 +282,13 @@ TEST(IPAlias, no_ip_alias)
 
 	server.Start(R"""(bind [::]:60053
 server 127.0.0.1:61053
-log-num 0
-log-console yes
-log-level debug
 dualstack-ip-selection no
 ip-alias 1.2.3.4 10.10.10.10
 ip-alias 5.6.7.8/32 11.11.11.11
 ip-alias 0102::/16 ffff::1
 ip-alias 0506::/16 ffff::2
 domain-rules /a.com/ -no-ip-alias
-cache-persist no)""");
+)""");
 	smartdns::Client client;
 	ASSERT_TRUE(client.Query("a.com", 60053));
 	std::cout << client.GetResult() << std::endl;

+ 6 - 24
test/cases/test-ip-rule.cc

@@ -60,10 +60,7 @@ TEST_F(IPRule, white_list)
 server udp://127.0.0.1:61053 -whitelist-ip
 server udp://127.0.0.1:62053 -whitelist-ip
 whitelist-ip 4.5.6.7/24
-log-num 0
-log-console yes
-log-level debug
-cache-persist no)""");
+)""");
 	smartdns::Client client;
 	ASSERT_TRUE(client.Query("a.com", 60053));
 	std::cout << client.GetResult() << std::endl;
@@ -104,10 +101,7 @@ TEST_F(IPRule, white_list_not_in)
 server udp://127.0.0.1:61053 -whitelist-ip
 server udp://127.0.0.1:62053 -whitelist-ip
 whitelist-ip 4.5.6.7/24
-log-num 0
-log-console yes
-log-level debug
-cache-persist no)""");
+)""");
 	smartdns::Client client;
 	ASSERT_TRUE(client.Query("a.com", 60053));
 	std::cout << client.GetResult() << std::endl;
@@ -146,10 +140,7 @@ TEST_F(IPRule, black_list)
 server udp://127.0.0.1:61053 -blacklist-ip
 server udp://127.0.0.1:62053 -blacklist-ip
 blacklist-ip 4.5.6.7/24
-log-num 0
-log-console yes
-log-level debug
-cache-persist no)""");
+)""");
 	smartdns::Client client;
 	ASSERT_TRUE(client.Query("a.com", 60053));
 	std::cout << client.GetResult() << std::endl;
@@ -184,10 +175,7 @@ TEST_F(IPRule, ignore_ip)
 	server.Start(R"""(bind [::]:60053
 server udp://127.0.0.1:61053 -blacklist-ip
 ignore-ip 1.2.3.0/24
-log-num 0
-log-console yes
-log-level debug
-cache-persist no)""");
+)""");
 	smartdns::Client client;
 	ASSERT_TRUE(client.Query("a.com", 60053));
 	std::cout << client.GetResult() << std::endl;
@@ -239,11 +227,8 @@ server udp://127.0.0.1:61053 -blacklist-ip
 ip-set -name ip-list -file )""" +
 				 file + R"""(
 ignore-ip ip-set:ip-list
-log-num 0
 speed-check-mode none
-log-console yes
-log-level debug
-cache-persist no)""");
+)""");
 	smartdns::Client client;
 	ASSERT_TRUE(client.Query("a.com", 60053));
 	std::cout << client.GetResult() << std::endl;
@@ -308,11 +293,8 @@ ip-set -name ip-list -file )""" +
 ip-set -name ip-list-ip -file )""" +
 				 file_ip + R"""(
 ip-alias ip-set:ip-list ip-set:ip-list-ip
-log-num 0
 speed-check-mode none
-log-console yes
-log-level debug
-cache-persist no)""");
+)""");
 	smartdns::Client client;
 	ASSERT_TRUE(client.Query("a.com", 60053));
 	std::cout << client.GetResult() << std::endl;

+ 1 - 4
test/cases/test-nameserver.cc

@@ -69,10 +69,7 @@ server 127.0.0.1:62053 -group g1 -exclude-default-group
 server 127.0.0.1:63053 -group g2 -exclude-default-group
 nameserver /a.com/g1
 nameserver /b.com/g2
-log-num 0
-log-console yes
-log-level debug
-cache-persist no)""");
+)""");
 	smartdns::Client client;
 	ASSERT_TRUE(client.Query("a.com", 60053));
 	std::cout << client.GetResult() << std::endl;

+ 1 - 3
test/cases/test-perf.cc

@@ -61,11 +61,9 @@ TEST_F(Perf, no_speed_check)
 
 	server.Start(R"""(bind [::]:60053
 server 127.0.0.1:61053
-log-num 0
-log-console yes
 speed-check-mode none
 log-level error
-cache-persist no)""");
+)""");
 	std::string file = "/tmp/smartdns-perftest-domain.list" + smartdns::GenerateRandomString(5);
 	std::string cmd = "dnsperf -p 60053";
 	cmd += " -d ";

+ 3 - 12
test/cases/test-ptr.cc

@@ -53,11 +53,8 @@ TEST_F(Ptr, query)
 
 	server.Start(R"""(bind [::]:60053
 server 127.0.0.1:61053
-log-num 0
-log-console yes
 dualstack-ip-selection no
-log-level debug
-cache-persist no)""");
+)""");
 	smartdns::Client client;
 	ASSERT_TRUE(client.Query("4.3.2.1.in-addr.arpa PTR", 60053));
 	std::cout << client.GetResult() << std::endl;
@@ -87,14 +84,11 @@ TEST_F(Ptr, address_expand_ptr)
 
 	server.Start(R"""(bind [::]:60053
 server 127.0.0.1:61053
-log-num 0
-log-console yes
-log-level debug
 speed-check-mode none
 expand-ptr-from-address yes
 address /a.com/10.11.12.13
 address /a.com/64:ff9b::1010:1010
-cache-persist no)""");
+)""");
 	smartdns::Client client;
 	ASSERT_TRUE(client.Query("13.12.11.10.in-addr.arpa PTR", 60053));
 	std::cout << client.GetResult() << std::endl;
@@ -139,11 +133,8 @@ TEST_F(Ptr, smartdns)
 	server.Start(R"""(bind [::]:60053
 server 127.0.0.1:61053
 server-name my-server
-log-num 0
-log-console yes
 dualstack-ip-selection no
-log-level debug
-cache-persist no)""");
+)""");
 	smartdns::Client client;
 	ASSERT_TRUE(client.Query("1.0.0.127.in-addr.arpa PTR", 60053));
 	std::cout << client.GetResult() << std::endl;

+ 5 - 20
test/cases/test-qtype-soa.cc

@@ -49,11 +49,8 @@ TEST_F(QtypeSOA, AAAA_HTTPS)
 
 	server.Start(R"""(bind [::]:60053
 server 127.0.0.1:61053
-log-num 0
-log-console yes
-log-level debug
 force-qtype-SOA 28,65
-cache-persist no)""");
+)""");
 	smartdns::Client client;
 	ASSERT_TRUE(client.Query("a.com AAAA", 60053));
 	std::cout << client.GetResult() << std::endl;
@@ -95,13 +92,10 @@ TEST_F(QtypeSOA, AAAA_Except)
 
 	server.Start(R"""(bind [::]:60053
 server 127.0.0.1:61053
-log-num 0
-log-console yes
-log-level debug
 dualstack-ip-selection no
 force-qtype-SOA 28
 address /a.com/-
-cache-persist no)""");
+)""");
 	smartdns::Client client;
 
 	ASSERT_TRUE(client.Query("a.com AAAA", 60053));
@@ -132,13 +126,10 @@ TEST_F(QtypeSOA, force_AAAA_SOA_Except)
 
 	server.Start(R"""(bind [::]:60053
 server 127.0.0.1:61053
-log-num 0
-log-console yes
-log-level debug
 dualstack-ip-selection no
 force-AAAA-SOA yes
 address /a.com/-
-cache-persist no)""");
+)""");
 	smartdns::Client client;
 
 	ASSERT_TRUE(client.Query("a.com AAAA", 60053));
@@ -169,12 +160,9 @@ TEST_F(QtypeSOA, force_AAAA_SOA)
 
 	server.Start(R"""(bind [::]:60053
 server 127.0.0.1:61053
-log-num 0
-log-console yes
-log-level debug
 speed-check-mode none
 force-AAAA-SOA yes
-cache-persist no)""");
+)""");
 	smartdns::Client client;
 	ASSERT_TRUE(client.Query("a.com A", 60053));
 	std::cout << client.GetResult() << std::endl;
@@ -214,11 +202,8 @@ TEST_F(QtypeSOA, bind_force_AAAA_SOA)
 bind [::]:60053
 bind [::]:60153 -force-aaaa-soa
 server 127.0.0.1:61053
-log-num 0
-log-console yes
-log-level debug
 speed-check-mode none
-cache-persist no)""");
+)""");
 	smartdns::Client client;
 	ASSERT_TRUE(client.Query("a.com A", 60053));
 	std::cout << client.GetResult() << std::endl;

+ 5 - 20
test/cases/test-rule.cc

@@ -49,12 +49,9 @@ TEST_F(Rule, Match)
 
 	server.Start(R"""(bind [::]:60053
 server 127.0.0.1:61053
-log-num 0
-log-console yes
-log-level debug
 speed-check-mode none
 address /a.com/5.6.7.8
-cache-persist no)""");
+)""");
 	smartdns::Client client;
 	ASSERT_TRUE(client.Query("a.com A", 60053));
 	std::cout << client.GetResult() << std::endl;
@@ -102,12 +99,9 @@ TEST_F(Rule, PrefixWildcardMatch)
 
 	server.Start(R"""(bind [::]:60053
 server 127.0.0.1:61053
-log-num 0
-log-console yes
-log-level debug
 speed-check-mode none
 address /*a.com/5.6.7.8
-cache-persist no)""");
+)""");
 	smartdns::Client client;
 	ASSERT_TRUE(client.Query("a.com A", 60053));
 	std::cout << client.GetResult() << std::endl;
@@ -164,12 +158,9 @@ TEST_F(Rule, SubDomainMatchOnly)
 
 	server.Start(R"""(bind [::]:60053
 server 127.0.0.1:61053
-log-num 0
-log-console yes
-log-level debug
 speed-check-mode none
 address /*.a.com/5.6.7.8
-cache-persist no)""");
+)""");
 	smartdns::Client client;
 	ASSERT_TRUE(client.Query("a.com A", 60053));
 	std::cout << client.GetResult() << std::endl;
@@ -217,12 +208,9 @@ TEST_F(Rule, RootDomainMatchOnly)
 
 	server.Start(R"""(bind [::]:60053
 server 127.0.0.1:61053
-log-num 0
-log-console yes
-log-level debug
 speed-check-mode none
 address /-.a.com/5.6.7.8
-cache-persist no)""");
+)""");
 	smartdns::Client client;
 	ASSERT_TRUE(client.Query("a.com A", 60053));
 	std::cout << client.GetResult() << std::endl;
@@ -279,13 +267,10 @@ TEST_F(Rule, AAAA_SOA)
 
 	server.Start(R"""(bind [::]:60053
 server 127.0.0.1:61053
-log-num 0
-log-console yes
-log-level debug
 speed-check-mode none
 address /-.a.com/#6
 address /*.b.com/#6
-cache-persist no)""");
+)""");
 	smartdns::Client client;
 	ASSERT_TRUE(client.Query("a.com AAAA", 60053));
 	std::cout << client.GetResult() << std::endl;

+ 1 - 3
test/cases/test-same-pending-query.cc

@@ -68,11 +68,9 @@ TEST_F(SamePending, pending)
 	server.Start(R"""(bind [::]:60053
 server 127.0.0.1:61053
 cache-size 0
-log-num 0
-log-console yes
 speed-check-mode none
 log-level error
-cache-persist no)""");
+)""");
 
 	std::vector<std::thread> threads;
 	uint64_t tick = get_tick_count();

+ 5 - 17
test/cases/test-server.cc

@@ -50,10 +50,7 @@ bind-tcp [::]:60053
 server tls://255.255.255.255
 server https://255.255.255.255
 server tcp://255.255.255.255
-log-num 0
-log-console yes
-log-level debug
-cache-persist no)""");
+)""");
 	smartdns::Client client;
 	ASSERT_TRUE(client.Query("a.com", 60053));
 	std::cout << client.GetResult() << std::endl;
@@ -92,10 +89,7 @@ TEST_F(Server, one_nxdomain)
 bind-tcp [::]:60053
 server 127.0.0.1:61053
 server 127.0.0.1:62053
-log-num 0
-log-console yes
-log-level debug
-cache-persist no)""");
+)""");
 	smartdns::Client client;
 	ASSERT_TRUE(client.Query("a.com", 60053));
 	std::cout << client.GetResult() << std::endl;
@@ -129,11 +123,8 @@ TEST_F(Server, retry_no_result_with_NOERROR)
 	server.Start(R"""(bind [::]:60053
 bind-tcp [::]:60053
 server 127.0.0.1:61053
-log-num 0
-log-console yes
 dualstack-ip-selection no
-log-level debug
-cache-persist no)""");
+)""");
 	smartdns::Client client;
 	ASSERT_TRUE(client.Query("a.com", 60053));
 	std::cout << client.GetResult() << std::endl;
@@ -158,15 +149,12 @@ TEST_F(Server, retry_no_response)
 	server.Start(R"""(bind [::]:60053
 bind-tcp [::]:60053
 server 127.0.0.1:61053
-log-num 0
-log-console yes
-log-level debug
-cache-persist no)""");
+)""");
 	smartdns::Client client;
 	ASSERT_TRUE(client.Query("a.com", 60053));
 	std::cout << client.GetResult() << std::endl;
 	ASSERT_EQ(client.GetAnswerNum(), 0);
 	EXPECT_EQ(client.GetStatus(), "SERVFAIL");
 	EXPECT_GE(client.GetQueryTime(), 1500);
-	EXPECT_GE(count, 8);
+	EXPECT_GE(count, 4);
 }

+ 9 - 36
test/cases/test-speed-check.cc

@@ -47,12 +47,9 @@ TEST_F(SpeedCheck, response_mode)
 
 	server.Start(R"""(bind [::]:60053
 server 127.0.0.1:61053
-log-num 0
-log-console yes
 response-mode first-ping
 domain-rules /a.com/ -r fastest-response
-log-level debug
-cache-persist no)""");
+)""");
 	smartdns::Client client;
 	ASSERT_TRUE(client.Query("b.com", 60053));
 	std::cout << client.GetResult() << std::endl;
@@ -89,11 +86,8 @@ TEST_F(SpeedCheck, none)
 
 	server.Start(R"""(bind [::]:60053
 server 127.0.0.1:61053
-log-num 0
-log-console yes
 speed-check-mode none
-log-level debug
-cache-persist no)""");
+)""");
 	smartdns::Client client;
 	ASSERT_TRUE(client.Query("b.com", 60053));
 	std::cout << client.GetResult() << std::endl;
@@ -130,11 +124,8 @@ TEST_F(SpeedCheck, domain_rules_none)
 
 	server.Start(R"""(bind [::]:60053
 server 127.0.0.1:61053
-log-num 0
-log-console yes
 domain-rules /a.com/ -c none
-log-level debug
-cache-persist no)""");
+)""");
 	smartdns::Client client;
 	ASSERT_TRUE(client.Query("b.com", 60053));
 	std::cout << client.GetResult() << std::endl;
@@ -171,11 +162,8 @@ TEST_F(SpeedCheck, only_ping)
 
 	server.Start(R"""(bind [::]:60053
 server 127.0.0.1:61053
-log-num 0
-log-console yes
 speed-check-mode ping
-log-level debug
-cache-persist no)""");
+)""");
 	smartdns::Client client;
 	ASSERT_TRUE(client.Query("b.com", 60053));
 	std::cout << client.GetResult() << std::endl;
@@ -204,11 +192,8 @@ TEST_F(SpeedCheck, no_ping_fallback_tcp)
 	server.MockPing(PING_TYPE_TCP, "5.6.7.8:80", 60, 100);
 	server.Start(R"""(bind [::]:60053
 server 127.0.0.1:61053
-log-num 0
-log-console yes
 speed-check-mode ping,tcp:80
-log-level debug
-cache-persist no)""");
+)""");
 	smartdns::Client client;
 	ASSERT_TRUE(client.Query("a.com", 60053));
 	std::cout << client.GetResult() << std::endl;
@@ -238,11 +223,8 @@ TEST_F(SpeedCheck, tcp_faster_than_ping)
 	server.MockPing(PING_TYPE_TCP, "5.6.7.8:80", 60, 10);
 	server.Start(R"""(bind [::]:60053
 server 127.0.0.1:61053
-log-num 0
-log-console yes
 speed-check-mode ping,tcp:80
-log-level debug
-cache-persist no)""");
+)""");
 	smartdns::Client client;
 	ASSERT_TRUE(client.Query("a.com", 60053));
 	std::cout << client.GetResult() << std::endl;
@@ -273,12 +255,9 @@ TEST_F(SpeedCheck, fastest_ip)
 
 	server.Start(R"""(bind [::]:60053
 server 127.0.0.1:61053
-log-num 0
-log-console yes
 speed-check-mode ping
 dualstack-ip-selection no
-log-level debug
-cache-persist no)""");
+)""");
 	smartdns::Client client;
 	ASSERT_TRUE(client.Query("b.com", 60053));
 	std::cout << client.GetResult() << std::endl;
@@ -332,12 +311,9 @@ TEST_F(SpeedCheck, unreach_best_ipv4)
 	server.Start(R"""(bind [::]:60053
 server 127.0.0.1:61053
 server 127.0.0.1:62053
-log-num 0
-log-console yes
 speed-check-mode ping
 dualstack-ip-selection no
-log-level debug
-cache-persist no)""");
+)""");
 	smartdns::Client client;
 	ASSERT_TRUE(client.Query("a.com", 60053));
 	std::cout << client.GetResult() << std::endl;
@@ -380,12 +356,9 @@ TEST_F(SpeedCheck, unreach_best_ipv6)
 	server.Start(R"""(bind [::]:60053
 server 127.0.0.1:61053
 server 127.0.0.1:62053
-log-num 0
-log-console yes
 speed-check-mode ping
 dualstack-ip-selection no
-log-level debug
-cache-persist no)""");
+)""");
 	smartdns::Client client;
 	ASSERT_TRUE(client.Query("a.com AAAA", 60053));
 	std::cout << client.GetResult() << std::endl;

+ 2 - 8
test/cases/test-srv.cc

@@ -50,11 +50,8 @@ TEST_F(SRV, query)
 
 	server.Start(R"""(bind [::]:60053
 server 127.0.0.1:61053
-log-num 0
-log-console yes
-log-level debug
 speed-check-mode none
-cache-persist no)""");
+)""");
 	smartdns::Client client;
 	ASSERT_TRUE(client.Query("_ldap._tcp.local.com SRV", 60053));
 	std::cout << client.GetResult() << std::endl;
@@ -85,14 +82,11 @@ TEST_F(SRV, match)
 
 	server.Start(R"""(bind [::]:60053
 server 127.0.0.1:61053
-log-num 0
-log-console yes
-log-level debug
 srv-record /_ldap._tcp.local.com/www.a.com,443,1,1
 srv-record /_ldap._tcp.local.com/www1.a.com,443,1,1
 srv-record /_ldap._tcp.local.com/www2.a.com,443,1,1
 speed-check-mode none
-cache-persist no)""");
+)""");
 	smartdns::Client client;
 	ASSERT_TRUE(client.Query("_ldap._tcp.local.com SRV", 60053));
 	std::cout << client.GetResult() << std::endl;

+ 6 - 24
test/cases/test-subnet.cc

@@ -85,11 +85,8 @@ TEST_F(SubNet, pass_subnet)
 
 	server.Start(R"""(bind [::]:60053
 server 127.0.0.1:61053
-log-num 0
-log-console yes
 dualstack-ip-selection no
-log-level debug
-cache-persist no)""");
+)""");
 	smartdns::Client client;
 	ASSERT_TRUE(client.Query("a.com A +subnet=8.8.8.8/24", 60053));
 	std::cout << client.GetResult() << std::endl;
@@ -155,12 +152,9 @@ TEST_F(SubNet, conf)
 
 	server.Start(R"""(bind [::]:60053
 server 127.0.0.1:61053
-log-num 0
-log-console yes
 dualstack-ip-selection no
 edns-client-subnet 8.8.8.8/24
-log-level debug
-cache-persist no)""");
+)""");
 	smartdns::Client client;
 	ASSERT_TRUE(client.Query("a.com A", 60053));
 	std::cout << client.GetResult() << std::endl;
@@ -228,12 +222,9 @@ TEST_F(SubNet, conf_v6)
 
 	server.Start(R"""(bind [::]:60053
 server 127.0.0.1:61053
-log-num 0
-log-console yes
 dualstack-ip-selection no
 edns-client-subnet ffff:ffff:ffff:ffff:ffff::/64
-log-level debug
-cache-persist no)""");
+)""");
 	smartdns::Client client;
 	ASSERT_TRUE(client.Query("a.com AAAA", 60053));
 	std::cout << client.GetResult() << std::endl;
@@ -299,12 +290,9 @@ TEST_F(SubNet, v4_server_subnet_txt)
 
 	server.Start(R"""(bind [::]:60053
 server 127.0.0.1:61053 -subnet 8.8.8.8/24
-log-num 0
-log-console yes
 dualstack-ip-selection no
-log-level debug
 rr-ttl-min 0
-cache-persist no)""");
+)""");
 	smartdns::Client client;
 	ASSERT_TRUE(client.Query("a.com TXT", 60053));
 	std::cout << client.GetResult() << std::endl;
@@ -369,13 +357,10 @@ TEST_F(SubNet, v6_default_subnet_txt)
 
 	server.Start(R"""(bind [::]:60053
 server 127.0.0.1:61053
-log-num 0
-log-console yes
 dualstack-ip-selection no
 rr-ttl-min 0
 edns-client-subnet ffff:ffff:ffff:ffff:ffff::/64
-log-level debug
-cache-persist no)""");
+)""");
 	smartdns::Client client;
 	ASSERT_TRUE(client.Query("a.com TXT", 60053));
 	std::cout << client.GetResult() << std::endl;
@@ -563,11 +548,8 @@ TEST_F(SubNet, per_server)
 	server.Start(R"""(bind [::]:60053
 server 127.0.0.1:62053 -subnet=8.8.8.8/24 -subnet=ffff:ffff:ffff:ffff:ffff::/64
 server 127.0.0.1:61053
-log-num 0
-log-console yes
 dualstack-ip-selection no
-log-level debug
-cache-persist no)""");
+)""");
 	smartdns::Client client;
 	ASSERT_TRUE(client.Query("a.com A", 60053));
 	std::cout << client.GetResult() << std::endl;

+ 8 - 0
test/server.cc

@@ -346,8 +346,16 @@ bool Server::Start(const std::string &conf, enum CONF_TYPE type)
 		}
 	};
 
+	const char *default_conf = R"""(
+log-num 0
+log-console yes
+log-level debug
+cache-persist no
+)""";
+
 	if (type == CONF_TYPE_STRING) {
 		conf_temp_file_.SetPattern("/tmp/smartdns_conf.XXXXXX");
+		conf_temp_file_.Write(default_conf);
 		conf_temp_file_.Write(conf);
 		conf_file = conf_temp_file_.GetPath();
 	} else if (type == CONF_TYPE_FILE) {