LCOV - code coverage report
Current view: top level - spdk/test/unit/lib/ioat/ioat.c - ioat_ut.c (source / functions) Hit Total Coverage
Test: Combined Lines: 42 56 75.0 %
Date: 2024-07-13 02:54:37 Functions: 2 7 28.6 %
Legend: Lines: hit not hit | Branches: + taken - not taken # not executed Branches: 0 0 -

           Branch data     Line data    Source code
       1                 :            : /*   SPDX-License-Identifier: BSD-3-Clause
       2                 :            :  *   Copyright (C) 2015 Intel Corporation.
       3                 :            :  *   All rights reserved.
       4                 :            :  */
       5                 :            : 
       6                 :            : #include "spdk_internal/cunit.h"
       7                 :            : 
       8                 :            : #include "ioat/ioat.c"
       9                 :            : 
      10                 :            : #include "spdk_internal/mock.h"
      11                 :            : 
      12                 :            : #include "common/lib/test_env.c"
      13                 :            : 
      14                 :            : int
      15                 :          0 : spdk_pci_enumerate(struct spdk_pci_driver *driver, spdk_pci_enum_cb enum_cb, void *enum_ctx)
      16                 :            : {
      17                 :          0 :         return -1;
      18                 :            : }
      19                 :            : 
      20                 :            : int
      21                 :          0 : spdk_pci_device_map_bar(struct spdk_pci_device *dev, uint32_t bar,
      22                 :            :                         void **mapped_addr, uint64_t *phys_addr, uint64_t *size)
      23                 :            : {
      24                 :          0 :         *mapped_addr = NULL;
      25                 :          0 :         *phys_addr = 0;
      26                 :          0 :         *size = 0;
      27                 :          0 :         return 0;
      28                 :            : }
      29                 :            : 
      30                 :            : int
      31                 :          0 : spdk_pci_device_unmap_bar(struct spdk_pci_device *dev, uint32_t bar, void *addr)
      32                 :            : {
      33                 :          0 :         return 0;
      34                 :            : }
      35                 :            : 
      36                 :            : int
      37                 :          0 : spdk_pci_device_cfg_read32(struct spdk_pci_device *dev, uint32_t *value,
      38                 :            :                            uint32_t offset)
      39                 :            : {
      40                 :          0 :         *value = 0xFFFFFFFFu;
      41                 :          0 :         return 0;
      42                 :            : }
      43                 :            : 
      44                 :            : int
      45                 :          0 : spdk_pci_device_cfg_write32(struct spdk_pci_device *dev, uint32_t value,
      46                 :            :                             uint32_t offset)
      47                 :            : {
      48                 :          0 :         return 0;
      49                 :            : }
      50                 :            : 
      51                 :            : static void
      52                 :          6 : ioat_state_check(void)
      53                 :            : {
      54                 :            :         /*
      55                 :            :          * CHANSTS's STATUS field is 3 bits (8 possible values), but only has 5 valid states:
      56                 :            :          * ACTIVE       0x0
      57                 :            :          * IDLE         0x1
      58                 :            :          * SUSPENDED    0x2
      59                 :            :          * HALTED       0x3
      60                 :            :          * ARMED        0x4
      61                 :            :          */
      62                 :            : 
      63                 :          6 :         CU_ASSERT(is_ioat_active(0) == 1); /* ACTIVE */
      64                 :          6 :         CU_ASSERT(is_ioat_active(1) == 0); /* IDLE */
      65                 :          6 :         CU_ASSERT(is_ioat_active(2) == 0); /* SUSPENDED */
      66                 :          6 :         CU_ASSERT(is_ioat_active(3) == 0); /* HALTED */
      67                 :          6 :         CU_ASSERT(is_ioat_active(4) == 0); /* ARMED */
      68                 :          6 :         CU_ASSERT(is_ioat_active(5) == 0); /* reserved */
      69                 :          6 :         CU_ASSERT(is_ioat_active(6) == 0); /* reserved */
      70                 :          6 :         CU_ASSERT(is_ioat_active(7) == 0); /* reserved */
      71                 :            : 
      72                 :          6 :         CU_ASSERT(is_ioat_idle(0) == 0); /* ACTIVE */
      73                 :          6 :         CU_ASSERT(is_ioat_idle(1) == 1); /* IDLE */
      74                 :          6 :         CU_ASSERT(is_ioat_idle(2) == 0); /* SUSPENDED */
      75                 :          6 :         CU_ASSERT(is_ioat_idle(3) == 0); /* HALTED */
      76                 :          6 :         CU_ASSERT(is_ioat_idle(4) == 0); /* ARMED */
      77                 :          6 :         CU_ASSERT(is_ioat_idle(5) == 0); /* reserved */
      78                 :          6 :         CU_ASSERT(is_ioat_idle(6) == 0); /* reserved */
      79                 :          6 :         CU_ASSERT(is_ioat_idle(7) == 0); /* reserved */
      80                 :            : 
      81                 :          6 :         CU_ASSERT(is_ioat_suspended(0) == 0); /* ACTIVE */
      82                 :          6 :         CU_ASSERT(is_ioat_suspended(1) == 0); /* IDLE */
      83                 :          6 :         CU_ASSERT(is_ioat_suspended(2) == 1); /* SUSPENDED */
      84                 :          6 :         CU_ASSERT(is_ioat_suspended(3) == 0); /* HALTED */
      85                 :          6 :         CU_ASSERT(is_ioat_suspended(4) == 0); /* ARMED */
      86                 :          6 :         CU_ASSERT(is_ioat_suspended(5) == 0); /* reserved */
      87                 :          6 :         CU_ASSERT(is_ioat_suspended(6) == 0); /* reserved */
      88                 :          6 :         CU_ASSERT(is_ioat_suspended(7) == 0); /* reserved */
      89                 :            : 
      90                 :          6 :         CU_ASSERT(is_ioat_halted(0) == 0); /* ACTIVE */
      91                 :          6 :         CU_ASSERT(is_ioat_halted(1) == 0); /* IDLE */
      92                 :          6 :         CU_ASSERT(is_ioat_halted(2) == 0); /* SUSPENDED */
      93                 :          6 :         CU_ASSERT(is_ioat_halted(3) == 1); /* HALTED */
      94                 :          6 :         CU_ASSERT(is_ioat_halted(4) == 0); /* ARMED */
      95                 :          6 :         CU_ASSERT(is_ioat_halted(5) == 0); /* reserved */
      96                 :          6 :         CU_ASSERT(is_ioat_halted(6) == 0); /* reserved */
      97                 :          6 :         CU_ASSERT(is_ioat_halted(7) == 0); /* reserved */
      98                 :          6 : }
      99                 :            : 
     100                 :            : int
     101                 :          6 : main(int argc, char **argv)
     102                 :            : {
     103                 :          6 :         CU_pSuite       suite = NULL;
     104                 :            :         unsigned int    num_failures;
     105                 :            : 
     106                 :          6 :         CU_initialize_registry();
     107                 :            : 
     108                 :          6 :         suite = CU_add_suite("ioat", NULL, NULL);
     109                 :            : 
     110                 :          6 :         CU_ADD_TEST(suite, ioat_state_check);
     111                 :            : 
     112                 :          6 :         num_failures = spdk_ut_run_tests(argc, argv, NULL);
     113                 :          6 :         CU_cleanup_registry();
     114                 :          6 :         return num_failures;
     115                 :            : }

Generated by: LCOV version 1.14