aboutsummaryrefslogtreecommitdiff
path: root/testing
diff options
context:
space:
mode:
authorDouglas Gilbert <dgilbert@interlog.com>2018-01-19 20:14:20 +0000
committerDouglas Gilbert <dgilbert@interlog.com>2018-01-19 20:14:20 +0000
commit6293187a432dd0bbf85961a897755bd0260f28ad (patch)
treed8a060af6e3e03f286881dc4d5ed6a398e466ccd /testing
parent400444efd4e3c2cd758aee250556c84e052634dc (diff)
downloadsg3_utils-6293187a432dd0bbf85961a897755bd0260f28ad.tar.gz
update BSD license from 3 to 2 clause aka FreeBSD license (without reference to FreeBSD project); more hex2* cleanup
git-svn-id: https://svn.bingwo.ca/repos/sg3_utils/trunk@746 6180dd3e-e324-4e3e-922d-17de1ae2f315
Diffstat (limited to 'testing')
-rw-r--r--testing/Makefile16
-rw-r--r--testing/Makefile.cplus2
-rw-r--r--testing/README7
-rw-r--r--testing/sg_chk_asc.c11
-rw-r--r--testing/sg_sense_test.c4
-rw-r--r--testing/tst_sg_lib.c64
6 files changed, 53 insertions, 51 deletions
diff --git a/testing/Makefile b/testing/Makefile
index 9471292a..9b7f6a83 100644
--- a/testing/Makefile
+++ b/testing/Makefile
@@ -27,22 +27,22 @@ MAN_PREF = man8
LARGE_FILE_FLAGS = -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64
# For C++/clang testing
-# ## CC = gcc
-# ## CC = g++
-# ## CC = clang
-# ## CC = clang++
+## CC = gcc
+CC = g++
+## CC = clang
+## CC = clang++
-CFLAGS = -g -O2 -W -Wall -iquote ../include -D_REENTRANT $(LARGE_FILE_FLAGS)
+##CFLAGS = -g -O2 -W -Wall -iquote ../include -D_REENTRANT $(LARGE_FILE_FLAGS)
# CFLAGS = -g -O2 -Wall -iquote ../include -D_REENTRANT -DSG_KERNEL_INCLUDES $(LARGE_FILE_FLAGS)
# CFLAGS = -g -O2 -Wall -pedantic -iquote ../include -D_REENTRANT $(LARGE_FILE_FLAGS)
# CFLAGS = -Wall -W -iquote ../include -D_REENTRANT $(LARGE_FILE_FLAGS) -pedantic -std=c11 --analyze
-# CFLAGS = -Wall -W -iquote ../include -D_REENTRANT $(LARGE_FILE_FLAGS) -pedantic -std=c++14
+CFLAGS = -Wall -W -iquote ../include -D_REENTRANT $(LARGE_FILE_FLAGS) -pedantic -std=c++14 -fPIC
LDFLAGS =
LIBFILESOLD = ../lib/sg_lib.o ../lib/sg_lib_data.o ../lib/sg_io_linux.o
-LIBFILESNEW = ../lib/sg_lib.o ../lib/sg_lib_data.o ../lib/sg_pt_linux.o \
- ../lib/sg_pt_common.o ../lib/sg_cmds_basic.o ../lib/sg_pt_linux_nvme.o
+LIBFILESNEW = ../lib/sg_pt_linux_nvme.o ../lib/sg_lib.o ../lib/sg_lib_data.o \
+ ../lib/sg_pt_linux.o ../lib/sg_pt_common.o ../lib/sg_cmds_basic.o
all: $(EXECS)
diff --git a/testing/Makefile.cplus b/testing/Makefile.cplus
index b884b291..31af2ff5 100644
--- a/testing/Makefile.cplus
+++ b/testing/Makefile.cplus
@@ -29,7 +29,7 @@ CPPFLAGS = -std=c++11 -pthread -g -O2 -W -Wall -iquote ../include -D_REENTRANT $
LDFLAGS = -std=c++11 -pthread
LIBFILESOLD = ../lib/sg_lib.o ../lib/sg_lib_data.o ../lib/sg_io_linux.o
-LIBFILESNEW = ../lib/sg_lib.o ../lib/sg_lib_data.o ../lib/sg_pt_linux.o
+LIBFILESNEW = ../lib/sg_lib.o ../lib/sg_lib_data.o ../lib/sg_pt_linux.o ../lib/sg_pt_common.o ../lib/sg_pt_linux_nvme.o
all: $(EXECS)
diff --git a/testing/README b/testing/README
index 5b6a9790..7ae56f63 100644
--- a/testing/README
+++ b/testing/README
@@ -4,7 +4,7 @@ needs to be executed in the parent directory followed by changing
directory to the lib directory and calling 'make' there.
Another way is to do a top level 'make' after the ./configure which
will make the libraries followed by all the utilities in the src/
-directory.
+directory. To make them in FreeBSD use 'make -f Makefile.freebsd' .
There is an brief explanation of each example in the README file in
the main (i.e. this directory's parent) directory. There are also
@@ -22,7 +22,8 @@ to get more information.
Those files with the extension "cpp" are C++ examples that use facilities
in C++11. They can be built by calling 'make -f Makefile.cplus'. A
-gcc/g++ compiler of 4.7.3 vintage or later will be required.
+gcc/g++ compiler of 4.7.3 vintage or later (or a recent clang compiler)
+will be required.
Douglas Gilbert
-4th November 2017
+19th January 2018
diff --git a/testing/sg_chk_asc.c b/testing/sg_chk_asc.c
index cb30075d..ef37729f 100644
--- a/testing/sg_chk_asc.c
+++ b/testing/sg_chk_asc.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2006-2015 Douglas Gilbert.
+ * Copyright (c) 2006-2018 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,7 +25,7 @@
* http://www.t10.org/lists/asc-num.txt
*/
-static char * version_str = "1.05 20150105";
+static const char * version_str = "1.06 20180119";
#define MAX_LINE_LEN 1024
@@ -59,7 +59,8 @@ static void usage()
int main(int argc, char * argv[])
{
- int k, j, res, c, num, len, asc, ascq;
+ int k, j, res, c, num, len;
+ unsigned int asc, ascq;
FILE * fp;
int offset = 24;
int verbose = 0;
@@ -138,7 +139,7 @@ int main(int argc, char * argv[])
continue;
num = sscanf(line, "%xh/%xh", &asc, &ascq);
if (1 == num)
- ascq = -1;
+ ascq = 999;
if (num < 1) {
if (verbose)
fprintf(stderr, "Badly formed line number %d (num=%d)\n",
@@ -169,7 +170,7 @@ printf("\"%s\",\n", b);
b[j] = toupper(b[j]);
bb[0] = '\0';
- if (ascq >= 0) {
+ if (ascq < 999) {
cp = sg_get_asc_ascq_str(asc, ascq, sizeof(bb) - 1, bb);
if (NULL == cp) {
fprintf(stderr, "no entry for %x,%x : %s\n", asc, ascq, b);
diff --git a/testing/sg_sense_test.c b/testing/sg_sense_test.c
index 4ada185b..683fc9b0 100644
--- a/testing/sg_sense_test.c
+++ b/testing/sg_sense_test.c
@@ -13,7 +13,7 @@
/* This is a simple program that tests the sense data descriptor format
printout function in sg_lib.c
-* Copyright (C) 2004-2016 D. Gilbert
+* Copyright (C) 2004-2018 D. Gilbert
* 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, or (at your option)
@@ -25,7 +25,7 @@
#define ME "sg_sense_test: "
-static char * version_str = "2.00 20160128";
+static const char * version_str = "2.01 20180119";
static struct option long_options[] = {
{"help", no_argument, 0, 'h'},
diff --git a/testing/tst_sg_lib.c b/testing/tst_sg_lib.c
index 13be7ff8..90741ff7 100644
--- a/testing/tst_sg_lib.c
+++ b/testing/tst_sg_lib.c
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2013-2016 Douglas Gilbert.
+ * Copyright (c) 2013-2018 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,15 +25,15 @@
*
*/
-static char * version_str = "1.04 20160503";
+static const char * version_str = "1.05 20180119";
#define MAX_LINE_LEN 1024
static struct option long_options[] = {
- {"dstrhex", no_argument, 0, 'd'},
{"help", no_argument, 0, 'h'},
+ {"hex2", no_argument, 0, 'H'},
{"leadin", required_argument, 0, 'l'},
{"printf", no_argument, 0, 'p'},
{"sense", no_argument, 0, 's'},
@@ -58,7 +58,7 @@ static const unsigned char desc_sense_data1[] = {
0xa, 0x6, 0x2, 0x1, 0x2, 0x0, 0x32, 0x01,
/* incorrect length indicator (ILI) */
0x5, 0x2, 0x0, 0x20,
- /* user data degment referral */
+ /* user data segment referral */
0xb, 26, 0x1, 0x0,
0,0,0,1, 0x1,0x2,0x3,0x4,0x5,0x6,0x7,0x8,
0x1,0x2,0x3,0x4,0x55,0x6,0x7,0x8,
@@ -136,12 +136,12 @@ static void
usage()
{
fprintf(stderr,
- "Usage: tst_sg_lib [--dstrhex] [--help] [--leadin=STR] "
+ "Usage: tst_sg_lib [--help] [--hex2] [--leadin=STR] "
"[--printf]\n"
" [--sense] [--unaligned] [--verbose] "
"[--version]\n"
- " where: --dstrhex|-d test dStrHex* variants\n"
- " --help|-h print out usage message\n"
+ " where; --help|-h print out usage message\n"
+ " --hex2|-H test hex2* variants\n"
" --leadin=STR|-l STR every line output by --sense "
"should\n"
" be prefixed by STR\n"
@@ -180,7 +180,7 @@ int
main(int argc, char * argv[])
{
int k, c, n, len;
- int do_dstrhex = 0;
+ int do_hex2 = 0;
int do_printf = 0;
int do_sense = 0;
int do_unaligned = 0;
@@ -193,19 +193,19 @@ main(int argc, char * argv[])
while (1) {
int option_index = 0;
- c = getopt_long(argc, argv, "dhl:psuvV", long_options,
+ c = getopt_long(argc, argv, "hHl:psuvV", long_options,
&option_index);
if (c == -1)
break;
switch (c) {
- case 'd':
- ++do_dstrhex;
- break;
case 'h':
case '?':
usage();
return 0;
+ case 'H':
+ ++do_hex2;
+ break;
case 'l':
leadin = optarg;
break;
@@ -360,21 +360,21 @@ main(int argc, char * argv[])
if (strlen(b) > 0)
printf("Resulting string: %s\n", b);
}
- if (do_dstrhex) {
- char b[] = {0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48,
- 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50,
- 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58};
+ if (do_hex2) {
+ uint8_t b[] = {0x41, 0x42, 0x43, 0x44, 0x45, 0x46, 0x47, 0x48,
+ 0x49, 0x4a, 0x4b, 0x4c, 0x4d, 0x4e, 0x4f, 0x50,
+ 0x51, 0x52, 0x53, 0x54, 0x55, 0x56, 0x57, 0x58};
++did_something;
for (k = 0; k < 18; ++k) {
printf("k=%d:\n", k);
- dStrHex(b, k, 0);
- dStrHexStr(b, k, "dSHS_0: ", 0, sizeof(bb), bb);
+ hex2stdout(b, k, 0);
+ hex2str(b, k, "h2str0: ", 0, sizeof(bb), bb);
printf("%s", bb);
- dStrHex(b, k, 1);
- dStrHexStr(b, k, "dSHS_1: ", 1, sizeof(bb), bb);
+ hex2stdout(b, k, 1);
+ hex2str(b, k, "h2str1: ", 1, sizeof(bb), bb);
printf("%s", bb);
- dStrHex(b, k, -1);
+ hex2stdout(b, k, -1);
printf("\n");
}
}
@@ -397,64 +397,64 @@ main(int argc, char * argv[])
printf("u16=0x%" PRIx16 "\n", u16);
sg_put_unaligned_le16(u16, u8);
printf(" le16:\n");
- dStrHex((const char *)u8, verbose ? 10 : 2, -1);
+ hex2stdout(u8, verbose ? 10 : 2, -1);
u16r = sg_get_unaligned_le16(u8);
printf(" u16r=0x%" PRIx16 "\n", u16r);
sg_put_unaligned_be16(u16, u8);
printf(" be16:\n");
- dStrHex((const char *)u8, verbose ? 10 : 2, -1);
+ hex2stdout(u8, verbose ? 10 : 2, -1);
u16r = sg_get_unaligned_be16(u8);
printf(" u16r=0x%" PRIx16 "\n\n", u16r);
printf("u24=0x%" PRIx32 "\n", u24);
sg_put_unaligned_le24(u24, u8);
printf(" le24:\n");
- dStrHex((const char *)u8, verbose ? 10 : 3, -1);
+ hex2stdout(u8, verbose ? 10 : 3, -1);
u24r = sg_get_unaligned_le24(u8);
printf(" u24r=0x%" PRIx32 "\n", u24r);
sg_put_unaligned_be24(u24, u8);
printf(" be24:\n");
- dStrHex((const char *)u8, verbose ? 10 : 3, -1);
+ hex2stdout(u8, verbose ? 10 : 3, -1);
u24r = sg_get_unaligned_be24(u8);
printf(" u24r=0x%" PRIx32 "\n\n", u24r);
printf("u32=0x%" PRIx32 "\n", u32);
sg_put_unaligned_le32(u32, u8);
printf(" le32:\n");
- dStrHex((const char *)u8, verbose ? 10 : 4, -1);
+ hex2stdout(u8, verbose ? 10 : 4, -1);
u32r = sg_get_unaligned_le32(u8);
printf(" u32r=0x%" PRIx32 "\n", u32r);
sg_put_unaligned_be32(u32, u8);
printf(" be32:\n");
- dStrHex((const char *)u8, verbose ? 10 : 4, -1);
+ hex2stdout(u8, verbose ? 10 : 4, -1);
u32r = sg_get_unaligned_be32(u8);
printf(" u32r=0x%" PRIx32 "\n\n", u32r);
printf("u48=0x%" PRIx64 "\n", u48);
sg_put_unaligned_le48(u48, u8);
printf(" le48:\n");
- dStrHex((const char *)u8, verbose ? 10 : 6, -1);
+ hex2stdout(u8, verbose ? 10 : 6, -1);
u48r = sg_get_unaligned_le48(u8);
printf(" u48r=0x%" PRIx64 "\n", u48r);
sg_put_unaligned_be48(u48, u8);
printf(" be48:\n");
- dStrHex((const char *)u8, verbose ? 10 : 6, -1);
+ hex2stdout(u8, verbose ? 10 : 6, -1);
u48r = sg_get_unaligned_be48(u8);
printf(" u48r=0x%" PRIx64 "\n\n", u48r);
printf("u64=0x%" PRIx64 "\n", u64);
sg_put_unaligned_le64(u64, u8);
printf(" le64:\n");
- dStrHex((const char *)u8, verbose ? 10 : 8, -1);
+ hex2stdout(u8, verbose ? 10 : 8, -1);
u64r = sg_get_unaligned_le64(u8);
printf(" u64r=0x%" PRIx64 "\n", u64r);
sg_put_unaligned_be64(u64, u8);
printf(" be64:\n");
- dStrHex((const char *)u8, verbose ? 10 : 8, -1);
+ hex2stdout(u8, verbose ? 10 : 8, -1);
u64r = sg_get_unaligned_be64(u8);
printf(" u64r=0x%" PRIx64 "\n\n", u64r);
printf(" be[8]:\n");
- dStrHex((const char *)u8, verbose ? 10 : 8, -1);
+ hex2stdout(u8, verbose ? 10 : 8, -1);
u64r = sg_get_unaligned_be(8, u8);
printf(" u64r[8]=0x%" PRIx64 "\n\n", u64r);
printf(" le[8]:\n");