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 dname[] = "www.baidu.com";
22 const int class = C_IN;
23 const int type = T_TXT;
24
25 /**
26 * @tc.name : res_query_0100
27 * @tc.desc : query the name server.
28 * @tc.level : Level 0
29 */
res_query_0100(void)30 void res_query_0100(void)
31 {
32 unsigned char buf[BUFSIZ] = {0};
33 int result = res_query(dname, class, type, buf, sizeof(buf));
34 // Because XTS test can not access internet, it is expected to return (-1).
35 if (result != -1) {
36 t_error("%s failed: result = %d\n", __func__, result);
37 }
38 }
39
40 /**
41 * @tc.name : res_query_0200
42 * @tc.desc : query the name server with an invalid type
43 * @tc.level : Level 2
44 */
res_query_0200(void)45 void res_query_0200(void)
46 {
47 unsigned char buf[BUFSIZ] = {0};
48 int result = res_query(dname, class, T_ANY + 1, buf, sizeof(buf));
49 if (result != -1) {
50 t_error("%s failed: result = %d\n", __func__, result);
51 }
52 }
53
main(int argc,char * argv[])54 int main(int argc, char *argv[])
55 {
56 res_query_0200();
57 return t_status;
58 }
59