4 * Copyright (c) Intel Corporation.
7 * Redistribution and use in source and binary forms, with or without
8 * modification, are permitted provided that the following conditions
11 * * Redistributions of source code must retain the above copyright
12 * notice, this list of conditions and the following disclaimer.
13 * * Redistributions in binary form must reproduce the above copyright
14 * notice, this list of conditions and the following disclaimer in
15 * the documentation and/or other materials provided with the
17 * * Neither the name of Intel Corporation nor the names of its
18 * contributors may be used to endorse or promote products derived
19 * from this software without specific prior written permission.
21 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
22 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
23 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
24 * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
25 * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
26 * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
27 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
28 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
29 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
30 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
34 #include "spdk_cunit.h"
36 #include "nvme/nvme_quirks.c"
39 test_nvme_quirks_striping(void)
41 struct spdk_pci_id pci_id
= {};
44 /* Non-Intel device should not have striping enabled */
45 quirks
= nvme_get_quirks(&pci_id
);
46 CU_ASSERT((quirks
& NVME_INTEL_QUIRK_STRIPING
) == 0);
48 /* Set the vendor id to Intel, but no device id. No striping. */
49 pci_id
.vendor_id
= SPDK_PCI_VID_INTEL
;
50 quirks
= nvme_get_quirks(&pci_id
);
51 CU_ASSERT((quirks
& NVME_INTEL_QUIRK_STRIPING
) == 0);
53 /* Device ID 0x0953 should have striping enabled */
54 pci_id
.device_id
= 0x0953;
55 quirks
= nvme_get_quirks(&pci_id
);
56 CU_ASSERT((quirks
& NVME_INTEL_QUIRK_STRIPING
) != 0);
58 /* Even if specific subvendor/subdevice ids are set,
59 * striping should be enabled.
61 pci_id
.subvendor_id
= SPDK_PCI_VID_INTEL
;
62 pci_id
.subdevice_id
= 0x3704;
63 quirks
= nvme_get_quirks(&pci_id
);
64 CU_ASSERT((quirks
& NVME_INTEL_QUIRK_STRIPING
) != 0);
66 pci_id
.subvendor_id
= 1234;
67 pci_id
.subdevice_id
= 42;
68 quirks
= nvme_get_quirks(&pci_id
);
69 CU_ASSERT((quirks
& NVME_INTEL_QUIRK_STRIPING
) != 0);
72 int main(int argc
, char **argv
)
74 CU_pSuite suite
= NULL
;
75 unsigned int num_failures
;
77 if (CU_initialize_registry() != CUE_SUCCESS
) {
78 return CU_get_error();
81 suite
= CU_add_suite("nvme_quirks", NULL
, NULL
);
83 CU_cleanup_registry();
84 return CU_get_error();
88 CU_add_test(suite
, "test nvme_quirks striping",
89 test_nvme_quirks_striping
) == NULL
91 CU_cleanup_registry();
92 return CU_get_error();
95 CU_basic_set_mode(CU_BRM_VERBOSE
);
97 num_failures
= CU_get_number_of_failures();
98 CU_cleanup_registry();