1 /*
2 * Copyright (C) 2014 The Android Open Source Project
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 <gtest/gtest.h>
18
19 #include <fcntl.h> // for loff_t on musl
20 #include <sys/types.h>
21
TEST(sys_types,type_sizes)22 TEST(sys_types, type_sizes) {
23 // gids, pids, and uids should be 32-bit on all systems.
24 ASSERT_EQ(4U, sizeof(gid_t));
25 ASSERT_EQ(4U, sizeof(pid_t));
26 ASSERT_EQ(4U, sizeof(uid_t));
27 // id_t is the 'generic'.
28 ASSERT_EQ(4U, sizeof(id_t));
29
30 // Some types were too small on 32-bit Android by mistake,
31 // but are correct on 64-bit Android.
32 #if defined(__LP64__)
33 ASSERT_EQ(8U, sizeof(dev_t));
34 ASSERT_EQ(8U, sizeof(off_t));
35 ASSERT_EQ(8U, sizeof(time_t));
36 #else
37 ASSERT_EQ(4U, sizeof(dev_t));
38 ASSERT_EQ(4U, sizeof(off_t));
39 ASSERT_EQ(4U, sizeof(time_t));
40 #endif
41 // These were right even on 32-bit Android.
42 ASSERT_EQ(8U, sizeof(loff_t));
43 ASSERT_EQ(8U, sizeof(off64_t));
44 }
45