From a27f5c38ab366e0447b30c7a46e4fcc9b4b2d67c Mon Sep 17 00:00:00 2001 From: Bartosz Golaszewski Date: Tue, 14 Apr 2020 14:45:25 +0200 Subject: [PATCH] tools: tests: fix regex patterns for timestamps in gpiomon test cases 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 --- tools/gpio-tools-test.bats | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/tools/gpio-tools-test.bats b/tools/gpio-tools-test.bats index 094a401..b756c43 100755 --- a/tools/gpio-tools-test.bats +++ b/tools/gpio-tools-test.bats @@ -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" { -- 2.30.2