From patchwork Wed Jan 17 18:02:31 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Benjamin Berg X-Patchwork-Id: 1887593 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@legolas.ozlabs.org Authentication-Results: legolas.ozlabs.org; dkim=pass (2048-bit key; secure) header.d=lists.infradead.org header.i=@lists.infradead.org header.a=rsa-sha256 header.s=bombadil.20210309 header.b=aWdYVU45; dkim=fail reason="signature verification failed" (2048-bit key; secure) header.d=sipsolutions.net header.i=@sipsolutions.net header.a=rsa-sha256 header.s=mail header.b=ZH3Bu+co; dkim-atps=neutral Authentication-Results: legolas.ozlabs.org; spf=none (no SPF record) smtp.mailfrom=lists.infradead.org (client-ip=198.137.202.133; helo=bombadil.infradead.org; envelope-from=hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org; receiver=patchwork.ozlabs.org) Received: from bombadil.infradead.org (bombadil.infradead.org [198.137.202.133]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature ECDSA (secp384r1) server-digest SHA384) (No client certificate requested) by legolas.ozlabs.org (Postfix) with ESMTPS id 4TFYg36jhwz1yPh for ; Thu, 18 Jan 2024 05:04:31 +1100 (AEDT) DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender: Content-Transfer-Encoding:Content-Type:List-Subscribe:List-Help:List-Post: List-Archive:List-Unsubscribe:List-Id:MIME-Version:Message-ID:Date:Subject:Cc :To:From:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:In-Reply-To:References: List-Owner; bh=Q0Fi1vqlJ/fJVpK7nz8yQQAdQbyJcoC9GaKTy2aV84U=; b=aWdYVU45hSjOyv dJPV14loBepJnK2Nwb+fZU4KevSSzv+VlvoclVJ4LIp+ldssmP63c0JkMKd+QPXQ/jZcyaAaGPMPB QZLwJZ0nN3tJ+u+l43TKZc1UR5WU/MEsMtdETQjx4ctkzdFkVs5qUxzx+uoE2WH7lT1rnnkH5WvOp 9Pa7JIsfqM43+PiIK2iKn+K6YktJdtK9/SFQVF9HIcpbwb+P1vH9ZvB5p70/U/hIEkWiBw+aBVKe2 WZzgx6A6Z5IDs1LIKmBjm18/FWaPX0HDvets+CMwf7sazJg7A/iexKHhPJW4IO4c0r/J9fPBsvkJz iQj15KojnavGdky5kIwg==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.96 #2 (Red Hat Linux)) id 1rQAFx-000Iaa-35; Wed, 17 Jan 2024 18:03:17 +0000 Received: from s3.sipsolutions.net ([2a01:4f8:242:246e::2] helo=sipsolutions.net) by bombadil.infradead.org with esmtps (Exim 4.96 #2 (Red Hat Linux)) id 1rQAFu-000IZZ-1L for hostap@lists.infradead.org; Wed, 17 Jan 2024 18:03:15 +0000 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=sipsolutions.net; s=mail; h=Content-Transfer-Encoding:MIME-Version: Message-ID:Date:Subject:Cc:To:From:Content-Type:Sender:Reply-To:Content-ID: Content-Description:Resent-Date:Resent-From:Resent-To:Resent-Cc: Resent-Message-ID:In-Reply-To:References; bh=UbcbyR94u8U15i77A2ljD88J6MO8sF8FXOaV0CgXM+U=; t=1705514594; x=1706724194; b=ZH3Bu+co7fKVErKkOys4ubeogBXHgE01ogUZC0Kbon3W6TBV/Zlbs2NqPNE2t9X+Icys5Ymg8zy IO4sEzWXJd2xO7IXAqcFneIhCh//r6NVMDIzQTd5B6X9jv0ix3bOxcDexYE/doqqnXarVWlRTe74W kG9yUUAFWVLOim/tltbG/RRvRQj/sxL4o3E0dHgDtn29lPlpDaYiaL2a8WFNffLvESm5iVlg4R2eE XgTh8zcnij7qi0MTHDd5iwZCSS/cyoIhIopkntzYuNszrogNCaerAq+SCqxT/6qKzYjNlbAw0MCjC E0FgbBif2ktaUeL4ffnARG6XCw6y2fYfuSlA==; Received: by sipsolutions.net with esmtpsa (TLS1.3:ECDHE_X25519__RSA_PSS_RSAE_SHA256__AES_256_GCM:256) (Exim 4.97) (envelope-from ) id 1rQAFr-00000006gJm-1qok; Wed, 17 Jan 2024 19:03:11 +0100 From: benjamin@sipsolutions.net To: hostap@lists.infradead.org Cc: Benjamin Berg Subject: [PATCH v2] hwsim: Use pgrep instead of ps Date: Wed, 17 Jan 2024 19:02:31 +0100 Message-ID: <20240117180231.2088768-1-benjamin@sipsolutions.net> X-Mailer: git-send-email 2.43.0 MIME-Version: 1.0 X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20240117_100314_456744_3322B0CA X-CRM114-Status: GOOD ( 12.33 ) X-Spam-Score: -0.2 (/) X-Spam-Report: Spam detection software, running on the system "bombadil.infradead.org", has NOT identified this incoming email as spam. The original message has been attached to this so you can view it or label similar future email. If you have any questions, see the administrator of that system for details. Content preview: From: Benjamin Berg The ps command as shipped by busybox does not support the "command" column. Change the code to use pgrep instead which will work fine in all environments. Content analysis details: (-0.2 points, 5.0 required) pts rule name description ---- ---------------------- -------------------------------------------------- -0.0 SPF_PASS SPF: sender matches SPF record -0.0 SPF_HELO_PASS SPF: HELO matches SPF record -0.1 DKIM_VALID_AU Message has a valid DKIM or DK signature from author's domain -0.1 DKIM_VALID Message has at least one valid DKIM or DK signature 0.1 DKIM_SIGNED Message has a DKIM or DK signature, not necessarily valid -0.1 DKIM_VALID_EF Message has a valid DKIM or DK signature from envelope-from domain X-BeenThere: hostap@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "Hostap" Errors-To: hostap-bounces+incoming=patchwork.ozlabs.org@lists.infradead.org From: Benjamin Berg The ps command as shipped by busybox does not support the "command" column. Change the code to use pgrep instead which will work fine in all environments. Signed-off-by: Benjamin Berg --- v2: * Add sleep 1 into inside.sh * Remove duplicate strip() * Raise an exception if PID was not found --- tests/hwsim/test_ap_eap.py | 17 ++++++----------- tests/hwsim/vm/inside.sh | 3 +++ 2 files changed, 9 insertions(+), 11 deletions(-) diff --git a/tests/hwsim/test_ap_eap.py b/tests/hwsim/test_ap_eap.py index bfc1bb417..beb02f965 100644 --- a/tests/hwsim/test_ap_eap.py +++ b/tests/hwsim/test_ap_eap.py @@ -7607,20 +7607,15 @@ def test_ap_wpa2_eap_psk_mac_addr_change(dev, apdev): params = hostapd.wpa2_eap_params(ssid="test-wpa2-eap") hapd = hostapd.add_ap(apdev[0], params) - cmd = subprocess.Popen(['ps', '-eo', 'pid,command'], stdout=subprocess.PIPE) - res = cmd.stdout.read().decode() + cmd = subprocess.Popen(['pgrep', '-nf', 'wpa_supplicant.*' + dev[0].ifname], stdout=subprocess.PIPE) + res = cmd.stdout.read().decode().strip() cmd.stdout.close() pid = 0 - for p in res.splitlines(): - if "wpa_supplicant" not in p: - continue - if dev[0].ifname not in p: - continue - pid = int(p.strip().split(' ')[0]) - if pid == 0: - logger.info("Could not find wpa_supplicant PID") - else: + if res: + pid = int(res) logger.info("wpa_supplicant PID %d" % pid) + else: + raise Exception("Could not find wpa_supplicant PID") addr = dev[0].get_status_field("address") subprocess.call(['ip', 'link', 'set', 'dev', dev[0].ifname, 'down']) diff --git a/tests/hwsim/vm/inside.sh b/tests/hwsim/vm/inside.sh index 38c5284d9..31dfb9d57 100755 --- a/tests/hwsim/vm/inside.sh +++ b/tests/hwsim/vm/inside.sh @@ -146,6 +146,9 @@ if [ "$TELNET" = "1" ] ; then ) & fi +# procps 3.3.17 needs an uptime of >1s (relevant for UML time-travel) +sleep 1 + # check if we're rebooting due to a kernel panic ... if grep -q 'Kernel panic' /tmp/logs/console ; then echo "KERNEL CRASHED!" >/dev/ttyS0