1
0
mirror of https://github.com/systemd/systemd.git synced 2025-03-19 22:50:17 +03:00

test: make the diff regex BRE-compatible

Since the GNU `diff` utility uses grep-style regular expressions[0], which
use the BRE style, we need to tweak the regex to make it work properly
(most notably - in BRE the meta characters need to be escaped).

```
$ diff a b
21c21
<   Volume Key: 256bit
---
>   Volume Key: 257bit
25c25
< Disk Ceiling: 323.2M
---
> Disk Ceiling: 323.1M

$ diff -I '^\s*Disk (Size|Free|Floor|Ceiling):' a b
21c21
<   Volume Key: 256bit
---
>   Volume Key: 257bit
25c25
< Disk Ceiling: 323.2M
---
> Disk Ceiling: 323.1M

$ diff -I '^\s*Disk \(Size\|Free\|Floor\|Ceiling\):' a b && echo OK
21c21
<   Volume Key: 256bit
---
>   Volume Key: 257bit
```

Caught in one of the nightly CentOS CI cron jobs.

[0] https://www.gnu.org/software/diffutils/manual/html_node/Specified-Lines.html
This commit is contained in:
Frantisek Sumsal 2021-11-18 17:19:03 +01:00
parent 9c41618008
commit 1285252823

View File

@ -19,7 +19,8 @@ inspect() {
homectl inspect "$USERNAME" | tee /tmp/a
userdbctl user "$USERNAME" | tee /tmp/b
diff -I '/^\s*Disk (Size|Free|Floor|Ceiling):/' /tmp/{a,b}
# diff uses the grep BREs for pattern matching
diff -I '^\s*Disk \(Size\|Free\|Floor\|Ceiling\):' /tmp/{a,b}
rm /tmp/{a,b}
}