1# =========================================================================== 2# 3# PUBLIC DOMAIN NOTICE 4# National Center for Biotechnology Information 5# 6# This software/database is a "United States Government Work" under the 7# terms of the United States Copyright Act. It was written as part of 8# the author's official duties as a United States Government employee and 9# thus cannot be copyrighted. This software/database is freely available 10# to the public for use. The National Library of Medicine and the U.S. 11# Government have not placed any restriction on its use or reproduction. 12# 13# Although all reasonable efforts have been taken to ensure the accuracy 14# and reliability of the software and data, the NLM and the U.S. 15# Government do not and cannot warrant the performance or results that 16# may be obtained by using this software or data. The NLM and the U.S. 17# Government disclaim all warranties, express or implied, including 18# warranties of performance, merchantability or fitness for any particular 19# purpose. 20# 21# Please cite the author in any work or product based on this material. 22# 23# =========================================================================== 24 25#echo $0 $* 26 27# =========================================================================== 28# run basic tests on an installation of sra-tools 29# $1 - installation directory 30# $2 - version number 31# 32# Error codes: 33# 1 - bad arguments 34# 2 - tests failed 35 36Usage() 37{ 38 echo "Usage: $0 <installation-directory> <version>" >&2 39 echo "" >&2 40 echo " installation-directory: path to SRA toollkit directory, e.g. ./sratoolkit.2.9.0-centos_linux64" >&2 41 echo " version: 3-part version number of the SRA toolkit, e.g. 2.9.0" >&2 42} 43 44RunTool() 45{ 46 echo RunTool $* 47 $* >/dev/null 2>&1 48 RC="$?" 49 if [ "$RC" != "0" ] 50 then 51 echo Returned $RC 52 FAILED="${FAILED} $* ;" 53 #else 54 # echo Returned $RC 55 fi 56} 57 58if [ "$#" -lt 1 ] 59then 60 Usage 61 exit 0 62elif [ "$1" == "-h" ] 63then 64 Usage 65 exit 0 66fi 67 68if [ "$1" == "" ] 69then 70 echo "Missing argument: sratoolkit installation directory" 71 Usage 72 exit 1 73fi 74TK_INSTALL_DIR=$1 75BIN_DIR=${TK_INSTALL_DIR}bin 76 77if [ "$2" == "" ] 78then 79 echo "Missing argument: version" 80 Usage 81 exit 1 82fi 83VERSION=$2 84 85FAILED="" 86 87################################ TEST sratoolkit ############################### 88 89echo 90echo "Smoke testing ${BIN_DIR} ..." 91 92# list all tools; vdb-passwd is obsolete but still in the package; sratools ios not to be run on its own 93TOOLS=$(ls -1 ${BIN_DIR} | grep -vw ncbi | grep -v vdb-passwd | grep -v sratools | grep -vE '[0-9]$') 94 95# run all tools with -h and -V 96 97for tool in ${TOOLS} 98do 99 100 RunTool ${BIN_DIR}/$tool -h 101 102 # All tools are supposed to respond to -V and --version, yet some respond only to --version, or -version, or nothing at all 103 VERSION_OPTION="-V" 104 if [ "${tool}" = "blastn_vdb" ] ; then VERSION_OPTION="-version"; fi 105 if [ "${tool}" = "sra-blastn" ] ; then VERSION_OPTION="-version"; fi 106 if [ "${tool}" = "sra-tblastn" ] ; then VERSION_OPTION="-version"; fi 107 if [ "${tool}" = "tblastn_vdb" ] ; then VERSION_OPTION="-version"; fi 108 if [ "${tool}" = "dump-ref-fasta" ] ; then VERSION_OPTION="--version"; fi 109 RunTool "${BIN_DIR}/$tool ${VERSION_OPTION} | grep ${VERSION}" 110 111done 112 113# run some key tools, check return codes 114RunTool ${BIN_DIR}/test-sra 115RunTool ${BIN_DIR}/vdb-config 116RunTool ${BIN_DIR}/prefetch SRR002749 117RunTool ${BIN_DIR}/vdb-dump SRR000001 -R 1 118RunTool ${BIN_DIR}/fastq-dump SRR002749 --fasta 0 -Z 119RunTool ${BIN_DIR}/sam-dump SRR002749 120RunTool ${BIN_DIR}/sra-pileup SRR619505 # --quiet 121 122if [ "${FAILED}" != "" ] 123then 124 echo "Failed: ${FAILED}" 125 exit 2 126fi 127 128echo "Sratoolkit smoke test successful" 129 130########################## TEST broken symbolic links ########################## 131echo 132echo "Checking broken symbolic links ..." 133echo find . -type l ! -exec test -e {} \; -print 134FAILED=`find . -type l ! -exec test -e {} \; -print` 135if [ "${FAILED}" != "" ] 136then 137 echo "Failed: found broken symbolic links ${FAILED}" | tr '\n' ' ' 138 echo 139 exit 4 140fi 141