1 /*
2  * Copyright (C) 2018 Samsung Electronics Co., Ltd.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 #include <memory>
18 #include <sys/mman.h>
19 
20 #include <gtest/gtest.h>
21 
22 #include <hardware/exynos/ion.h>
23 #include "ion_test_fixture.h"
24 
25 class ExynosApiTest : public IonAllHeapsTest {
26 };
27 
TEST_F(ExynosApiTest,ApiTest)28 TEST_F(ExynosApiTest, ApiTest)
29 {
30     static const size_t allocationSizes[] = {4*1024, 64*1024, 1024*1024, 2*1024*1024};
31     static const unsigned int exynosHeaps[] = {
32         EXYNOS_ION_HEAP_SYSTEM_MASK,
33         EXYNOS_ION_HEAP_CRYPTO_MASK,
34         EXYNOS_ION_HEAP_VIDEO_STREAM_MASK,
35         EXYNOS_ION_HEAP_CAMERA,
36     };
37 
38     for (unsigned int heapMask : exynosHeaps) {
39         for (size_t size : allocationSizes) {
40             SCOPED_TRACE(::testing::Message() << "heap " << heapMask);
41             SCOPED_TRACE(::testing::Message() << "size " << size);
42             int map_fd = -1;
43             ASSERT_EQ(0, exynos_ion_alloc(m_ionFd, size, heapMask, 0, &map_fd));
44             ASSERT_GE(map_fd, 0);
45             ASSERT_EQ(0, close(map_fd));
46         }
47     }
48 }
49