mcelog: Add a test for leaky bucket logging.

The leaky bucket code is not performing anywhere near what I had expected.
Here is a test which is #ifdef'd out by default.  Compile with
gcc -DTEST_LEAKY_BUCKET -DTEST_LEAKY_BUCKET_DEBUG -o test-leaky-bucket
leaky-bucket.c

Run the test to see when events get logged.

Compile with:
gcc -DTEST_LEAKY_BUCKET -o test-leaky-bucket leaky-bucket.c

./test-leaky-bucket  # Should print nothing and return 0.

Signed-off-by: Robin Holt <robinmholt@gmail.com>
To: Andi Kleen <ak@linux.intel.com>
Signed-off-by: Andi Kleen <ak@linux.intel.com>
mcelog: Make leaky-bucket log more sane.

When initialized with a threshold string of "X / Y", the leaky bucket
code will currently log every Xth event.  It will reset to the 0th event
whenever the event is more than Y seconds after the previous event.
This behavior is nothing close to what I had expected nor would guess
the normal administrator would expect.

This patch brings things more in line with my expectations.  The first
Xth events will be logged, and then, for every Y/X seconds, one additional
event will be allowed to be logged.

There is no testing for an inc value larger than 1.

Signed-off-by: Robin Holt <robinmholt@gmail.com>
To: Andi Kleen <ak@linux.intel.com>
Signed-off-by: Andi Kleen <ak@linux.intel.com>