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/membarrier.h>
17 #include "functionalext.h"
18
19 /**
20 * @tc.name : membarrier_0100
21 * @tc.desc : Verify memory masking
22 * (all parameters are valid, CMD is not equal to MEMBARRIER_CMD_PRIVATE_EXPEDITED)
23 * @tc.level : Level 0
24 */
membarrier_0100(void)25 void membarrier_0100(void)
26 {
27 int result = membarrier(MEMBARRIER_CMD_REGISTER_PRIVATE_EXPEDITED, 0);
28 EXPECT_EQ("membarrier_0100", result, 0);
29 }
30
31 /**
32 * @tc.name : membarrier_0200
33 * @tc.desc : Verify memory masking (valid with CMD equal to MEMBARRIER_CMD_PRIVATE_EXPEDITED)
34 * @tc.level : Level 1
35 */
membarrier_0200(void)36 void membarrier_0200(void)
37 {
38 int result = membarrier(MEMBARRIER_CMD_PRIVATE_EXPEDITED, 0);
39 EXPECT_EQ("membarrier_0200", result, 0);
40 }
41
42 /**
43 * @tc.name : membarrier_0300
44 * @tc.desc : Verify that memory masking is not possible (CMD argument is invalid)
45 * @tc.level : Level 2
46 */
membarrier_0300(void)47 void membarrier_0300(void)
48 {
49 int result = membarrier(-1, 0);
50 EXPECT_EQ("membarrier_0300", result, -1);
51 }
52
main(int argc,char * argv[])53 int main(int argc, char *argv[])
54 {
55 membarrier_0100();
56 membarrier_0200();
57 membarrier_0300();
58 return t_status;
59 }