LCOV - code coverage report
Current view: top level - spdk/test/unit/lib/nvme/nvme_quirks.c - nvme_quirks_ut.c (source / functions) Hit Total Coverage
Test: Combined Lines: 30 30 100.0 %
Date: 2024-07-15 17:50:13 Functions: 3 3 100.0 %
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) 2016 Intel Corporation.
       3                 :            :  *   All rights reserved.
       4                 :            :  */
       5                 :            : 
       6                 :            : #include "spdk_internal/cunit.h"
       7                 :            : 
       8                 :            : #include "nvme/nvme_quirks.c"
       9                 :            : 
      10                 :          3 : SPDK_LOG_REGISTER_COMPONENT(nvme)
      11                 :            : 
      12                 :            : static void
      13                 :          3 : test_nvme_quirks_striping(void)
      14                 :            : {
      15                 :          3 :         struct spdk_pci_id pci_id = {};
      16                 :          3 :         uint64_t quirks = 0;
      17                 :            : 
      18                 :            :         /* Non-Intel device should not have striping enabled */
      19                 :          3 :         quirks = nvme_get_quirks(&pci_id);
      20                 :          3 :         CU_ASSERT((quirks & NVME_INTEL_QUIRK_STRIPING) == 0);
      21                 :            : 
      22                 :            :         /* Set the vendor id to Intel, but no device id. No striping. */
      23                 :          3 :         pci_id.class_id = SPDK_PCI_CLASS_NVME;
      24                 :          3 :         pci_id.vendor_id = SPDK_PCI_VID_INTEL;
      25                 :          3 :         quirks = nvme_get_quirks(&pci_id);
      26                 :          3 :         CU_ASSERT((quirks & NVME_INTEL_QUIRK_STRIPING) == 0);
      27                 :            : 
      28                 :            :         /* Device ID 0x0953 should have striping enabled */
      29                 :          3 :         pci_id.device_id = 0x0953;
      30                 :          3 :         quirks = nvme_get_quirks(&pci_id);
      31                 :          3 :         CU_ASSERT((quirks & NVME_INTEL_QUIRK_STRIPING) != 0);
      32                 :            : 
      33                 :            :         /* Even if specific subvendor/subdevice ids are set,
      34                 :            :          * striping should be enabled.
      35                 :            :          */
      36                 :          3 :         pci_id.subvendor_id = SPDK_PCI_VID_INTEL;
      37                 :          3 :         pci_id.subdevice_id = 0x3704;
      38                 :          3 :         quirks = nvme_get_quirks(&pci_id);
      39                 :          3 :         CU_ASSERT((quirks & NVME_INTEL_QUIRK_STRIPING) != 0);
      40                 :            : 
      41                 :          3 :         pci_id.subvendor_id = 1234;
      42                 :          3 :         pci_id.subdevice_id = 42;
      43                 :          3 :         quirks = nvme_get_quirks(&pci_id);
      44                 :          3 :         CU_ASSERT((quirks & NVME_INTEL_QUIRK_STRIPING) != 0);
      45                 :          3 : }
      46                 :            : 
      47                 :            : int
      48                 :          3 : main(int argc, char **argv)
      49                 :            : {
      50                 :          3 :         CU_pSuite       suite = NULL;
      51                 :            :         unsigned int    num_failures;
      52                 :            : 
      53                 :          3 :         CU_initialize_registry();
      54                 :            : 
      55                 :          3 :         suite = CU_add_suite("nvme_quirks", NULL, NULL);
      56                 :            : 
      57                 :          3 :         CU_ADD_TEST(suite, test_nvme_quirks_striping);
      58                 :            : 
      59                 :          3 :         num_failures = spdk_ut_run_tests(argc, argv, NULL);
      60                 :          3 :         CU_cleanup_registry();
      61                 :          3 :         return num_failures;
      62                 :            : }

Generated by: LCOV version 1.14