• 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 <stdlib.h>
17 #include "functionalext.h"
18 
f1()19 void f1()
20 {}
f2()21 void f2()
22 {}
23 
24 /**
25  * @tc.name      : at_quick_exit_0100
26  * @tc.desc      : Verify that the function pointed to can be registered (the number of registrations
27  *                 is less than 32).
28  * @tc.level     : Level 0
29  */
at_quick_exit_0100(void)30 void at_quick_exit_0100(void)
31 {
32     int result = at_quick_exit(f1);
33     quick_exit(0);
34     EXPECT_EQ("at_quick_exit_0100", result, 0);
35 }
36 
37 /**
38  * @tc.name      : at_quick_exit_0200
39  * @tc.desc      : Verify that the pointed function cannot be registered (the number of registrations
40  *                 is greater than 32).
41  * @tc.level     : Level 2
42  */
at_quick_exit_0200(void)43 void at_quick_exit_0200(void)
44 {
45     int result;
46     for (int i = 0; i < 32; i++) {
47         at_quick_exit(f2);
48     }
49     result = at_quick_exit(f2);
50     quick_exit(0);
51     EXPECT_EQ("at_quick_exit_0200", result, -1);
52 }
53 
main(int argc,char * argv[])54 int main(int argc, char *argv[])
55 {
56     at_quick_exit_0100();
57     at_quick_exit_0200();
58     return t_status;
59 }
60