tools: tests: fix regex patterns for timestamps in gpiomon test cases
authorBartosz Golaszewski <bgolaszewski@baylibre.com>
Tue, 14 Apr 2020 12:45:25 +0000 (14:45 +0200)
committerBartosz Golaszewski <bgolaszewski@baylibre.com>
Tue, 14 Apr 2020 14:28:13 +0000 (16:28 +0200)
Commit f8850206e160 ("gpio: Switch timestamps to ktime_get_ns()") in the
linux kernel (released in v5.7-rc1) changed the clock used to generate
line events from real-time to monotonic. This has the effect of making
the timestamp values much smaller and it uncovered a bug in regex
patterns used to verify gpiomon output: they don't expect there to be
any whitespace characters in the timestamp part of the line.

Fix it by accepting any number of whitespace chars between the opening
'[' and the first digit of the timestamp.

Fixes: 9c5a6f31ebff ("tests: use GLib for library test cases and bats for gpio-tools")
Signed-off-by: Bartosz Golaszewski <bgolaszewski@baylibre.com>
tools/gpio-tools-test.bats

index 094a4010b61aef01a481397484828228399dead3..b756c438e426cc7b1b639621b0fd8ebf2508d10f 100755 (executable)
@@ -684,7 +684,7 @@ teardown() {
 
        test "$status" -eq "0"
        output_regex_match \
-"event:\\s+RISING\\s+EDGE\\s+offset:\\s+4\\s+timestamp:\\s+\[[0-9]+\.[0-9]+\]"
+"event:\\s+RISING\\s+EDGE\\s+offset:\\s+4\\s+timestamp:\\s+\[\s*[0-9]+\.[0-9]+\]"
 }
 
 @test "gpiomon: single falling edge event" {
@@ -701,7 +701,7 @@ teardown() {
 
        test "$status" -eq "0"
        output_regex_match \
-"event:\\s+FALLING\\s+EDGE\\s+offset:\\s+4\\s+timestamp:\\s+\[[0-9]+\.[0-9]+\]"
+"event:\\s+FALLING\\s+EDGE\\s+offset:\\s+4\\s+timestamp:\\s+\[\s*[0-9]+\.[0-9]+\]"
 }
 
 @test "gpiomon: single falling edge event (pull-up)" {
@@ -719,7 +719,7 @@ teardown() {
 
        test "$status" -eq "0"
        output_regex_match \
-"event:\\s+FALLING\\s+EDGE\\s+offset:\\s+4\\s+timestamp:\\s+\[[0-9]+\.[0-9]+\]"
+"event:\\s+FALLING\\s+EDGE\\s+offset:\\s+4\\s+timestamp:\\s+\[\s*[0-9]+\.[0-9]+\]"
 }
 
 @test "gpiomon: single rising edge event (pull-down)" {
@@ -737,7 +737,7 @@ teardown() {
 
        test "$status" -eq "0"
        output_regex_match \
-"event:\\s+RISING\\s+EDGE\\s+offset:\\s+4\\s+timestamp:\\s+\[[0-9]+\.[0-9]+\]"
+"event:\\s+RISING\\s+EDGE\\s+offset:\\s+4\\s+timestamp:\\s+\[\s*[0-9]+\.[0-9]+\]"
 }
 
 @test "gpiomon: single rising edge event (active-low)" {
@@ -755,7 +755,7 @@ teardown() {
 
        test "$status" -eq "0"
        output_regex_match \
-"event:\\s+RISING\\s+EDGE\\s+offset:\\s+4\\s+timestamp:\\s+\[[0-9]+\.[0-9]+\]"
+"event:\\s+RISING\\s+EDGE\\s+offset:\\s+4\\s+timestamp:\\s+\[\s*[0-9]+\.[0-9]+\]"
 }
 
 @test "gpiomon: single rising edge event (silent mode)" {
@@ -791,9 +791,9 @@ teardown() {
 
        test "$status" -eq "0"
        output_regex_match \
-"event\\:\\s+FALLING\\s+EDGE\\s+offset\\:\\s+4\\s+timestamp:\\s+\\[[0-9]+\\.[0-9]+\\]"
+"event\\:\\s+FALLING\\s+EDGE\\s+offset\\:\\s+4\\s+timestamp:\\s+\\[\s*[0-9]+\\.[0-9]+\\]"
        output_regex_match \
-"event\\:\\s+RISING\\s+EDGE\\s+offset\\:\\s+4\\s+timestamp:\\s+\\[[0-9]+\\.[0-9]+\\]"
+"event\\:\\s+RISING\\s+EDGE\\s+offset\\:\\s+4\\s+timestamp:\\s+\\[\s*[0-9]+\\.[0-9]+\\]"
 }
 
 @test "gpiomon: exit after SIGINT" {
@@ -835,9 +835,9 @@ teardown() {
 
        test "$status" -eq "0"
        output_regex_match \
-"event\\:\\s+FALLING\\s+EDGE\\s+offset\\:\\s+4\\s+timestamp:\\s+\\[[0-9]+\\.[0-9]+\\]"
+"event\\:\\s+FALLING\\s+EDGE\\s+offset\\:\\s+4\\s+timestamp:\\s+\\[\s*[0-9]+\\.[0-9]+\\]"
        output_regex_match \
-"event\\:\\s+RISING\\s+EDGE\\s+offset\\:\\s+4\\s+timestamp:\\s+\\[[0-9]+\\.[0-9]+\\]"
+"event\\:\\s+RISING\\s+EDGE\\s+offset\\:\\s+4\\s+timestamp:\\s+\\[\s*[0-9]+\\.[0-9]+\\]"
 }
 
 @test "gpiomon: watch multiple lines" {