1 /* 2 * Copyright (c) 2021 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 #ifndef PARAM_TEST_STUB 16 #define PARAM_TEST_STUB 17 #include <cstdio> 18 #include <cstdlib> 19 #include <cstring> 20 #include <gtest/gtest.h> 21 #include <sys/socket.h> 22 #include <sys/types.h> 23 24 #include "param_manager.h" 25 #include "param_security.h" 26 #include "param_utils.h" 27 #include "securec.h" 28 29 #ifdef __cplusplus 30 #if __cplusplus 31 extern "C" { 32 #endif 33 #endif 34 35 #ifndef PARAM_SUPPORT_SELINUX 36 typedef struct ParameterNode { 37 const char *paraName; 38 const char *paraContext; 39 } ParameterNode; 40 41 typedef struct ParamContextsList { 42 struct ParameterNode info; 43 struct ParamContextsList *next; 44 } ParamContextsList; 45 46 typedef struct SrcInfo { 47 int sockFd; 48 struct ucred uc; 49 } SrcInfo; 50 #endif 51 52 void PrepareInitUnitTestEnv(void); 53 void TestSetSelinuxOps(void); 54 void SetTestPermissionResult(int result); 55 void TestSetParamCheckResult(const char *prefix, uint16_t mode, int result); 56 int TestCheckParamPermission(const ParamSecurityLabel *srcLabel, const char *name, uint32_t mode); 57 int TestFreeLocalSecurityLabel(ParamSecurityLabel *srcLabel); 58 59 #ifdef __cplusplus 60 #if __cplusplus 61 } 62 #endif 63 #endif 64 #endif // PARAM_TEST_STUB_