2 * Copyright (C) ARM Limited 2012-2014. All rights reserved.
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License version 2 as
6 * published by the Free Software Foundation.
11 * Test functions for mali_t600_hw code.
14 static int is_read_scheduled(const struct timespec *current_time, u32 *prev_time_s, s32 *next_read_time_ns);
16 static int test_is_read_scheduled(u32 s, u32 ns, u32 prev_s, s32 next_ns, int expected_result, s32 expected_next_ns)
18 struct timespec current_time;
19 u32 prev_time_s = prev_s;
20 s32 next_read_time_ns = next_ns;
22 current_time.tv_sec = s;
23 current_time.tv_nsec = ns;
25 if (is_read_scheduled(¤t_time, &prev_time_s, &next_read_time_ns) != expected_result) {
26 pr_err("Failed do_read(%u, %u, %u, %d): expected %d\n", s, ns, prev_s, next_ns, expected_result);
30 if (next_read_time_ns != expected_next_ns) {
31 pr_err("Failed: next_read_ns expected=%d, actual=%d\n", expected_next_ns, next_read_time_ns);
38 static void test_all_is_read_scheduled(void)
40 const int HIGHEST_NS = 999999999;
41 int n_tests_passed = 0;
43 pr_err("gator: running tests on %s\n", __FILE__);
45 n_tests_passed += test_is_read_scheduled(0, 0, 0, 0, 1, READ_INTERVAL_NSEC); /* Null time */
46 n_tests_passed += test_is_read_scheduled(100, 1000, 0, 0, 1, READ_INTERVAL_NSEC + 1000); /* Initial values */
48 n_tests_passed += test_is_read_scheduled(100, HIGHEST_NS, 100, HIGHEST_NS + 500, 0, HIGHEST_NS + 500);
49 n_tests_passed += test_is_read_scheduled(101, 0001, 100, HIGHEST_NS + 500, 0, HIGHEST_NS + 500 - NSEC_PER_SEC);
50 n_tests_passed += test_is_read_scheduled(101, 600, 100, HIGHEST_NS + 500 - NSEC_PER_SEC, 1, 600 + READ_INTERVAL_NSEC);
52 n_tests_passed += test_is_read_scheduled(101, 600, 100, HIGHEST_NS + 500, 1, 600 + READ_INTERVAL_NSEC);
54 pr_err("gator: %d tests passed\n", n_tests_passed);