• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 <sys/timex.h>
17 #include "functionalext.h"
18 
19 extern int __adjtimex_time64(struct timex *);
20 
21 const int32_t NUM_NEG = -1;
22 
23 /**
24  * @tc.name      : adjtimex_0100
25  * @tc.desc      : Verify the time to tune the kernel.
26  * @tc.level     : Level 0
27  */
adjtimex_0100(void)28 void adjtimex_0100(void)
29 {
30     struct timex tx;
31     tx.offset = ADJ_OFFSET;
32     tx.tick = ADJ_TICK;
33     tx.maxerror = ADJ_MAXERROR;
34     tx.esterror = ADJ_ESTERROR;
35     tx.constant = ADJ_TIMECONST;
36     tx.freq = ADJ_FREQUENCY;
37     tx.status = ADJ_STATUS;
38     tx.precision = 1;
39     tx.tolerance = 1;
40     tx.ppsfreq = 1;
41     tx.jitter = 1;
42     tx.stabil = 1;
43     tx.jitcnt = 1;
44     tx.calcnt = 1;
45     tx.errcnt = 1;
46     tx.stbcnt = 1;
47     int result = adjtimex(&tx);
48     EXPECT_NE("adjtimex_0100", result, NUM_NEG);
49 }
50 
51 /**
52  * @tc.name      : adjtimex_time64_0100
53  * @tc.desc      : Verify the time to tune the kernel.
54  * @tc.level     : Level 0
55  */
adjtimex_time64_0100(void)56 void adjtimex_time64_0100(void)
57 {
58     struct timex tx;
59     tx.offset = ADJ_OFFSET;
60     tx.tick = ADJ_TICK;
61     tx.maxerror = ADJ_MAXERROR;
62     tx.esterror = ADJ_ESTERROR;
63     tx.constant = ADJ_TIMECONST;
64     tx.freq = ADJ_FREQUENCY;
65     tx.status = ADJ_STATUS;
66     tx.precision = 1;
67     tx.tolerance = 1;
68     tx.ppsfreq = 1;
69     tx.jitter = 1;
70     tx.stabil = 1;
71     tx.jitcnt = 1;
72     tx.calcnt = 1;
73     tx.errcnt = 1;
74     tx.stbcnt = 1;
75     int result = __adjtimex_time64(&tx);
76     EXPECT_NE("adjtimex_time64_0100", result, NUM_NEG);
77 }
78 
main(int argc,char * argv[])79 int main(int argc, char *argv[])
80 {
81     adjtimex_0100();
82     adjtimex_time64_0100();
83 
84     return t_status;
85 }
86