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 <syslog.h>
17
18 #include "test.h"
19
20 const int maskpri = LOG_UPTO(LOG_WARNING);
21
22 /**
23 * @tc.name : setlogmask_0100
24 * @tc.desc : set log priority mask
25 * @tc.level : Level 0
26 */
setlogmask_0100(void)27 void setlogmask_0100(void)
28 {
29 int result = setlogmask(maskpri);
30
31 result = setlogmask(result);
32
33 if (result != maskpri) {
34 t_error("%s failed: result = %d\n", __func__, result);
35 }
36 }
37
38 /**
39 * @tc.name : setlogmask_0200
40 * @tc.desc : set log an invalid priority mask
41 * @tc.level : Level 2
42 */
setlogmask_0200(void)43 void setlogmask_0200(void)
44 {
45 int result = setlogmask(0);
46
47 if (result != setlogmask(result)) {
48 t_error("%s failed: result = %d\n", __func__, result);
49 }
50 }
51
main(int argc,char * argv[])52 int main(int argc, char *argv[])
53 {
54 setlogmask_0100();
55 setlogmask_0200();
56
57 return t_status;
58 }
59