Received: by 2002:a25:8b12:0:0:0:0:0 with SMTP id i18csp604934ybl; Mon, 12 Aug 2019 23:13:15 -0700 (PDT) X-Google-Smtp-Source: APXvYqx9zs7nzZmR2C5Z7N463TAU5NaHtSz8AGBam/2qeEgM2VGBRIU0TWCmFWoVz57fBJlospXJ X-Received: by 2002:a65:680b:: with SMTP id l11mr33272243pgt.35.1565676795040; Mon, 12 Aug 2019 23:13:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1565676795; cv=none; d=google.com; s=arc-20160816; b=q0KifLKH4BhCCkxbFhvjRSVbwS2tPABSAMRzBOQixE3bgeMUA2iSQiUx+G3Jvr9ci0 CrGv4udLG/5cF4EvrQvNbe7gRkDVTaRg2e51OckoyHef2I+eNse506iwI2QLXA8fmQmP vn0iXQ12Cf3gBzd0sd2TteV6eVia9X2wTJlmy0xv3J87VSZfOYZJyMrZlyEjRKpxCHbp BRnhsASR60rrAHhbMDuUN27TdXZ+slEOoGW/sFRT0oR/dJh1TNvuboGQc8tLI14fAUJj e4tP0oXY24N8EvsaSjnSUUChWqPVetD31GdZKrpZf+/FydQRwkxeEOsUs0dp/tI2Thla f3Pg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:content-transfer-encoding:mime-version :references:in-reply-to:message-id:date:subject:cc:to:from :dkim-signature:dkim-signature; bh=tfjxeCtOt/zjkP/k6+2p52MgrQfqToiEPXPQHRk3l/0=; b=zE5iWgRY32X/EBZ4HSTfHOIvdF0/hQW3kYMcsN9XXZymQj4aogiS7vBvHJGnUAMXrW kXXBmyAfzuYO92VCm00xfESoQv/6+jbCwADMf2sPx3gM5niQAeYS6fve9eIzu2PfXbRn 5UdwGRmWQpvEOs+2N/eGmJWeFDONpsH/X62dYb9KsMAoix2awFem+6IpGNzeKma1J4zt tA6hpFau6rHLWQDQqWzYZHVxsc6fpoYQUJT688I+rbZ5a1fIiF1i9tX35ErVJNUXjDVi Adxyh9YYLGiNl8mXGLh9KwCuqBoTei3MYiWkyjusCyNON43F0e3iDk3o/NZe9SuTINzW e1Qw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2019-08-05 header.b=SI1H4ybB; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=hWzOqaGX; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id 35si30406813pgm.168.2019.08.12.23.12.59; Mon, 12 Aug 2019 23:13:15 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; dkim=pass header.i=@oracle.com header.s=corp-2019-08-05 header.b=SI1H4ybB; dkim=pass header.i=@oracle.com header.s=corp-2018-07-02 header.b=hWzOqaGX; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=oracle.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727811AbfHMGMH (ORCPT + 99 others); Tue, 13 Aug 2019 02:12:07 -0400 Received: from userp2130.oracle.com ([156.151.31.86]:60904 "EHLO userp2130.oracle.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727776AbfHMGME (ORCPT ); Tue, 13 Aug 2019 02:12:04 -0400 Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x7D68sFA010844; Tue, 13 Aug 2019 06:11:45 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=corp-2019-08-05; bh=tfjxeCtOt/zjkP/k6+2p52MgrQfqToiEPXPQHRk3l/0=; b=SI1H4ybBHfNsYu/Iq7509UOI1VugUK3iV4C2jN5o9Uhac0JNJ5it4UX5QPSrxZf2oGwj RgoEUetbN1autivZAxCizMV0pdEiZIP1cs4cCamatDBjsbUNirmTF2NLi1kQZsfJJobe kkaHIt4nCocvIrRkxPgSCvWDCH6Owzy7rK+my4nThcBKzl+lTWRJ0Co/xM3G3FqpDK+7 AWyaCQWaDGQcZI0GPy8NitoNK5HE9n/UEQkv4RZfMTNf8tQDpfeEdGC6XF4QEKtl6Img gOe94eUzCaozXo25qnIpufC9qIGBjOMClQWqDDMLbmJvCnsqYZB48QT/FFhRRpGqcCFG Bg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id : in-reply-to : references : mime-version : content-transfer-encoding; s=corp-2018-07-02; bh=tfjxeCtOt/zjkP/k6+2p52MgrQfqToiEPXPQHRk3l/0=; b=hWzOqaGXKwpzIdSDdWIddVoqjiwHK+49GsjUFU8opMFYOQuSPlN+ZgJPKMDvR1M3gfg+ d2qRY4wIZVnjuCQqSII+S5LQozuTfzSNb2KGWogQbeWS4zxqoEiZ9rfOtfsdkmcyN9Xl V/cMLDe5JB4Uu3koOm/K3WJaWHPmnvx+c7/ESMgCzjvcVYyKlyO9Ue0xaNJLHiDOxsCW Irbhua8yDqmDBf+qCnix/kxI+UZnuklVMk1nZi+qTkFyzd/UrdEWNVaVEUKk7/wxruor ZHmvkm4wzvdBbv3pB1jbz9R7x20sT6lHImhDN9KjjiwEVCKqe+eZlFwmHHfQlCksWtkS Lg== Received: from aserp3020.oracle.com (aserp3020.oracle.com [141.146.126.70]) by userp2130.oracle.com with ESMTP id 2u9nbtc13t-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 13 Aug 2019 06:11:45 +0000 Received: from pps.filterd (aserp3020.oracle.com [127.0.0.1]) by aserp3020.oracle.com (8.16.0.27/8.16.0.27) with SMTP id x7D67Txc157148; Tue, 13 Aug 2019 06:11:44 GMT Received: from aserv0122.oracle.com (aserv0122.oracle.com [141.146.126.236]) by aserp3020.oracle.com with ESMTP id 2u9nrenmd3-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK); Tue, 13 Aug 2019 06:11:44 +0000 Received: from abhmp0019.oracle.com (abhmp0019.oracle.com [141.146.116.25]) by aserv0122.oracle.com (8.14.4/8.14.4) with ESMTP id x7D6Bif7013702; Tue, 13 Aug 2019 06:11:44 GMT Received: from abi.no.oracle.com (/10.172.144.123) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 12 Aug 2019 23:11:43 -0700 From: Knut Omang To: linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Cc: linux-doc@vger.kernel.org, linux-kbuild@vger.kernel.org, Shuah Khan , Jonathan Corbet , Masahiro Yamada , Michal Marek , Greg Kroah-Hartman , Shreyans Devendra Doshi <0xinfosect0r@gmail.com>, Alan Maguire , Brendan Higgins , Kevin Hilman , Hidenori Yamaji , Frank Rowand , Timothy Bird , Luis Chamberlain , "Theodore Ts'o" , Daniel Vetter , Stephen Boyd , Knut Omang Subject: [RFC 14/19] ktf: Internal debugging facilities Date: Tue, 13 Aug 2019 08:09:29 +0200 Message-Id: <2e0a915bf97d241eced54efa540c9a11a1996c27.1565676440.git-series.knut.omang@oracle.com> X-Mailer: git-send-email 2.20.1 In-Reply-To: References: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9347 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=0 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1908130067 X-Proofpoint-Virus-Version: vendor=nai engine=6000 definitions=9347 signatures=668685 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 priorityscore=1501 malwarescore=0 suspectscore=0 phishscore=0 bulkscore=0 spamscore=0 clxscore=1015 lowpriorityscore=0 mlxscore=0 impostorscore=0 mlxlogscore=999 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1906280000 definitions=main-1908130067 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Utilities for convenient and runtime enabled/disabled printk debugging mainly intended for debugging ktf itself and subtle early issues with execution/running of tests. ktf_debug.h: User mode debug function definitions Signed-off-by: Knut Omang --- tools/testing/selftests/ktf/lib/ktf_debug.cc | 20 +++++++- tools/testing/selftests/ktf/lib/ktf_debug.h | 59 +++++++++++++++++++++- 2 files changed, 79 insertions(+) create mode 100644 tools/testing/selftests/ktf/lib/ktf_debug.cc create mode 100644 tools/testing/selftests/ktf/lib/ktf_debug.h diff --git a/tools/testing/selftests/ktf/lib/ktf_debug.cc b/tools/testing/selftests/ktf/lib/ktf_debug.cc new file mode 100644 index 0000000..18ff443 --- /dev/null +++ b/tools/testing/selftests/ktf/lib/ktf_debug.cc @@ -0,0 +1,20 @@ +/* Copyright (c) 2012 Oracle Corporation. All rights reserved + * + * SPDX-License-Identifier: GPL-2.0 + */ + +#include "ktf_debug.h" +#include + +unsigned long ktf_debug_mask = 0; + + +void ktf_debug_init() +{ + ktf_debug_mask = 0; + char* dbg_mask_str = getenv("KTF_DEBUG_MASK"); + if (dbg_mask_str) { + ktf_debug_mask = strtol(dbg_mask_str, NULL, 0); + log(KTF_INFO_V, "debug mask set to 0x%lx\n", ktf_debug_mask); + } +} diff --git a/tools/testing/selftests/ktf/lib/ktf_debug.h b/tools/testing/selftests/ktf/lib/ktf_debug.h new file mode 100644 index 0000000..dc761a4 --- /dev/null +++ b/tools/testing/selftests/ktf/lib/ktf_debug.h @@ -0,0 +1,59 @@ +/* Copyright (c) 2012 Oracle Corporation. All rights reserved + * Author: Knut Omang + * + * SPDX-License-Identifier: GPL-2.0 + * + * ktf_debug.h: User mode debug function definitions + * - intended for test debugging. + * + * Enabled by setting bits in the environment variable KTF_DEBUG_MASK + */ + +#ifndef _KTF_DEBUG_H +#define _KTF_DEBUG_H +#include +#include +#include +#include +#include +#include + +extern unsigned long ktf_debug_mask; + + +#define KTF_ERR 0x1 +#define KTF_WARN 0x2 +#define KTF_INFO 0x4 +#define KTF_INFO_V 0x100 +#define KTF_MR 0x2000 +#define KTF_DEBUG 0x10000 +#define KTF_POLL 0x20000 +#define KTF_EVENT 0x40000 +#define KTF_DEBUG_V 0x1000000 +#define KTF_DUMP 0x2000000 + +/* Call this to initialize the debug logic from + * environment KTF_DEBUG_MASK + */ +void ktf_debug_init(); + +#define log(level, format, arg...) \ +do {\ + if (level & ktf_debug_mask) {\ + char _tm[30]; \ + time_t _tv = time(NULL);\ + ctime_r(&_tv,_tm);\ + _tm[24] = '\0';\ + fprintf(stderr, "%s [%ld] %s: " format, \ + _tm, (long unsigned int) pthread_self(), __func__, ## arg); \ + }\ +} while (0) + +#define logs(class, stmt_list) \ + do { \ + if (ktf_debug_mask & class) { \ + stmt_list; \ + } \ + } while (0) + +#endif -- git-series 0.9.1