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