Looking at test_write10_residuals.c, test_write12_residuals.c and test_write16_residuals.c tests the similarity of the testing scenario can be found. There are several EDTL and SPDTL combinations which are the same for different length write command tests. They form the core of testing scenario of these commands. There aren't so much differences in the way of testing these combinations itself either. It is possible to move the main parameters describing the testing scenario into a separate structure and move the scenario itself into a separate function. It will increase the readability and reduce the duplicate code of these tests.
46 lines
1.6 KiB
C
46 lines
1.6 KiB
C
/*
|
|
Copyright (C) 2013 by Ronnie Sahlberg <ronniesahlberg@gmail.com>
|
|
|
|
This program is free software; you can redistribute it and/or modify
|
|
it under the terms of the GNU General Public License as published by
|
|
the Free Software Foundation; either version 2 of the License, or
|
|
(at your option) any later version.
|
|
|
|
This program is distributed in the hope that it will be useful,
|
|
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
GNU General Public License for more details.
|
|
|
|
You should have received a copy of the GNU General Public License
|
|
along with this program; if not, see <http://www.gnu.org/licenses/>.
|
|
*/
|
|
|
|
#ifndef _ISCSI_TESTS_WRITE_RESIDUALS_H_
|
|
#define _ISCSI_TESTS_WRITE_RESIDUALS_H_
|
|
|
|
#include <stddef.h>
|
|
#include <stdbool.h>
|
|
|
|
struct residuals_test_data {
|
|
size_t cdb_size; /* The size of CDB in bytes */
|
|
|
|
unsigned int xfer_len; /* The number of logical blocks of
|
|
data that shall be transferred */
|
|
|
|
unsigned int buf_len; /* Expected Data Transfer Length */
|
|
|
|
unsigned int residuals_kind; /* Overflow or Underflow as in
|
|
enum scsi_residual */
|
|
|
|
size_t residuals_amount; /* The amount of residual data in bytes */
|
|
|
|
bool check_overwrite; /* Whether the test checks for overwrite or not */
|
|
|
|
const char *log_messages; /* Test case description */
|
|
};
|
|
|
|
extern bool command_is_implemented;
|
|
extern void write_residuals_test (const struct residuals_test_data *tdata);
|
|
|
|
#endif /* _ISCSI_TESTS_WRITE_RESIDUALS_H_ */
|