From patchwork Thu Jul 26 08:34:26 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yixin Zhang X-Patchwork-Id: 949538 X-Patchwork-Delegate: petr.vorel@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=lists.linux.it (client-ip=2001:1418:10:5::2; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=intel.com Received: from picard.linux.it (picard.linux.it [IPv6:2001:1418:10:5::2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41bllN5KCFz9ryn for ; Thu, 26 Jul 2018 18:34:56 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id AC47F3E61BC for ; Thu, 26 Jul 2018 10:34:53 +0200 (CEST) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-4.smtp.seeweb.it (in-4.smtp.seeweb.it [IPv6:2001:4b78:1:20::4]) by picard.linux.it (Postfix) with ESMTP id BC61C3E6104 for ; Thu, 26 Jul 2018 10:34:51 +0200 (CEST) Received: from mga04.intel.com (mga04.intel.com [192.55.52.120]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by in-4.smtp.seeweb.it (Postfix) with ESMTPS id 09F981001BC5 for ; Thu, 26 Jul 2018 10:34:48 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by fmsmga104.fm.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 26 Jul 2018 01:34:46 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.51,404,1526367600"; d="scan'208";a="59949208" Received: from yixin-desktop.sh.intel.com ([10.239.161.27]) by orsmga008.jf.intel.com with ESMTP; 26 Jul 2018 01:34:38 -0700 From: Yixin Zhang To: ltp@lists.linux.it Date: Thu, 26 Jul 2018 16:34:26 +0800 Message-Id: <20180726083426.19026-1-yixin.zhang@intel.com> X-Mailer: git-send-email 2.14.1 X-Virus-Scanned: clamav-milter 0.99.2 at in-4.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=-0.0 required=7.0 tests=SPF_PASS autolearn=disabled version=3.4.0 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on in-4.smtp.seeweb.it Cc: Yixin Zhang Subject: [LTP] [PATCH v2 ltp] runltp: fix shellcheck error for sending email X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.18 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" runltp:894:11: error: Couldn't parse this test expression. [SC1073] runltp:894:13: error: If grouping expressions inside [..], use \( ..\). [SC1026] runltp:894:15: error: Expected test to end here (don't wrap commands in []/[[]]). Fix any mentioned problems and try again. [SC1072] Change '-o' to '&&' according to the comment and context. Then as "$LOGFILE_NAME" is always not empty, remove below "if" statement and update indentation accordingly: if [ -z "$HTMLFILE_NAME" ] && [ -z "$OUTPUTFILE_NAME" ] && [ -z "$LOGFILE_NAME" ]; then ##User does not have output/logs/html-output, nothing to be mailed in this situation echo "Nothing to be mailed here...." Signed-off-by: Yixin Zhang --- runltp | 139 +++++++++++++++++++++++++++++++---------------------------------- 1 file changed, 67 insertions(+), 72 deletions(-) diff --git a/runltp b/runltp index 24ea94fe5..3f3aa4f53 100755 --- a/runltp +++ b/runltp @@ -890,78 +890,73 @@ main() fi - if [ "$ALT_EMAIL_OUT" -eq 1 ] ; then ## User wants reports to be e-mailed - if [ [ ! "$HTMLFILE_NAME" ] -o [ ! "$OUTPUTFILE_NAME" ] -o [ ! "$LOGFILE_NAME" ] ] ; then - ##User does not have output/logs/html-output, nothing to be mailed in this situation - echo "Nothing to be mailed here...." - else - TAR_FILE_NAME=LTP_RUN_$version_date$DEFAULT_FILE_NAME_GENERATION_TIME.tar - if [ "$HTMLFILE_NAME" ] ; then ## HTML file Exists - if [ "$ALT_HTML_OUT" -ne 1 ] ; then ## The HTML file path is absolute and not $LTPROOT/output - mkdir -p $LTPROOT/output ## We need to create this Directory - cp $HTMLFILE_NAME $LTPROOT/output/ - fi - fi - if [ "$OUTPUTFILE_NAME" ] ; then ## Output file exists - if [ "$ALT_DIR_OUT" -ne 1 ] ; then ## The Output file path is absolute and not $LTPROOT/output - mkdir -p $LTPROOT/output ## We need to create this Directory - cp $OUTPUTFILE_NAME $LTPROOT/output/ - fi - fi - if [ "$LOGFILE_NAME" ] ; then ## Log file exists - if [ "$ALT_DIR_RES" -ne 1 ] ; then ## The Log file path is absolute and not $LTPROOT/results - mkdir -p $LTPROOT/results ## We need to create this Directory - cp $LOGFILE_NAME $LTPROOT/results/ - fi - fi - if [ -d $LTPROOT/output ] ; then - tar -cf ./$TAR_FILE_NAME $LTPROOT/output - if [ $? -eq 0 ]; then - echo "Created TAR File: ./$TAR_FILE_NAME successfully, added $LTPROOT/output" - else - echo "Cannot Create TAR File: ./$TAR_FILE_NAME for adding $LTPROOT/output" - fi - fi - if [ -d $LTPROOT/results ] ; then - tar -uf ./$TAR_FILE_NAME $LTPROOT/results - if [ $? -eq 0 ]; then - echo "Updated TAR File: ./$TAR_FILE_NAME successfully, added $LTPROOT/results" - else - echo "Cannot Update TAR File: ./$TAR_FILE_NAME for adding $LTPROOT/results" - fi - fi - if [ -e $LTPROOT/nohup.out ] ; then ## If User would have Chosen nohup to do ltprun - tar -uf ./$TAR_FILE_NAME $LTPROOT/nohup.out - if [ $? -eq 0 ]; then - echo "Updated TAR File: ./$TAR_FILE_NAME successfully, added $LTPROOT/nohup.out" - else - echo "Cannot Update TAR File: ./$TAR_FILE_NAME for adding $LTPROOT/nohup.out" - fi - fi - gzip ./$TAR_FILE_NAME ## gzip this guy - if [ $? -eq 0 ]; then - echo "Gunzipped TAR File: ./$TAR_FILE_NAME" - else - echo "Cannot Gunzip TAR File: ./$TAR_FILE_NAME" - fi - if which mutt >/dev/null 2>&1; then - echo "Starting mailing reports to: $EMAIL_TO, file: ./$TAR_FILE_NAME.gz" - mutt -a ./$TAR_FILE_NAME.gz -s "LTP Reports on $test_start_time" -- $EMAIL_TO < /dev/null - if [ $? -eq 0 ]; then - echo "Reports Successfully mailed to: $EMAIL_TO" - else - echo "Reports cannot be mailed to: $EMAIL_TO" - fi - else ## Use our Ageold mail program - echo "Starting mailing reports to: $EMAIL_TO, file: ./$TAR_FILE_NAME.gz" - uuencode ./$TAR_FILE_NAME.gz $TAR_FILE_NAME.gz | mail $EMAIL_TO -s "LTP Reports on $test_start_time" - if [ $? -eq 0 ]; then - echo "Reports Successfully mailed to: $EMAIL_TO" - else - echo "Reports cannot be mailed to: $EMAIL_TO" - fi - fi - fi + if [ "$ALT_EMAIL_OUT" -eq 1 ] ; then ## User wants reports to be e-mailed + TAR_FILE_NAME=LTP_RUN_$version_date$DEFAULT_FILE_NAME_GENERATION_TIME.tar + if [ "$HTMLFILE_NAME" ] ; then ## HTML file Exists + if [ "$ALT_HTML_OUT" -ne 1 ] ; then ## The HTML file path is absolute and not $LTPROOT/output + mkdir -p $LTPROOT/output ## We need to create this Directory + cp $HTMLFILE_NAME $LTPROOT/output/ + fi + fi + if [ "$OUTPUTFILE_NAME" ] ; then ## Output file exists + if [ "$ALT_DIR_OUT" -ne 1 ] ; then ## The Output file path is absolute and not $LTPROOT/output + mkdir -p $LTPROOT/output ## We need to create this Directory + cp $OUTPUTFILE_NAME $LTPROOT/output/ + fi + fi + if [ "$LOGFILE_NAME" ] ; then ## Log file exists + if [ "$ALT_DIR_RES" -ne 1 ] ; then ## The Log file path is absolute and not $LTPROOT/results + mkdir -p $LTPROOT/results ## We need to create this Directory + cp $LOGFILE_NAME $LTPROOT/results/ + fi + fi + if [ -d $LTPROOT/output ] ; then + tar -cf ./$TAR_FILE_NAME $LTPROOT/output + if [ $? -eq 0 ]; then + echo "Created TAR File: ./$TAR_FILE_NAME successfully, added $LTPROOT/output" + else + echo "Cannot Create TAR File: ./$TAR_FILE_NAME for adding $LTPROOT/output" + fi + fi + if [ -d $LTPROOT/results ] ; then + tar -uf ./$TAR_FILE_NAME $LTPROOT/results + if [ $? -eq 0 ]; then + echo "Updated TAR File: ./$TAR_FILE_NAME successfully, added $LTPROOT/results" + else + echo "Cannot Update TAR File: ./$TAR_FILE_NAME for adding $LTPROOT/results" + fi + fi + if [ -e $LTPROOT/nohup.out ] ; then ## If User would have Chosen nohup to do ltprun + tar -uf ./$TAR_FILE_NAME $LTPROOT/nohup.out + if [ $? -eq 0 ]; then + echo "Updated TAR File: ./$TAR_FILE_NAME successfully, added $LTPROOT/nohup.out" + else + echo "Cannot Update TAR File: ./$TAR_FILE_NAME for adding $LTPROOT/nohup.out" + fi + fi + gzip ./$TAR_FILE_NAME ## gzip this guy + if [ $? -eq 0 ]; then + echo "Gunzipped TAR File: ./$TAR_FILE_NAME" + else + echo "Cannot Gunzip TAR File: ./$TAR_FILE_NAME" + fi + if which mutt >/dev/null 2>&1; then + echo "Starting mailing reports to: $EMAIL_TO, file: ./$TAR_FILE_NAME.gz" + mutt -a ./$TAR_FILE_NAME.gz -s "LTP Reports on $test_start_time" -- $EMAIL_TO < /dev/null + if [ $? -eq 0 ]; then + echo "Reports Successfully mailed to: $EMAIL_TO" + else + echo "Reports cannot be mailed to: $EMAIL_TO" + fi + else ## Use our Ageold mail program + echo "Starting mailing reports to: $EMAIL_TO, file: ./$TAR_FILE_NAME.gz" + uuencode ./$TAR_FILE_NAME.gz $TAR_FILE_NAME.gz | mail $EMAIL_TO -s "LTP Reports on $test_start_time" + if [ $? -eq 0 ]; then + echo "Reports Successfully mailed to: $EMAIL_TO" + else + echo "Reports cannot be mailed to: $EMAIL_TO" + fi + fi fi [ ! -z "$QUIET_MODE" ] && { echo "INFO: Test end time: $(date)" ; }