Received: by 2002:a25:6193:0:0:0:0:0 with SMTP id v141csp4397317ybb; Tue, 14 Apr 2020 06:34:01 -0700 (PDT) X-Google-Smtp-Source: APiQypKn8Wiv9TlUNNhVG+8lRgz89WmVfzBLoBh2QqjsJBnrcqUVXc3fzT8EBddcOrmPNnP68BXl X-Received: by 2002:a17:906:390a:: with SMTP id f10mr162146eje.74.1586871241681; Tue, 14 Apr 2020 06:34:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1586871241; cv=none; d=google.com; s=arc-20160816; b=BqZJv22Mys0cznOyt7P/zyzj9K1XgUIkvYLaM8x41IwLrUTb6Xa//FPcCAFewkLdtt C41fDgFnNxsVWGJY9TJGG3LDiwe0rLCV8a+Hpdl4sCyzhEd/Prrg4UqY5cLyqLcBt/yL imYZO832Dwj175AY54qfZKRG4GDu3sdV0dmNy1TjdM1ufVqsIKVlqbmE0+Cp58Lux0dn gpLu1HU0lHOi2GwLdBVvG77sbE1g3Uj9i+F43DcvE7TIafARgVwtngO1jGeGllO22vsV s9IF3f/hz0jOmO5ZpKdDLL9fcZdKYZknAb5D4VVdoXqf53b3WyfCfmpylNiIHu0pYLsr h+Yw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:message-id:date:subject:cc:to:from :dkim-signature:dkim-filter; bh=fIogUCuLgNQKFtvh7YqqkjdIiaB59x4bncfm64giQ2o=; b=Qro+STopLOpuwtkO3g4BFDxBPAMf49ZWO01dk6/vuN16lKOrc1i2Oj5ZqBfN94k7hV iD1zSyKUFv55FpSwN8nN19rs0Pyitnk9ny2mm0R6H4B6okrHcRlzp/Aa0cklHWsjpykv 9sEcGohTEVMNckgJkjFU82F+qHbtN9UH6QSCXoRRi6HwjpCnC6ot7MfdXak1pxeEGpLQ rLqv5koreAqK/0R7R35odvXjmyfQS7BYwpct5MAXZ3qAVz5RNlxS6HHIFz3jHWqSnd8q sMByQS9amHZW7GTSJbH4WPcKqqP4r0uy+S8PEp2/Der63yVxD9lakBRWUAD4cDEzN2L3 VZng== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=o3JUi6EW; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.microsoft.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id v6si5837935edf.296.2020.04.14.06.33.37; Tue, 14 Apr 2020 06:34:01 -0700 (PDT) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.microsoft.com header.s=default header.b=o3JUi6EW; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.microsoft.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2388305AbgDMUVw (ORCPT + 99 others); Mon, 13 Apr 2020 16:21:52 -0400 Received: from linux.microsoft.com ([13.77.154.182]:48632 "EHLO linux.microsoft.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S2388296AbgDMUVu (ORCPT ); Mon, 13 Apr 2020 16:21:50 -0400 Received: from LAPTOP-IRBENCB0.localdomain (162-237-133-238.lightspeed.rcsntx.sbcglobal.net [162.237.133.238]) by linux.microsoft.com (Postfix) with ESMTPSA id 1AE3220B4737; Mon, 13 Apr 2020 13:21:49 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.11.0 linux.microsoft.com 1AE3220B4737 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.microsoft.com; s=default; t=1586809309; bh=fIogUCuLgNQKFtvh7YqqkjdIiaB59x4bncfm64giQ2o=; h=From:To:Cc:Subject:Date:From; b=o3JUi6EWx+OUkEwhcEsoigVab8Cq7OQYQnzYKl0OeN0uW52a9uuP1bRYRNdA6I44U fciwJWJlq/jhTXDKwPiRS5hXiP2WKa9fALcnyq5gG95CalFMOoyUhBo79YGWNtnU2s 9iB4c8EOpzyBcEUO5huy1g4MBHFyW7shnHOJ51Dg= From: Tyler Hicks To: Shuah Khan Cc: Stanislav Kinsbursky , linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH] selftests/ipc: Fix test failure seen after initial test run Date: Mon, 13 Apr 2020 15:21:45 -0500 Message-Id: <20200413202145.11056-1-tyhicks@linux.microsoft.com> X-Mailer: git-send-email 2.17.1 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org After successfully running the IPC msgque test once, subsequent runs result in a test failure: $ sudo ./run_kselftest.sh TAP version 13 1..1 # selftests: ipc: msgque # Failed to get stats for IPC queue with id 0 # Failed to dump queue: -22 # Bail out! # # Pass 0 Fail 0 Xfail 0 Xpass 0 Skip 0 Error 0 not ok 1 selftests: ipc: msgque # exit=1 The dump_queue() function loops through the possible message queue index values using calls to msgctl(kern_id, MSG_STAT, ...) where kern_id represents the index value. The first time the test is ran, the initial index value of 0 is valid and the test is able to complete. The index value of 0 is not valid in subsequent test runs and the loop attempts to try index values of 1, 2, 3, and so on until a valid index value is found that corresponds to the message queue created earlier in the test. The msgctl() syscall returns -1 and sets errno to EINVAL when invalid index values are used. The test failure is caused by incorrectly comparing errno to -EINVAL when cycling through possible index values. Fix invalid test failures on subsequent runs of the msgque test by correctly comparing errno values to a non-negated EINVAL. Fixes: 3a665531a3b7 ("selftests: IPC message queue copy feature test") Signed-off-by: Tyler Hicks --- tools/testing/selftests/ipc/msgque.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/testing/selftests/ipc/msgque.c b/tools/testing/selftests/ipc/msgque.c index 4c156aeab6b8..5ec4d9e18806 100644 --- a/tools/testing/selftests/ipc/msgque.c +++ b/tools/testing/selftests/ipc/msgque.c @@ -137,7 +137,7 @@ int dump_queue(struct msgque_data *msgque) for (kern_id = 0; kern_id < 256; kern_id++) { ret = msgctl(kern_id, MSG_STAT, &ds); if (ret < 0) { - if (errno == -EINVAL) + if (errno == EINVAL) continue; printf("Failed to get stats for IPC queue with id %d\n", kern_id); -- 2.17.1