]> granicus.if.org Git - strace/commitdiff
strace-S.test: cleanup
authorDmitry V. Levin <ldv@altlinux.org>
Mon, 9 May 2016 23:42:28 +0000 (23:42 +0000)
committerDmitry V. Levin <ldv@altlinux.org>
Tue, 10 May 2016 00:38:52 +0000 (00:38 +0000)
* tests/strace-S.test: Rewrite using sed.

tests/strace-S.test

index 97a5f7b96238fe34ca848a1169b1d616f45467d2..7b188aa67bd8b35612a0f0ae2eec4153c6960480 100755 (executable)
@@ -5,48 +5,24 @@
 . "${srcdir=.}/init.sh"
 
 run_prog_skip_if_failed date > /dev/null
-run_strace -c -S calls $args
-OUT="$LOG.out"
-EXP="$LOG.exp"
-
-rm -f "$OUT" "$EXP"
-
-check_prog awk
-check_prog sort
-awk '{print $4}' "$LOG" > "$OUT"
-
-exec 4<&0 0<"$OUT"
-while
-read item
-do
-       if [ "$item" = "---------" ]
-       then
-               break
-       fi
-done
-
-while
-read item
-do
-       if [ "$item" = "---------" ]
-       then
-               break
-       fi
-
-       echo "$item" >> "$EXP"
-done
-
-exec 0<&4
-
-if [ -s $EXP ]
-then
-       sort -c -g -r "$EXP"
-       if [ "$?" = "1" ]
-       then
-               fail_ "not sorted"
-       fi
-else
-       fail_ "no file"
-fi
-
-rm -f "$OUT" "$EXP"
+
+test_c()
+{
+       local sortby sortopts sedexpr
+       sortby="$1"; shift
+       sortopts="$1"; shift
+       sedexpr="$1"; shift
+
+       run_strace -c -S "$sortby" date > /dev/null
+       sed -ne "$sedexpr" < "$LOG" > "$OUT"
+
+       [ -s "$OUT" ] ||
+               fail_ "$STRACE $args output mismatch"
+       LC_ALL=C sort -c $sortopts "$OUT" ||
+               fail_ "$STRACE $args output not sorted properly"
+}
+
+c='[[:space:]]\+\([^[:space:]]\+\)'
+test_c calls '-n -r' '/^[[:space:]]\+[0-9]/ s/^'"$c$c$c$c"'[[:space:]].*/\4/p'
+
+rm -f "$OUT"