43 #include "my_config.h"
44 #include <gtest/gtest.h>
46 #include "my_global.h"
49 namespace mysys_my_rdtsc_unittest {
51 const int LOOP_COUNT= 100;
66 void RDTimeStampCounter::test_init()
102 TEST_F(RDTimeStampCounter, TestCycle)
104 ulonglong t1= my_timer_cycles();
110 for (i=0 ; i < LOOP_COUNT ; i++)
112 t2= my_timer_cycles();
121 EXPECT_TRUE((backward <= 1)) <<
"The cycle timer is strictly increasing";
123 if (myt.cycles.routine != 0)
124 EXPECT_TRUE((nonzero != 0)) <<
"The cycle timer is implemented";
126 EXPECT_TRUE((nonzero == 0))
127 <<
"The cycle timer is not implemented and returns 0";
131 TEST_F(RDTimeStampCounter, TestNanosecond)
133 ulonglong t1= my_timer_nanoseconds();
139 for (i=0 ; i < LOOP_COUNT ; i++)
141 t2= my_timer_nanoseconds();
149 EXPECT_TRUE((backward == 0)) <<
"The nanosecond timer is increasing";
151 if (myt.nanoseconds.routine != 0)
152 EXPECT_TRUE((nonzero != 0)) <<
"The nanosecond timer is implemented";
154 EXPECT_TRUE((nonzero == 0))
155 <<
"The nanosecond timer is not implemented and returns 0";
159 TEST_F(RDTimeStampCounter, TestMicrosecond)
161 ulonglong t1= my_timer_microseconds();
167 for (i=0 ; i < LOOP_COUNT ; i++)
169 t2= my_timer_microseconds();
177 EXPECT_TRUE((backward == 0)) <<
"The microsecond timer is increasing";
179 if (myt.microseconds.routine != 0)
180 EXPECT_TRUE((nonzero != 0)) <<
"The microsecond timer is implemented";
182 EXPECT_TRUE((nonzero == 0))
183 <<
"The microsecond timer is not implemented and returns 0";
187 TEST_F(RDTimeStampCounter, TestMillisecond)
189 ulonglong t1= my_timer_milliseconds();
195 for (i=0 ; i < LOOP_COUNT ; i++)
197 t2= my_timer_milliseconds();
205 EXPECT_TRUE((backward == 0)) <<
"The millisecond timer is increasing";
207 if (myt.milliseconds.routine != 0)
208 EXPECT_TRUE((nonzero != 0)) <<
"The millisecond timer is implemented";
210 EXPECT_TRUE((nonzero == 0))
211 <<
"The millisecond timer is not implemented and returns 0";
215 TEST_F(RDTimeStampCounter, TestTick)
217 ulonglong t1= my_timer_ticks();
223 for (i=0 ; i < LOOP_COUNT ; i++)
225 t2= my_timer_ticks();
233 EXPECT_TRUE((backward == 0)) <<
"The tick timer is increasing";
235 if (myt.ticks.routine != 0)
236 EXPECT_TRUE((nonzero != 0)) <<
"The tick timer is implemented";
238 EXPECT_TRUE((nonzero == 0))
239 <<
"The tick timer is not implemented and returns 0";