[PATCH v2 1/2] Add an option for raising Strauss awareness
Eugene Syromyatnikov
evgsyr at gmail.com
Fri Apr 1 18:24:39 UTC 2022
As der Strauss is the strace's mascot and also an endangered species,
it is a strace's responsibility now to raise awareness about it.
* src/strauss.c: New file.
* src/strauss.h: New header.
* src/Makefile.am (strace_SOURCES): Add them.
* src/strace.c: Include "strauss.h".
(version_verbosity): New static variable.
(print_version): Add verbosity argument, call print_strauss.
(increase_version_verbosity): New function.
(init) <case 'V'>: Call increase_version_verbosity.
(init): Call print_version and exit if version_verbosity is non-zero.
* tests/strauss_body.exp: New file.
* tests/strauss_head.exp: Likewise.
* tests/Makefile.am (EXTRA_DIST): Add them.
* tests/strace-V.test: Update expected output, add checks.
* strace.1.in: Document it.
* NEWS: Mention it.
---
NEWS | 1 +
doc/strace.1.in | 2 ++
src/Makefile.am | 2 ++
src/strace.c | 23 +++++++++++++++---
src/strauss.c | 66 ++++++++++++++++++++++++++++++++++++++++++++++++++
src/strauss.h | 19 +++++++++++++++
tests/Makefile.am | 2 ++
tests/strace-V.test | 35 ++++++++++++++++++++------
tests/strauss_body.exp | 26 ++++++++++++++++++++
tests/strauss_head.exp | 11 +++++++++
10 files changed, 176 insertions(+), 11 deletions(-)
create mode 100644 src/strauss.c
create mode 100644 src/strauss.h
create mode 100644 tests/strauss_body.exp
create mode 100644 tests/strauss_head.exp
diff --git a/NEWS b/NEWS
index 0b10571..9ffbc4f 100644
--- a/NEWS
+++ b/NEWS
@@ -2,6 +2,7 @@ Noteworthy changes in release ?.?? (????-??-??)
===============================================
* Improvements
+ * Added an interface of raising des Strausses awareness.
* Bug fixes
diff --git a/doc/strace.1.in b/doc/strace.1.in
index 2f8d02c..0e8fabd 100644
--- a/doc/strace.1.in
+++ b/doc/strace.1.in
@@ -1566,6 +1566,8 @@ proceeds as usual and stops traced processes on every system call.
.B \-\-version
Print the version number of
.BR strace .
+Multiple instances of the option beyond specific threshold tend to increase
+Strauss awareness.
.SS "Time specification format description"
.PP
Time values can be specified as a decimal floating point number
diff --git a/src/Makefile.am b/src/Makefile.am
index ab5428c..7773bb0 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -350,6 +350,8 @@ libstrace_a_SOURCES = \
static_assert.h \
statx.c \
statx.h \
+ strauss.c \
+ strauss.h \
string_to_uint.c \
string_to_uint.h \
swapon.c \
diff --git a/src/strace.c b/src/strace.c
index 94d6169..60d4038 100644
--- a/src/strace.c
+++ b/src/strace.c
@@ -36,6 +36,7 @@
#include "ptrace_syscall_info.h"
#include "scno.h"
#include "printsiginfo.h"
+#include "strauss.h"
#include "trace_event.h"
#include "xstring.h"
#include "delay.h"
@@ -92,6 +93,8 @@ static int rflag_scale = 1000;
static int rflag_width = 6;
static bool print_pid_pfx;
+static unsigned int version_verbosity;
+
/* -I n */
enum {
INTR_NOT_SET = 0,
@@ -218,7 +221,7 @@ strerror(int err_no)
#endif /* HAVE_STERRROR */
static void
-print_version(void)
+print_version(unsigned int verbosity)
{
static const char features[] =
#ifdef ENABLE_STACKTRACE
@@ -253,6 +256,9 @@ print_version(void)
PACKAGE_NAME, PACKAGE_VERSION, COPYRIGHT_YEAR, PACKAGE_URL);
printf("\nOptional features enabled:%s\n",
features[0] ? features : " (none)");
+
+ /* Raise strauss awareness */
+ print_strauss(verbosity);
}
static void
@@ -2048,6 +2054,13 @@ make_env(char **orig_env, char *const *env_changes, size_t env_change_count)
return new_env;
}
+static void
+increase_version_verbosity(void)
+{
+ if (version_verbosity < (STRAUSS_START_VERBOSITY + strauss_lines))
+ version_verbosity++;
+}
+
/*
* Initialization part of main() was eating much stack (~0.5k),
* which was unused after init.
@@ -2396,8 +2409,7 @@ init(int argc, char *argv[])
qualify_abbrev("none");
break;
case 'V':
- print_version();
- exit(0);
+ increase_version_verbosity();
break;
case 'w':
count_wallclock = 1;
@@ -2496,6 +2508,11 @@ init(int argc, char *argv[])
}
}
+ if (version_verbosity) {
+ print_version(version_verbosity);
+ exit(0);
+ }
+
argv += optind;
argc -= optind;
diff --git a/src/strauss.c b/src/strauss.c
new file mode 100644
index 0000000..e3a240f
--- /dev/null
+++ b/src/strauss.c
@@ -0,0 +1,66 @@
+/*
+ * Strauss awareness implementation.
+ *
+ * Copyright (c) 2018-2019 The strace developers.
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: LGPL-2.1-or-later
+ */
+
+#include "defs.h"
+
+#include "strauss.h"
+
+static const char *strauss[] = {
+ "",
+ " ____",
+ " / \\",
+ " |-. .-.|",
+ " (_@)(_@)",
+ " .---_ \\",
+ " /.. \\_/",
+ " |__.-^ /",
+ " } |",
+ " | [",
+ " [ ]",
+ " ] |",
+ " | [",
+ " [ ]",
+ " / | __",
+ " \\| |/ _/ /_",
+ " \\ | |//___/__/__/_",
+ "\\\\ \\ / // -____/_",
+ "// \" \\\\ \\___.-",
+ " // \\\\ __.----._/_",
+ "/ '/|||\\` .- __>",
+ "[ / __.-",
+ "[ [ }",
+ "\\ \\ /",
+ " \"-._____ \\.____.--\"",
+ " | | | |",
+ " | | | |",
+ " | | | |",
+ " | | | |",
+ " { } { }",
+ " | | | |",
+ " | | | |",
+ " | | | |",
+ " / { | |",
+ " .-\" / [ -._",
+ "/___/ / \\ \\___\"-.",
+ " -\" \"-",
+ };
+
+const size_t strauss_lines = ARRAY_SIZE(strauss);
+
+void
+print_strauss(size_t verbosity)
+{
+ if (verbosity < STRAUSS_START_VERBOSITY)
+ return;
+
+ verbosity = MIN(verbosity - STRAUSS_START_VERBOSITY, strauss_lines);
+
+ for (size_t i = 0; i < verbosity; i++)
+ puts(strauss[i]);
+}
diff --git a/src/strauss.h b/src/strauss.h
new file mode 100644
index 0000000..fb2e427
--- /dev/null
+++ b/src/strauss.h
@@ -0,0 +1,19 @@
+/*
+ * Strauss awareness interface declarations.
+ *
+ * Copyright (c) 2018-2019 The strace developers.
+ * All rights reserved.
+ *
+ * SPDX-License-Identifier: LGPL-2.1-or-later
+ */
+
+#ifndef STRACE_STRAUSS_H
+#define STRACE_STRAUSS_H
+
+enum { STRAUSS_START_VERBOSITY = 5 };
+
+extern const size_t strauss_lines;
+
+extern void print_strauss(size_t verbosity);
+
+#endif /* STRACE_STRAUSS_H */
diff --git a/tests/Makefile.am b/tests/Makefile.am
index cd7e84c..d21230b 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -714,6 +714,8 @@ EXTRA_DIST = \
strace-k.test \
strace-r.expected \
strace.supp \
+ strauss_body.exp \
+ strauss_head.exp \
sun_path.expected \
syntax.sh \
trace_clock.in \
diff --git a/tests/strace-V.test b/tests/strace-V.test
index fdac7a3..a46948e 100755
--- a/tests/strace-V.test
+++ b/tests/strace-V.test
@@ -38,13 +38,32 @@ option_secontext=$(get_config_option ENABLE_SECONTEXT " secontext")
features="${option_unwind}${option_demangle}${option_m32}${option_mx32}${option_secontext}"
[ -n "$features" ] || features=" (none)"
-cat > "$EXP" << __EOF__
-$(get_config_str PACKAGE_NAME) -- version $(get_config_str PACKAGE_VERSION)
-Copyright (c) 1991-${config_year} The strace developers <$(get_config_str PACKAGE_URL)>.
-This is free software; see the source for copying conditions. There is NO
-warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+for i in $(seq 4); do
+ case "$i" in
+ 1) opt="-V";;
+ 2) opt="-V -V -V -V";;
+ 3) opt="-VVVV -VVVV -VVVV -VVVV";;
+ 4) opt="-VVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVVV";;
+ esac
-Optional features enabled:${features}
-__EOF__
+ run_strace ${opt} > "${LOG}.${opt}"
-match_diff "$OUT" "$EXP"
+ cat > "${EXP}.${opt}" <<-__EOF__
+ $(get_config_str PACKAGE_NAME) -- version $(get_config_str PACKAGE_VERSION)
+ Copyright (c) 1991-${config_year} The strace developers <$(get_config_str PACKAGE_URL)>.
+ This is free software; see the source for copying conditions. There is NO
+ warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
+
+ Optional features enabled:${features}
+ __EOF__
+
+ if [ 3 -le "$i" ]; then
+ cat $srcdir/strauss_head.exp >> "${EXP}.${opt}"
+ fi
+
+ if [ 4 -le "$i" ]; then
+ cat $srcdir/strauss_body.exp >> "${EXP}.${opt}"
+ fi
+
+ match_diff "${LOG}.${opt}" "${EXP}.${opt}"
+done
diff --git a/tests/strauss_body.exp b/tests/strauss_body.exp
new file mode 100644
index 0000000..ca457b4
--- /dev/null
+++ b/tests/strauss_body.exp
@@ -0,0 +1,26 @@
+ ] |
+ | [
+ [ ]
+ / | __
+ \| |/ _/ /_
+ \ | |//___/__/__/_
+\\ \ / // -____/_
+// " \\ \___.-
+ // \\ __.----._/_
+/ '/|||\` .- __>
+[ / __.-
+[ [ }
+\ \ /
+ "-._____ \.____.--"
+ | | | |
+ | | | |
+ | | | |
+ | | | |
+ { } { }
+ | | | |
+ | | | |
+ | | | |
+ / { | |
+ .-" / [ -._
+/___/ / \ \___"-.
+ -" "-
diff --git a/tests/strauss_head.exp b/tests/strauss_head.exp
new file mode 100644
index 0000000..cfb6fe4
--- /dev/null
+++ b/tests/strauss_head.exp
@@ -0,0 +1,11 @@
+
+ ____
+ / \
+ |-. .-.|
+ (_@)(_@)
+ .---_ \
+ /.. \_/
+ |__.-^ /
+ } |
+ | [
+ [ ]
--
2.10.2
More information about the Strace-devel
mailing list