lists.openwall.net   lists  /  announce  owl-users  owl-dev  john-users  john-dev  passwdqc-users  yescrypt  popa3d-users  /  oss-security  kernel-hardening  musl  sabotage  tlsify  passwords  /  crypt-dev  xvendor  /  Bugtraq  Full-Disclosure  linux-kernel  linux-netdev  linux-ext4  linux-hardening  linux-cve-announce  PHC 
Open Source and information security mailing list archives
 
Hash Suite: Windows password security audit tool. GUI, reports in PDF.
[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Date: Sun, 11 Feb 2024 00:50:03 +0100
From: Łukasz Bartosik <ukaszb@...omium.org>
To: Jason Baron <jbaron@...mai.com>,
	Jim Cromie <jim.cromie@...il.com>,
	Greg Kroah-Hartman <gregkh@...uxfoundation.org>,
	Andrew Morton <akpm@...ux-foundation.org>,
	Kees Cook <keescook@...omium.org>,
	Douglas Anderson <dianders@...omium.org>
Cc: Guenter Roeck <groeck@...gle.com>,
	Yaniv Tzoreff <yanivt@...gle.com>,
	Benson Leung <bleung@...gle.com>,
	Steven Rostedt <rostedt@...dmis.org>,
	Vincent Whitchurch <vincent.whitchurch@...s.com>,
	Pekka Paalanen <ppaalanen@...il.com>,
	Sean Paul <seanpaul@...omium.org>,
	Daniel Vetter <daniel@...ll.ch>,
	Simon Ser <contact@...rsion.fr>,
	John Ogness <john.ogness@...utronix.de>,
	Petr Mladek <pmladek@...e.com>,
	Sergey Senozhatsky <sergey.senozhatsky@...il.com>,
	linux-kernel@...r.kernel.org,
	upstream@...ihalf.com
Subject: [PATCH v4 33/39] dyndbg-test: setup environment for tests execution

Add function setup_env_for_tests which prepares dynamic debug
and trace environment for tests execution. This is to clean up
previous settings or leftovers after a failing test. The function
setup_env_for_tests does the following to prepare the environment:
- unloads test_dynamic_debug, test_dynamic_debug_submod modules
if any of them is loaded,
- it prints info about all callsites which have flags != "_" and
sets these flags to "_:0",
- it closes open trace instances and deletes their respective
directories.

The patch also refactors ifrmmod function.

Signed-off-by: Łukasz Bartosik <ukaszb@...omium.org>
---
 .../dynamic_debug/dyndbg_selftest.sh          | 36 +++++++++++++++++--
 1 file changed, 34 insertions(+), 2 deletions(-)

diff --git a/tools/testing/selftests/dynamic_debug/dyndbg_selftest.sh b/tools/testing/selftests/dynamic_debug/dyndbg_selftest.sh
index 86bb039df4a1..f8b81e8a3bd6 100755
--- a/tools/testing/selftests/dynamic_debug/dyndbg_selftest.sh
+++ b/tools/testing/selftests/dynamic_debug/dyndbg_selftest.sh
@@ -147,8 +147,8 @@ function error_log_ref {
 }
 
 function ifrmmod {
-    lsmod | grep $1 2>&1>/dev/null || echo $1 not there
-    lsmod | grep $1 2>&1>/dev/null && rmmod $1
+    lsmod | grep $1 2>&1>/dev/null || ([ "$2" == "-v" ] && echo "module '$1' is not loaded")
+    lsmod | grep $1 2>&1>/dev/null && rmmod $1 && [ "$2" == "-v" ] && echo "unload module '$1'"
 }
 
 # $1 - text to search for
@@ -657,6 +657,37 @@ function test_private_trace_fill_trace_index {
     check_trace_instance_dir trace_instance_63 0
 }
 
+# prepares dynamic debug and trace environment for tests execution
+function setup_env_for_tests {
+    echo -e "${GREEN}# SETUP_ENV_FOR_TESTS ${NC}"
+
+    echo "MODULES"
+    ifrmmod test_dynamic_debug_submod -v	# unload test_dynamic_debug_submod module
+                                                # if it is loaded
+    ifrmmod test_dynamic_debug -v	# unload test_dynamic_debug module it if is loaded
+    echo
+
+    # display all callsites which have flags != "_"
+    echo "CALLSITES with flags != \":0\""
+    cat /proc/dynamic_debug/control | grep -v "=_" | grep -v "not set" | grep -v "^$" \
+	    | grep -v "#: Opened trace instances" | grep -v "#: Default trace destination"
+    ddcmd module,*,=_:0 # clear all flags and set dest to 0
+    echo
+
+    # close all opened trace instances and delete their respective directories
+    echo "OPEN trace instance"
+    output=$(tail -n9 /proc/dynamic_debug/control | grep "#: Opened trace instances" \
+	    | cut -f3 -d":" | xargs -n1)
+    for dst in $output
+    do
+        echo "close trace instance '$dst'"
+	echo close,$dst > /proc/dynamic_debug/control
+	echo "delete '/sys/kernel/debug/tracing/instances/$dst' directory"
+	rmdir /sys/kernel/debug/tracing/instances/$dst
+    done
+    echo
+}
+
 tests_list=(
     basic_tests
     comma_terminator_tests
@@ -680,6 +711,7 @@ tests_list=(
 
 # Run tests
 
+setup_env_for_tests
 for test in "${tests_list[@]}"
 do
     $test
-- 
2.43.0.687.g38aa6559b0-goog


Powered by blists - more mailing lists

Powered by Openwall GNU/*/Linux Powered by OpenVZ