Skip to contentSkip to conversation

Test exit code fixlets

PATCH In review Sam James 3 participants 10 messages Aug 20, 2024 – Oct 12, 2024

lore
Share & tools
lore

Sam James

author
#0 lore raw

cover Test exit code fixlets

A small set of exit code fixes to tests.

There are some other issues that are worth discussing, like pipelines and ignoring the exit code there, but a lot of that stuff doesn't matter *too* much given the test output is checked anyway.

Sam James (3):
test: fix exit code in tst.ipv4remotetcp.sh
test: fix exit code typo in tst.core.sh
test: fix exit code in tst.newprobes.sh

 test/unittest/ip/tst.ipv4remotetcp.sh | 2 +-
 test/unittest/options/tst.core.sh     | 2 +-
 test/unittest/pid/tst.newprobes.sh    | 2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

base-commit: c84954cdc6fb017034e2c3fe4445a7c8981d35e9

Signature · 1 line
2.46.0
author
#1 lore raw

PATCH 1/3 test: fix exit code in tst.ipv4remotetcp.sh

$? was clobbered by the status=$? assignment above, see:

```
$ bash -c 'false ; x=$? ; echo $? ; echo ${x}'
0
1
```

We could just drop the status assignment but I just chose to do this instead.

---
 test/unittest/ip/tst.ipv4remotetcp.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
test/unittest/ip/tst.ipv4remotetcp.sh +1 -1
index 32c3435a..99ba1161 100755
@@ -98,4 +98,4 @@ EODTRACE
 
 status=$?
 
-exit $?
+exit ${status}
Signature · 1 line
2.46.0
Reviewed-by on v1 1/3
#2 lore raw

Re: [PATCH 1/3] test: fix exit code in tst.ipv4remotetcp.sh

Quoted 9 lines · Sam James

$? was clobbered by the status=$? assignment above, see:

```
$ bash -c 'false ; x=$? ; echo $? ; echo ${x}'
0
1
```

We could just drop the status assignment but I just chose to do this instead.

... and committed with Signed-off-by added.

Quoted 17 lines
---
 test/unittest/ip/tst.ipv4remotetcp.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
test/unittest/ip/tst.ipv4remotetcp.sh +1 -1
index 32c3435a..99ba1161 100755
@@ -98,4 +98,4 @@ EODTRACE
 
 status=$?
 
-exit $?
+exit ${status}
Signature · 1 line
2.46.0
author
#3 lore raw

PATCH 2/3 test: fix exit code typo in tst.core.sh

In reply to Sam James

$rcc is not set, but $rc is. Use that.

---
 test/unittest/options/tst.core.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
test/unittest/options/tst.core.sh +1 -1
index 48a58508..18727c6a 100755
@@ -16,4 +16,4 @@ file core | tee /dev/stderr | \
 rc=$?
 rm -f core
 
-exit $rcc
+exit $rc
Signature · 1 line
2.46.0
Reviewed-by on v1 2/3
#4 lore raw

Re: [PATCH 2/3] test: fix exit code typo in tst.core.sh

Quoted 1 line · Sam James

$rcc is not set, but $rc is. Use that.

... and committed with Signed-off-by added.

Quoted 17 lines
---
 test/unittest/options/tst.core.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
test/unittest/options/tst.core.sh +1 -1
index 48a58508..18727c6a 100755
@@ -16,4 +16,4 @@ file core | tee /dev/stderr | \
 rc=$?
 rm -f core
 
-exit $rcc
+exit $rc
Signature · 1 line
2.46.0
author
#5 lore raw

PATCH 3/3 test: fix exit code in tst.newprobes.sh

In reply to Sam James

$status is never assigned, just use $?.

---
 test/unittest/pid/tst.newprobes.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
test/unittest/pid/tst.newprobes.sh +1 -1
index a4944688..0980d3b3 100755
@@ -44,4 +44,4 @@ tick-1s
 }
 EOF
 
-exit $status
+exit $?
Signature · 1 line
2.46.0
#6 lore raw

Re: [PATCH 3/3] test: fix exit code in tst.newprobes.sh

Another question about this test is whether "pid*:awk::" is even a legitimate probe description for pid probes;  do we allow wildcards for pid numbers in pid provider names?  Anyhow, that's a separate issue from the one raised in this patch;  it does, however, perhaps influence where we want to go with the test.

Quoted 15 lines · Sam James

$status is never assigned, just use $?.

---
  test/unittest/pid/tst.newprobes.sh | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
test/unittest/pid/tst.newprobes.sh +1 -1
index a4944688..0980d3b3 100755
@@ -44,4 +44,4 @@ tick-1s
  }
  EOF
 
-exit $status
+exit $?
Reviewed-by on v1 3/3
#7 lore raw

Re: [PATCH 3/3] test: fix exit code in tst.newprobes.sh

In reply to Sam James
Quoted 1 line · Sam James

$status is never assigned, just use $?.

... and committed with Signed-off-by added.

Quoted 17 lines
---
 test/unittest/pid/tst.newprobes.sh | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
test/unittest/pid/tst.newprobes.sh +1 -1
index a4944688..0980d3b3 100755
@@ -44,4 +44,4 @@ tick-1s
 }
 EOF
 
-exit $status
+exit $?
Signature · 1 line
2.46.0
#8 lore raw

Re: [PATCH 3/3] test: fix exit code in tst.newprobes.sh

Maybe I am a few patches behind.  I thought this test used pid*:awk:: and was therefore XFAIL.  I do not object to the patch, but I was only curious if we wanted a "real fix" to the test. There are other cases where tests have multiple problems and we do not generally seem to settle for fixing only one of the problems. Again, though, I'm okay with the patch... it's an improvement over what's there.

Quoted 23 lines · Kris Van Hees
Quoted 1 line · Sam James

$status is never assigned, just use $?.

... and committed with Signed-off-by added.

Quoted 17 lines
---
  test/unittest/pid/tst.newprobes.sh | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
test/unittest/pid/tst.newprobes.sh +1 -1
index a4944688..0980d3b3 100755
@@ -44,4 +44,4 @@ tick-1s
  }
  EOF
 
-exit $status
+exit $?
Signature · 1 line
2.46.0
#9 lore raw

Re: [PATCH 3/3] test: fix exit code in tst.newprobes.sh

Quoted 6 lines · Eugene Loh

Maybe I am a few patches behind.  I thought this test used pid*:awk:: and was therefore XFAIL.  I do not object to the patch, but I was only curious if we wanted a "real fix" to the test. There are other cases where tests have multiple problems and we do not generally seem to settle for fixing only one of the problems. Again, though, I'm okay with the patch... it's an improvement over what's there.

In general, yes, when we encounter a case like this we tend to fix other more fundamental problems with the test. In this case, since it is part of a larger series of test clean up work, I took it as-is so as to not delay the cleanup any longer. But yes, the test will still need extra work to ensure it is actually correct in terms of functionality.

Quoted 23 lines · Kris Van Hees
Quoted 22 lines · Sam James
Quoted 1 line

$status is never assigned, just use $?.

... and committed with Signed-off-by added.

Quoted 16 lines
---
  test/unittest/pid/tst.newprobes.sh | 2 +-
  1 file changed, 1 insertion(+), 1 deletion(-)
test/unittest/pid/tst.newprobes.sh +1 -1
index a4944688..0980d3b3 100755
@@ -44,4 +44,4 @@ tick-1s
  }
  EOF
-exit $status
+exit $?
Signature · 1 line
2.46.0