1 /** 2 * Copyright (c) 2024 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 #ifndef GWP_ASAN_TEST_H 17 #define GWP_ASAN_TEST_H 18 19 #include <stdbool.h> 20 #include <stdio.h> 21 #include <stdlib.h> 22 #include "gwp_asan.h" 23 config_gwp_asan_environment(bool logPath)24void config_gwp_asan_environment(bool logPath) 25 { 26 system("param set gwp_asan.sample.all true"); 27 28 // If gwp_asan is inited by __dls3, 29 // it just samples some allocations randomly, 30 // the test may not be able to trigger the error, 31 // so just skip the test. 32 if (!may_init_gwp_asan(true)) { 33 system("param set gwp_asan.sample.all false"); 34 printf("Skip gwp_asan test because it may be inited by __dls3 randomly, just rerun the test.\n"); 35 exit(0); 36 } 37 38 if (logPath) { 39 system("param set gwp_asan.log.path file"); 40 } 41 } 42 cancel_gwp_asan_environment(bool logPath)43void cancel_gwp_asan_environment(bool logPath) 44 { 45 if (logPath) { 46 system("param set gwp_asan.log.path default"); 47 } 48 system("param set gwp_asan.sample.all false"); 49 } 50 51 #endif