LCOV - code coverage report
Current view: top level - app/test - test_cycles.c (source / functions) Hit Total Coverage
Test: Code coverage Lines: 16 17 94.1 %
Date: 2024-12-01 18:57:19 Functions: 3 3 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 4 8 50.0 %

           Branch data     Line data    Source code
       1                 :            : /* SPDX-License-Identifier: BSD-3-Clause
       2                 :            :  * Copyright(c) 2010-2014 Intel Corporation
       3                 :            :  */
       4                 :            : 
       5                 :            : #include <stdio.h>
       6                 :            : #include <stdint.h>
       7                 :            : 
       8                 :            : #include <rte_common.h>
       9                 :            : #include <rte_cycles.h>
      10                 :            : 
      11                 :            : #include "test.h"
      12                 :            : 
      13                 :            : /*
      14                 :            :  * rte_delay_us_callback test
      15                 :            :  *
      16                 :            :  * - check if callback is correctly registered/unregistered
      17                 :            :  *
      18                 :            :  */
      19                 :            : 
      20                 :            : static unsigned int pattern;
      21                 :          2 : static void my_rte_delay_us(unsigned int us)
      22                 :            : {
      23                 :          2 :         pattern += us;
      24                 :          2 : }
      25                 :            : 
      26                 :            : static int
      27                 :          1 : test_user_delay_us(void)
      28                 :            : {
      29                 :          1 :         pattern = 0;
      30                 :            : 
      31                 :          1 :         rte_delay_us(2);
      32         [ +  - ]:          1 :         if (pattern != 0)
      33                 :            :                 return -1;
      34                 :            : 
      35                 :            :         /* register custom delay function */
      36                 :          1 :         rte_delay_us_callback_register(my_rte_delay_us);
      37                 :            : 
      38                 :          1 :         rte_delay_us(2);
      39         [ +  - ]:          1 :         if (pattern != 2)
      40                 :            :                 return -1;
      41                 :            : 
      42                 :          1 :         rte_delay_us(3);
      43         [ +  - ]:          1 :         if (pattern != 5)
      44                 :            :                 return -1;
      45                 :            : 
      46                 :            :         /* restore original delay function */
      47                 :          1 :         rte_delay_us_callback_register(rte_delay_us_block);
      48                 :            : 
      49                 :          1 :         rte_delay_us(3);
      50         [ -  + ]:          1 :         if (pattern != 5)
      51                 :          0 :                 return -1;
      52                 :            : 
      53                 :            :         return 0;
      54                 :            : }
      55                 :            : 
      56                 :        251 : REGISTER_FAST_TEST(user_delay_us, true, true, test_user_delay_us);

Generated by: LCOV version 1.14