summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDmitry V. Levin <ldv@strace.io>2023-04-01 08:00:00 +0000
committerDmitry V. Levin <ldv@strace.io>2023-04-01 08:00:00 +0000
commit7a289e79bb5f14e91c874a3b5429e072e7b50bbd (patch)
tree704f43dae3e532499612b3ae43adb203dd0efe4d
parent64d48b2d908ed033797783d21c37a0a119d07f42 (diff)
downloadstrace-7a289e79bb5f14e91c874a3b5429e072e7b50bbd.tar.gz
Make --tips more easily available
Allow --tips option to be used without any tracing, so that tips, tricks and tweaks could be displayed without running any program or attaching to any process. * src/strace.c (init): When --tips is specified without running any program or attaching to any process, show the tips and exit. * tests/strace--tips-0.exp: New file. * tests/Makefile.am (check_DATA): Add it. * tests/strace--tips.test: Check that simple "strace --tips=0" works as expected. * tests/options-syntax.test: Update expected output.
-rw-r--r--src/strace.c4
-rw-r--r--tests/Makefile.am1
-rwxr-xr-xtests/options-syntax.test2
-rw-r--r--tests/strace--tips-0.exp10
-rwxr-xr-xtests/strace--tips.test5
5 files changed, 21 insertions, 1 deletions
diff --git a/src/strace.c b/src/strace.c
index 21b693d02..7a58bdbd6 100644
--- a/src/strace.c
+++ b/src/strace.c
@@ -2606,6 +2606,10 @@ init(int argc, char *argv[])
argc -= optind;
if (argc < 0 || (!nprocs && !argc)) {
+ if (show_tips != TIPS_NONE) {
+ print_totd();
+ exit(exit_code);
+ }
error_msg_and_help("must have PROG [ARGS] or -p PID");
}
diff --git a/tests/Makefile.am b/tests/Makefile.am
index 9cbfc33f8..70153a5b1 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -718,6 +718,7 @@ check_DATA = \
strace--syscall-times-s.expected \
strace--syscall-times-us.expected \
strace--tips.exp \
+ strace--tips-0.exp \
strace-T_upper.expected \
strauss_body.exp \
strauss_head.exp \
diff --git a/tests/options-syntax.test b/tests/options-syntax.test
index c400fa689..c76c161d9 100755
--- a/tests/options-syntax.test
+++ b/tests/options-syntax.test
@@ -95,7 +95,7 @@ for opt in '--tips' \
'--tips=format:compact --tips' \
'--tips --tips=format:full,3,none,id:42,compact'
do
- check_h "must have PROG [ARGS] or -p PID" $opt
+ check_h "invalid -a argument: '-42'" $opt -a -42
done
check_h 'PROG [ARGS] must be specified with -D/--daemonize' -D -p $$
diff --git a/tests/strace--tips-0.exp b/tests/strace--tips-0.exp
new file mode 100644
index 000000000..9fb3d1f56
--- /dev/null
+++ b/tests/strace--tips-0.exp
@@ -0,0 +1,10 @@
+ ______________________________________________ ____
+ / \ / \
+ | strace has an extensive manual page | |-. .-.|
+ | that covers all the possible options \ (_@)(_@)
+ | and contains several useful invocation \ .---_ \
+ | examples. _\ /.. \_/
+ | / |__.-^ /
+ | | } |
+ \______________________________________________/ | [
+ [ ]
diff --git a/tests/strace--tips.test b/tests/strace--tips.test
index c08733bbc..7bb89c0d0 100755
--- a/tests/strace--tips.test
+++ b/tests/strace--tips.test
@@ -11,6 +11,11 @@ tips_fmt_opt=""
[ 1 -ne "$TIPS_FULL" ] || tips_fmt_opt="--tips=full"
+# Check that simple "strace --tips=0" works as expected
+args='--tips=0'
+"$STRACE" $args 2> "${OUT}"
+match_diff "${OUT}" $srcdir/strace--tips-0.exp
+
# Check that random tip is random
"$STRACE" -qqq -enone --tips $tips_fmt_opt ../sleep 0 2> "${OUT}.r0"
i=0