aboutsummaryrefslogtreecommitdiff
path: root/utils
diff options
context:
space:
mode:
authorDouglas Gilbert <dgilbert@interlog.com>2016-01-27 15:13:35 +0000
committerDouglas Gilbert <dgilbert@interlog.com>2016-01-27 15:13:35 +0000
commit572d431816271830cc321c2c7b596236e5708ea0 (patch)
treefc4216b9e9af787d73423029acfd9632f214db4a /utils
parent92f622b977ac1f47099c4092b816e11f531f47c2 (diff)
downloadsg3_utils-572d431816271830cc321c2c7b596236e5708ea0.tar.gz
sg_logs: LPS misalignment lpage; sg_format: add ffmt option; sg_lib: big sense reporting rework
git-svn-id: https://svn.bingwo.ca/repos/sg3_utils/trunk@657 6180dd3e-e324-4e3e-922d-17de1ae2f315
Diffstat (limited to 'utils')
-rw-r--r--utils/tst_sg_lib.c148
1 files changed, 116 insertions, 32 deletions
diff --git a/utils/tst_sg_lib.c b/utils/tst_sg_lib.c
index f1c20d91..4755c806 100644
--- a/utils/tst_sg_lib.c
+++ b/utils/tst_sg_lib.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013-2014 Douglas Gilbert.
+ * Copyright (c) 2013-2015 Douglas Gilbert.
* All rights reserved.
* Use of this source code is governed by a BSD-style
* license that can be found in the BSD_LICENSE file.
@@ -25,24 +25,25 @@
*
*/
-static char * version_str = "1.02 20151127";
+static char * version_str = "1.03 20160126";
#define MAX_LINE_LEN 1024
static struct option long_options[] = {
- {"dtsrhex", 0, 0, 'd'},
- {"help", 0, 0, 'h'},
- {"printf", 0, 0, 'p'},
- {"sense", 0, 0, 's'},
- {"unaligned", 0, 0, 'u'},
- {"verbose", 0, 0, 'v'},
- {"version", 0, 0, 'V'},
- {0, 0, 0, 0},
+ {"dtsrhex", no_argument, 0, 'd'},
+ {"help", no_argument, 0, 'h'},
+ {"leadin", required_argument, 0, 'l'},
+ {"printf", no_argument, 0, 'p'},
+ {"sense", no_argument, 0, 's'},
+ {"unaligned", no_argument, 0, 'u'},
+ {"verbose", no_argument, 0, 'v'},
+ {"version", no_argument, 0, 'V'},
+ {0, 0, 0, 0}, /* sentinel */
};
-const unsigned char desc_sense_data1[] = {
+static const unsigned char desc_sense_data1[] = {
/* unrec_err, excessive_writes, sdat_ovfl, additional_len=? */
0x72, 0x1, 0x3, 0x2, 0x80, 0x0, 0x0, 12+12+8+4+8+4+28,
/* Information: 0x11223344556677bb */
@@ -64,7 +65,7 @@ const unsigned char desc_sense_data1[] = {
2,0,0x12,0x34,
};
-const unsigned char desc_sense_data2[] = {
+static const unsigned char desc_sense_data2[] = {
/* ill_req, inv fld in para list, additional_len=? */
0x72, 0x5, 0x26, 0x0, 0x0, 0x0, 0x0, 8+4,
/* sense key specific: SKSV=1, C/D*=0, bitp=7 bytep=34 */
@@ -73,23 +74,83 @@ const unsigned char desc_sense_data2[] = {
0x3, 0x2, 0x0, 0x45,
};
+static const unsigned char desc_sense_data3[] = {
+ /* medium err, vibration induced ..., additional_len=? */
+ 0x72, 0x3, 0x9, 0x5, 0x0, 0x0, 0x0, 32+16,
+ /* 0xd: block dev: sense key specific: SKSV=1, retry_count=257, fru=0x45
+ * info=0x1122334455, command_specific=0x1 */
+ 0xd, 0x1e, 0xa0, 0x0, 0x80, 0x1, 0x1, 0x45,
+ 0x0, 0x0, 0x0, 0x11, 0x22, 0x33, 0x44, 0x55,
+ 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1,
+ /* following sbc3 (standard) and sbc4r10 inconsistency; add padding */
+ 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
+ /* 0xe: reason: send_to_given+henceforth, lu, naa-5, 0x5333333000001f40 */
+ 0xe, 0xe, 0x0, 0x1, 0x1, 0x3, 0x0, 0x8,
+ 0x53, 0x33, 0x33, 0x30, 0x0, 0x0, 0x1f, 0x40,
+ };
+
+static const unsigned char desc_sense_data4[] = {
+ /* ill_req, inv fld in para list, additional_len=? */
+ 0x72, 0x5, 0x26, 0x0, 0x0, 0x0, 0x0, 24,
+ /* Forwarded sense data, FSDT=0, sd_src=7, f_status=2 */
+ 0xc, 22, 0x7, 0x2,
+ /* ill_req, inv fld in para list, additional_len=? */
+ 0x72, 0x5, 0x26, 0x0, 0x0, 0x0, 0x0, 8+4,
+ /* sense key specific: SKSV=1, C/D*=0, bitp=7 bytep=34 */
+ 0x2, 0x6, 0x0, 0x0, 0x8f, 0x0, 0x34, 0x0,
+ /* field replaceable code=0x45 */
+ 0x3, 0x2, 0x0, 0x45,
+ };
+
+static const unsigned char desc_sense_data5[] = {
+ /* no_sense, ATA info available */
+ 0x72, 0x0, 0x0, 0x1d, 0x0, 0x0, 0x0, 14+14,
+ /* ATA descriptor extend=1 */
+ 0x9, 0xc, 0x1, 0x0, 0x34, 0x12, 0x44, 0x11,
+ 0x55, 0x22, 0x66, 0x33, 0x1, 0x0,
+ /* ATA descriptor extend=0 */
+ 0x9, 0xc, 0x0, 0x0, 0x34, 0x12, 0x44, 0x11,
+ 0x55, 0x22, 0x66, 0x33, 0x1, 0x0,
+ };
+
+static const unsigned char desc_sense_data6[] = {
+ /* UA, req, subsidiary bindinganged */
+ 0x72, 0x6, 0x3f, 0x1a, 0x0, 0x0, 0x0, 26+12+12,
+ /* 0xe: designator, reason: preferred admin lu, uuid */
+ 0xe, 0x18, 0x0, 0x4, 0x1, 0xa, 0x0, 0x12,
+ 0x10, 0x0, 0x11, 0x22, 0x33, 0x44, 0x55, 0x66,
+ 0x77, 0x88, 0x99, 0xaa, 0xbb, 0xcc, 0xdd, 0xee,
+ 0xfe, 0xdc,
+ /* 0x0: Information(valid): lun */
+ 0x0, 0xa, 0x80, 0x0,
+ 0x0, 0x1, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0,
+ /* 0x1: Command specific: 0x1 */
+ 0x1, 0xa, 0x0, 0x0,
+ 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x1,
+ };
+
+static const char * leadin = NULL;
+
static void
usage()
{
- fprintf(stderr, "Usage: "
- "tst_sg_lib [--dstrhex] [--help] [--printf] [--sense] "
- "[--unaligned]\n"
- " [--verbose] [--version]\n"
- " where: --dstrhex|-d test dStrHex* variants\n"
- " --help|-h print out usage message\n"
- " --printf|-p test library printf variants\n"
- " --sense|-s test sense data handling\n"
- " --unaligned|-u test unaligned data handling\n"
- " --verbose|-v increase verbosity\n"
- " --version|-V print version string and exit\n\n"
- "Test various parts of sg_lib, see options\n"
- );
+ fprintf(stderr,
+ "Usage: tst_sg_lib [--dstrhex] [--help] [--leadin=STR] "
+ "[--printf] [--sense]\n"
+ " [--unaligned] [--verbose] [--version]\n"
+ " where: --dstrhex|-d test dStrHex* variants\n"
+ " --help|-h print out usage message\n"
+ " --leadin=STR|-l STR every line output by --sense "
+ "should\n"
+ " be prefixed by STR\n"
+ " --printf|-p test library printf variants\n"
+ " --sense|-s test sense data handling\n"
+ " --unaligned|-u test unaligned data handling\n"
+ " --verbose|-v increase verbosity\n"
+ " --version|-V print version string and exit\n\n"
+ "Test various parts of sg_lib, see options\n"
+ );
}
@@ -130,7 +191,7 @@ main(int argc, char * argv[])
while (1) {
int option_index = 0;
- c = getopt_long(argc, argv, "dhpsuvV", long_options,
+ c = getopt_long(argc, argv, "dhl:psuvV", long_options,
&option_index);
if (c == -1)
break;
@@ -143,6 +204,9 @@ main(int argc, char * argv[])
case '?':
usage();
return 0;
+ case 'l':
+ leadin = optarg;
+ break;
case 'p':
++do_printf;
break;
@@ -176,18 +240,38 @@ main(int argc, char * argv[])
if (do_sense ) {
++did_something;
- sg_print_sense("desc_sense_data test1", desc_sense_data1,
- (int)sizeof(desc_sense_data1), 1);
+ printf("desc_sense_data test1:\n");
+ sg_print_sense(leadin, desc_sense_data1,
+ (int)sizeof(desc_sense_data1), verbose);
printf("\n");
#if 1
- sg_get_sense_str("sg_get_sense_str(ds_data1)", desc_sense_data1,
- sizeof(desc_sense_data1), 1, sizeof(b), b);
+ printf("sg_get_sense_str(ds_data1):\n");
+ sg_get_sense_str(leadin, desc_sense_data1,
+ sizeof(desc_sense_data1), verbose, sizeof(b), b);
printf("sg_get_sense_str: strlen(b)->%zd\n", strlen(b));
printf("%s", b);
printf("\n");
#endif
- sg_print_sense("desc_sense_data test2", desc_sense_data2,
- (int)sizeof(desc_sense_data2), 1);
+ printf("desc_sense_data test2\n");
+ sg_print_sense(leadin, desc_sense_data2,
+ (int)sizeof(desc_sense_data2), verbose);
+ printf("\n");
+ printf("desc_sense block dev combo plus designator test3\n");
+ sg_print_sense(leadin, desc_sense_data3,
+ (int)sizeof(desc_sense_data3), verbose);
+ printf("\n");
+ printf("desc_sense forwarded sense test4\n");
+ sg_print_sense(leadin, desc_sense_data4,
+ (int)sizeof(desc_sense_data4), verbose);
+ printf("\n");
+ printf("desc_sense ATA Info test5\n");
+ sg_print_sense(leadin, desc_sense_data5,
+ (int)sizeof(desc_sense_data5), verbose);
+ printf("\n");
+ printf("desc_sense UA subsidiary binfing changed test6\n");
+ sg_print_sense(leadin, desc_sense_data6,
+ (int)sizeof(desc_sense_data6), verbose);
+ printf("\n");
printf("\n");
}