From patchwork Mon Jan 20 03:20:37 2025 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Aaron Merey X-Patchwork-Id: 105077 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 4060F3858C52 for ; Mon, 20 Jan 2025 03:23:30 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 4060F3858C52 Authentication-Results: sourceware.org; dkim=pass (1024-bit key, unprotected) header.d=redhat.com header.i=@redhat.com header.a=rsa-sha256 header.s=mimecast20190719 header.b=bCyFjU5O X-Original-To: elfutils-devel@sourceware.org Delivered-To: elfutils-devel@sourceware.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.129.124]) by sourceware.org (Postfix) with ESMTP id 72DF73858410 for ; Mon, 20 Jan 2025 03:20:57 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 72DF73858410 Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=redhat.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=redhat.com ARC-Filter: OpenARC Filter v1.0.0 sourceware.org 72DF73858410 Authentication-Results: server2.sourceware.org; arc=none smtp.remote-ip=170.10.129.124 ARC-Seal: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1737343257; cv=none; b=Z6QXZ2y7aijGrYB5+TDCf7PLlxYvFO63vzT3Z0ePBf1S15XgbVBQsgcfR0mf3+WnTKhvTiLVkxegqnLvrILYgrfIRMfX/rgloq8SdLXpnMNUUsLg9+mypCjRed3OQAnaJDGsUwO8Q1bBrgu9xwqDTEKSlFyhjr5+nU1P4ntv43U= ARC-Message-Signature: i=1; a=rsa-sha256; d=sourceware.org; s=key; t=1737343257; c=relaxed/simple; bh=h7vPp2G5RMFxmTkjfOGSGlUcfOQKLe6KK4jmnnmodtk=; h=DKIM-Signature:From:To:Subject:Date:Message-ID:MIME-Version; b=UYuBjazoL+5NUPTw9ZSkPdFuJCBUHQC1bZbI0l0iApkqyKYso8b1P2X6/DwAw+m9X19/2tR13PI2FPjSD2jbEFnUjUOolMl+noasAQVIs4nLwj2+I7WadxXtr7/+a+GB7ZfhEfKE6Cam9r494aw+0KPo67j2fa8tgNbPjhb1eAQ= ARC-Authentication-Results: i=1; server2.sourceware.org DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 72DF73858410 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1737343257; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=kDrvwkyV2XsUWmDO7x5EB5R8InZTk0UwK0ZvOFsg/EU=; b=bCyFjU5O9/47m09Fe5QZ0NnJ6EhoA3qRXmjGl9JJGUcXWZFPE2fJMlBprHm0pCYMnBXN1T fXFNJE/L86MlSoUczcMFdS+DRw1r/XV+pjGnL6H5AHJ1EAu1Z7dNoe25mFEEjmxtRiFExg Ws8iRFLthMIu6+vWXaaRie1s1XnFG7E= Received: from mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (ec2-54-186-198-63.us-west-2.compute.amazonaws.com [54.186.198.63]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-447-mELOXZEaNaenBLscnx8WSg-1; Sun, 19 Jan 2025 22:20:55 -0500 X-MC-Unique: mELOXZEaNaenBLscnx8WSg-1 X-Mimecast-MFC-AGG-ID: mELOXZEaNaenBLscnx8WSg Received: from mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com [10.30.177.15]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mx-prod-mc-03.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTPS id F252D19560AA for ; Mon, 20 Jan 2025 03:20:54 +0000 (UTC) Received: from fedora.redhat.com (unknown [10.22.80.25]) by mx-prod-int-02.mail-002.prod.us-west-2.aws.redhat.com (Postfix) with ESMTP id 421FE195608A; Mon, 20 Jan 2025 03:20:54 +0000 (UTC) From: Aaron Merey To: elfutils-devel@sourceware.org Cc: Aaron Merey Subject: [PATCH 11/15] Add tests/thread-safety-subr.sh Date: Sun, 19 Jan 2025 22:20:37 -0500 Message-ID: <20250120032041.280173-11-amerey@redhat.com> In-Reply-To: <20250120032041.280173-1-amerey@redhat.com> References: <20250120032041.280173-1-amerey@redhat.com> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 3.0 on 10.30.177.15 X-Mimecast-Spam-Score: 0 X-Mimecast-MFC-PROC-ID: daSgvwcmlO7H3FZ9eGV6Cbj7F1BcOQZ76YpFYJBPbQg_1737343255 X-Mimecast-Originator: redhat.com content-type: text/plain; charset="US-ASCII"; x-default=true X-Spam-Status: No, score=-13.6 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, KAM_SHORT, RCVD_IN_DNSWL_NONE, RCVD_IN_MSPIKE_H5, RCVD_IN_MSPIKE_WL, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: elfutils-devel@sourceware.org X-Mailman-Version: 2.1.30 Precedence: list List-Id: Elfutils-devel mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: elfutils-devel-bounces~patchwork=sourceware.org@sourceware.org thread-safety-subr.sh contains subroutine check_thread_safety_enabled which skips further testing when either USE_LOCKS is false or when attempting to use valgrind with address or memory sanitizer enabled. * tests/Makefile.am (EXTRA_DIST): Add thread-safety-subr.sh. * tests/thread-safety-subr.sh: New file. Signed-off-by: Aaron Merey --- tests/Makefile.am | 1 + tests/thread-safety-subr.sh | 53 +++++++++++++++++++++++++++++++++++++ 2 files changed, 54 insertions(+) create mode 100644 tests/thread-safety-subr.sh diff --git a/tests/Makefile.am b/tests/Makefile.am index e4fe72f0..9ca97b6f 100644 --- a/tests/Makefile.am +++ b/tests/Makefile.am @@ -689,6 +689,7 @@ EXTRA_DIST = run-arextract.sh run-arsymtest.sh run-ar.sh \ testfile-dwp-cu-index-overflow.source \ testfile-define-file.bz2 \ testfile-sysroot.tar.bz2 run-sysroot.sh run-debuginfod-seekable.sh + thread-safety-subr.sh if USE_HELGRIND diff --git a/tests/thread-safety-subr.sh b/tests/thread-safety-subr.sh new file mode 100644 index 00000000..9d361850 --- /dev/null +++ b/tests/thread-safety-subr.sh @@ -0,0 +1,53 @@ +#! /bin/sh +# Subroutines for thread safety testing +# Copyright (C) 2024 Red Hat, Inc. +# This file is part of elfutils. +# +# This file is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 3 of the License, or +# (at your option) any later version. +# +# elfutils is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program. If not, see . + +. $srcdir/test-subr.sh + +# Verify that thread safety tests can be run. If not, skip further testing. +check_thread_safety_enabled() +{ + # Extract build settings. + USE_LOCKS=$(grep '^#define USE_LOCKS' \ + ${abs_builddir}/../config.h | awk '{print $3}') + USE_ADDRESS_SANITIZER=$(grep 'USE_ADDRESS_SANITIZER_TRUE' \ + ${abs_builddir}/../config.status | awk -F'=' '{print $2}') + USE_MEMORY_SANITIZER=$(grep 'USE_MEMORY_SANITIZER_TRUE' \ + ${abs_builddir}/../config.status | awk -F'=' '{print $2}') + + # Test will only be run if USE_LOCKS is defined. Otherwise, skip. + if [[ "$USE_LOCKS" != 1 ]]; then + echo "USE_LOCKS is not defined. Skipping test." + exit 77 + fi + + if [[ "x$VALGRIND_CMD" == "x" ]]; then + return 0 + fi + + # Cannot use Valgrind and Address Sanitizer together. + if [[ "$USE_ADDRESS_SANITIZER" != "\"#\"" ]]; then + echo "Address Sanitizer is enabled. Skipping test." + exit 77 + fi + + # Cannot use Valgrind and Memory Sanitizer together. + if [[ "$USE_MEMORY_SANITIZER" != "\"#\"" ]]; then + echo "Memory Sanitizer is enabled. Skipping test." + exit 77 + fi +}