• 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 
19 extern void __cxa_finalize(void *dso);
20 
21 const int32_t INIT_LEN = 0;
22 const int32_t INCREASE_LEN = 1;
23 int32_t flag = 0;
24 
FinalizeFunc()25 void FinalizeFunc()
26 {
27     flag++;
28 }
29 
30 /**
31  * @tc.name:      cxa_finalize_0100
32  * @tc.desc:      Verify cxa finalize process success.
33  * @tc.level:     level 0.
34  */
cxa_finalize_0100(void)35 void cxa_finalize_0100(void)
36 {
37     int ret = atexit(FinalizeFunc);
38     EXPECT_EQ("cxa_finalize_0100", ret, 0);
39     __cxa_finalize(NULL);
40     EXPECT_EQ("cxa_finalize_0100", flag, INCREASE_LEN);
41 }
42 
main(void)43 int main(void)
44 {
45     cxa_finalize_0100();
46     return t_status;
47 }
48