Rob Barnes | a01ee36 | 2020-09-14 07:46:19 -0600 | [diff] [blame] | 1 | /* SPDX-License-Identifier: GPL-2.0-only */ |
| 2 | |
| 3 | #include <device/dram/ddr4.h> |
| 4 | #include <tests/test.h> |
| 5 | |
| 6 | static void ddr4_speed_mhz_to_mts_test(void **state) |
| 7 | { |
| 8 | assert_int_equal(0, ddr4_speed_mhz_to_reported_mts(0)); |
| 9 | assert_int_equal(0, ddr4_speed_mhz_to_reported_mts(667)); |
| 10 | |
| 11 | assert_int_equal(1600, ddr4_speed_mhz_to_reported_mts(668)); |
| 12 | assert_int_equal(1600, ddr4_speed_mhz_to_reported_mts(800)); |
| 13 | |
| 14 | assert_int_equal(1866, ddr4_speed_mhz_to_reported_mts(801)); |
| 15 | assert_int_equal(1866, ddr4_speed_mhz_to_reported_mts(933)); |
| 16 | assert_int_equal(1866, ddr4_speed_mhz_to_reported_mts(934)); |
| 17 | |
| 18 | assert_int_equal(2133, ddr4_speed_mhz_to_reported_mts(1066)); |
| 19 | assert_int_equal(2133, ddr4_speed_mhz_to_reported_mts(1067)); |
| 20 | |
| 21 | assert_int_equal(2400, ddr4_speed_mhz_to_reported_mts(1200)); |
| 22 | |
| 23 | assert_int_equal(2666, ddr4_speed_mhz_to_reported_mts(1333)); |
| 24 | |
| 25 | assert_int_equal(2933, ddr4_speed_mhz_to_reported_mts(1466)); |
| 26 | |
| 27 | assert_int_equal(3200, ddr4_speed_mhz_to_reported_mts(1467)); |
| 28 | assert_int_equal(3200, ddr4_speed_mhz_to_reported_mts(1600)); |
| 29 | |
| 30 | assert_int_equal(0, ddr4_speed_mhz_to_reported_mts(1601)); |
| 31 | assert_int_equal(0, ddr4_speed_mhz_to_reported_mts(INT16_MAX)); |
| 32 | } |
| 33 | |
| 34 | int main(void) |
| 35 | { |
| 36 | const struct CMUnitTest tests[] = { |
| 37 | cmocka_unit_test(ddr4_speed_mhz_to_mts_test) |
| 38 | }; |
| 39 | |
Jakub Czapiga | 7c6081e | 2021-08-25 16:27:35 +0200 | [diff] [blame] | 40 | return cb_run_group_tests(tests, NULL, NULL); |
Rob Barnes | a01ee36 | 2020-09-14 07:46:19 -0600 | [diff] [blame] | 41 | } |