LCOV - code coverage report
Current view: top level - app/test - test_byteorder.c (source / functions) Hit Total Coverage
Test: Code coverage Lines: 11 11 100.0 %
Date: 2025-01-02 22:41:34 Functions: 2 2 100.0 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 3 6 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                 :            : #include <unistd.h>
       8                 :            : #include <inttypes.h>
       9                 :            : 
      10                 :            : #include <rte_byteorder.h>
      11                 :            : 
      12                 :            : #include "test.h"
      13                 :            : 
      14                 :            : static volatile uint16_t u16 = 0x1337;
      15                 :            : static volatile uint32_t u32 = 0xdeadbeefUL;
      16                 :            : static volatile uint64_t u64 = 0xdeadcafebabefaceULL;
      17                 :            : 
      18                 :            : /*
      19                 :            :  * Byteorder functions
      20                 :            :  * ===================
      21                 :            :  *
      22                 :            :  * - check that optimized byte swap functions are working for each
      23                 :            :  *   size (16, 32, 64 bits)
      24                 :            :  */
      25                 :            : 
      26                 :            : static int
      27                 :          1 : test_byteorder(void)
      28                 :            : {
      29                 :            :         uint16_t res_u16;
      30                 :            :         uint32_t res_u32;
      31                 :            :         uint64_t res_u64;
      32                 :            : 
      33                 :          1 :         res_u16 = rte_bswap16(u16);
      34                 :          1 :         printf("%"PRIx16" -> %"PRIx16"\n", u16, res_u16);
      35         [ +  - ]:          1 :         if (res_u16 != 0x3713)
      36                 :            :                 return -1;
      37                 :            : 
      38                 :          1 :         res_u32 = rte_bswap32(u32);
      39                 :          1 :         printf("%"PRIx32" -> %"PRIx32"\n", u32, res_u32);
      40         [ +  - ]:          1 :         if (res_u32 != 0xefbeaddeUL)
      41                 :            :                 return -1;
      42                 :            : 
      43                 :          1 :         res_u64 = rte_bswap64(u64);
      44                 :          1 :         printf("%"PRIx64" -> %"PRIx64"\n", u64, res_u64);
      45         [ +  - ]:          1 :         if (res_u64 != 0xcefabebafecaaddeULL)
      46                 :            :                 return -1;
      47                 :            : 
      48                 :            :         res_u16 = rte_bswap16(0x1337);
      49                 :            :         printf("const %"PRIx16" -> %"PRIx16"\n", (uint16_t)0x1337, res_u16);
      50                 :            :         if (res_u16 != 0x3713)
      51                 :            :                 return -1;
      52                 :            : 
      53                 :            :         res_u32 = rte_bswap32(0xdeadbeefUL);
      54                 :            :         printf("const %"PRIx32" -> %"PRIx32"\n", (uint32_t) 0xdeadbeef, res_u32);
      55                 :            :         if (res_u32 != 0xefbeaddeUL)
      56                 :            :                 return -1;
      57                 :            : 
      58                 :            :         res_u64 = rte_bswap64(0xdeadcafebabefaceULL);
      59                 :            :         printf("const %"PRIx64" -> %"PRIx64"\n", (uint64_t) 0xdeadcafebabefaceULL, res_u64);
      60                 :            :         if (res_u64 != 0xcefabebafecaaddeULL)
      61                 :            :                 return -1;
      62                 :            : 
      63                 :            :         return 0;
      64                 :            : }
      65                 :            : 
      66                 :        251 : REGISTER_FAST_TEST(byteorder_autotest, true, true, test_byteorder);

Generated by: LCOV version 1.14