LCOV - code coverage report
Current view: top level - test - test-ratelimit.c (source / functions) Hit Total Coverage
Test: systemd_full.info Lines: 15 15 100.0 %
Date: 2019-08-23 13:36:53 Functions: 2 2 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 10 14 71.4 %

           Branch data     Line data    Source code
       1                 :            : /* SPDX-License-Identifier: LGPL-2.1+ */
       2                 :            : 
       3                 :            : #include <unistd.h>
       4                 :            : 
       5                 :            : #include "macro.h"
       6                 :            : #include "ratelimit.h"
       7                 :            : #include "time-util.h"
       8                 :            : 
       9                 :          4 : static void test_ratelimit_below(void) {
      10                 :            :         int i;
      11                 :          4 :         RATELIMIT_DEFINE(ratelimit, 1 * USEC_PER_SEC, 10);
      12                 :            : 
      13         [ +  + ]:         44 :         for (i = 0; i < 10; i++)
      14         [ -  + ]:         40 :                 assert_se(ratelimit_below(&ratelimit));
      15         [ -  + ]:          4 :         assert_se(!ratelimit_below(&ratelimit));
      16                 :          4 :         sleep(1);
      17         [ +  + ]:         44 :         for (i = 0; i < 10; i++)
      18         [ -  + ]:         40 :                 assert_se(ratelimit_below(&ratelimit));
      19                 :            : 
      20                 :          4 :         RATELIMIT_INIT(ratelimit, 0, 10);
      21         [ +  + ]:      40004 :         for (i = 0; i < 10000; i++)
      22         [ -  + ]:      40000 :                 assert_se(ratelimit_below(&ratelimit));
      23                 :          4 : }
      24                 :            : 
      25                 :          4 : int main(int argc, char *argv[]) {
      26                 :          4 :         test_ratelimit_below();
      27                 :            : 
      28                 :          4 :         return 0;
      29                 :            : }

Generated by: LCOV version 1.14