From patchwork Mon Aug 20 11:23:46 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Kodanev X-Patchwork-Id: 959602 X-Patchwork-Delegate: petr.vorel@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=lists.linux.it (client-ip=2001:1418:10:5::2; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=oracle.com header.i=@oracle.com header.b="NvbLDeeb"; dkim-atps=neutral Received: from picard.linux.it (picard.linux.it [IPv6:2001:1418:10:5::2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41vB5W2BfDz9s4c for ; Mon, 20 Aug 2018 21:14:06 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 1EB4A3E6477 for ; Mon, 20 Aug 2018 13:14:04 +0200 (CEST) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-3.smtp.seeweb.it (in-3.smtp.seeweb.it [IPv6:2001:4b78:1:20::3]) by picard.linux.it (Postfix) with ESMTP id 635BE3E640F for ; Mon, 20 Aug 2018 13:13:58 +0200 (CEST) Received: from userp2120.oracle.com (userp2120.oracle.com [156.151.31.85]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by in-3.smtp.seeweb.it (Postfix) with ESMTPS id 6DDA11A00EFE for ; Mon, 20 Aug 2018 13:13:57 +0200 (CEST) Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w7KB95nj091863 for ; Mon, 20 Aug 2018 11:13:55 GMT DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=oracle.com; h=from : to : cc : subject : date : message-id; s=corp-2018-07-02; bh=SQ9NDBZGzJCxKcmLPKVbnoIXylnxXGOvB/OaUWDLo7k=; b=NvbLDeebLAxBpbQSoEXQwkuM8UmIlk4j3+beXcgrs4+uxnHiqJfPmXCBuopePJyaMMdx jbtZBDu6Ne04fir+adkjefVjiuQe/nqfePl0PLw8St4Xd3Kr72SQAg9PcEOKAed4z0Tf /VnKVqZkg0rwfSvKT6QMMa3CUrd04bnX3C09xQlA2i8CUeq3uzedEQIAELYRARTFPito eiYa/nhjBrjOcEi+KySCkqUKEZKlLYIEdIcpoDEc+9wPJousW8cTzh4Kf5wPseUHV2aL sisqWgm6ZQ015JBAflK+DwUGYpzNc+cDKY8fDygMHu+lD5ySRQ6PBN5IScD21Y/3TEHL dQ== Received: from userv0022.oracle.com (userv0022.oracle.com [156.151.31.74]) by userp2120.oracle.com with ESMTP id 2kxc3qdm6s-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 20 Aug 2018 11:13:54 +0000 Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by userv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w7KBDsC7005951 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 20 Aug 2018 11:13:54 GMT Received: from abhmp0012.oracle.com (abhmp0012.oracle.com [141.146.116.18]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w7KBDrjO022329 for ; Mon, 20 Aug 2018 11:13:54 GMT Received: from ak.ru.oracle.com (/10.162.80.29) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 20 Aug 2018 04:13:53 -0700 From: Alexey Kodanev To: ltp@lists.linux.it Date: Mon, 20 Aug 2018 14:23:46 +0300 Message-Id: <1534764229-26993-1-git-send-email-alexey.kodanev@oracle.com> X-Mailer: git-send-email 1.7.1 X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8990 signatures=668707 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 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-1807170000 definitions=main-1808200122 X-Virus-Scanned: clamav-milter 0.99.2 at in-3.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=0.1 required=7.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU, SPF_HELO_PASS, SPF_PASS autolearn=disabled version=3.4.0 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on in-3.smtp.seeweb.it Subject: [LTP] [PATCH v2 1/4] lib/tst_test.c: add 'needs_drivers' option with tst_check_drivers cmd X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.18 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" The drivers are checked with modprobe. If modprobe is not available on the system, the checks are silently skipped. Signed-off-by: Alexey Kodanev Reviewed-by: Petr Vorel --- v2: * moved tst_check_driver() from tst_test.h to tst_kernel.h * added the new option description to the doc and comment to tst_kernel.h * iterating over the driver list moved out from tst_check_drivers(), the function renamed accordingly. doc/test-writing-guidelines.txt | 10 ++++++++++ include/tst_kernel.h | 8 ++++++++ include/tst_test.h | 3 +++ lib/tst_kernel.c | 9 +++++++++ lib/tst_test.c | 9 +++++++++ testcases/lib/.gitignore | 1 + testcases/lib/Makefile | 2 +- testcases/lib/tst_check_drivers.c | 24 ++++++++++++++++++++++++ 8 files changed, 65 insertions(+), 1 deletions(-) create mode 100644 testcases/lib/tst_check_drivers.c diff --git a/doc/test-writing-guidelines.txt b/doc/test-writing-guidelines.txt index a169724..7a458d5 100644 --- a/doc/test-writing-guidelines.txt +++ b/doc/test-writing-guidelines.txt @@ -1449,6 +1449,16 @@ https://www.kernel.org/doc/html/latest/admin-guide/tainted-kernels.html CRC32c checksum generation is supported by LTP. In order to use it, the test should include "tst_checksum.h" header, then can call tst_crc32c(). +2.2.26 Checking kernel for the driver support +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +Someties test needs certain drivers to be available in the kernel and must +end with TCONF if any are missing. For this task there is the '.needs_drivers' +option which accepts NULL-terminated array of the drivers names. + +Since it relies on modprobe command, the check will be skipped if the command +itself is not available on the system. + 2.3 Writing a testcase in shell ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ diff --git a/include/tst_kernel.h b/include/tst_kernel.h index 5d5c04c..88941e1 100644 --- a/include/tst_kernel.h +++ b/include/tst_kernel.h @@ -23,4 +23,12 @@ */ int tst_kernel_bits(void); +/** + * Checks support for the kernel driver. + * + * @param name The name of the driver. + * @return Returns 0 if the kernel has the driver or modprobe is missing. + */ +int tst_check_driver(const char *name); + #endif /* TST_KERNEL_H__ */ diff --git a/include/tst_test.h b/include/tst_test.h index 98dacf3..55c1418 100644 --- a/include/tst_test.h +++ b/include/tst_test.h @@ -170,6 +170,9 @@ struct tst_test { /* NULL terminated array of resource file names */ const char *const *resource_files; + + /* NULL terminated array of needed kernel drivers */ + const char * const *needs_drivers; }; /* diff --git a/lib/tst_kernel.c b/lib/tst_kernel.c index 42d64cb..ad00d2d 100644 --- a/lib/tst_kernel.c +++ b/lib/tst_kernel.c @@ -45,3 +45,12 @@ int tst_kernel_bits(void) return kernel_bits; } + +int tst_check_driver(const char *name) +{ + const char * const argv[] = { "modprobe", name, NULL }; + int res = tst_run_cmd_(NULL, argv, "/dev/null", "/dev/null", 1); + + /* 255 - it looks like modprobe not available */ + return (res == 255) ? 0 : res; +} diff --git a/lib/tst_test.c b/lib/tst_test.c index 2f3d357..dcc4088 100644 --- a/lib/tst_test.c +++ b/lib/tst_test.c @@ -767,6 +767,15 @@ static void do_setup(int argc, char *argv[]) if (tst_test->min_kver) check_kver(); + if (tst_test->needs_drivers) { + const char *name; + int i; + + for (i = 0; (name = tst_test->needs_drivers[i]); ++i) + if (tst_check_driver(name)) + tst_brk(TCONF, "%s driver not available", name); + } + if (tst_test->format_device) tst_test->needs_device = 1; diff --git a/testcases/lib/.gitignore b/testcases/lib/.gitignore index a9034e4..d83a48e 100644 --- a/testcases/lib/.gitignore +++ b/testcases/lib/.gitignore @@ -1,5 +1,6 @@ /tst_sleep /tst_random +/tst_check_drivers /tst_checkpoint /tst_rod /tst_kvcmp diff --git a/testcases/lib/Makefile b/testcases/lib/Makefile index 3547e16..e1dea3b 100644 --- a/testcases/lib/Makefile +++ b/testcases/lib/Makefile @@ -28,6 +28,6 @@ INSTALL_TARGETS := *.sh MAKE_TARGETS := tst_sleep tst_random tst_checkpoint tst_rod tst_kvcmp\ tst_device tst_net_iface_prefix tst_net_ip_prefix tst_net_vars\ - tst_getconf tst_supported_fs + tst_getconf tst_supported_fs tst_check_drivers include $(top_srcdir)/include/mk/generic_leaf_target.mk diff --git a/testcases/lib/tst_check_drivers.c b/testcases/lib/tst_check_drivers.c new file mode 100644 index 0000000..c1d879d --- /dev/null +++ b/testcases/lib/tst_check_drivers.c @@ -0,0 +1,24 @@ +// SPDX-License-Identifier: GPL-2.0-or-later +/* Copyright (c) 2018 Oracle and/or its affiliates. All Rights Reserved. */ + +#include +#include "tst_kernel.h" + +int main(int argc, const char *argv[]) +{ + const char *name; + int i; + + if (argc < 2) { + fprintf(stderr, "Please provide kernel driver list\n"); + return 1; + } + + for (i = 1; (name = argv[i]); ++i) + if (tst_check_driver(name)) { + fprintf(stderr, "%s", name); + return 1; + } + + return 0; +} From patchwork Mon Aug 20 11:23:47 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Kodanev X-Patchwork-Id: 959601 X-Patchwork-Delegate: petr.vorel@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=lists.linux.it (client-ip=213.254.12.146; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=oracle.com header.i=@oracle.com header.b="t/6uyAMH"; dkim-atps=neutral Received: from picard.linux.it (picard.linux.it [213.254.12.146]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41vB5V5pkBz9s3Z for ; Mon, 20 Aug 2018 21:14:03 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 8192A3E6410 for ; Mon, 20 Aug 2018 13:14:00 +0200 (CEST) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-4.smtp.seeweb.it (in-4.smtp.seeweb.it [IPv6:2001:4b78:1:20::4]) by picard.linux.it (Postfix) with ESMTP id 635F73E6410 for ; Mon, 20 Aug 2018 13:13:58 +0200 (CEST) Received: from userp2120.oracle.com (userp2120.oracle.com [156.151.31.85]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by in-4.smtp.seeweb.it (Postfix) with ESMTPS id 908781000361 for ; Mon, 20 Aug 2018 13:13:57 +0200 (CEST) Received: from pps.filterd (userp2120.oracle.com [127.0.0.1]) by userp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w7KB9GA3091918 for ; Mon, 20 Aug 2018 11:13:55 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; s=corp-2018-07-02; bh=MzHfg9WvWbqv5ISVJXZ1+4yxEvXYOFCr80XjJpr2Iek=; b=t/6uyAMH+inAAyGzcyGtLVrHnWUuyescU+euPmMMn4jvnxNU3R+ehN6LGnFMiu1Gwlme 8VZWaxYl/ZOjhyJQYljA2AkJX6KVWEStvLDkv+v86t5ntdoJ3V+MBBGlmnLpyHnXik8K /PCZXF2MKjEi0l9VzoVeTG2rOYFcyZ9zevy10JdvtkD+9azJeK1jC/VWKywF8yfQ1r/E 9aVg0VGv8zKSucESnDTuVOCAJdgu1JPyENz5ruKOZ0/FPErPFmSuTaKXgHMuiE2NjAMX oVBPDUvG2wOW+qNTTYq4CFcPxMx1x71it4lM0/vDhxYocnc9GBE1lF5qFXXLr6ZB2mlC iQ== Received: from aserv0022.oracle.com (aserv0022.oracle.com [141.146.126.234]) by userp2120.oracle.com with ESMTP id 2kxc3qdm6t-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 20 Aug 2018 11:13:55 +0000 Received: from aserv0121.oracle.com (aserv0121.oracle.com [141.146.126.235]) by aserv0022.oracle.com (8.14.4/8.14.4) with ESMTP id w7KBDsWi014306 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 20 Aug 2018 11:13:54 GMT Received: from abhmp0012.oracle.com (abhmp0012.oracle.com [141.146.116.18]) by aserv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w7KBDsvf022336 for ; Mon, 20 Aug 2018 11:13:54 GMT Received: from ak.ru.oracle.com (/10.162.80.29) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 20 Aug 2018 04:13:54 -0700 From: Alexey Kodanev To: ltp@lists.linux.it Date: Mon, 20 Aug 2018 14:23:47 +0300 Message-Id: <1534764229-26993-2-git-send-email-alexey.kodanev@oracle.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1534764229-26993-1-git-send-email-alexey.kodanev@oracle.com> References: <1534764229-26993-1-git-send-email-alexey.kodanev@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8990 signatures=668707 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=705 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1808200122 X-Virus-Scanned: clamav-milter 0.99.2 at in-4.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=0.1 required=7.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU, SPF_HELO_PASS, SPF_PASS autolearn=disabled version=3.4.0 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on in-4.smtp.seeweb.it Subject: [LTP] [PATCH v2 2/4] lib/tst_test.sh: add TST_NEEDS_DRIVERS parameter X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.18 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" The drivers are checked with 'tst_check_drivers' command. Signed-off-by: Alexey Kodanev Acked-by: Petr Vorel --- v2: add a check for empty TST_NEEDS_DRIVERS doc/test-writing-guidelines.txt | 1 + testcases/lib/tst_test.sh | 12 ++++++++++++ 2 files changed, 13 insertions(+), 0 deletions(-) diff --git a/doc/test-writing-guidelines.txt b/doc/test-writing-guidelines.txt index 7a458d5..8ebff5f 100644 --- a/doc/test-writing-guidelines.txt +++ b/doc/test-writing-guidelines.txt @@ -1653,6 +1653,7 @@ simply by setting right '$TST_NEEDS_FOO'. | 'TST_NEEDS_CMDS' | String with command names that has to be present for the test (see below). | 'TST_NEEDS_MODULE' | Test module name needed for the test (see below). +| 'TST_NEEDS_DRIVERS'| Checks kernel drivers support for the test. |============================================================================= Checking for presence of commands diff --git a/testcases/lib/tst_test.sh b/testcases/lib/tst_test.sh index e553b49..23d66eb 100644 --- a/testcases/lib/tst_test.sh +++ b/testcases/lib/tst_test.sh @@ -285,6 +285,16 @@ tst_check_cmds() return 0 } +tst_test_drivers() +{ + [ $# -eq 0 ] && return 0 + + local drv="$(tst_check_drivers $@ 2>&1)" + + [ -n "$drv" ] && tst_brk TCONF "$drv driver not available" + return 0 +} + tst_is_int() { [ "$1" -eq "$1" ] 2>/dev/null @@ -332,6 +342,7 @@ tst_run() OPTS|USAGE|PARSE_ARGS|POS_ARGS);; NEEDS_ROOT|NEEDS_TMPDIR|NEEDS_DEVICE|DEVICE);; NEEDS_CMDS|NEEDS_MODULE|MODPATH|DATAROOT);; + NEEDS_DRIVERS);; IPV6|IPVER|TEST_DATA|TEST_DATA_IFS);; RETRY_FUNC|RETRY_FN_EXP_BACKOFF);; *) tst_res TWARN "Reserved variable TST_$_tst_i used!";; @@ -369,6 +380,7 @@ tst_run() fi tst_test_cmds $TST_NEEDS_CMDS + tst_test_drivers $TST_NEEDS_DRIVERS if [ -n "$TST_MIN_KVER" ]; then tst_kvcmp -lt "$TST_MIN_KVER" && \ From patchwork Mon Aug 20 11:23:48 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Kodanev X-Patchwork-Id: 959603 X-Patchwork-Delegate: petr.vorel@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=lists.linux.it (client-ip=213.254.12.146; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=oracle.com header.i=@oracle.com header.b="ULkPM9b1"; dkim-atps=neutral Received: from picard.linux.it (picard.linux.it [213.254.12.146]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41vB5b3HrQz9s3Z for ; Mon, 20 Aug 2018 21:14:11 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 021473E6474 for ; Mon, 20 Aug 2018 13:14:09 +0200 (CEST) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-4.smtp.seeweb.it (in-4.smtp.seeweb.it [217.194.8.4]) by picard.linux.it (Postfix) with ESMTP id 555843E6433 for ; Mon, 20 Aug 2018 13:14:05 +0200 (CEST) Received: from aserp2120.oracle.com (aserp2120.oracle.com [141.146.126.78]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by in-4.smtp.seeweb.it (Postfix) with ESMTPS id 88C6510000F6 for ; Mon, 20 Aug 2018 13:14:04 +0200 (CEST) Received: from pps.filterd (aserp2120.oracle.com [127.0.0.1]) by aserp2120.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w7KBE0r0136521 for ; Mon, 20 Aug 2018 11:14:02 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; s=corp-2018-07-02; bh=iuKD5q6IEEfBuiSZv/a97gsHTluq1uDZ8PXiuLuSQfA=; b=ULkPM9b1G2W9uDRQXAzvDAeSI6MCnFCdCO6cQHB4IDY4LE/m6VFKBoE7bHcNv7bAcfmz OZjdKRC53USoNORHhFt3sYqwIdzghtQE7gDjrGzgktvktq+TSk1uu/a2f4hvzLYDLWMS 2yjj9cyODsU/Hapq3wgm3tlafa2jxLrvTYQ55JJK9SSTKR5jJo92xxsdAKiM64BMRoRA Mtc890NpixeFzCvMkMuJWGTdfE9QJnTq93a2nEfySbBaLB/mkoiMtC/A0hdkaO7ok5dq vDY3B9yVWpCO3ICQ5WF+FqIYrOr2PY4+JL6dxnfQk8ebO6IyhTkCdKNf87ksh1UCMfEq BQ== Received: from aserv0021.oracle.com (aserv0021.oracle.com [141.146.126.233]) by aserp2120.oracle.com with ESMTP id 2kxbdpnp0b-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 20 Aug 2018 11:14:02 +0000 Received: from userv0121.oracle.com (userv0121.oracle.com [156.151.31.72]) by aserv0021.oracle.com (8.14.4/8.14.4) with ESMTP id w7KBDucC005553 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 20 Aug 2018 11:13:56 GMT Received: from abhmp0012.oracle.com (abhmp0012.oracle.com [141.146.116.18]) by userv0121.oracle.com (8.14.4/8.13.8) with ESMTP id w7KBDur4023785 for ; Mon, 20 Aug 2018 11:13:56 GMT Received: from ak.ru.oracle.com (/10.162.80.29) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 20 Aug 2018 04:13:55 -0700 From: Alexey Kodanev To: ltp@lists.linux.it Date: Mon, 20 Aug 2018 14:23:48 +0300 Message-Id: <1534764229-26993-3-git-send-email-alexey.kodanev@oracle.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1534764229-26993-1-git-send-email-alexey.kodanev@oracle.com> References: <1534764229-26993-1-git-send-email-alexey.kodanev@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8990 signatures=668707 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 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-1807170000 definitions=main-1808200123 X-Virus-Scanned: clamav-milter 0.99.2 at in-4.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=0.1 required=7.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU, SPF_HELO_PASS, SPF_PASS autolearn=disabled version=3.4.0 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on in-4.smtp.seeweb.it Subject: [LTP] [PATCH v2 3/4] lib/tst_test.sh: add TST_RTNL_CHK() helper function X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.18 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" It should parse iproute commands output and exit the test with TCONF if there are certain messages returned from iproute/RTNETLINK. Signed-off-by: Alexey Kodanev --- v2: no changes testcases/lib/tst_test.sh | 16 ++++++++++++++++ 1 files changed, 16 insertions(+), 0 deletions(-) diff --git a/testcases/lib/tst_test.sh b/testcases/lib/tst_test.sh index 23d66eb..6837eb1 100644 --- a/testcases/lib/tst_test.sh +++ b/testcases/lib/tst_test.sh @@ -202,6 +202,22 @@ TST_RETRY_FUNC() return $2 } +TST_RTNL_CHK() +{ + local msg1="RTNETLINK answers: Function not implemented" + local msg2="RTNETLINK answers: Operation not supported" + local output="$($@ 2>&1 || echo 'LTP_ERR')" + local msg + + echo "$output" | grep -q "LTP_ERR" || return 0 + + for msg in "$msg1" "$msg2"; do + echo "$output" | grep -q "$msg" && tst_brk TCONF "'$@': $msg" + done + + tst_brk TBROK "$@ failed: $output" +} + tst_umount() { local device="$1" From patchwork Mon Aug 20 11:23:49 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexey Kodanev X-Patchwork-Id: 959604 X-Patchwork-Delegate: petr.vorel@gmail.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (mailfrom) smtp.mailfrom=lists.linux.it (client-ip=2001:1418:10:5::2; helo=picard.linux.it; envelope-from=ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it; receiver=) Authentication-Results: ozlabs.org; dmarc=fail (p=none dis=none) header.from=oracle.com Authentication-Results: ozlabs.org; dkim=fail reason="signature verification failed" (2048-bit key; unprotected) header.d=oracle.com header.i=@oracle.com header.b="NYS7/3zp"; dkim-atps=neutral Received: from picard.linux.it (picard.linux.it [IPv6:2001:1418:10:5::2]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 41vB5g0BgDz9s3Z for ; Mon, 20 Aug 2018 21:14:14 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 417A93E6486 for ; Mon, 20 Aug 2018 13:14:12 +0200 (CEST) X-Original-To: ltp@lists.linux.it Delivered-To: ltp@picard.linux.it Received: from in-2.smtp.seeweb.it (in-2.smtp.seeweb.it [IPv6:2001:4b78:1:20::2]) by picard.linux.it (Postfix) with ESMTP id 859DA3E644E for ; Mon, 20 Aug 2018 13:14:05 +0200 (CEST) Received: from userp2130.oracle.com (userp2130.oracle.com [156.151.31.86]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by in-2.smtp.seeweb.it (Postfix) with ESMTPS id C306C600152 for ; Mon, 20 Aug 2018 13:14:04 +0200 (CEST) Received: from pps.filterd (userp2130.oracle.com [127.0.0.1]) by userp2130.oracle.com (8.16.0.22/8.16.0.22) with SMTP id w7KBE3Dv109982 for ; Mon, 20 Aug 2018 11:14:03 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; s=corp-2018-07-02; bh=BT1xL65Txpoh1KXU7cJRq+ndpEc2mjoymGdAyQTQ6VA=; b=NYS7/3zpMccJfS3GtduZPS8cuB6+x2cKFEuU8qIVXI7sa15sPgKY/8GfyciVdlQLkq/c 1psiKRlY7QcIW5muIKvcyFp01ijgi/h5Cy2RS3HYaIZ95vOQenaGLEzs1S0ZKA5ixNQ4 CD41ItHvALnQel3X2z74cCH7CqOA33LeffIW68NP+dIoajx/zjRRQZ8xn/VEt4i0M0/e 0u91QJXBbRKawUvZrXIF8n6A/Qf76EafnKrU/vlVZvBHKSe3/ciMPeQKrfdMfQDUVdBd 2NjwC67p741D9JgUdGK9FmbDH5Hmyof0FKIHfgLTahYaPhynCxRmdeYkjFFlQjgqPi58 Ig== Received: from userv0021.oracle.com (userv0021.oracle.com [156.151.31.71]) by userp2130.oracle.com with ESMTP id 2kxavtdq5s-1 (version=TLSv1.2 cipher=ECDHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 20 Aug 2018 11:14:02 +0000 Received: from userv0122.oracle.com (userv0122.oracle.com [156.151.31.75]) by userv0021.oracle.com (8.14.4/8.14.4) with ESMTP id w7KBDvlC010971 (version=TLSv1/SSLv3 cipher=DHE-RSA-AES256-GCM-SHA384 bits=256 verify=OK) for ; Mon, 20 Aug 2018 11:13:57 GMT Received: from abhmp0012.oracle.com (abhmp0012.oracle.com [141.146.116.18]) by userv0122.oracle.com (8.14.4/8.14.4) with ESMTP id w7KBDvn5007409 for ; Mon, 20 Aug 2018 11:13:57 GMT Received: from ak.ru.oracle.com (/10.162.80.29) by default (Oracle Beehive Gateway v4.0) with ESMTP ; Mon, 20 Aug 2018 04:13:56 -0700 From: Alexey Kodanev To: ltp@lists.linux.it Date: Mon, 20 Aug 2018 14:23:49 +0300 Message-Id: <1534764229-26993-4-git-send-email-alexey.kodanev@oracle.com> X-Mailer: git-send-email 1.7.1 In-Reply-To: <1534764229-26993-1-git-send-email-alexey.kodanev@oracle.com> References: <1534764229-26993-1-git-send-email-alexey.kodanev@oracle.com> X-Proofpoint-Virus-Version: vendor=nai engine=5900 definitions=8990 signatures=668707 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 suspectscore=1 malwarescore=0 phishscore=0 bulkscore=0 spamscore=0 mlxscore=0 mlxlogscore=583 adultscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1807170000 definitions=main-1808200123 X-Virus-Scanned: clamav-milter 0.99.2 at in-2.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=0.1 required=7.0 tests=DKIM_SIGNED,DKIM_VALID, DKIM_VALID_AU, SPF_HELO_PASS, SPF_PASS autolearn=disabled version=3.4.0 X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on in-2.smtp.seeweb.it Subject: [LTP] [PATCH v2 4/4] network/ipsec: replace ipsec_try() with TST_RTNL_CHK() X-BeenThere: ltp@lists.linux.it X-Mailman-Version: 2.1.18 Precedence: list List-Id: Linux Test Project List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: ltp-bounces+incoming=patchwork.ozlabs.org@lists.linux.it Sender: "ltp" Signed-off-by: Alexey Kodanev Acked-by: Petr Vorel --- v2: fixed missing ip before TST_RTNL_CHK testcases/network/stress/ipsec/ipsec_lib.sh | 21 +++------------------ 1 files changed, 3 insertions(+), 18 deletions(-) diff --git a/testcases/network/stress/ipsec/ipsec_lib.sh b/testcases/network/stress/ipsec/ipsec_lib.sh index aedba9b..b099fde 100644 --- a/testcases/network/stress/ipsec/ipsec_lib.sh +++ b/testcases/network/stress/ipsec/ipsec_lib.sh @@ -157,21 +157,6 @@ ipsec_set_algoline() esac } -ipsec_try() -{ - local output="$($@ 2>&1 || echo 'TERR')" - - if echo "$output" | grep -q "TERR"; then - echo "$output" | grep -q \ - 'RTNETLINK answers: Function not implemented' && \ - tst_brk TCONF "'$@': not implemented" - echo "$output" | grep -q \ - 'RTNETLINK answers: Operation not supported' && \ - tst_brk TCONF "'$@': not supported (maybe missing 'ip${TST_IPV6}_vti' kernel module)" - tst_brk TBROK "$@ failed: $output" - fi -} - # tst_ipsec target src_addr dst_addr: config ipsec # # target: target of the configuration host ( lhost / rhost ) @@ -195,7 +180,7 @@ tst_ipsec() if [ $target = lhost ]; then local spi_1="0x$SPI" local spi_2="0x$(( $SPI + 1 ))" - ipsec_try ip xfrm state add src $src dst $dst spi $spi_1 \ + TST_RTNL_CHK ip xfrm state add src $src dst $dst spi $spi_1 \ $p $ALG mode $mode sel src $src dst $dst ROD ip xfrm state add src $dst dst $src spi $spi_2 \ $p $ALG mode $mode sel src $dst dst $src @@ -257,12 +242,12 @@ tst_ipsec_vti() cleanup_vti=$vti if [ $target = lhost ]; then - ipsec_try ip li add $vti $type local $src remote $dst $key $d + TST_RTNL_CHK ip li add $vti $type local $src remote $dst $key $d ROD ip li set $vti up local spi_1="spi 0x$SPI" local spi_2="spi 0x$(( $SPI + 1 ))" - ipsec_try $ipx st add $o_dir $p $spi_1 $ALG $m + TST_RTNL_CHK $ipx st add $o_dir $p $spi_1 $ALG $m ROD $ipx st add $i_dir $p $spi_2 $ALG $m ROD $ipx po add dir out tmpl $o_dir $p $m $mrk ROD $ipx po add dir in tmpl $i_dir $p $m $mrk