mirror of
https://github.com/checkpoint-restore/criu.git
synced 2026-01-23 02:14:37 +00:00
Optimized shell code with <'s (instead of cat + |)
This patch optimizes shell code as reading a single file as input using a 'cat' command to a program. It is considered to be a Useless Use of Cat (UUOC). It's more efficient to simply use redirection. However, in some cases, even using the redirection operator '<' seems unnecessary. Signed-off-by: KKrypt <sankalpacharya1211@gmail.com>
This commit is contained in:
parent
7cae16e971
commit
34e2b02219
13 changed files with 16 additions and 16 deletions
|
|
@ -9,7 +9,7 @@ prep
|
|||
./test/zdtm.py run -t zdtm/static/maps00 --fault 3 --report report -f h || fail
|
||||
|
||||
# FIXME: fhandles looks broken on btrfs
|
||||
cat /proc/self/mountinfo | grep -P "/.* / " | grep -q btrfs || NOBTRFS=$?
|
||||
grep -P "/.* / " /proc/self/mountinfo | grep -q btrfs || NOBTRFS=$?
|
||||
if [ $NOBTRFS -eq 1 ] ; then
|
||||
./test/zdtm.py run -t zdtm/static/inotify_irmap --fault 128 --pre 2 -f uns || fail
|
||||
fi
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ function stop_test {
|
|||
wtime=1
|
||||
cd ../../zdtm/static/
|
||||
make maps04.stop
|
||||
cat maps04.out | fgrep PASS || fail "Test failed"
|
||||
fgrep PASS maps04.out || fail "Test failed"
|
||||
echo "OK"
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -72,6 +72,6 @@ ${CRIU} restore -D "${IMGDIR}/$NRSNAP/" -o restore.log -d -v4 || fail "Fail to r
|
|||
|
||||
cd ../../zdtm/static/
|
||||
make mem-touch.stop
|
||||
cat mem-touch.out | fgrep PASS || fail "Test failed"
|
||||
fgrep PASS mem-touch.out || fail "Test failed"
|
||||
|
||||
echo "Test PASSED"
|
||||
|
|
|
|||
|
|
@ -84,7 +84,7 @@ ${CRIU} restore -D "${IMGDIR}/$NRSNAP/" -o restore.log -d -v4 || fail "Fail to r
|
|||
|
||||
cd ../../zdtm/static/
|
||||
make mem-touch.stop
|
||||
cat mem-touch.out | fgrep PASS || fail "Test failed"
|
||||
fgrep PASS mem-touch.out || fail "Test failed"
|
||||
|
||||
if [[ $dedup_ok_2 -ne 0 || $dedup_ok_1 -ne 0 ]]; then
|
||||
fail "Dedup test failed"
|
||||
|
|
|
|||
|
|
@ -78,7 +78,7 @@ fi
|
|||
|
||||
cd ../../zdtm/static/
|
||||
make mem-touch.stop
|
||||
cat mem-touch.out | fgrep PASS || fail "Test failed"
|
||||
fgrep PASS mem-touch.out || fail "Test failed"
|
||||
|
||||
if [ $restore_dedup_ok -ne 0 ]; then
|
||||
fail "Dedup test failed"
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@ ${CRIU} restore -D "${IMGDIR}/$NRSNAP/" -o restore.log -d -v4 || fail "Fail to r
|
|||
|
||||
cd ../../zdtm/static/
|
||||
make mem-touch.stop
|
||||
cat mem-touch.out | fgrep PASS || fail "Test failed"
|
||||
fgrep PASS mem-touch.out || fail "Test failed"
|
||||
|
||||
if [[ $dedup_ok_2 -ne 0 || $dedup_ok_1 -ne 0 ]]; then
|
||||
fail "Dedup test failed"
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ ${CRIU} restore -D "${IMGDIR}/$NRSNAP/" -o restore.log --auto-dedup -d -v4 || fa
|
|||
make -C ../../zdtm/static/ maps04.stop
|
||||
sleep 1
|
||||
|
||||
cat "../zdtm/static/maps04.out" | fgrep PASS || fail "Test failed"
|
||||
fgrep PASS "../zdtm/static/maps04.out" || fail "Test failed"
|
||||
|
||||
size=$(du -sh -BK dump/1/pages-*.img | grep -Eo '[0-9]+' | head -1)
|
||||
if [ $size -ne 0 ] ; then
|
||||
|
|
|
|||
|
|
@ -69,6 +69,6 @@ ${CRIU} restore -D "${IMGDIR}/$NRSNAP/" -o restore.log -d -v4 || fail "Fail to r
|
|||
|
||||
cd ../../zdtm/static/
|
||||
make mem-touch.stop
|
||||
cat mem-touch.out | fgrep PASS || fail "Test failed"
|
||||
fgrep PASS mem-touch.out || fail "Test failed"
|
||||
|
||||
echo "Test PASSED"
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@ cd $INMNTNS
|
|||
|
||||
mount --make-rprivate /
|
||||
|
||||
for i in `cat /proc/self/mounts | awk '{ print $2 }'`; do
|
||||
for i in `awk '{ print $2 }' < /proc/self/mounts`; do
|
||||
[ '/' = "$i" ] && continue
|
||||
[ '/proc' = "$i" ] && continue
|
||||
[ '/dev' = "$i" ] && continue
|
||||
|
|
|
|||
|
|
@ -12,12 +12,12 @@ kill -0 $pid || exit
|
|||
cat /proc/$pid/mountinfo | sort -k 4
|
||||
echo "Suspend server"
|
||||
${CRIU} dump -D dump -o dump.log -t $pid -v4 || {
|
||||
cat dump/dump.log | grep Error
|
||||
grep Error dump/dump.log
|
||||
exit 1
|
||||
}
|
||||
echo "Resume server"
|
||||
${CRIU} restore -d -D dump -o restore.log -v4 || {
|
||||
cat dump/dump.log | grep Error
|
||||
grep Error dump/dump.log
|
||||
exit 1
|
||||
}
|
||||
cat /proc/$pid/mountinfo | sort -k 4
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ exec 33< $MNT1
|
|||
exec 34< $MNT2
|
||||
$CRIU dump -v4 -t $pid -o dump.log -D images --external $NS[$ino]:test_ns --external $NS[$ino2]:test_ns2
|
||||
RESULT=$?
|
||||
cat images/dump.log | grep -B 5 Error || echo ok
|
||||
grep -B 5 Error images/dump.log || echo ok
|
||||
[ "$RESULT" != "0" ] && {
|
||||
echo "CRIU dump failed"
|
||||
echo FAIL
|
||||
|
|
@ -70,7 +70,7 @@ cat images/dump.log | grep -B 5 Error || echo ok
|
|||
|
||||
$CRIU restore -v4 -o restore.log -D images --inherit-fd fd[33]:test_ns --inherit-fd fd[34]:test_ns2 -d
|
||||
RESULT=$?
|
||||
cat images/restore.log | grep -B 5 Error || echo ok
|
||||
grep -B 5 Error images/restore.log || echo ok
|
||||
[ "$RESULT" != "0" ] && {
|
||||
echo "CRIU restore failed"
|
||||
echo FAIL
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ mkdir -p images_pidns
|
|||
echo "$CRIU dump -v4 -o dump.log -t $PID -D images_pidns --external $PIDNS:exti"
|
||||
$CRIU dump -v4 -o dump.log -t $PID -D images_pidns --external $PIDNS:exti
|
||||
RESULT=$?
|
||||
cat images_pidns/dump.log | grep -B 5 Error || echo ok
|
||||
grep -B 5 Error images_pidns/dump.log || echo ok
|
||||
[ "$RESULT" != "0" ] && {
|
||||
echo "CRIU dump failed"
|
||||
echo FAIL
|
||||
|
|
@ -48,7 +48,7 @@ exec {pidns_fd}< /proc/self/ns/pid
|
|||
echo "$CRIU restore -v4 -o restore.log -D images_pidns --restore-detached --inherit-fd fd[$pidns_fd]:exti"
|
||||
$CRIU restore -v4 -o restore.log -D images_pidns --restore-detached --inherit-fd fd[$pidns_fd]:exti --pidfile test.pidfile
|
||||
RESULT=$?
|
||||
cat images_pidns/restore.log | grep -B 5 Error || echo ok
|
||||
grep -B 5 Error images_pidns/restore.log || echo ok
|
||||
[ "$RESULT" != "0" ] && {
|
||||
echo "CRIU restore failed"
|
||||
echo FAIL
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@ done
|
|||
${CRIU} restore -D data -o restore.log -v4 --lib `pwd`/lib -d || exit 1
|
||||
kill $pid
|
||||
while :; do
|
||||
cat output | grep PASS && break
|
||||
grep PASS output && break
|
||||
sleep 1
|
||||
done
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue