diff options
author | Douglas Gilbert <dgilbert@interlog.com> | 2018-07-15 18:29:28 +0000 |
---|---|---|
committer | Douglas Gilbert <dgilbert@interlog.com> | 2018-07-15 18:29:28 +0000 |
commit | 35431d98669788d1565c9a7b5d8619b8846a0df9 (patch) | |
tree | 2367642607a3c8d0fa9d6fbee318bfd553420f31 /testing | |
parent | ceb7178cbfe8f784f8148da8725098395abb0578 (diff) | |
download | sg3_utils-35431d98669788d1565c9a7b5d8619b8846a0df9.tar.gz |
sg_lib: fix bug in producing exit status strings
git-svn-id: https://svn.bingwo.ca/repos/sg3_utils/trunk@783 6180dd3e-e324-4e3e-922d-17de1ae2f315
Diffstat (limited to 'testing')
-rw-r--r-- | testing/Makefile.cplus_fb | 79 | ||||
-rw-r--r-- | testing/Makefile.freebsd | 12 | ||||
-rw-r--r-- | testing/tst_sg_lib.c | 42 |
3 files changed, 108 insertions, 25 deletions
diff --git a/testing/Makefile.cplus_fb b/testing/Makefile.cplus_fb new file mode 100644 index 00000000..a41c2346 --- /dev/null +++ b/testing/Makefile.cplus_fb @@ -0,0 +1,79 @@ +SHELL = /bin/sh + +PREFIX=/usr/local +INSTDIR=$(DESTDIR)/$(PREFIX)/bin +MANDIR=$(DESTDIR)/$(PREFIX)/man + +## CC = g++ +## LD = g++ +## CC = clang++ +## LD = clang++ + +## This is just an example FreeBSD Makefile for how to build for clang++ +## All .cpp execs in this directory are Linux specific so there is +## nothing to do for FreeBSD. +## Not optimum but it works around 20180715 [dpg] + +# EXECS = sg_tst_context +EXECS = + +EXTRAS = + +BSG_EXTRAS = + + +MAN_PGS = +MAN_PREF = man8 + +LARGE_FILE_FLAGS = -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 + +CXXFLAGS = -std=c++11 -pthread -g -O2 -W -Wall -iquote ../include -D_REENTRANT $(LARGE_FILE_FLAGS) +# CPPFLAGS = -std=c++11 -pthread -g -O2 -W -Wall -iquote ../include -D_REENTRANT $(LARGE_FILE_FLAGS) -DDEBUG +## 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) + +LDFLAGS = -std=c++11 -pthread + +LIBFILESOLD = ../lib/sg_lib.o ../lib/sg_lib_data.o +LIBFILESNEW = ../lib/sg_lib.o ../lib/sg_lib_data.o ../lib/sg_pt_freebsd.o ../lib/sg_pt_common.o \ + ../lib/sg_cmds_basic.o + +all: $(EXECS) + +extras: $(EXTRAS) + + +depend dep: + for i in $(EXECS).cpp; do $(CXX) $(INCLUDES) $(CXXFLAGS) -M $$i; \ + done > .depend + +clean: + /bin/rm -f *.o $(EXECS) $(EXTRAS) $(BSG_EXTRAS) core .depend + +sg_tst_context: sg_tst_async.o $(LIBFILESNEW) + $(CXX) -o $@ $(LDFLAGS) $^ + +install: $(EXECS) + install -d $(INSTDIR) + for name in $^; \ + do install -s -o root -g root -m 755 $$name $(INSTDIR); \ + done + install -d $(MANDIR)/$(MAN_PREF) + for mp in $(MAN_PGS); \ + do install -o root -g root -m 644 $$mp $(MANDIR)/$(MAN_PREF); \ + gzip -9f $(MANDIR)/$(MAN_PREF)/$$mp; \ + done + +uninstall: + dists="$(EXECS)"; \ + for name in $$dists; do \ + rm -f $(INSTDIR)/$$name; \ + done + for mp in $(MAN_PGS); do \ + rm -f $(MANDIR)/$(MAN_PREF)/$$mp.gz; \ + done + +## ifeq (.depend,$(wildcard .depend)) +## include .depend +## endif diff --git a/testing/Makefile.freebsd b/testing/Makefile.freebsd index b7dcef27..6cfe7d8f 100644 --- a/testing/Makefile.freebsd +++ b/testing/Makefile.freebsd @@ -8,10 +8,10 @@ MANDIR=$(DESTDIR)/$(PREFIX)/man # the default C compiler is clang. Swap the comment marks (lines starting # with '#') on the next 4 (non-blank) lines. # CC = gcc -CC = clang +# CC = clang # LD = gcc -LD = clang +# LD = clang EXECS = sg_sense_test sg_chk_asc sg_tst_nvme tst_sg_lib @@ -54,17 +54,17 @@ clean: /bin/rm -f *.o $(EXECS) $(EXTRAS) core .depend sg_sense_test: sg_sense_test.o $(D_FILES) - $(LD) -o $@ $(LDFLAGS) $@.o $(D_FILES) + $(CC) -o $@ $(LDFLAGS) $@.o $(D_FILES) # building sg_chk_asc depends on a prior successful make in ../lib sg_chk_asc: sg_chk_asc.o $(D_FILES) - $(LD) -o $@ $(LDFLAGS) $@.o $(D_FILES) + $(CC) -o $@ $(LDFLAGS) $@.o $(D_FILES) sg_tst_nvme: sg_tst_nvme.o $(D_FILES) - $(LD) -o $@ $(LDFLAGS) $@.o $(D_FILES) + $(CC) -o $@ $(LDFLAGS) $@.o $(D_FILES) tst_sg_lib: tst_sg_lib.o $(D_FILES) - $(LD) -o $@ $(LDFLAGS) $@.o $(D_FILES) + $(CC) -o $@ $(LDFLAGS) $@.o $(D_FILES) install: $(EXECS) install -d $(INSTDIR) diff --git a/testing/tst_sg_lib.c b/testing/tst_sg_lib.c index 5b5725d3..027e6fb2 100644 --- a/testing/tst_sg_lib.c +++ b/testing/tst_sg_lib.c @@ -19,7 +19,7 @@ #include <time.h> -#ifdef __GNUC__ +#if defined(__GNUC__) && ! defined(SG_LIB_FREEBSD) #include <byteswap.h> #endif @@ -42,7 +42,7 @@ * related to snprintf(). */ -static const char * version_str = "1.11 20180706"; +static const char * version_str = "1.11 20180715"; #define MAX_LINE_LEN 1024 @@ -160,26 +160,27 @@ usage() "[--printf]\n" " [--sense] [--unaligned] [--verbose] " "[--version]\n" -#ifdef __GNUC__ - " where: --byteswap=B|-b B B is 16, 32 or 64; tests " - "NUM byteswaps\n" - " compared to sg_unaligned " + " where:\n" +#if defined(__GNUC__) && ! defined(SG_LIB_FREEBSD) + " --byteswap=B|-b B B is 16, 32 or 64; tests NUM " + "byteswaps\n" + " compared to sg_unaligned " "equivalent\n" - " --exit|-e test exit status strings\n" + " --exit|-e test exit status strings\n" #else - " where: --exit|-e test exit status strings\n" + " --exit|-e test exit status strings\n" #endif - " --help|-h print out usage message\n" - " --hex2|-H test hex2* variants\n" - " --leadin=STR|-l STR every line output by --sense " + " --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" - " --num=NUM|-n NUM number of iterations (def=1)\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" + " be prefixed by STR\n" + " --num=NUM|-n NUM number of iterations (def=1)\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. Sense data tests " "overlap\nsomewhat with examples/sg_sense_test .\n" ); @@ -297,6 +298,8 @@ main(int argc, char * argv[]) } if (do_exit_status) { + ++did_something; + printf("Test Exit Status strings (add -v for long version):\n"); printf(" No error (es=0): %s\n", sg_get_category_sense_str(0, b_len, b, vb)); @@ -315,6 +318,7 @@ main(int argc, char * argv[]) printf("%s\n", get_exit_status_str(8, (vb > 0), b_len, b)); printf("%s\n", get_exit_status_str(25, (vb > 0), b_len, b)); printf("%s\n", get_exit_status_str(33, (vb > 0), b_len, b)); + printf("%s\n", get_exit_status_str(36, (vb > 0), b_len, b)); printf("%s\n", get_exit_status_str(48, (vb > 0), b_len, b)); printf("%s\n", get_exit_status_str(50, (vb > 0), b_len, b)); printf("%s\n", get_exit_status_str(51, (vb > 0), b_len, b)); @@ -551,7 +555,7 @@ main(int argc, char * argv[]) printf(" u64r[v=8 bytes]=0x%" PRIx64 "\n\n", u64r); } -#ifdef __GNUC__ +#if defined(__GNUC__) && ! defined(SG_LIB_FREEBSD) if (byteswap_sz > 0) { uint32_t elapsed_msecs; uint16_t count16 = 0; |