Skip to contentSkip to conversation

tools: tests: port tests to shunit2

PATCH In review Bartosz Golaszewski 2 participants 2 messages Jun 15, 2023 GPIO

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 tools: tests: port tests to shunit2

From: Bartosz Golaszewski <[email protected]>

BATS seems to run pretty slowly. Part of it may be the n+1 time parsing the test files mentioned in the BATS docs.

This is a quick and dirty port of test cases to shunit2 - a different testing framework for shell scripts. It sped up test execution for me by ~40%.

---
 tools/Makefile.am                             |   2 +-
 tools/gpio-tools-test                         |  57 ---
 ...o-tools-test.bats => gpio-tools-test.bash} | 426 ++++++++++--------
 3 files changed, 230 insertions(+), 255 deletions(-)
 delete mode 100755 tools/gpio-tools-test
 rename tools/{gpio-tools-test.bats => gpio-tools-test.bash} (88%)
tools/Makefile.am +1 -1
index bdad8f7..d03305d 100644
@@ -34,6 +34,6 @@ EXTRA_DIST = gpio-tools-test gpio-tools-test.bats
 
 if WITH_TESTS
 
-noinst_SCRIPTS = gpio-tools-test gpio-tools-test.bats
+noinst_SCRIPTS = gpio-tools-test.bash
 
 endif
tools/gpio-tools-test deleted +0 -57

57 lines not on this page · raw message

tools/gpio-tools-test.bash renamed from tools/gpio-tools-test.bats +229 -197

1,492 lines not on this page · raw message

Signature · 1 line
2.39.2
#1 lore raw
Quoted 9 lines · Bartosz Golaszewski

From: Bartosz Golaszewski <[email protected]>

BATS seems to run pretty slowly. Part of it may be the n+1 time parsing the test files mentioned in the BATS docs.

This is a quick and dirty port of test cases to shunit2 - a different testing framework for shell scripts. It sped up test execution for me by ~40%.

That is a lot faster for me too:

Ran 165 tests.

OK

real 0m41.300s
user 0m10.122s
sys 0m22.926s

while it is > 2m30 with bats, so ~75% speedup.

Though I get these errors on some tests:

test_gpiodetect_all_chips
./gpio-tools-test.bash: line 40: assertContains: command not found ./gpio-tools-test.bash: line 40: assertContains: command not found ./gpio-tools-test.bash: line 40: assertContains: command not found test_gpiodetect_a_chip

and the overall test suite still passed, which is a bit of a worry.

Hmmm, seems assertContains was added in 2.1.8 and I'm still on 2.1.6. I'll have to update.

Overall looks promising.

Cheers,
Kent.