tools: selftests: Use "grep -E" instead of "egrep"
Commit Message
The latest version of grep claims the egrep is now obsolete so the build
now contains warnings that look like:
egrep: warning: egrep is obsolescent; using grep -E
fix this up by moving the related file to use "grep -E" instead.
sed -i "s/egrep/grep -E/g" `grep egrep -rwl tools/testing/selftests`
Here are the steps to install the latest grep:
wget http://ftp.gnu.org/gnu/grep/grep-3.8.tar.gz
tar xf grep-3.8.tar.gz
cd grep-3.8 && ./configure && make
sudo make install
export PATH=/usr/local/bin:$PATH
Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
---
.../selftests/ftrace/test.d/preemptirq/irqsoff_tracer.tc | 8 ++++----
tools/testing/selftests/gpio/gpio-sim.sh | 2 +-
tools/testing/selftests/kselftest_deps.sh | 2 +-
tools/testing/selftests/net/toeplitz.sh | 2 +-
tools/testing/selftests/powerpc/scripts/hmi.sh | 2 +-
tools/testing/selftests/rcutorture/bin/console-badness.sh | 2 +-
tools/testing/selftests/rcutorture/bin/kvm-build.sh | 4 ++--
tools/testing/selftests/rcutorture/bin/kvm-find-errors.sh | 4 ++--
tools/testing/selftests/rcutorture/bin/kvm.sh | 4 ++--
tools/testing/selftests/rcutorture/bin/parse-console.sh | 10 +++++-----
10 files changed, 20 insertions(+), 20 deletions(-)
Comments
On 11/18/22 02:28, Tiezhu Yang wrote:
> The latest version of grep claims the egrep is now obsolete so the build
> now contains warnings that look like:
> egrep: warning: egrep is obsolescent; using grep -E
> fix this up by moving the related file to use "grep -E" instead.
>
> sed -i "s/egrep/grep -E/g" `grep egrep -rwl tools/testing/selftests`
>
> Here are the steps to install the latest grep:
>
> wget http://ftp.gnu.org/gnu/grep/grep-3.8.tar.gz
> tar xf grep-3.8.tar.gz
> cd grep-3.8 && ./configure && make
> sudo make install
> export PATH=/usr/local/bin:$PATH
>
Does this change work without the latest grep? It seems to work on
grep (GNU grep) 3.7 when I ran quick test on kselftest_deps.sh with
your change.
> Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
> ---
> .../selftests/ftrace/test.d/preemptirq/irqsoff_tracer.tc | 8 ++++----
> tools/testing/selftests/gpio/gpio-sim.sh | 2 +-
> tools/testing/selftests/kselftest_deps.sh | 2 +-
> tools/testing/selftests/net/toeplitz.sh | 2 +-
> tools/testing/selftests/powerpc/scripts/hmi.sh | 2 +-
> tools/testing/selftests/rcutorture/bin/console-badness.sh | 2 +-
> tools/testing/selftests/rcutorture/bin/kvm-build.sh | 4 ++--
> tools/testing/selftests/rcutorture/bin/kvm-find-errors.sh | 4 ++--
> tools/testing/selftests/rcutorture/bin/kvm.sh | 4 ++--
> tools/testing/selftests/rcutorture/bin/parse-console.sh | 10 +++++-----
> 10 files changed, 20 insertions(+), 20 deletions(-)
>
Please split these into sepratate 5 patches. All rcu changes in one, net in
one, powerpc etc.
The change looks good to me.
thanks,
-- Shuah
On 11/22/2022 11:43 PM, Shuah Khan wrote:
> On 11/18/22 02:28, Tiezhu Yang wrote:
>> The latest version of grep claims the egrep is now obsolete so the build
>> now contains warnings that look like:
>> egrep: warning: egrep is obsolescent; using grep -E
>> fix this up by moving the related file to use "grep -E" instead.
>>
>> sed -i "s/egrep/grep -E/g" `grep egrep -rwl tools/testing/selftests`
>>
>> Here are the steps to install the latest grep:
>>
>> wget http://ftp.gnu.org/gnu/grep/grep-3.8.tar.gz
>> tar xf grep-3.8.tar.gz
>> cd grep-3.8 && ./configure && make
>> sudo make install
>> export PATH=/usr/local/bin:$PATH
>>
>
> Does this change work without the latest grep? It seems to work on
> grep (GNU grep) 3.7 when I ran quick test on kselftest_deps.sh with
> your change.
Yes, AFAIK, "grep -E" is supported by various versions of grep.
We can see the following NEWS in grep-3.8 release announcement [1]:
"The egrep and fgrep commands, which have been deprecated since
release 2.5.3 (2007), now warn that they are obsolescent and should
be replaced by grep -E and grep -F."
[1] https://savannah.gnu.org/forum/forum.php?forum_id=10227
>
>> Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
>> ---
>> .../selftests/ftrace/test.d/preemptirq/irqsoff_tracer.tc | 8
>> ++++----
>> tools/testing/selftests/gpio/gpio-sim.sh | 2 +-
>> tools/testing/selftests/kselftest_deps.sh | 2 +-
>> tools/testing/selftests/net/toeplitz.sh | 2 +-
>> tools/testing/selftests/powerpc/scripts/hmi.sh | 2 +-
>> tools/testing/selftests/rcutorture/bin/console-badness.sh | 2 +-
>> tools/testing/selftests/rcutorture/bin/kvm-build.sh | 4
>> ++--
>> tools/testing/selftests/rcutorture/bin/kvm-find-errors.sh | 4
>> ++--
>> tools/testing/selftests/rcutorture/bin/kvm.sh | 4
>> ++--
>> tools/testing/selftests/rcutorture/bin/parse-console.sh | 10
>> +++++-----
>> 10 files changed, 20 insertions(+), 20 deletions(-)
>>
>
> Please split these into sepratate 5 patches. All rcu changes in one, net in
> one, powerpc etc.
OK, maybe 6 patches,
(1) rcutorture
(2) ftrace
(3) powerpc
(4) gpio
(5) net
(6) kselftest_deps.sh
>
> The change looks good to me.
Thank you, I will send v2 later.
Thanks,
Tiezhu
@@ -46,10 +46,10 @@ cat trace
grep -q "tracer: preemptoff" trace || fail
# Check the end of the section
-egrep -q "5.....us : <stack trace>" trace || fail
+grep -E -q "5.....us : <stack trace>" trace || fail
# Check for 500ms of latency
-egrep -q "latency: 5..... us" trace || fail
+grep -E -q "latency: 5..... us" trace || fail
reset_tracer
@@ -69,10 +69,10 @@ cat trace
grep -q "tracer: irqsoff" trace || fail
# Check the end of the section
-egrep -q "5.....us : <stack trace>" trace || fail
+grep -E -q "5.....us : <stack trace>" trace || fail
# Check for 500ms of latency
-egrep -q "latency: 5..... us" trace || fail
+grep -E -q "latency: 5..... us" trace || fail
reset_tracer
exit 0
@@ -27,7 +27,7 @@ remove_chip() {
continue
fi
- LINES=`ls $CONFIGFS_DIR/$CHIP/$BANK/ | egrep ^line`
+ LINES=`ls $CONFIGFS_DIR/$CHIP/$BANK/ | grep -E ^line`
if [ "$?" = 0 ]; then
for LINE in $LINES; do
if [ -e $CONFIGFS_DIR/$CHIP/$BANK/$LINE/hog ]; then
@@ -90,7 +90,7 @@ pass_libs=()
pass_cnt=0
# Get all TARGETS from selftests Makefile
-targets=$(egrep "^TARGETS +|^TARGETS =" Makefile | cut -d "=" -f2)
+targets=$(grep -E "^TARGETS +|^TARGETS =" Makefile | cut -d "=" -f2)
# Single test case
if [ $# -eq 2 ]
@@ -32,7 +32,7 @@ DEV="eth0"
# This is determined by reading the RSS indirection table using ethtool.
get_rss_cfg_num_rxqs() {
echo $(ethtool -x "${DEV}" |
- egrep [[:space:]]+[0-9]+:[[:space:]]+ |
+ grep -E [[:space:]]+[0-9]+:[[:space:]]+ |
cut -d: -f2- |
awk '{$1=$1};1' |
tr ' ' '\n' |
@@ -36,7 +36,7 @@ trap "ppc64_cpu --smt-snooze-delay=100" 0 1
# for each chip+core combination
# todo - less fragile parsing
-egrep -o 'OCC: Chip [0-9a-f]+ Core [0-9a-f]' < /sys/firmware/opal/msglog |
+grep -E -o 'OCC: Chip [0-9a-f]+ Core [0-9a-f]' < /sys/firmware/opal/msglog |
while read chipcore; do
chip=$(echo "$chipcore"|awk '{print $3}')
core=$(echo "$chipcore"|awk '{print $5}')
@@ -10,7 +10,7 @@
#
# Authors: Paul E. McKenney <paulmck@kernel.org>
-egrep 'Badness|WARNING:|Warn|BUG|===========|BUG: KCSAN:|Call Trace:|Oops:|detected stalls on CPUs/tasks:|self-detected stall on CPU|Stall ended before state dump start|\?\?\? Writer stall state|rcu_.*kthread starved for|!!!' |
+grep -E 'Badness|WARNING:|Warn|BUG|===========|BUG: KCSAN:|Call Trace:|Oops:|detected stalls on CPUs/tasks:|self-detected stall on CPU|Stall ended before state dump start|\?\?\? Writer stall state|rcu_.*kthread starved for|!!!' |
grep -v 'ODEBUG: ' |
grep -v 'This means that this is a DEBUG kernel and it is' |
grep -v 'Warning: unable to open an initial console' |
@@ -45,10 +45,10 @@ fi
ncpus="`getconf _NPROCESSORS_ONLN`"
make -j$((2 * ncpus)) $TORTURE_KMAKE_ARG > $resdir/Make.out 2>&1
retval=$?
-if test $retval -ne 0 || grep "rcu[^/]*": < $resdir/Make.out | egrep -q "Stop|Error|error:|warning:" || egrep -q "Stop|Error|error:" < $resdir/Make.out
+if test $retval -ne 0 || grep "rcu[^/]*": < $resdir/Make.out | grep -E -q "Stop|Error|error:|warning:" || grep -E -q "Stop|Error|error:" < $resdir/Make.out
then
echo Kernel build error
- egrep "Stop|Error|error:|warning:" < $resdir/Make.out
+ grep -E "Stop|Error|error:|warning:" < $resdir/Make.out
echo Run aborted.
exit 3
fi
@@ -32,9 +32,9 @@ for i in ${rundir}/*/Make.out
do
scenariodir="`dirname $i`"
scenariobasedir="`echo ${scenariodir} | sed -e 's/\.[0-9]*$//'`"
- if egrep -q "error:|warning:|^ld: .*undefined reference to" < $i
+ if grep -E -q "error:|warning:|^ld: .*undefined reference to" < $i
then
- egrep "error:|warning:|^ld: .*undefined reference to" < $i > $i.diags
+ grep -E "error:|warning:|^ld: .*undefined reference to" < $i > $i.diags
files="$files $i.diags $i"
elif ! test -f ${scenariobasedir}/vmlinux && ! test -f "${rundir}/re-run"
then
@@ -586,7 +586,7 @@ awk < $T/cfgcpu.pack \
echo kvm-end-run-stats.sh "$resdir/$ds" "$starttime" >> $T/script
# Extract the tests and their batches from the script.
-egrep 'Start batch|Starting build\.' $T/script | grep -v ">>" |
+grep -E 'Start batch|Starting build\.' $T/script | grep -v ">>" |
sed -e 's/:.*$//' -e 's/^echo //' -e 's/-ovf//' |
awk '
/^----Start/ {
@@ -623,7 +623,7 @@ then
elif test "$dryrun" = sched
then
# Extract the test run schedule from the script.
- egrep 'Start batch|Starting build\.' $T/script | grep -v ">>" |
+ grep -E 'Start batch|Starting build\.' $T/script | grep -v ">>" |
sed -e 's/:.*$//' -e 's/^echo //'
nbuilds="`grep 'Starting build\.' $T/script |
grep -v ">>" | sed -e 's/:.*$//' -e 's/^echo //' |
@@ -65,7 +65,7 @@ then
fi
grep --binary-files=text 'torture:.*ver:' $file |
- egrep --binary-files=text -v '\(null\)|rtc: 000000000* ' |
+ grep -E --binary-files=text -v '\(null\)|rtc: 000000000* ' |
sed -e 's/^(initramfs)[^]]*] //' -e 's/^\[[^]]*] //' |
sed -e 's/^.*ver: //' |
awk '
@@ -128,17 +128,17 @@ then
then
summary="$summary Badness: $n_badness"
fi
- n_warn=`grep -v 'Warning: unable to open an initial console' $file | grep -v 'Warning: Failed to add ttynull console. No stdin, stdout, and stderr for the init process' | egrep -c 'WARNING:|Warn'`
+ n_warn=`grep -v 'Warning: unable to open an initial console' $file | grep -v 'Warning: Failed to add ttynull console. No stdin, stdout, and stderr for the init process' | grep -E -c 'WARNING:|Warn'`
if test "$n_warn" -ne 0
then
summary="$summary Warnings: $n_warn"
fi
- n_bugs=`egrep -c '\bBUG|Oops:' $file`
+ n_bugs=`grep -E -c '\bBUG|Oops:' $file`
if test "$n_bugs" -ne 0
then
summary="$summary Bugs: $n_bugs"
fi
- n_kcsan=`egrep -c 'BUG: KCSAN: ' $file`
+ n_kcsan=`grep -E -c 'BUG: KCSAN: ' $file`
if test "$n_kcsan" -ne 0
then
if test "$n_bugs" = "$n_kcsan"
@@ -158,7 +158,7 @@ then
then
summary="$summary lockdep: $n_badness"
fi
- n_stalls=`egrep -c 'detected stalls on CPUs/tasks:|self-detected stall on CPU|Stall ended before state dump start|\?\?\? Writer stall state' $file`
+ n_stalls=`grep -E -c 'detected stalls on CPUs/tasks:|self-detected stall on CPU|Stall ended before state dump start|\?\?\? Writer stall state' $file`
if test "$n_stalls" -ne 0
then
summary="$summary Stalls: $n_stalls"