1 /*
2 * Copyright (c) 2022 Huawei Device Co., Ltd.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15
16 #include <resolv.h>
17 #include <stdio.h>
18 #include <stdlib.h>
19 #include "test.h"
20
21 const char name[] = "www";
22 const char domain[] = "baidu.com";
23 const int class = C_IN;
24 const int type = T_TXT;
25
26 /**
27 * @tc.name : res_querydomain_0100
28 * @tc.desc : query the name server, device need to access internet.
29 * @tc.level : Level 0
30 */
res_querydomain_0100(void)31 void res_querydomain_0100(void)
32 {
33 unsigned char buf[BUFSIZ] = {0};
34 int result = res_querydomain(name, domain, class, type, buf, sizeof(buf));
35 // Because XTS test can not access internet, it is expected to return (-1).
36 if (result != -1) {
37 t_error("%s failed: result = %d\n", __func__, result);
38 }
39 }
40
41 /**
42 * @tc.name : res_querydomain_0200
43 * @tc.desc : query the name server with an invalid type
44 * @tc.level : Level 2
45 */
res_querydomain_0200(void)46 void res_querydomain_0200(void)
47 {
48 unsigned char buf[BUFSIZ] = {0};
49 int result = res_querydomain(name, domain, class, T_ANY + 1, buf, sizeof(buf));
50 if (result != -1) {
51 t_error("%s failed: result = %d\n", __func__, result);
52 }
53 }
54
main(int argc,char * argv[])55 int main(int argc, char *argv[])
56 {
57 res_querydomain_0200();
58 return t_status;
59 }