From patchwork Sat Feb 10 23:50:03 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?=C5=81ukasz_Bartosik?= X-Patchwork-Id: 199344 Return-Path: Delivered-To: ouuuleilei@gmail.com Received: by 2002:a05:7300:50ea:b0:106:860b:bbdd with SMTP id r10csp1702128dyd; Sat, 10 Feb 2024 15:59:04 -0800 (PST) X-Google-Smtp-Source: AGHT+IG1Wkpw4daXusjxTWKpKk0typyDHQqTtcwe6LLZ2EQlDQM7VP7VUOkmdibru/dW9HXFBqjK X-Received: by 2002:ac8:5acb:0:b0:42c:5856:4b94 with SMTP id d11-20020ac85acb000000b0042c58564b94mr9012995qtd.4.1707609544272; Sat, 10 Feb 2024 15:59:04 -0800 (PST) ARC-Seal: i=2; a=rsa-sha256; t=1707609544; cv=pass; d=google.com; s=arc-20160816; b=vx0g1gEVUoKghU5oKegIuyshavoG6XxOd/6DevsoEK+KFgPZA+sj+py3lhzUWl/2tz olPoiRA/ZEcZ2RGOBnZ31D4SZO3EqdQmBEK0XpN7QmBAuAfbwK62AYZAICMW3fY0eK5u gHYJZymRAEhQS2hLMQK/kTJdFvHO78rqcT/R776OkFYq/kzqQbNeHsEQh1VFi16ckP+d 75rRCTiT7MML4eRokyGyd/tnf81jvzkAppX5gHptjmxHNP5//Ms2SMV9OeG0drUTtbaJ rFo228iEz+nNmBP+K7k2mP6Qvqv5CIXByfaBQOFuO1tRUekXKMCYwrHCjo2GzGV0Hdj+ 2KZg== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=0fePKdpvwVIgbzeITeSRDnfaI3pNosmqbiOFvtjCGd4=; fh=F85fYeOuluv0PlA9qzz+77XEfteIk6Suj3u9UTX0g7c=; b=LGfgNrTUt1vv9D6ZIj1HuW+9pS0AVbpFjBNVTaVW4OedLrCfvnxGErXfu9XiLtXvFx E/w86RLXOcXvfdRJJP0SiDzfnG5yc39xdzsltVSmh4pszcil11lIdYm2tRSZ3t455sup XHN2UKGbvLWoBHyiEzeELQ3DeZY8hKi1kqeOfyyIeBrvcN09myJs5/fwwfhqMp0AG+ut GZrjft5ebgdkyA1f8biul3VzmJRvi7a7N6nSrhxMp4dpU1L0uyapvVORzaGy1g4neGpD bIQNM3vaecYm2rIl0D2xPXa/Ee5Fdz1pVsjhJ2eYWXFf17vRYdbAnQ/96TLh5ihZp2Cj X77w==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=ZgGtHSlM; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-60616-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-60616-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org X-Forwarded-Encrypted: i=2; AJvYcCVueQgUiDbI1VygA0ciHakXJ5xcghGNwPoC6MnglKdx1cH5cAWH5oCNVV1/HcqwAVUpwOAc/MSaKfDjML18lCvhhoK8bQ== Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [2604:1380:45d1:ec00::1]) by mx.google.com with ESMTPS id g6-20020ac85d46000000b0042c4d2e9bd2si5466652qtx.521.2024.02.10.15.59.04 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Feb 2024 15:59:04 -0800 (PST) Received-SPF: pass (google.com: domain of linux-kernel+bounces-60616-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) client-ip=2604:1380:45d1:ec00::1; Authentication-Results: mx.google.com; dkim=pass header.i=@chromium.org header.s=google header.b=ZgGtHSlM; arc=pass (i=1 spf=pass spfdomain=chromium.org dkim=pass dkdomain=chromium.org dmarc=pass fromdomain=chromium.org); spf=pass (google.com: domain of linux-kernel+bounces-60616-ouuuleilei=gmail.com@vger.kernel.org designates 2604:1380:45d1:ec00::1 as permitted sender) smtp.mailfrom="linux-kernel+bounces-60616-ouuuleilei=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=chromium.org Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 0876E1C21BA9 for ; Sat, 10 Feb 2024 23:59:04 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id B07236026F; Sat, 10 Feb 2024 23:51:31 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b="ZgGtHSlM" Received: from mail-lf1-f67.google.com (mail-lf1-f67.google.com [209.85.167.67]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4913864CF6 for ; Sat, 10 Feb 2024 23:51:26 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.67 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707609088; cv=none; b=J1SsMQwokzk3Zx6v0nUNMoRu6giY+Dbr/tpc3CYUkwpPyxT0HXMyXxyBaS/bezYYpJ6o2aoHfJ7P9g8we6WON0e+vBft8td1OT9w81u7t92hWVUU/WhYPMe4zYnDd+sikqN+LtibDg+G/wbqAAHJnUNbjaSAVGUZJP7JGti8LQw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1707609088; c=relaxed/simple; bh=BgpJuFbGh1uswlxIaHPo2wvw9RKXh2Tg8JfjcMwd1b0=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=bV18MIlZFDCV/lzYbTe22VDdK4RUHYqrCPaoZWSVgQSbspHmfyttOm9wHgmZ1rtS9nxpFr7RalX8EIm/CNST+z/rMLw8psHNEInFpgIzbrJwFQnqeV/0oDfnZa1uM6TcAoKNToH7uUgroPNNl6apCkfXVrFrHOhDJSyFaTlLP5s= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org; spf=pass smtp.mailfrom=chromium.org; dkim=pass (1024-bit key) header.d=chromium.org header.i=@chromium.org header.b=ZgGtHSlM; arc=none smtp.client-ip=209.85.167.67 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=chromium.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=chromium.org Received: by mail-lf1-f67.google.com with SMTP id 2adb3069b0e04-51168addef1so3887340e87.1 for ; Sat, 10 Feb 2024 15:51:26 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=chromium.org; s=google; t=1707609084; x=1708213884; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=0fePKdpvwVIgbzeITeSRDnfaI3pNosmqbiOFvtjCGd4=; b=ZgGtHSlMBHdlXSSArbiLbydJUD17HeurhXehlb2xa1YwEdiThxXw9oju9fgkStt+4S ZRxH8mg4k7ofhhy9d5fWt+b/EtM/SSoCXOb9hZZmZOfq+q1aP68cP0bbyQdP2bqP5McT QxbDVpQOoZXSdnO5+PFE7pPIc4ayqxWcVzyk4= X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1707609084; x=1708213884; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=0fePKdpvwVIgbzeITeSRDnfaI3pNosmqbiOFvtjCGd4=; b=uKOIp/vg4ucD25aGyIXsnlfSqoKMBxMNfjoNQw/4jgNwfy1c3jHdBQkGoT1JFIOqws yFG9LHdAuwHyLWPXx/iTytHClxqwGNYtcefEml0r/WiYvK4ZsPCChiC+fhoqh1mtPvi+ bW7KxHDLdssYgEvkJ3Per6yHKBFBmECqrac9ul9336+Yc8GO9I4dLNFwkjHQbNPnd9QI SQWadNVlZ3ojpRg+grnPK5IGpMhOGlvBgHHA3Im2OGDN+cXVQsXIkjGgZMKe22FqhNdI 7ZTdBak1eTvUfUJK9b9jHhgYMurNXFXMsM4YHy+2S4N2zt9EJQ6Fs7WX2oB/D+0lJeBc Gm4w== X-Gm-Message-State: AOJu0YwFMyI0Cvs+498ZtKlHtrHUNnCXEnJ+Lbv4pwik/Lp0WL1VqtMn FgZ6iH0wB2w+XOXE/i7nrP7Fw1+AQBSGPLc1b/8Q44XxV/tTWa4eNpLjIjs+ X-Received: by 2002:ac2:485b:0:b0:511:5ef9:ebb0 with SMTP id 27-20020ac2485b000000b005115ef9ebb0mr1792496lfy.25.1707609084554; Sat, 10 Feb 2024 15:51:24 -0800 (PST) X-Forwarded-Encrypted: i=1; AJvYcCVe25uHF/Y6h5rhYjF7VhDkIljr93LL8p0J1F3LUwmAn/7U9VPhzTn/QCvhBXbjahw0V3qcMX0aw1kZU658PZh4oLCCYR3KmuEiJJw9a6XaZJnicBA2Ly4oilWLX2VKAixMLmou78F1vdvwei+pM8GGFvCxBWbXns8SJNbNabpmt23RsdMn2Lf7iRGISBK1xPHAJcK+/2q6lA8DhRUZBeFEfIzOk1FfSzhqKkw/ivPY4pQA2GJAS9jGs3XmewRKzxa/IgASN651oYd8S9Vp0QXUEgXy5m89gXVpS9h4xyZJWAGGULs1HPUpTWui+Q09vsa3462QT+Gykelb8HkZ54eiQB82x8f8pR8fbaMMc5Ees2dRUW/5udtR7dOghbogBsBplVQSGYSFrVQ9v2J/TG1IIIurutHekjF3Cxfw80Atlpvl48Cu3S7DAorBIqU8juja95tCwpijBiLQ25MKJlFMhLjlRtWpvwC7U19TJyeLZaGEJV8PnqHtvmU8FXaWRhiW2jZNOvvOBDJgkV6HTfFM2D8LYaxBdltM1Yn2nJNFcJavYekToXJu+lb/C4Jlj2Xk7zqhVpYxiI9nPZG1xHOxWpbnVnp/2cyhmec3Jo6iJGN7eA== Received: from ukaszb-l.roam.corp.google.com (alfa56.extreme-net.one.pl. [213.77.89.56]) by smtp.gmail.com with ESMTPSA id o27-20020a056512051b00b0051179ae1846sm365561lfb.280.2024.02.10.15.51.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 10 Feb 2024 15:51:24 -0800 (PST) From: =?utf-8?q?=C5=81ukasz_Bartosik?= To: Jason Baron , Jim Cromie , Greg Kroah-Hartman , Andrew Morton , Kees Cook , Douglas Anderson Cc: Guenter Roeck , Yaniv Tzoreff , Benson Leung , Steven Rostedt , Vincent Whitchurch , Pekka Paalanen , Sean Paul , Daniel Vetter , Simon Ser , John Ogness , Petr Mladek , Sergey Senozhatsky , linux-kernel@vger.kernel.org, upstream@semihalf.com Subject: [PATCH v4 33/39] dyndbg-test: setup environment for tests execution Date: Sun, 11 Feb 2024 00:50:03 +0100 Message-ID: <20240210235009.2405808-34-ukaszb@chromium.org> X-Mailer: git-send-email 2.43.0.687.g38aa6559b0-goog In-Reply-To: <20240210235009.2405808-1-ukaszb@chromium.org> References: <20240210235009.2405808-1-ukaszb@chromium.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 X-getmail-retrieved-from-mailbox: INBOX X-GMAIL-THRID: 1790558385662929901 X-GMAIL-MSGID: 1790558385662929901 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 --- .../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