]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
scsi: core: Add passthrough tests for success and no failure definitions
authorMike Christie <michael.christie@oracle.com>
Mon, 13 Jan 2025 18:07:57 +0000 (12:07 -0600)
committerMartin K. Petersen <martin.petersen@oracle.com>
Tue, 21 Jan 2025 17:16:17 +0000 (12:16 -0500)
This patch adds scsi_check_passthrough() tests for the cases where a
command completes successfully and when the command failed but the caller
did not pass in a list of failures.

Signed-off-by: Mike Christie <michael.christie@oracle.com>
Link: https://lore.kernel.org/r/20250113180757.16691-1-michael.christie@oracle.com
Reviewed-by: Bart Van Assche <bvanassche@acm.org>
Signed-off-by: Martin K. Petersen <martin.petersen@oracle.com>
drivers/scsi/scsi_lib_test.c

index 99834426a100a7548c913682049a280e2bd512ff..ae8af0e0047a85870d272ade16dcee5e97a0ae5b 100644 (file)
@@ -67,6 +67,13 @@ static void scsi_lib_test_multiple_sense(struct kunit *test)
        };
        int i;
 
+       /* Success */
+       sc.result = 0;
+       KUNIT_EXPECT_EQ(test, 0, scsi_check_passthrough(&sc, &failures));
+       KUNIT_EXPECT_EQ(test, 0, scsi_check_passthrough(&sc, NULL));
+       /* Command failed but caller did not pass in a failures array */
+       scsi_build_sense(&sc, 0, ILLEGAL_REQUEST, 0x91, 0x36);
+       KUNIT_EXPECT_EQ(test, 0, scsi_check_passthrough(&sc, NULL));
        /* Match end of array */
        scsi_build_sense(&sc, 0, ILLEGAL_REQUEST, 0x91, 0x36);
        KUNIT_EXPECT_EQ(test, -EAGAIN, scsi_check_passthrough(&sc, &failures));