#At file:///home/malff/BZR_TREE/mysql-trunk-perfschema/ based on revid:marc.alff@stripped
2939 Marc Alff 2009-11-03
Unit tests cleanup
modified:
storage/perfschema/unittest/pfs-t.cc
storage/perfschema/unittest/pfs_timer-t.cc
=== modified file 'storage/perfschema/unittest/pfs-t.cc'
--- a/storage/perfschema/unittest/pfs-t.cc 2009-09-21 09:35:17 +0000
+++ b/storage/perfschema/unittest/pfs-t.cc 2009-11-04 03:11:29 +0000
@@ -74,6 +74,7 @@ void test_bootstrap()
param.m_thread_sizing= 0;
param.m_table_sizing= 0;
param.m_file_sizing= 0;
+ param.m_file_handle_sizing= 0;
param.m_events_waits_history_sizing= 0;
param.m_events_waits_history_long_sizing= 0;
@@ -115,6 +116,7 @@ PSI * load_perfschema()
param.m_thread_sizing= 10;
param.m_table_sizing= 10;
param.m_file_sizing= 10;
+ param.m_file_handle_sizing= 50;
param.m_events_waits_history_sizing= 10;
param.m_events_waits_history_long_sizing= 10;
@@ -711,8 +713,8 @@ void test_init_disabled()
psi->create_file(file_key_A, "foo", (File) 65000);
file_A1= lookup_file_by_name("foo");
ok(file_A1 == NULL, "not instrumented");
- ok(file_lost == 1, "lost a file");
- file_lost= 0;
+ ok(file_handle_lost == 1, "lost a file handle");
+ file_handle_lost= 0;
/* enabled F-A + enabled T-1: instrumentation */
=== modified file 'storage/perfschema/unittest/pfs_timer-t.cc'
--- a/storage/perfschema/unittest/pfs_timer-t.cc 2009-09-21 09:35:17 +0000
+++ b/storage/perfschema/unittest/pfs_timer-t.cc 2009-11-04 03:11:29 +0000
@@ -29,9 +29,8 @@ void test_timers()
ulonglong t3_b;
ulonglong t4_b;
ulonglong t5_b;
- ulonglong five_sec_in_pico;
- ulonglong milli_error;
- ulonglong tick_error;
+ ulonglong five_sec_in_pico_low;
+ ulonglong five_sec_in_pico_high;
init_timers();
@@ -50,11 +49,9 @@ void test_timers()
t4_b= get_timer_value(TIMER_NAME_MILLISEC);
t5_b= get_timer_value(TIMER_NAME_TICK);
- five_sec_in_pico= (ulonglong) (5*1e12);
- /* precision with slow (milli) timers is bad, expecting to be within 2 ms */
- milli_error= (ulonglong) (2*1e9);
- /* precision with very slow (tick) timers is very bad, expecting to be within 200 ms */
- tick_error= (ulonglong) (200*1e9);
+ /* Checking we are within a 1/1000 range */
+ five_sec_in_pico_low= (ulonglong) (5*1e12 * 0.999);
+ five_sec_in_pico_high= (ulonglong) (5*1e12 * 1.001);
diag("cycle a: %13llu", t1_a);
diag("nano a: %13llu", t2_a);
@@ -74,20 +71,58 @@ void test_timers()
diag("milli b-a: %13llu", t4_b-t4_a);
diag("tick b-a: %13llu", t5_b-t5_a);
- ok(t1_b > t1_a, "cycle timer ascending");
- ok(t2_b > t2_a, "nano timer ascending");
- ok(t3_b > t3_a, "micro timer ascending");
- ok(t4_b > t4_a, "milli timer ascending");
- ok(t5_b > t5_a, "tick timer ascending");
-
- ok(t1_b - t1_a > five_sec_in_pico, "cycle timer counting ok");
- ok(t2_b - t2_a > five_sec_in_pico, "nano timer counting ok");
- ok(t3_b - t3_a > five_sec_in_pico, "micro timer counting ok");
- /*
- Does not work, timers are just too inaccurate
- ok(t4_b - t4_a > five_sec_in_pico - milli_error, "milli timer counting ok (with margin)");
- ok(t5_b - t5_a > five_sec_in_pico - tick_error, "tick timer counting ok (with margin)");
- */
+ if ((t1_a == 0) && (t1_b == 0))
+ {
+ skip(3, "cycle timer not implemented");
+ }
+ else
+ {
+ ok(t1_b > t1_a, "cycle timer ascending");
+ ok(t1_b - t1_a >= five_sec_in_pico_low, "cycle timer count >= low limit");
+ ok(t1_b - t1_a <= five_sec_in_pico_high, "cycle timer count <= high limit");
+ }
+
+ if ((t2_a == 0) && (t2_b == 0))
+ {
+ skip(3, "nano timer not implemented");
+ }
+ else
+ {
+ ok(t2_b > t2_a, "nano timer ascending");
+ ok(t2_b - t2_a >= five_sec_in_pico_low, "nano timer count >= low limit");
+ ok(t2_b - t2_a <= five_sec_in_pico_high, "nano timer count <= high limit");
+ }
+
+ if ((t3_a == 0) && (t3_b == 0))
+ {
+ skip(3, "micro timer not implemented");
+ }
+ else
+ {
+ ok(t3_b > t3_a, "micro timer ascending");
+ ok(t3_b - t3_a >= five_sec_in_pico_low, "micro timer count >= low limit");
+ ok(t3_b - t3_a <= five_sec_in_pico_high, "micro timer count <= high limit");
+ }
+
+ if ((t4_a == 0) && (t4_b == 0))
+ {
+ skip(1, "milli timer not implemented");
+ }
+ else
+ {
+ ok(t4_b > t4_a, "milli timer ascending");
+ /* Timer too inaccurate to have a reliable test */
+ }
+
+ if ((t5_a == 0) && (t5_b == 0))
+ {
+ skip(1, "tick timer not implemented");
+ }
+ else
+ {
+ ok(t5_b > t5_a, "tick timer ascending");
+ /* Timer too inaccurate to have a reliable test */
+ }
}
void do_all_tests()
@@ -97,7 +132,7 @@ void do_all_tests()
int main(int, char **)
{
- plan(8);
+ plan(11);
MY_INIT("pfs_timer-t");
do_all_tests();
return 0;
Attachment: [text/bzr-bundle] bzr/marc.alff@sun.com-20091104031129-tal43zp1vdi96kiy.bundle