* [PATCH] common/filter: Don't use strtonum
@ 2019-12-02 9:43 Kusanagi Kouichi
2019-12-08 15:50 ` Eryu Guan
0 siblings, 1 reply; 5+ messages in thread
From: Kusanagi Kouichi @ 2019-12-02 9:43 UTC (permalink / raw)
To: fstests
It's a gawk extension and not needed. Make tests pass with non-gawk.
Signed-off-by: Kusanagi Kouichi <slash@ac.auone-net.jp>
---
common/filter | 23 +++++++++++++----------
tests/generic/386 | 2 +-
tests/xfs/009 | 10 +++++-----
3 files changed, 19 insertions(+), 16 deletions(-)
diff --git a/common/filter b/common/filter
index 2477f386..e02cc0b9 100644
--- a/common/filter
+++ b/common/filter
@@ -241,9 +241,9 @@ _filter_xfs_io_units_modified()
/wrote/ {
split($2, bytes, "/")
- bytes_written = strtonum(bytes[1])
+ bytes_written = bytes[1]
- offset = strtonum($NF)
+ offset = $NF
unit_start = offset / unit_size
unit_start = int(unit_start)
@@ -487,14 +487,17 @@ _filter_busy_mount()
_filter_od()
{
BLOCK_SIZE=$(_get_block_size $SCRATCH_MNT)
- $AWK_PROG -v block_size=$BLOCK_SIZE '
- /^[0-9]+/ {
- offset = strtonum("0"$1);
- $1 = sprintf("%o", offset / block_size);
- print $0;
- }
- /\*/
- '
+ while read line
+ do
+ if test "$line" = '*'
+ then
+ printf '*\n'
+ continue
+ fi
+
+ offset="${line%% *}"
+ printf '%o%s\n' $((offset / BLOCK_SIZE)) "${line#$offset}"
+ done
}
# Remove quotes from failed mknod calls. Starting with Coreutils v8.25,
diff --git a/tests/generic/386 b/tests/generic/386
index 462c5869..ba6e654e 100755
--- a/tests/generic/386
+++ b/tests/generic/386
@@ -75,7 +75,7 @@ _filter_quota_rpt() {
# This function parses the human-readable values produced
# by xfs_quota output
function byte_size(value, result) {
- result = strtonum(value);
+ result = value;
unit = value;
gsub("[0-9][0-9]*", "", unit);
shift = index("KMGTPE", unit);
diff --git a/tests/xfs/009 b/tests/xfs/009
index 6a31514c..956c4772 100755
--- a/tests/xfs/009
+++ b/tests/xfs/009
@@ -66,12 +66,12 @@ _block_filter()
/CMD/ {
split($3, off, "=")
- offset = strtonum(off[2])
+ offset = off[2]
if (offset != -1)
offset = offset / bsize
split($4, len, "=")
- nr_blocks = strtonum(len[2])
+ nr_blocks = len[2]
if (nr_blocks != -1)
nr_blocks = nr_blocks / bsize
@@ -82,13 +82,13 @@ _block_filter()
/MAP/ {
split($2, off, "=")
- offset = strtonum(off[2])
+ offset = off[2]
if (offset != -1)
offset = offset / bsize
split($3, len, "=")
- nr_blocks = strtonum(len[2])
+ nr_blocks = len[2]
if (nr_blocks != -1)
nr_blocks = nr_blocks / bsize
@@ -100,7 +100,7 @@ _block_filter()
/TRUNCATE/ {
split($2, off, "=")
- offset = strtonum(off[2]) / bsize
+ offset = off[2] / bsize
printf(" %s off=%s\n", $1, offset)
--
2.24.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
* Re: [PATCH] common/filter: Don't use strtonum
2019-12-02 9:43 [PATCH] common/filter: Don't use strtonum Kusanagi Kouichi
@ 2019-12-08 15:50 ` Eryu Guan
0 siblings, 0 replies; 5+ messages in thread
From: Eryu Guan @ 2019-12-08 15:50 UTC (permalink / raw)
To: Kusanagi Kouichi; +Cc: fstests
On Mon, Dec 02, 2019 at 06:43:01PM +0900, Kusanagi Kouichi wrote:
> It's a gawk extension and not needed. Make tests pass with non-gawk.
gawk is listed in README as one of the "prerequisite packages", so I
think using gawk extention is fine. But if we could get rid of it
easily, that will be better.
Thanks for the fix!
Eryu
>
> Signed-off-by: Kusanagi Kouichi <slash@ac.auone-net.jp>
> ---
> common/filter | 23 +++++++++++++----------
> tests/generic/386 | 2 +-
> tests/xfs/009 | 10 +++++-----
> 3 files changed, 19 insertions(+), 16 deletions(-)
>
> diff --git a/common/filter b/common/filter
> index 2477f386..e02cc0b9 100644
> --- a/common/filter
> +++ b/common/filter
> @@ -241,9 +241,9 @@ _filter_xfs_io_units_modified()
> /wrote/ {
> split($2, bytes, "/")
>
> - bytes_written = strtonum(bytes[1])
> + bytes_written = bytes[1]
>
> - offset = strtonum($NF)
> + offset = $NF
>
> unit_start = offset / unit_size
> unit_start = int(unit_start)
> @@ -487,14 +487,17 @@ _filter_busy_mount()
> _filter_od()
> {
> BLOCK_SIZE=$(_get_block_size $SCRATCH_MNT)
> - $AWK_PROG -v block_size=$BLOCK_SIZE '
> - /^[0-9]+/ {
> - offset = strtonum("0"$1);
> - $1 = sprintf("%o", offset / block_size);
> - print $0;
> - }
> - /\*/
> - '
> + while read line
> + do
> + if test "$line" = '*'
> + then
> + printf '*\n'
> + continue
> + fi
> +
> + offset="${line%% *}"
> + printf '%o%s\n' $((offset / BLOCK_SIZE)) "${line#$offset}"
> + done
> }
>
> # Remove quotes from failed mknod calls. Starting with Coreutils v8.25,
> diff --git a/tests/generic/386 b/tests/generic/386
> index 462c5869..ba6e654e 100755
> --- a/tests/generic/386
> +++ b/tests/generic/386
> @@ -75,7 +75,7 @@ _filter_quota_rpt() {
> # This function parses the human-readable values produced
> # by xfs_quota output
> function byte_size(value, result) {
> - result = strtonum(value);
> + result = value;
> unit = value;
> gsub("[0-9][0-9]*", "", unit);
> shift = index("KMGTPE", unit);
> diff --git a/tests/xfs/009 b/tests/xfs/009
> index 6a31514c..956c4772 100755
> --- a/tests/xfs/009
> +++ b/tests/xfs/009
> @@ -66,12 +66,12 @@ _block_filter()
>
> /CMD/ {
> split($3, off, "=")
> - offset = strtonum(off[2])
> + offset = off[2]
> if (offset != -1)
> offset = offset / bsize
>
> split($4, len, "=")
> - nr_blocks = strtonum(len[2])
> + nr_blocks = len[2]
> if (nr_blocks != -1)
> nr_blocks = nr_blocks / bsize
>
> @@ -82,13 +82,13 @@ _block_filter()
>
> /MAP/ {
> split($2, off, "=")
> - offset = strtonum(off[2])
> + offset = off[2]
> if (offset != -1)
> offset = offset / bsize
>
> split($3, len, "=")
>
> - nr_blocks = strtonum(len[2])
> + nr_blocks = len[2]
>
> if (nr_blocks != -1)
> nr_blocks = nr_blocks / bsize
> @@ -100,7 +100,7 @@ _block_filter()
>
> /TRUNCATE/ {
> split($2, off, "=")
> - offset = strtonum(off[2]) / bsize
> + offset = off[2] / bsize
>
> printf(" %s off=%s\n", $1, offset)
>
> --
> 2.24.0
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] common/filter: Don't use strtonum
2019-12-01 15:47 ` Eryu Guan
@ 2019-12-02 9:34 ` Kusanagi Kouichi
0 siblings, 0 replies; 5+ messages in thread
From: Kusanagi Kouichi @ 2019-12-02 9:34 UTC (permalink / raw)
To: Eryu Guan; +Cc: fstests
On 2019-12-01 23:47:47 +0800, Eryu Guan wrote:
> On Fri, Nov 29, 2019 at 04:21:08PM +0900, Kusanagi Kouichi wrote:
> > It's a gawk extension and not needed. Make tests pass with non-gawk.
> >
> > Signed-off-by: Kusanagi Kouichi <slash@ac.auone-net.jp>
>
> I noticed that you sent another two patches that fix similar issue in
> another test. I think we could fold them into one patch that fixes all
> the strtonum problem.
>
> Thanks,
> Eryu
I'll fold them into this patch and resend.
^ permalink raw reply [flat|nested] 5+ messages in thread
* Re: [PATCH] common/filter: Don't use strtonum
2019-11-29 7:21 Kusanagi Kouichi
@ 2019-12-01 15:47 ` Eryu Guan
2019-12-02 9:34 ` Kusanagi Kouichi
0 siblings, 1 reply; 5+ messages in thread
From: Eryu Guan @ 2019-12-01 15:47 UTC (permalink / raw)
To: Kusanagi Kouichi; +Cc: fstests
On Fri, Nov 29, 2019 at 04:21:08PM +0900, Kusanagi Kouichi wrote:
> It's a gawk extension and not needed. Make tests pass with non-gawk.
>
> Signed-off-by: Kusanagi Kouichi <slash@ac.auone-net.jp>
I noticed that you sent another two patches that fix similar issue in
another test. I think we could fold them into one patch that fixes all
the strtonum problem.
Thanks,
Eryu
> ---
> common/filter | 23 +++++++++++++----------
> 1 file changed, 13 insertions(+), 10 deletions(-)
>
> diff --git a/common/filter b/common/filter
> index 2477f386..e02cc0b9 100644
> --- a/common/filter
> +++ b/common/filter
> @@ -241,9 +241,9 @@ _filter_xfs_io_units_modified()
> /wrote/ {
> split($2, bytes, "/")
>
> - bytes_written = strtonum(bytes[1])
> + bytes_written = bytes[1]
>
> - offset = strtonum($NF)
> + offset = $NF
>
> unit_start = offset / unit_size
> unit_start = int(unit_start)
> @@ -487,14 +487,17 @@ _filter_busy_mount()
> _filter_od()
> {
> BLOCK_SIZE=$(_get_block_size $SCRATCH_MNT)
> - $AWK_PROG -v block_size=$BLOCK_SIZE '
> - /^[0-9]+/ {
> - offset = strtonum("0"$1);
> - $1 = sprintf("%o", offset / block_size);
> - print $0;
> - }
> - /\*/
> - '
> + while read line
> + do
> + if test "$line" = '*'
> + then
> + printf '*\n'
> + continue
> + fi
> +
> + offset="${line%% *}"
> + printf '%o%s\n' $((offset / BLOCK_SIZE)) "${line#$offset}"
> + done
> }
>
> # Remove quotes from failed mknod calls. Starting with Coreutils v8.25,
> --
> 2.24.0
>
^ permalink raw reply [flat|nested] 5+ messages in thread
* [PATCH] common/filter: Don't use strtonum
@ 2019-11-29 7:21 Kusanagi Kouichi
2019-12-01 15:47 ` Eryu Guan
0 siblings, 1 reply; 5+ messages in thread
From: Kusanagi Kouichi @ 2019-11-29 7:21 UTC (permalink / raw)
To: fstests
It's a gawk extension and not needed. Make tests pass with non-gawk.
Signed-off-by: Kusanagi Kouichi <slash@ac.auone-net.jp>
---
common/filter | 23 +++++++++++++----------
1 file changed, 13 insertions(+), 10 deletions(-)
diff --git a/common/filter b/common/filter
index 2477f386..e02cc0b9 100644
--- a/common/filter
+++ b/common/filter
@@ -241,9 +241,9 @@ _filter_xfs_io_units_modified()
/wrote/ {
split($2, bytes, "/")
- bytes_written = strtonum(bytes[1])
+ bytes_written = bytes[1]
- offset = strtonum($NF)
+ offset = $NF
unit_start = offset / unit_size
unit_start = int(unit_start)
@@ -487,14 +487,17 @@ _filter_busy_mount()
_filter_od()
{
BLOCK_SIZE=$(_get_block_size $SCRATCH_MNT)
- $AWK_PROG -v block_size=$BLOCK_SIZE '
- /^[0-9]+/ {
- offset = strtonum("0"$1);
- $1 = sprintf("%o", offset / block_size);
- print $0;
- }
- /\*/
- '
+ while read line
+ do
+ if test "$line" = '*'
+ then
+ printf '*\n'
+ continue
+ fi
+
+ offset="${line%% *}"
+ printf '%o%s\n' $((offset / BLOCK_SIZE)) "${line#$offset}"
+ done
}
# Remove quotes from failed mknod calls. Starting with Coreutils v8.25,
--
2.24.0
^ permalink raw reply related [flat|nested] 5+ messages in thread
end of thread, other threads:[~2019-12-08 15:50 UTC | newest]
Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-12-02 9:43 [PATCH] common/filter: Don't use strtonum Kusanagi Kouichi
2019-12-08 15:50 ` Eryu Guan
-- strict thread matches above, loose matches on Subject: below --
2019-11-29 7:21 Kusanagi Kouichi
2019-12-01 15:47 ` Eryu Guan
2019-12-02 9:34 ` Kusanagi Kouichi
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.