From patchwork Fri Aug 31 13:24:53 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Junchi Chen X-Patchwork-Id: 964293 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=intel.com 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 421q7D0gg7z9s1x for ; Fri, 31 Aug 2018 16:23:34 +1000 (AEST) Received: from picard.linux.it (localhost [IPv6:::1]) by picard.linux.it (Postfix) with ESMTP id 443BB3E73E5 for ; Fri, 31 Aug 2018 08:23:31 +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 ED4DA3E736D for ; Fri, 31 Aug 2018 08:23:29 +0200 (CEST) Received: from mga09.intel.com (mga09.intel.com [134.134.136.24]) (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 C04E3601947 for ; Fri, 31 Aug 2018 08:23:28 +0200 (CEST) X-Amp-Result: SKIPPED(no attachment in message) X-Amp-File-Uploaded: False Received: from orsmga008.jf.intel.com ([10.7.209.65]) by orsmga102.jf.intel.com with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 30 Aug 2018 23:23:26 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.53,309,1531810800"; d="scan'208";a="69527260" Received: from lckqa-nuc7i5dnhe.sh.intel.com ([10.239.161.22]) by orsmga008.jf.intel.com with ESMTP; 30 Aug 2018 23:23:26 -0700 From: Junchi Chen To: ltp@lists.linux.it Date: Fri, 31 Aug 2018 21:24:53 +0800 Message-Id: <20180831132453.6461-1-junchi.chen@intel.com> X-Mailer: git-send-email 2.17.1 X-Virus-Scanned: clamav-milter 0.99.2 at in-2.smtp.seeweb.it X-Virus-Status: Clean X-Spam-Status: No, score=0.0 required=7.0 tests=DATE_IN_FUTURE_06_12 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 ltp] syscalls/bind03: Add version compare according to behaviour difference. 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" ISSUE: The case is designed to test the behaviour diverse caused by kernel commit 0fb44559ffd6. And it failed for the new behaviour. ACTION: Add a version compare to split part of the test. Signed-off-by: Junchi Chen --- testcases/kernel/syscalls/bind/bind03.c | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/testcases/kernel/syscalls/bind/bind03.c b/testcases/kernel/syscalls/bind/bind03.c index 2fe342a54..955a69dd2 100644 --- a/testcases/kernel/syscalls/bind/bind03.c +++ b/testcases/kernel/syscalls/bind/bind03.c @@ -13,6 +13,7 @@ #include #include +#include "tst_kvercmp.h" #include "tst_test.h" #include "tst_safe_net.h" @@ -37,16 +38,28 @@ void run(void) /* * Once a STREAM UNIX domain socket has been bound, it can't be - * rebound. Expected error is EINVAL. + * rebound. */ if (bind(sock1, (struct sockaddr *)&sun, sizeof(sun)) == 0) { tst_res(TFAIL, "re-binding of socket succeeded"); return; } - if (errno != EINVAL) { - tst_res(TFAIL | TERRNO, "expected EINVAL"); - return; + /* + * The behavious diverse according to kernel version + * for v4.10 or later, the expected error is EADDRINUSE, + * otherwise EINVAL. + */ + if (tst_kvercmp(4, 10, 0) < 0) { + if (errno != EINVAL) { + tst_res(TFAIL | TERRNO, "expected EINVAL"); + return; + } + } else { + if (errno != EADDRINUSE) { + tst_res(TFAIL | TERRNO, "expected EADDRINUSE"); + return; + } } sock2 = SAFE_SOCKET(PF_UNIX, SOCK_STREAM, 0);