Skip to contentSkip to conversation

gpio-tools-test.bats: modify delays in toggle test

PATCH Superseded [email protected] 3 participants 14 messages May 24, 2023 – Jun 1, 2023 GPIO

v1 of 4 Superseded Latest is v4 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 gpio-tools-test.bats: modify delays in toggle test

From: Joe Slater <[email protected]>

The test "gpioset: toggle (continuous)" uses fixed delays to test toggling values. This is not reliable, so we switch to looking for transitions from one value to another.

---
 tools/gpio-tools-test.bats | 24 +++++++++++++++++++-----
 1 file changed, 19 insertions(+), 5 deletions(-)
tools/gpio-tools-test.bats +19 -5
index adbce94..977d718 100755
@@ -141,6 +141,20 @@ gpiosim_check_value() {
 	[ "$VAL" = "$EXPECTED" ]
 }
 
+gpiosim_wait_value() {
+	local OFFSET=$2
+	local EXPECTED=$3
+	local DEVNAME=${GPIOSIM_DEV_NAME[$1]}
+	local CHIPNAME=${GPIOSIM_CHIP_NAME[$1]}
+
+	for i in {1..10} ; do
+		VAL=$(<$GPIOSIM_SYSFS/$DEVNAME/$CHIPNAME/sim_gpio$OFFSET/value)
+		[ "$VAL" = "$EXPECTED" ] && return
+		sleep 0.1
+	done
+	return 1
+}
+
 gpiosim_cleanup() {
 	for CHIP in ${!GPIOSIM_CHIP_NAME[@]}
 	do
@@ -1567,15 +1581,15 @@ request_release_line() {
 	gpiosim_check_value sim0 4 0
 	gpiosim_check_value sim0 7 0
 
-	sleep 1
-
-	gpiosim_check_value sim0 1 0
+	# sleeping fixed amounts can be unreliable, so we
+	# sync to the toggles
+	#
+	gpiosim_wait_value sim0 1 0
 	gpiosim_check_value sim0 4 1
 	gpiosim_check_value sim0 7 1
 
-	sleep 1
 
-	gpiosim_check_value sim0 1 1
+	gpiosim_wait_value sim0 1 1
 	gpiosim_check_value sim0 4 0
 	gpiosim_check_value sim0 7 0
 }
Signature · 1 line
2.25.1
#1 lore raw
Quoted 6 lines · On Wed, May 24, 2023 at 02:09:45PM -0700, [email protected] wrote:

From: Joe Slater <[email protected]>

The test "gpioset: toggle (continuous)" uses fixed delays to test toggling values. This is not reliable, so we switch to looking for transitions from one value to another.

That test is prone to spurious failures if either the test or gpioset get delayed for any reason, so good idea.

Quoted 17 lines
---
 tools/gpio-tools-test.bats | 24 +++++++++++++++++++-----
 1 file changed, 19 insertions(+), 5 deletions(-)
tools/gpio-tools-test.bats +4 -0
index adbce94..977d718 100755
@@ -141,6 +141,20 @@ gpiosim_check_value() {
 	[ "$VAL" = "$EXPECTED" ]
 }
 
+gpiosim_wait_value() {
+	local OFFSET=$2
+	local EXPECTED=$3
+	local DEVNAME=${GPIOSIM_DEV_NAME[$1]}

tools/gpio-tools-test.bats gpiosim_check_value() { · line 157

Quoted 10 lines
tools/gpio-tools-test.bats +10 -0
+	local CHIPNAME=${GPIOSIM_CHIP_NAME[$1]}
+
+	for i in {1..10} ; do
+		VAL=$(<$GPIOSIM_SYSFS/$DEVNAME/$CHIPNAME/sim_gpio$OFFSET/value)
+		[ "$VAL" = "$EXPECTED" ] && return
+		sleep 0.1
+	done
+	return 1
+}
+

Not a huge fan of the loop limit and sleep period being hard coded, as those control the time to wait, but as it is only used in the one place I can live with it.

Quoted 7 lines
tools/gpio-tools-test.bats +0 -0
 gpiosim_cleanup() {
 	for CHIP in ${!GPIOSIM_CHIP_NAME[@]}
 	do
@@ -1567,15 +1581,15 @@ request_release_line() {
 	gpiosim_check_value sim0 4 0
 	gpiosim_check_value sim0 7 0
 

tools/gpio-tools-test.bats request_release_line() { · line 1590

Quoted 10 lines
tools/gpio-tools-test.bats +4 -3
-	sleep 1
-
-	gpiosim_check_value sim0 1 0
+	# sleeping fixed amounts can be unreliable, so we
+	# sync to the toggles
+	#
+	gpiosim_wait_value sim0 1 0
 	gpiosim_check_value sim0 4 1
 	gpiosim_check_value sim0 7 1
 

The comment is confusing once the sleep is removed, so just drop it. If you want to describe what gpiosim_wait_value() does and when it should be used then add that before the function itself.

The test toggles the line at 1s intervals to try to improve the chances of the test and gpioset staying in sync. Could that be reduced now, without impacting reliability? (this test suite being glacial is a personal bugbear)

Cheers,
Kent.

#2 lore raw
Quoted 77 lines

-----Original Message-----
From: Kent Gibson <[email protected]>
Sent: Wednesday, May 24, 2023 8:53 PM
To: Slater, Joseph <[email protected]>
Cc: [email protected]; MacLeod, Randy <[email protected]>
Subject: Re: [libgpiod][PATCH 1/1] gpio-tools-test.bats: modify delays in toggle test

Quoted 6 lines · On Wed, May 24, 2023 at 02:09:45PM -0700, [email protected] wrote:

From: Joe Slater <[email protected]>

The test "gpioset: toggle (continuous)" uses fixed delays to test toggling values. This is not reliable, so we switch to looking for transitions from one value to another.

That test is prone to spurious failures if either the test or gpioset get delayed for any reason, so good idea.

Quoted 11 lines
---
 tools/gpio-tools-test.bats | 24 +++++++++++++++++++-----
 1 file changed, 19 insertions(+), 5 deletions(-)
tools/gpio-tools-test.bats +0 -0
index adbce94..977d718 100755
@@ -141,6 +141,20 @@ gpiosim_check_value() {
 	[ "$VAL" = "$EXPECTED" ]

tools/gpio-tools-test.bats gpiosim_check_value() { · line 151

Quoted 10 lines
tools/gpio-tools-test.bats +8 -0
 }
 
+gpiosim_wait_value() {
+	local OFFSET=$2
+	local EXPECTED=$3
+	local DEVNAME=${GPIOSIM_DEV_NAME[$1]}
+	local CHIPNAME=${GPIOSIM_CHIP_NAME[$1]}
+
+	for i in {1..10} ; do
+
	VAL=$(<$GPIOSIM_SYSFS/$DEVNAME/$CHIPNAME/sim_gpio$OFFSET/v

alue)

tools/gpio-tools-test.bats gpiosim_check_value() { · line 157

Quoted 6 lines
tools/gpio-tools-test.bats +6 -0
+		[ "$VAL" = "$EXPECTED" ] && return
+		sleep 0.1
+	done
+	return 1
+}
+

Not a huge fan of the loop limit and sleep period being hard coded, as those control the time to wait, but as it is only used in the one place I can live with it.

Quoted 7 lines
tools/gpio-tools-test.bats +0 -0
 gpiosim_cleanup() {
 	for CHIP in ${!GPIOSIM_CHIP_NAME[@]}
 	do
@@ -1567,15 +1581,15 @@ request_release_line() {
 	gpiosim_check_value sim0 4 0
 	gpiosim_check_value sim0 7 0
 

tools/gpio-tools-test.bats request_release_line() { · line 1590

Quoted 10 lines
tools/gpio-tools-test.bats +4 -3
-	sleep 1
-
-	gpiosim_check_value sim0 1 0
+	# sleeping fixed amounts can be unreliable, so we
+	# sync to the toggles
+	#
+	gpiosim_wait_value sim0 1 0
 	gpiosim_check_value sim0 4 1
 	gpiosim_check_value sim0 7 1
 

The comment is confusing once the sleep is removed, so just drop it. If you want to describe what gpiosim_wait_value() does and when it should be used then add that before the function itself.

Quoted 4 lines

The test toggles the line at 1s intervals to try to improve the chances of the test and gpioset staying in sync.
Could that be reduced now, without impacting reliability?
(this test suite being glacial is a personal bugbear)

[Slater, Joseph] I'll get rid of the comment and try the test with a shorter toggle time. The series of 159 tests takes, maybe, 10-15 minutes for me, so I don't think saving a second or two here would make much difference, though.
Joe

Quoted 3 lines

Cheers,
Kent.

#3 lore raw
Quoted 20 lines · Joseph
Quoted 11 lines

-----Original Message-----
From: Kent Gibson <[email protected]>
Sent: Wednesday, May 24, 2023 8:53 PM
To: Slater, Joseph <[email protected]>
Cc: [email protected]; MacLeod, Randy <[email protected]>
Subject: Re: [libgpiod][PATCH 1/1] gpio-tools-test.bats: modify delays in toggle test

Quoted 8 lines

The comment is confusing once the sleep is removed, so just drop it. If you want to describe what gpiosim_wait_value() does and when it should be used then add that before the function itself.

The test toggles the line at 1s intervals to try to improve the chances of the test and gpioset staying in sync.
Could that be reduced now, without impacting reliability?
(this test suite being glacial is a personal bugbear)

Quoted 5 lines

[Slater, Joseph] I'll get rid of the comment and try the test with a shorter toggle time. The series of 159 tests takes, maybe, 10-15 minutes for me, so I don't think saving a second or two here would make much difference, though.
Joe

I did mention it was glacial, so I feel your pain - you have no idea how many times I've run that test suite - though it is a bit quicker than 10-15 for me.

So no problem with leaving the timings as is. I can look at it some other time - revisiting that test suite to try to speed it up is on my todo list - somewhere near the bottom.

I look forward to v2.

Cheers,
Kent.

#4 lore raw
In reply to Slater, Joseph
Quoted 83 lines · Joseph
Quoted 78 lines

-----Original Message-----
From: Kent Gibson <[email protected]>
Sent: Wednesday, May 24, 2023 8:53 PM
To: Slater, Joseph <[email protected]>
Cc: [email protected]; MacLeod, Randy <[email protected]>
Subject: Re: [libgpiod][PATCH 1/1] gpio-tools-test.bats: modify delays in toggle test

Quoted 6 lines · On Wed, May 24, 2023 at 02:09:45PM -0700, [email protected] wrote:

From: Joe Slater <[email protected]>

The test "gpioset: toggle (continuous)" uses fixed delays to test toggling values. This is not reliable, so we switch to looking for transitions from one value to another.

That test is prone to spurious failures if either the test or gpioset get delayed for any reason, so good idea.

Quoted 11 lines
---
 tools/gpio-tools-test.bats | 24 +++++++++++++++++++-----
 1 file changed, 19 insertions(+), 5 deletions(-)
tools/gpio-tools-test.bats +0 -0
index adbce94..977d718 100755
@@ -141,6 +141,20 @@ gpiosim_check_value() {
    [ "$VAL" = "$EXPECTED" ]

tools/gpio-tools-test.bats gpiosim_check_value() { · line 151

Quoted 10 lines
tools/gpio-tools-test.bats +8 -0
 }
 
+gpiosim_wait_value() {
+   local OFFSET=$2
+   local EXPECTED=$3
+   local DEVNAME=${GPIOSIM_DEV_NAME[$1]}
+   local CHIPNAME=${GPIOSIM_CHIP_NAME[$1]}
+
+   for i in {1..10} ; do
+
      VAL=$(<$GPIOSIM_SYSFS/$DEVNAME/$CHIPNAME/sim_gpio$OFFSET/v

alue)

tools/gpio-tools-test.bats gpiosim_check_value() { · line 157

Quoted 6 lines
tools/gpio-tools-test.bats +6 -0
+           [ "$VAL" = "$EXPECTED" ] && return
+           sleep 0.1
+   done
+   return 1
+}
+

Not a huge fan of the loop limit and sleep period being hard coded, as those control the time to wait, but as it is only used in the one place I can live with it.

Quoted 7 lines
tools/gpio-tools-test.bats +0 -0
 gpiosim_cleanup() {
    for CHIP in ${!GPIOSIM_CHIP_NAME[@]}
    do
@@ -1567,15 +1581,15 @@ request_release_line() {
    gpiosim_check_value sim0 4 0
    gpiosim_check_value sim0 7 0
 

tools/gpio-tools-test.bats request_release_line() { · line 1590

Quoted 10 lines
tools/gpio-tools-test.bats +4 -3
-   sleep 1
-
-   gpiosim_check_value sim0 1 0
+   # sleeping fixed amounts can be unreliable, so we
+   # sync to the toggles
+   #
+   gpiosim_wait_value sim0 1 0
    gpiosim_check_value sim0 4 1
    gpiosim_check_value sim0 7 1
 

The comment is confusing once the sleep is removed, so just drop it. If you want to describe what gpiosim_wait_value() does and when it should be used then add that before the function itself.

Quoted 4 lines

The test toggles the line at 1s intervals to try to improve the chances of the test and gpioset staying in sync.
Could that be reduced now, without impacting reliability?
(this test suite being glacial is a personal bugbear)

Quoted 5 lines

[Slater, Joseph] I'll get rid of the comment and try the test with a shorter toggle time. The series of 159 tests takes, maybe, 10-15 minutes for me, so I don't think saving a second or two here would make much difference, though.
Joe

That can't be right, are you running it on a toaster? It takes 26 seconds on my regular lenovo thinkpad laptop which is still longer than I'd like but quite acceptable for now (though I agree it would be great to improve it).

Bart

#5 lore raw
Quoted 10 lines · Bartosz Golaszewski
Quoted 7 lines · Joseph

[Slater, Joseph] I'll get rid of the comment and try the test with a shorter toggle time. The series of 159 tests takes, maybe, 10-15 minutes for me, so I don't think saving a second or two here would make much difference, though.
Joe

Quoted 5 lines

That can't be right, are you running it on a toaster? It takes 26 seconds on my regular lenovo thinkpad laptop which is still longer than I'd like but quite acceptable for now (though I agree it would be great to improve it).

Consider yourself blessed.
I just got:

real 2m25.956s

on my test VM.
Not sure exactly what the hold up is - it isn't using much CPU, or any other resources AFAICT.
Compared to all the other test suites I run, this is far and away the slowest, especially since switching everything over to gpio-sim.

Cheers,
Kent.

#6 lore raw
Quoted 21 lines · Kent Gibson
Quoted 10 lines · Bartosz Golaszewski
Quoted 7 lines · Joseph

[Slater, Joseph] I'll get rid of the comment and try the test with a shorter toggle time. The series of 159 tests takes, maybe, 10-15 minutes for me, so I don't think saving a second or two here would make much difference, though.
Joe

Quoted 5 lines

That can't be right, are you running it on a toaster? It takes 26 seconds on my regular lenovo thinkpad laptop which is still longer than I'd like but quite acceptable for now (though I agree it would be great to improve it).

Consider yourself blessed.
I just got:

Quoted 7 lines

real 2m25.956s

on my test VM.
Not sure exactly what the hold up is - it isn't using much CPU, or any other resources AFAICT.
Compared to all the other test suites I run, this is far and away the slowest, especially since switching everything over to gpio-sim.

I agree it's too slow - be it 20 seconds or 2 minutes. But similarly to you - it's very low on my TODO list as I only run it every once in a while. I'd be happy to accept any patches improving the situation of course.

Bart

#7 lore raw
Quoted 30 lines · Bartosz Golaszewski
Quoted 21 lines · Kent Gibson
Quoted 10 lines · Bartosz Golaszewski
Quoted 7 lines · Joseph

[Slater, Joseph] I'll get rid of the comment and try the test with a shorter toggle time. The series of 159 tests takes, maybe, 10-15 minutes for me, so I don't think saving a second or two here would make much difference, though.
Joe

Quoted 5 lines

That can't be right, are you running it on a toaster? It takes 26 seconds on my regular lenovo thinkpad laptop which is still longer than I'd like but quite acceptable for now (though I agree it would be great to improve it).

Consider yourself blessed.
I just got:

Quoted 7 lines

real 2m25.956s

on my test VM.
Not sure exactly what the hold up is - it isn't using much CPU, or any other resources AFAICT.
Compared to all the other test suites I run, this is far and away the slowest, especially since switching everything over to gpio-sim.

Quoted 5 lines

I agree it's too slow - be it 20 seconds or 2 minutes. But similarly to you - it's very low on my TODO list as I only run it every once in a while. I'd be happy to accept any patches improving the situation of course.

Same. I already had a go at streamlining the tests when I updated them for v2, so it is somewhat better than it was, but it is still painfully slow for me.
To improve further I'd have to start digging around to see what bats is up to. Speaking of which, do we need to stick with bats? I've driven similar tests with Python in the past, and I'm sure that would provide a better experience.
What constraints do we have?

Cheers,
Kent.

#8 lore raw
Quoted 38 lines · Kent Gibson
Quoted 30 lines · Bartosz Golaszewski
Quoted 21 lines · Kent Gibson
Quoted 10 lines · Bartosz Golaszewski
Quoted 7 lines · Joseph

[Slater, Joseph] I'll get rid of the comment and try the test with a shorter toggle time. The series of 159 tests takes, maybe, 10-15 minutes for me, so I don't think saving a second or two here would make much difference, though.
Joe

Quoted 5 lines

That can't be right, are you running it on a toaster? It takes 26 seconds on my regular lenovo thinkpad laptop which is still longer than I'd like but quite acceptable for now (though I agree it would be great to improve it).

Consider yourself blessed.
I just got:

Quoted 7 lines

real 2m25.956s

on my test VM.
Not sure exactly what the hold up is - it isn't using much CPU, or any other resources AFAICT.
Compared to all the other test suites I run, this is far and away the slowest, especially since switching everything over to gpio-sim.

Quoted 5 lines

I agree it's too slow - be it 20 seconds or 2 minutes. But similarly to you - it's very low on my TODO list as I only run it every once in a while. I'd be happy to accept any patches improving the situation of course.

Quoted 9 lines

Same. I already had a go at streamlining the tests when I updated them for v2, so it is somewhat better than it was, but it is still painfully slow for me.
To improve further I'd have to start digging around to see what bats is up to. Speaking of which, do we need to stick with bats? I've driven similar tests with Python in the past, and I'm sure that would provide a better experience.
What constraints do we have?

I went with bats because it looked the fastest to write tests in - it's shell after all.

But I think that we could potentially package whatever python subprocess code we need into enough helper wrappers that it wouldn't be much more complex than this.

We also already have python wrappers for libgpiosim ready.

No objections from my side, it's just that I won't have time to rewrite the entire thing in Python anytime soon.

Bartosz

#9 lore raw
Quoted 49 lines · Bartosz Golaszewski
Quoted 38 lines · Kent Gibson
Quoted 30 lines · Bartosz Golaszewski
Quoted 21 lines · Kent Gibson
Quoted 10 lines · Bartosz Golaszewski
Quoted 7 lines · Joseph

[Slater, Joseph] I'll get rid of the comment and try the test with a shorter toggle time. The series of 159 tests takes, maybe, 10-15 minutes for me, so I don't think saving a second or two here would make much difference, though.
Joe

Quoted 5 lines

That can't be right, are you running it on a toaster? It takes 26 seconds on my regular lenovo thinkpad laptop which is still longer than I'd like but quite acceptable for now (though I agree it would be great to improve it).

Consider yourself blessed.
I just got:

Quoted 7 lines

real 2m25.956s

on my test VM.
Not sure exactly what the hold up is - it isn't using much CPU, or any other resources AFAICT.
Compared to all the other test suites I run, this is far and away the slowest, especially since switching everything over to gpio-sim.

Quoted 5 lines

I agree it's too slow - be it 20 seconds or 2 minutes. But similarly to you - it's very low on my TODO list as I only run it every once in a while. I'd be happy to accept any patches improving the situation of course.

Quoted 9 lines

Same. I already had a go at streamlining the tests when I updated them for v2, so it is somewhat better than it was, but it is still painfully slow for me.
To improve further I'd have to start digging around to see what bats is up to. Speaking of which, do we need to stick with bats? I've driven similar tests with Python in the past, and I'm sure that would provide a better experience.
What constraints do we have?

Quoted 3 lines

I went with bats because it looked the fastest to write tests in - it's shell after all.

Really? I wouldn't write anything of consequence in shell if Python was an option.

How about Rust? I've gotten over how spartan the Rust test framework is so I wouldn't have a problem writing it in that either.

Quoted 4 lines

But I think that we could potentially package whatever python subprocess code we need into enough helper wrappers that it wouldn't be much more complex than this.

The end result would look similar in terms of test complexity, but should be much easier to write and debug.
Not that that counts for much given we have a functional bats test suite.

Quoted 2 lines

We also already have python wrappers for libgpiosim ready.

Exactly. And Rust bindings too.

Quoted 3 lines

No objections from my side, it's just that I won't have time to rewrite the entire thing in Python anytime soon.

I'll update my todo list. No promises - it is low priority given the only real problem with the bats solution is its performance.

Cheers,
Kent.

#10 lore raw
Quoted 55 lines · Kent Gibson
Quoted 49 lines · Bartosz Golaszewski
Quoted 38 lines · Kent Gibson
Quoted 30 lines · Bartosz Golaszewski
Quoted 21 lines · Kent Gibson
Quoted 10 lines · Bartosz Golaszewski
Quoted 7 lines · Joseph

[Slater, Joseph] I'll get rid of the comment and try the test with a shorter toggle time. The series of 159 tests takes, maybe, 10-15 minutes for me, so I don't think saving a second or two here would make much difference, though.
Joe

Quoted 5 lines

That can't be right, are you running it on a toaster? It takes 26 seconds on my regular lenovo thinkpad laptop which is still longer than I'd like but quite acceptable for now (though I agree it would be great to improve it).

Consider yourself blessed.
I just got:

Quoted 7 lines

real 2m25.956s

on my test VM.
Not sure exactly what the hold up is - it isn't using much CPU, or any other resources AFAICT.
Compared to all the other test suites I run, this is far and away the slowest, especially since switching everything over to gpio-sim.

Quoted 5 lines

I agree it's too slow - be it 20 seconds or 2 minutes. But similarly to you - it's very low on my TODO list as I only run it every once in a while. I'd be happy to accept any patches improving the situation of course.

Quoted 9 lines

Same. I already had a go at streamlining the tests when I updated them for v2, so it is somewhat better than it was, but it is still painfully slow for me.
To improve further I'd have to start digging around to see what bats is up to. Speaking of which, do we need to stick with bats? I've driven similar tests with Python in the past, and I'm sure that would provide a better experience.
What constraints do we have?

Quoted 3 lines

I went with bats because it looked the fastest to write tests in - it's shell after all.

Quoted 6 lines

Really? I wouldn't write anything of consequence in shell if Python was an option.

How about Rust? I've gotten over how spartan the Rust test framework is so I wouldn't have a problem writing it in that either.

I have a very strong preference for Python. I am quite bad at Rust. Whatever is in bindings/rust/ is Viresh' jurisdiction and I defer to him but I would prefer to be able to keep track of what's happening in tools/ and work on it myself without too much frustration. And writing anything in rust has been pure frustration so far.

Bartosz

Quoted 25 lines
Quoted 4 lines

But I think that we could potentially package whatever python subprocess code we need into enough helper wrappers that it wouldn't be much more complex than this.

The end result would look similar in terms of test complexity, but should be much easier to write and debug.
Not that that counts for much given we have a functional bats test suite.

Quoted 2 lines

We also already have python wrappers for libgpiosim ready.

Exactly. And Rust bindings too.

Quoted 3 lines

No objections from my side, it's just that I won't have time to rewrite the entire thing in Python anytime soon.

I'll update my todo list. No promises - it is low priority given the only real problem with the bats solution is its performance.

Cheers,
Kent.

#11 lore raw
Quoted 19 lines · Bartosz Golaszewski
Quoted 11 lines · Kent Gibson
Quoted 8 lines · Bartosz Golaszewski
Quoted 3 lines · Kent Gibson
Quoted 1 line · Bartosz Golaszewski

On Tue, May 30, 2023 at 12:05 PM Kent Gibson <[email protected]> wrote:

I went with bats because it looked the fastest to write tests in - it's shell after all.

Quoted 6 lines

Really? I wouldn't write anything of consequence in shell if Python was an option.

How about Rust? I've gotten over how spartan the Rust test framework is so I wouldn't have a problem writing it in that either.

Quoted 6 lines

I have a very strong preference for Python. I am quite bad at Rust. Whatever is in bindings/rust/ is Viresh' jurisdiction and I defer to him but I would prefer to be able to keep track of what's happening in tools/ and work on it myself without too much frustration. And writing anything in rust has been pure frustration so far.

Fair enough, Python it is then.

I personally had no problem picking up Rust - seems Rust and I have a similar view - I've always had issues with the vagueness of ownership and lifetimes in other languages, particularly C/C++. Rust gets it. And if you do make a hash of something clippy provides good suggestions, or at least clearly identifies the problem. That helped me a lot with the learning curve.

Cheers,
Kent.

#12 lore raw
Quoted 37 lines · Kent Gibson
Quoted 19 lines · Bartosz Golaszewski
Quoted 11 lines · Kent Gibson
Quoted 8 lines · Bartosz Golaszewski
Quoted 3 lines · Kent Gibson
Quoted 1 line · Bartosz Golaszewski

On Tue, May 30, 2023 at 12:05 PM Kent Gibson <[email protected]> wrote:

I went with bats because it looked the fastest to write tests in - it's shell after all.

Quoted 6 lines

Really? I wouldn't write anything of consequence in shell if Python was an option.

How about Rust? I've gotten over how spartan the Rust test framework is so I wouldn't have a problem writing it in that either.

Quoted 6 lines

I have a very strong preference for Python. I am quite bad at Rust. Whatever is in bindings/rust/ is Viresh' jurisdiction and I defer to him but I would prefer to be able to keep track of what's happening in tools/ and work on it myself without too much frustration. And writing anything in rust has been pure frustration so far.

Fair enough, Python it is then.

I personally had no problem picking up Rust - seems Rust and I have a similar view - I've always had issues with the vagueness of ownership and lifetimes in other languages, particularly C/C++. Rust gets it. And if you do make a hash of something clippy provides good suggestions, or at least clearly identifies the problem. That helped me a lot with the learning curve.

Quoted 2 lines

Cheers,
Kent.

Before jumping into a complete rewrite, I thought it's worth at least giving bats a chance and see if we can simply fix the delay. A quick strace run is telling me this:

% time seconds usecs/call calls errors syscall
------ ----------- ----------- --------- --------- ------------------
91,93 20,569295 1014 20284 8653 wait4

  1,72    0,384721           0    814827           rt_sigprocmask
  1,35    0,301451           1    171558    142755 readlink
  1,19    0,265404           1    261357         8 read
  1,04    0,233103          20     11283           clone
  0,50    0,110845          16      6848      1025 execve
  0,49    0,110042           0    128382     13692 newfstatat
  0,33    0,073843           0     95369     49559 ioctl
  0,25    0,055440           0     78664           mmap
  0,20    0,044861           2     22081           write

[...]

It suggests, there's some issue with waiting for exiting processes that if we fix, we should decrease the test time by at least 90%.

Bart

#13 lore raw
Quoted 58 lines · Bartosz Golaszewski
Quoted 37 lines · Kent Gibson
Quoted 19 lines · Bartosz Golaszewski
Quoted 11 lines · Kent Gibson
Quoted 8 lines · Bartosz Golaszewski
Quoted 3 lines · Kent Gibson
Quoted 1 line · Bartosz Golaszewski

On Tue, May 30, 2023 at 12:05 PM Kent Gibson <[email protected]> wrote:

I went with bats because it looked the fastest to write tests in - it's shell after all.

Quoted 6 lines

Really? I wouldn't write anything of consequence in shell if Python was an option.

How about Rust? I've gotten over how spartan the Rust test framework is so I wouldn't have a problem writing it in that either.

Quoted 6 lines

I have a very strong preference for Python. I am quite bad at Rust. Whatever is in bindings/rust/ is Viresh' jurisdiction and I defer to him but I would prefer to be able to keep track of what's happening in tools/ and work on it myself without too much frustration. And writing anything in rust has been pure frustration so far.

Fair enough, Python it is then.

I personally had no problem picking up Rust - seems Rust and I have a similar view - I've always had issues with the vagueness of ownership and lifetimes in other languages, particularly C/C++. Rust gets it. And if you do make a hash of something clippy provides good suggestions, or at least clearly identifies the problem. That helped me a lot with the learning curve.

Quoted 2 lines

Cheers,
Kent.

Before jumping into a complete rewrite, I thought it's worth at least giving bats a chance and see if we can simply fix the delay. A quick strace run is telling me this:

% time seconds usecs/call calls errors syscall
------ ----------- ----------- --------- --------- ------------------
91,93 20,569295 1014 20284 8653 wait4

  1,72    0,384721           0    814827           rt_sigprocmask
  1,35    0,301451           1    171558    142755 readlink
  1,19    0,265404           1    261357         8 read
  1,04    0,233103          20     11283           clone
  0,50    0,110845          16      6848      1025 execve
  0,49    0,110042           0    128382     13692 newfstatat
  0,33    0,073843           0     95369     49559 ioctl
  0,25    0,055440           0     78664           mmap
  0,20    0,044861           2     22081           write
Quoted 6 lines

[...]

It suggests, there's some issue with waiting for exiting processes that if we fix, we should decrease the test time by at least 90%.

Bart

Nevermind that, turns out strace -c -f doesn't do what I thought it does. It only shows the stats for the top process which mostly just waits for other processes. That's not the culprit. I need to figure out a way to correctly profile this.

Bart