Received: by 2002:a89:288:0:b0:1f7:eeee:6653 with SMTP id j8csp579594lqh; Tue, 7 May 2024 08:00:20 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCVe3NrKXhTV3c0eVZDxjfDQ7gXwoo8KlANxQPZC3zOwkS+gjKY/EBDmnz8FOm0yAqFcE9GJGRs9CAB3ms75+uR5gfgGigOYkCvvc2rrQA== X-Google-Smtp-Source: AGHT+IHDpOq9h6gW+wDbKBdvxa8AxJVCZzXKs16lvuRJ8Eevty6SyytCSe2OePgmmKhUH1bL2lTL X-Received: by 2002:a05:620a:8124:b0:792:91f9:739 with SMTP id os36-20020a05620a812400b0079291f90739mr8046987qkn.27.1715094019762; Tue, 07 May 2024 08:00:19 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1715094019; cv=pass; d=google.com; s=arc-20160816; b=RkKKug6pF2cewVahN8Mlahh03OMLaHv8XA4RH1YtKlj8Wiisz5Da4iD8sHXqg2QRPt OuACIuiOXFdV6ol5KulmXE6k67RQJH2Dyvg0k4oHKYVgM4IxlAYSj9sdEKvJz757Zv9Q a/OK5WmHKN5vcFs1csLDzJ29AR7eY3uFfgtwFAnIqyycdpTykJAMuryAk291pvf9NmPK s+6T+X99mD6+xWhlgrIdsKCDN/H+EkVUc5GV+DROzTN/j0o9ijUOYl9tXOYAz5ppAVj+ BrfMg+7tdAb+5bRf7yHqEAaWsEKCQA3l1kfqTBR0RXqWe817S1hDbG/AfSU2eDowwGui uABw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:in-reply-to:from:content-language :references:cc:to:subject:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:date:dkim-signature:message-id; bh=7F0zXFjGnIAReIrIEeVFWuD6Utz0jQNZcSyrYMCpOT4=; fh=PM6Fi+BxAb47zECJLVgexIvK4aQFvpQQGGhAv9YtenQ=; b=sWEjIahSuye2rzN1ZSuSAE/yV9aIV9Q84M2VQ8rUMYlL+ItmN4fO7aE1sLsrWg8rQ5 hN9asTOKy/HKaHqXL0cpTxb4HA7voPaIV5+uRfkrYIUhp8iC9EnqT/M/FmpXiYSBx8ly qnXgucJnPnVJK2b4hmPrSYHjF86YNAY+qSzRadbAy56ETZN9tNpYHNppoRIkqG3cKok1 A9AJNB9hp9lXPbtrjiT2/Rbts0OL5T1CcNTwaHJlFIPASDFP/5njTsbrVVhNPy6ehapo XzO8KVWe8DAIAJPIVw1/L/n6K4nbN2YavjRkYN3+7MHzpyJrj+3iROjU4SmIW6BFEhoq bRkg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=S+rTj6WI; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-171641-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-171641-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Return-Path: Received: from ny.mirrors.kernel.org (ny.mirrors.kernel.org. [147.75.199.223]) by mx.google.com with ESMTPS id br41-20020a05620a462900b00790ef75385csi12770951qkb.15.2024.05.07.08.00.19 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 May 2024 08:00:19 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-171641-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) client-ip=147.75.199.223; Authentication-Results: mx.google.com; dkim=pass header.i=@linux.dev header.s=key1 header.b=S+rTj6WI; arc=pass (i=1 spf=pass spfdomain=linux.dev dkim=pass dkdomain=linux.dev dmarc=pass fromdomain=linux.dev); spf=pass (google.com: domain of linux-kernel+bounces-171641-linux.lists.archive=gmail.com@vger.kernel.org designates 147.75.199.223 as permitted sender) smtp.mailfrom="linux-kernel+bounces-171641-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linux.dev Received: from smtp.subspace.kernel.org (wormhole.subspace.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ny.mirrors.kernel.org (Postfix) with ESMTPS id 6358D1C239A8 for ; Tue, 7 May 2024 15:00:19 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id D66ED1607B7; Tue, 7 May 2024 15:00:13 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b="S+rTj6WI" Received: from out-173.mta1.migadu.com (out-173.mta1.migadu.com [95.215.58.173]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id A227215FCE8 for ; Tue, 7 May 2024 15:00:09 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=95.215.58.173 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715094012; cv=none; b=WmzlT5qRxCIJJmxioxjn/XqKNzC4IDANQS32yEt8WoSu/dCP/Y5O2dZqZKkg078+UNWXYbl0Mw+ByS88GmdDtZ2ZBLF1RoFErz1F6RijPDSUsa7D71Eg5P9aUNGG3Qz49fyFsGisWZxgntZMGT7cjgABBOAk2e3c/C2Gbnc9fCY= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715094012; c=relaxed/simple; bh=7DMliRef7hOuh6uBFLJxeHt7dv1FUEnkYZ8kcm/kZdg=; h=Message-ID:Date:MIME-Version:Subject:To:Cc:References:From: In-Reply-To:Content-Type; b=BX1uR8QFN23KpQVZ7YqjfdoUZNg3PWicaHh92TvW6ojDXvcwxahH+Nl8KfLLIUdrAAxa27oi8SIBHxcE3HcW6Gi8xVkCw6gRe9O32T0vjR3VS5DQsyNyKw5ouHTemLdMgFaLxDRyrY0aUWfBRRBcylJ9eiObcBhHdQnahyDQbYY= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev; spf=pass smtp.mailfrom=linux.dev; dkim=pass (1024-bit key) header.d=linux.dev header.i=@linux.dev header.b=S+rTj6WI; arc=none smtp.client-ip=95.215.58.173 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linux.dev Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linux.dev Message-ID: DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linux.dev; s=key1; t=1715094007; 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=7F0zXFjGnIAReIrIEeVFWuD6Utz0jQNZcSyrYMCpOT4=; b=S+rTj6WIgX4WHCUV1seGXxdSXO2OiTDQLvWIvBSzFAnDvTsuylxqLiSAn8G6o3m9CtP681 HlqRos8FLKJ7CUsDAVePmdR1t5bg2jsjrteLtjy1N2YlzYZjNqSdh8g56daGHGvkd5ZHUn 7H/GJYgTkX29ppaMRGOhkxAHZ/BQjPA= Date: Tue, 7 May 2024 22:59:36 +0800 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Subject: Re: [PATCH] selftests: introduce additional eventfd test coverage To: "Bird, Tim" , Shuah Khan , Christian Brauner , Andrew Morton Cc: SShuah Khan , Andrei Vagin , Mathieu Desnoyers , Steven Rostedt , Dave Young , "linux-kselftest@vger.kernel.org" , "linux-kernel@vger.kernel.org" References: <20240505144648.18347-1-wen.yang@linux.dev> Content-Language: en-US X-Report-Abuse: Please report any abuse attempt to abuse@migadu.com and include these headers. From: Wen Yang In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Migadu-Flow: FLOW_OUT On 2024/5/7 02:30, Bird, Tim wrote: > > >> -----Original Message----- >> From: Wen Yang >> Add several new test cases which assert corner cases on the eventfd >> mechanism, for example, the supplied buffer is less than 8 bytes, >> attempting to write a value that is too large, etc. >> >> ./eventfd_test >> # Starting 9 tests from 1 test cases. >> # RUN global.eventfd01 ... >> # OK global.eventfd01 >> ok 1 global.eventfd01 > > These are horrible test case names. Can you please use strings which indicate > what is being tested, that are useful to a human? > -- Tim > Thank you for the review. I will do the change and send v2 soon. -- Best wishes, Wen >> # RUN global.eventfd02 ... >> # OK global.eventfd02 >> ok 2 global.eventfd02 >> # RUN global.eventfd03 ... >> # OK global.eventfd03 >> ok 3 global.eventfd03 >> # RUN global.eventfd04 ... >> # OK global.eventfd04 >> ok 4 global.eventfd04 >> # RUN global.eventfd05 ... >> # OK global.eventfd05 >> ok 5 global.eventfd05 >> # RUN global.eventfd06 ... >> # OK global.eventfd06 >> ok 6 global.eventfd06 >> # RUN global.eventfd07 ... >> # OK global.eventfd07 >> ok 7 global.eventfd07 >> # RUN global.eventfd08 ... >> # OK global.eventfd08 >> ok 8 global.eventfd08 >> # RUN global.eventfd09 ... >> # OK global.eventfd09 >> ok 9 global.eventfd09 >> # PASSED: 9 / 9 tests passed. >> # Totals: pass:9 fail:0 xfail:0 xpass:0 skip:0 error:0 >> >> Signed-off-by: Wen Yang >> Cc: SShuah Khan >> Cc: Christian Brauner >> Cc: Andrei Vagin >> Cc: Mathieu Desnoyers >> Cc: Steven Rostedt >> Cc: Andrew Morton >> Cc: Dave Young >> Cc: linux-kselftest@vger.kernel.org >> Cc: linux-kernel@vger.kernel.org >> --- >> .../filesystems/eventfd/eventfd_test.c | 116 ++++++++++++++++++ >> 1 file changed, 116 insertions(+) >> >> diff --git a/tools/testing/selftests/filesystems/eventfd/eventfd_test.c b/tools/testing/selftests/filesystems/eventfd/eventfd_test.c >> index f142a137526c..eeab8df5b1b5 100644 >> --- a/tools/testing/selftests/filesystems/eventfd/eventfd_test.c >> +++ b/tools/testing/selftests/filesystems/eventfd/eventfd_test.c >> @@ -183,4 +183,120 @@ TEST(eventfd05) >> close(fd); >> } >> >> +/* >> + * A write(2) fails with the error EINVAL if the size of the supplied buffer >> + * is less than 8 bytes, or if an attempt is made to write the value >> + * 0xffffffffffffffff. >> + */ >> +TEST(eventfd06) >> +{ >> + uint64_t value = 1; >> + ssize_t size; >> + int fd; >> + >> + fd = sys_eventfd2(0, 0); >> + ASSERT_GE(fd, 0); >> + >> + size = write(fd, &value, sizeof(int)); >> + EXPECT_EQ(size, -1); >> + EXPECT_EQ(errno, EINVAL); >> + >> + value = (uint64_t)-1; >> + size = write(fd, &value, sizeof(value)); >> + EXPECT_EQ(size, -1); >> + EXPECT_EQ(errno, EINVAL); >> + >> + close(fd); >> +} >> + >> +/* >> + * A read(2) fails with the error EINVAL if the size of the supplied buffer is >> + * less than 8 bytes. >> + */ >> +TEST(eventfd07) >> +{ >> + int value = 0; >> + ssize_t size; >> + int fd; >> + >> + fd = sys_eventfd2(0, 0); >> + ASSERT_GE(fd, 0); >> + >> + size = write(fd, &value, sizeof(value)); >> + EXPECT_EQ(size, -1); >> + EXPECT_EQ(errno, EINVAL); >> + >> + close(fd); >> +} >> + >> +/* >> + * If EFD_SEMAPHORE was not specified and the eventfd counter has a nonzero >> + * value, then a read(2) returns 8 bytes containing that value, and the >> + * counter's value is reset to zero. >> + * If the eventfd counter is zero at the time of the call to read(2), then the >> + * call fails with the error EAGAIN if the file descriptor has been made nonblocking. >> + */ >> +TEST(eventfd08) >> +{ >> + uint64_t value; >> + ssize_t size; >> + int fd; >> + int i; >> + >> + fd = sys_eventfd2(0, EFD_NONBLOCK); >> + ASSERT_GE(fd, 0); >> + >> + value = 1; >> + for (i = 0; i < 10000000; i++) { >> + size = write(fd, &value, sizeof(value)); >> + EXPECT_EQ(size, sizeof(value)); >> + } >> + >> + size = read(fd, &value, sizeof(value)); >> + EXPECT_EQ(size, sizeof(uint64_t)); >> + EXPECT_EQ(value, 10000000); >> + >> + size = read(fd, &value, sizeof(value)); >> + EXPECT_EQ(size, -1); >> + EXPECT_EQ(errno, EAGAIN); >> + >> + close(fd); >> +} >> + >> +/* >> + * If EFD_SEMAPHORE was specified and the eventfd counter has a nonzero value, >> + * then a read(2) returns 8 bytes containing the value 1, and the counter's >> + * value is decremented by 1. >> + * If the eventfd counter is zero at the time of the call to read(2), then the >> + * call fails with the error EAGAIN if the file descriptor has been made nonblocking. >> + */ >> +TEST(eventfd09) >> +{ >> + uint64_t value; >> + ssize_t size; >> + int fd; >> + int i; >> + >> + fd = sys_eventfd2(0, EFD_SEMAPHORE|EFD_NONBLOCK); >> + ASSERT_GE(fd, 0); >> + >> + value = 1; >> + for (i = 0; i < 10000000; i++) { >> + size = write(fd, &value, sizeof(value)); >> + EXPECT_EQ(size, sizeof(value)); >> + } >> + >> + for (i = 0; i < 10000000; i++) { >> + size = read(fd, &value, sizeof(value)); >> + EXPECT_EQ(size, sizeof(value)); >> + EXPECT_EQ(value, 1); >> + } >> + >> + size = read(fd, &value, sizeof(value)); >> + EXPECT_EQ(size, -1); >> + EXPECT_EQ(errno, EAGAIN); >> + >> + close(fd); >> +} >> + >> TEST_HARNESS_MAIN >> -- >> 2.25.1 >> >