Marat Dukhan | e5d6049 | 2018-03-08 12:47:27 -0800 | [diff] [blame] | 1 | #include <gtest/gtest.h> |
| 2 | |
| 3 | #include <stdint.h> |
| 4 | #include <string.h> |
| 5 | |
| 6 | #include <string> |
| 7 | |
| 8 | #define CPUINFO_BUILD_PROP_VALUE_MAX 92 |
| 9 | #define CPUINFO_ARM_CHIPSET_NAME_MAX 48 |
| 10 | |
| 11 | extern "C" void cpuinfo_arm_android_parse_ro_arch( |
| 12 | const char arch[CPUINFO_BUILD_PROP_VALUE_MAX], |
| 13 | uint32_t cores, |
| 14 | uint32_t max_cpu_freq_max, |
| 15 | char chipset_name[CPUINFO_ARM_CHIPSET_NAME_MAX]); |
| 16 | |
| 17 | inline std::string parse_ro_arch( |
| 18 | std::string arch, uint32_t cores=1, uint32_t max_cpu_freq_max=0) |
| 19 | { |
| 20 | char arch_buffer[CPUINFO_BUILD_PROP_VALUE_MAX]; |
| 21 | strncpy(arch_buffer, arch.c_str(), CPUINFO_BUILD_PROP_VALUE_MAX); |
| 22 | char chipset_name[CPUINFO_ARM_CHIPSET_NAME_MAX]; |
| 23 | cpuinfo_arm_android_parse_ro_arch( |
| 24 | arch_buffer, cores, max_cpu_freq_max, chipset_name); |
| 25 | return std::string(chipset_name, strnlen(chipset_name, CPUINFO_ARM_CHIPSET_NAME_MAX)); |
| 26 | } |
| 27 | |
| 28 | TEST(RO_ARCH, samsung_exynos) { |
| 29 | EXPECT_EQ("Samsung Exynos 3470", |
| 30 | parse_ro_arch("exynos3470")); |
| 31 | EXPECT_EQ("Samsung Exynos 3475", |
| 32 | parse_ro_arch("exynos3475")); |
| 33 | EXPECT_EQ("Samsung Exynos 4415", |
| 34 | parse_ro_arch("exynos4415")); |
| 35 | EXPECT_EQ("Samsung Exynos 5260", |
| 36 | parse_ro_arch("exynos5260")); |
| 37 | EXPECT_EQ("Samsung Exynos 5410", |
| 38 | parse_ro_arch("exynos5410")); |
| 39 | EXPECT_EQ("Samsung Exynos 5420", |
Marat Dukhan | ab7f949 | 2018-03-08 13:06:40 -0800 | [diff] [blame^] | 40 | parse_ro_arch("exynos5420", 4)); |
Marat Dukhan | e5d6049 | 2018-03-08 12:47:27 -0800 | [diff] [blame] | 41 | EXPECT_EQ("Samsung Exynos 5422", |
| 42 | parse_ro_arch("exynos5422")); |
| 43 | EXPECT_EQ("Samsung Exynos 5430", |
| 44 | parse_ro_arch("exynos5430")); |
| 45 | EXPECT_EQ("Samsung Exynos 5433", |
| 46 | parse_ro_arch("exynos5433")); |
| 47 | EXPECT_EQ("Samsung Exynos 7420", |
| 48 | parse_ro_arch("exynos7420")); |
| 49 | EXPECT_EQ("Samsung Exynos 7570", |
| 50 | parse_ro_arch("exynos7570")); |
| 51 | EXPECT_EQ("Samsung Exynos 7580", |
| 52 | parse_ro_arch("exynos7580", 8)); |
| 53 | EXPECT_EQ("Samsung Exynos 7870", |
| 54 | parse_ro_arch("exynos7870")); |
| 55 | EXPECT_EQ("Samsung Exynos 7872", |
| 56 | parse_ro_arch("exynos7872")); |
| 57 | EXPECT_EQ("Samsung Exynos 7880", |
| 58 | parse_ro_arch("exynos7880")); |
| 59 | EXPECT_EQ("Samsung Exynos 7885", |
| 60 | parse_ro_arch("exynos7885")); |
| 61 | EXPECT_EQ("Samsung Exynos 8890", |
| 62 | parse_ro_arch("exynos8890")); |
| 63 | EXPECT_EQ("Samsung Exynos 8895", |
| 64 | parse_ro_arch("exynos8895")); |
| 65 | EXPECT_EQ("Samsung Exynos 9810", |
| 66 | parse_ro_arch("exynos9810")); |
| 67 | } |