1 /*
2 * Copyright (c) 2023 Intel Corporation.
3 *
4 * SPDX-License-Identifier: Apache-2.0
5 */
6
7 #include "iut.h"
8 #include "sedi_driver_rtc.h"
9
test_rtc_inc(int argc,char ** argv)10 static int test_rtc_inc(int argc, char **argv)
11 {
12 uint32_t test_loops = 1000000;
13 uint64_t cnt_rtc = 0;
14 uint64_t us_rtc = 0;
15 uint64_t us_start = 0;
16
17 us_start = us_rtc = sedi_rtc_get_us();
18
19 if (argc) {
20 test_loops = (uint32_t)strtoul(argv[0], NULL, 0);
21 }
22
23 iut_case_print("test loops = %d\n", test_loops);
24
25 for (uint32_t i = 0; i < test_loops; i++) {
26 uint64_t cnt = sedi_rtc_get();
27 uint64_t us = sedi_rtc_get_us();
28
29 if (cnt < cnt_rtc) {
30 iut_case_print("loop %d, cnt error, %llu->%llu\n",
31 i, cnt_rtc, cnt);
32 TEST_ASSERT_TRUE(0);
33 }
34 if (us < us_rtc) {
35 iut_case_print("loop %d, us error, %llu->%llu\n",
36 i, us_rtc, us);
37 TEST_ASSERT_TRUE(0);
38 }
39
40 cnt_rtc = cnt;
41 us_rtc = us;
42 }
43
44
45 iut_case_print("test exec time = %u us\n", (uint32_t)(us_rtc - us_start));
46 return IUT_ERR_OK;
47 }
48 DEFINE_IUT_CASE(rtc_inc, sedi.rtc, IUT_ATTRI_AUTORUN);
49