]> git.ipfire.org Git - thirdparty/systemd.git/commitdiff
test: use sed and grep instead of perl
authorZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Mon, 8 May 2023 11:43:03 +0000 (13:43 +0200)
committerZbigniew Jędrzejewski-Szmek <zbyszek@in.waw.pl>
Tue, 9 May 2023 06:11:10 +0000 (08:11 +0200)
This gets rid of the all-but-one remaining uses of perl. I tested the new code
on my machine, so I'm fairly confident that it works as expected.

install_iscsi() has one majestic perl invocation, but we can't get rid of it
easily: it extends the code of tgt-admin to print some list of files. Obviously
this only works because tgt-admin is written in perl, and perl will be installed
if tgt-admin is installed. install_iscsi() is used in TEST-64-UDEV-STORAGE
conditionally if tgtadm is installed, so this can stay as is.

test/test-functions

index cef2a780d4c8464937efc9711f6e3417c489b4e4..2d303f47999c387923e71a2e243f24079dbc3373 100644 (file)
@@ -818,19 +818,19 @@ install_valgrind() {
         exit 1
     fi
 
-    local valgrind_bins valgrind_libs valgrind_dbg_and_supp
+    local valgrind_bins valgrind_libs valgrind_supp
 
-    readarray -t valgrind_bins < <(strace -e execve valgrind /bin/true 2>&1 >/dev/null | perl -lne 'print $1 if /^execve\("([^"]+)"/')
+    readarray -t valgrind_bins < <(strace -e execve valgrind /bin/true 2>&1 >/dev/null |
+                                       sed -r -n 's/execve\("([^"]*)".*/\1/p')
     image_install "${valgrind_bins[@]}"
 
-    readarray -t valgrind_libs < <(LD_DEBUG=files valgrind /bin/true 2>&1 >/dev/null | perl -lne 'print $1 if m{calling init: (/.*vgpreload_.*)}')
+    readarray -t valgrind_libs < <(LD_DEBUG=files valgrind /bin/true 2>&1 >/dev/null |
+                                       sed -r -n 's|.*calling init: (/.*vgpreload_.*)|\1|p')
     image_install "${valgrind_libs[@]}"
 
-    readarray -t valgrind_dbg_and_supp < <(
-        strace -e open valgrind /bin/true 2>&1 >/dev/null |
-        perl -lne 'if (my ($fname) = /^open\("([^"]+).*= (?!-)\d+/) { print $fname if $fname =~ /debug|\.supp$/ }'
-    )
-    image_install "${valgrind_dbg_and_supp[@]}"
+    readarray -t valgrind_supp < <(strace -e open valgrind /bin/true 2>&1 >/dev/null |
+                                       sed -r -n 's,open\("([^"]*(/debug[^"]*|\.supp))".*= [0-9].*,\1,p')
+    image_install "${valgrind_supp[@]}"
 }
 
 create_valgrind_wrapper() {
@@ -1455,16 +1455,13 @@ check_asan_reports() {
             ret=$((ret+1))
         fi
 
+        # May 08 13:23:31 H testleak[2907148]: SUMMARY: AddressSanitizer: 4 byte(s) leaked in 1 allocation(s).
         pids="$(
-            "$JOURNALCTL" -D "$root/var/log/journal" | perl -alne '
-                 BEGIN {
-                     %services_to_ignore = (
-                         "dbus-daemon" => undef,
-                         "dbus-broker-launch" => undef,
-                     );
-                 }
-                 print $2 if /\s(\S*)\[(\d+)\]:\s*SUMMARY:\s+\w+Sanitizer/ && !exists $services_to_ignore{$1}'
+            "$JOURNALCTL" -D "$root/var/log/journal" --grep 'SUMMARY: .*Sanitizer:' |
+                   grep -v -E 'dbus-daemon|dbus-broker-launch' |
+                   sed -r -n 's/.* .+\[([0-9]+)\]: SUMMARY:.*/\1/p'
         )"
+
         if [[ -n "$pids" ]]; then
             ret=$((ret+1))
             for pid in $pids; do