Skip to contentSkip to conversation

Change "mv $targetdir/log $logdir/$log" to "cp $targetdir/log $logdir/$log"

PATCH Yi Zhang 2 participants 2 messages Sep 7, 2015 – Oct 9, 2015 1 message not in the archive MD RAID

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

Yi Zhang

author
#1 lore raw

Hi Neil
When I execute mdadm test with --save-logs set, found below error, could you help check it?

Error log:
tests/10ddf-fail-readd... FAILED - see /var/tmp/log-10ddf-fail-readd for details
cp: cannot stat ‘/var/tmp/log’: No such file or directory

Code:
if ( set -ex ; . $_script ) &> $targetdir/log
then
echo "succeeded"
_fail=0
else
log=log
cat $targetdir/stderr >> $targetdir/log
echo "=======================dmesg=================" >> $targetdir/log dmesg | tail -n 200 >> $targetdir/log
if [ $exitonerror == 0 ]; then
log=log-basename $_script
mv $targetdir/log $logdir/$log // This step will move $targetdir/log to $logdir/$log,
fi
echo "FAILED - see $logdir/$log for details"
_fail=1
fi
if [ "$savelogs" == "1" ]; then
cp $targetdir/log $logdir/$_basename.log // If I set $savelogs here, the $targetdir/log doesn't exist now
fi

So could we change the mv to cp?

test +1 -1
index d0a6cb8..118fa96 100755
@@ -318,7 +318,7 @@ do_test() {
       dmesg | tail -n 200 >> $targetdir/log
       if [ $exitonerror == 0 ]; then
          log=log-`basename $_script`
-         mv $targetdir/log $logdir/$log
+         cp $targetdir/log $logdir/$log
       fi
       echo "FAILED - see $logdir/$log for details"
       _fail=1

Best Regards,
Yi Zhang

--
To unsubscribe from this list: send the line "unsubscribe linux-raid" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html

#2 lore raw
Quoted 7 lines · Yi Zhang

Hi Neil
When I execute mdadm test with --save-logs set, found below error, could you help check it?

Error log:
tests/10ddf-fail-readd... FAILED - see /var/tmp/log-10ddf-fail-readd for details
cp: cannot stat ‘/var/tmp/log’: No such file or directory

Thanks for the report.
I've applied the following which should fix this (and other issues).

Thanks,
NeilBrown

From c54f485288b50c90fa289e79fa66ae01e9162a2d Mon Sep 17 00:00:00 2001
From: NeilBrown <[email protected]>
Date: Fri, 9 Oct 2015 16:00:59 +1100
Subject: [PATCH] test: don't move $target/log

Recent change to rename $target/log to a more stable name on error broke --save-logs as $targetdir/log no longer existed to be copied.

So change it to a 'cp', not a 'mv'.
While we are fixing things, use $_basename instead of calling basename again, and only use "$logdir" if logs were requested.

And make use "see .. for details" has correct file name.

test +4 -4
index d0a6cb858212..5315ab97dde0 100755
@@ -17,7 +17,6 @@ then
 fi
 
 testdir="tests"
-logdir="$testdir/logs"
 logsave=0
 exitonerror=1
 
@@ -317,10 +316,11 @@ do_test() {
       echo "=======================dmesg=================" >> $targetdir/log
       dmesg | tail -n 200 >> $targetdir/log
       if [ $exitonerror == 0 ]; then
-	  log=log-`basename $_script`
-	  mv $targetdir/log $logdir/$log
+	  cp $targetdir/log $targetdir/log-$_basename
+	  echo "FAILED - see $targetdir/log-$_basename for details"
+      else
+	  echo "FAILED - see $targetdir/log for details"
       fi
-      echo "FAILED - see $logdir/$log for details"
       _fail=1
     fi
     if [ "$savelogs" == "1" ]; then