Received: by 2002:ab2:3350:0:b0:1f4:6588:b3a7 with SMTP id o16csp314912lqe; Sat, 6 Apr 2024 02:24:24 -0700 (PDT) X-Forwarded-Encrypted: i=3; AJvYcCXUE8HdiT6WPUy0y1ixnFXAocm008YNqW/GDoseXjlwtKYMaeuhok9hvv9baVaoqLB3v49DdqnigsNM4ht6DE1nD4QImdNdGMGWxAWOjg== X-Google-Smtp-Source: AGHT+IGTYUGAxQICClQNxg1Df3T4qlHM0rx9HPenct6nZw4r6cB9VZLRq/R2fKmEApkMQPpEZ8rI X-Received: by 2002:a05:6a21:99a9:b0:1a7:1c5:4746 with SMTP id ve41-20020a056a2199a900b001a701c54746mr5115100pzb.1.1712395464326; Sat, 06 Apr 2024 02:24:24 -0700 (PDT) ARC-Seal: i=2; a=rsa-sha256; t=1712395464; cv=pass; d=google.com; s=arc-20160816; b=I4isoQl3ivi911FwJNBUZXd/yBEyndgRLAGleL0lQJo9WAMhrwnFnlGiqTROR+bNgw Ru4DJdFBAdebrxTNA3tNiksaqNl2lLwwG4LhdTM8lahhz8RDzDAlpQfbaS8xN95i5SCi GQ+jPTnUupcRnrugaFQb5uwY/30Tw6ZpEENQi1+hIBXb9bLkC0OVbXV+sC5pekDU2toX aL/NCoK+YLz7ub9cpOFZgf4SUqOyIep5lZFzNI3N9xBbdPpccn3873IAECo9iE+jm6zj ueYLJXTLI7zKeGZv1l8Z6jhAIWsuxPDs/xs34Oz7dnzdUA+VtN56qWJ6ushM5b2ZW/lV 9Zsw== ARC-Message-Signature: i=2; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:list-unsubscribe :list-subscribe:list-id:precedence:references:in-reply-to:message-id :date:subject:cc:to:from:dkim-signature; bh=qzaONF2ufkMLEwxVO924M3LwWzApnPaibbBgBkLZGxs=; fh=RCOQrcSmc39Cw8XBMcVdx9U6sf1caW5aKUn4DyB8/hU=; b=bx+ezdrHMqr2Du3XHAqNqqNua3dEwebOKEgwwD6pBNbv+odFbZUjLpl4j84kWmdB4E y/H+Ms3aumGyJNGKDNgTEliEb509ClvBKQ1gaZtUgk3lWGbZ0BT59k8x8kstZWxjOz8w sOumiGhBykLl+Oo2Pq2ZDFICvbrAPN6pZ81G46LAZ/mK+Z92GlGhowRIfySUOwQ/6qQi 3201ERg79JX9bd9jFkhKuKLSyWCDiaXuR/lzDu5LPyAq5MeUvohXjES3/5sWoURKHmJv kgRKoumB6t+9GII8eVAfk8Na1fRZQ6ZMbZWhFSJtWapJD3PXr8/en8Upa+OY0giCMI0V Exlg==; dara=google.com ARC-Authentication-Results: i=2; mx.google.com; dkim=pass header.i=@canonical.com header.s=20210705 header.b=lB2l4Ywu; arc=pass (i=1 spf=pass spfdomain=canonical.com dkim=pass dkdomain=canonical.com dmarc=pass fromdomain=canonical.com); spf=pass (google.com: domain of linux-kernel+bounces-133874-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-133874-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=canonical.com Return-Path: Received: from sv.mirrors.kernel.org (sv.mirrors.kernel.org. [139.178.88.99]) by mx.google.com with ESMTPS id f30-20020aa79d9e000000b006ece1eb725fsi2747874pfq.266.2024.04.06.02.24.24 for (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 06 Apr 2024 02:24:24 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel+bounces-133874-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) client-ip=139.178.88.99; Authentication-Results: mx.google.com; dkim=pass header.i=@canonical.com header.s=20210705 header.b=lB2l4Ywu; arc=pass (i=1 spf=pass spfdomain=canonical.com dkim=pass dkdomain=canonical.com dmarc=pass fromdomain=canonical.com); spf=pass (google.com: domain of linux-kernel+bounces-133874-linux.lists.archive=gmail.com@vger.kernel.org designates 139.178.88.99 as permitted sender) smtp.mailfrom="linux-kernel+bounces-133874-linux.lists.archive=gmail.com@vger.kernel.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=canonical.com 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 sv.mirrors.kernel.org (Postfix) with ESMTPS id 05495281DDC for ; Sat, 6 Apr 2024 09:24:24 +0000 (UTC) Received: from localhost.localdomain (localhost.localdomain [127.0.0.1]) by smtp.subspace.kernel.org (Postfix) with ESMTP id E67C84CE12; Sat, 6 Apr 2024 09:20:38 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=canonical.com header.i=@canonical.com header.b="lB2l4Ywu" Received: from smtp-relay-internal-1.canonical.com (smtp-relay-internal-1.canonical.com [185.125.188.123]) (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 B502D3FBA5 for ; Sat, 6 Apr 2024 09:20:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=185.125.188.123 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712395238; cv=none; b=X6flFC5WAr9i3OswDgzdKK4TNM5bvU462MNd0//ibKsvfiuWVoeMbWJVqeCSg/UC1SHUgN9EdF+vH5Wcg4ucTVKlMAPrmuXm4yx1eZbzf7A3qy276BcqCZkPqc0woqjoWYnRKzRovwFwN72NhAHUrKq/2R0y0SDAfFAbEIRgUcE= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1712395238; c=relaxed/simple; bh=V866d7v0EUjhFe+hV0qrTNaTJ3Gb92BOJZHI+Gz3L24=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=OPM8zzPQj0i4bpguCtlbpeYlCQDT/S8I5ON4/hXPhJm33BqXxBjSoVHHY4GpSBmRh1G1RcBOl/xM8ENcKmmnjjmWXnMI+rPNXhaQ8BhqKrYzwwRUnGrdUxzVdxo2z20NovUlovz6FKvYl9UIcX3jKktrmDp3skBbSoLLGTH6kJg= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=canonical.com; spf=pass smtp.mailfrom=canonical.com; dkim=pass (2048-bit key) header.d=canonical.com header.i=@canonical.com header.b=lB2l4Ywu; arc=none smtp.client-ip=185.125.188.123 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=canonical.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=canonical.com Received: from mail-lf1-f70.google.com (mail-lf1-f70.google.com [209.85.167.70]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by smtp-relay-internal-1.canonical.com (Postfix) with ESMTPS id E20F73FB79 for ; Sat, 6 Apr 2024 09:20:25 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=canonical.com; s=20210705; t=1712395225; bh=qzaONF2ufkMLEwxVO924M3LwWzApnPaibbBgBkLZGxs=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=lB2l4YwunUmf2+jdL5QZxL41cjtSDwXWT5tyAkjETaS2mqoFUw64VqBO38dZlClyM 3qTgiQkszAevQm6LYhm/Xt/oWFxGhj0slblNBezlrx+jOBXquWkY9hQ2KYYLGYjz0p wFPzndEPnlNINkfaIEuOR/nRjOQNKRYysVgpJo4EdiQgub9ET8NEVnSI6JiI8a74oP xx6ESaa3TmLuwMoPDiiQQFDxVQWn20fAs/y6csbQt+eTAa9IFOU6O6Hheza4DUJahT VVnLmJiNGvh+mnrq8C8Jy18XK8/cGu0JPi9XITL4rwOLdWB8coHbMEQC48cYLJbcfN yGB3h7ZJVz1hg== Received: by mail-lf1-f70.google.com with SMTP id 2adb3069b0e04-516ddd6d66fso140389e87.1 for ; Sat, 06 Apr 2024 02:20:25 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1712395219; x=1713000019; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=qzaONF2ufkMLEwxVO924M3LwWzApnPaibbBgBkLZGxs=; b=IJMcSpm9AxLBLXTVOOiynHaFlHdLh2d2H+r5GKSfsiXqOc2DD/M/xmwQYmWinuCHii fHizmEjCUJwhXGCqGaSxSFgRuOESoVPB4EFrOiuHJaGSCFkZhhD/QzF5iqaqtbV98Zy0 6nYRQ+h4RzroOsTVaiPr2jnhVrhZONULJEN/w+A+61kyJTccIuMd3Optfy+RzW4r0sVX wF7D0KDzNNvubMNE/6XxIE4Ei8Iysjjag3MKTKrQX2RCete0WVplVS0zl3aSg9RL//n7 BDydtssSoVR17Uy2/N6FZRXEUPwA4MNsunUps9ztBiXTnsg3cTqKV0FNM9VUzekA8+77 NACg== X-Forwarded-Encrypted: i=1; AJvYcCXsuNO3MN4fT0jCtK7GbfWvxKEm5MyQ9mi9AkY6DBSqoPuFPofv9Z+eWP8etWEsmNo04QnuvrsfZJ4xqiGLhfJCllBjj8KQ2ysviKKz X-Gm-Message-State: AOJu0YxeWz1+z5n53AS5otUnuICZfthxcTFkkPpBniTa/LCkYOAQ4Fxn FU3u52e0gITEFWGUVuSU5XQ3HG6FIy5DBpy/W2ZVwH3EeArVkBPEiT7wM5/wRjupYuSHx035LPM /U66ipn/gx/3Yz/D18cPR2Rgv7ewMksiyGtYhDvEuEvEU5iKC8malxnI6HEAeIbIL0P9du4JKFI tRWg== X-Received: by 2002:ac2:528f:0:b0:516:ace0:9a75 with SMTP id q15-20020ac2528f000000b00516ace09a75mr2341483lfm.23.1712395219275; Sat, 06 Apr 2024 02:20:19 -0700 (PDT) X-Received: by 2002:ac2:528f:0:b0:516:ace0:9a75 with SMTP id q15-20020ac2528f000000b00516ace09a75mr2341471lfm.23.1712395218819; Sat, 06 Apr 2024 02:20:18 -0700 (PDT) Received: from gpd.station (net-2-39-142-110.cust.vodafonedsl.it. [2.39.142.110]) by smtp.gmail.com with ESMTPSA id l23-20020a7bc457000000b00414924f307csm5779993wmi.26.2024.04.06.02.20.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Sat, 06 Apr 2024 02:20:18 -0700 (PDT) From: Andrea Righi To: Andrii Nakryiko , Eduard Zingerman Cc: Alexei Starovoitov , Daniel Borkmann , Martin KaFai Lau , Song Liu , Yonghong Song , John Fastabend , KP Singh , Stanislav Fomichev , Hao Luo , Jiri Olsa , David Vernet , Tejun Heo , bpf@vger.kernel.org, linux-kselftest@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH v4 4/4] selftests/bpf: Add tests for ring__consume_n and ring_buffer__consume_n Date: Sat, 6 Apr 2024 11:15:44 +0200 Message-ID: <20240406092005.92399-5-andrea.righi@canonical.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240406092005.92399-1-andrea.righi@canonical.com> References: <20240406092005.92399-1-andrea.righi@canonical.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Add tests for new API ring__consume_n() and ring_buffer__consume_n(). Signed-off-by: Andrea Righi --- tools/testing/selftests/bpf/prog_tests/ringbuf.c | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tools/testing/selftests/bpf/prog_tests/ringbuf.c b/tools/testing/selftests/bpf/prog_tests/ringbuf.c index 48c5695b7abf..33aba7684ab9 100644 --- a/tools/testing/selftests/bpf/prog_tests/ringbuf.c +++ b/tools/testing/selftests/bpf/prog_tests/ringbuf.c @@ -304,10 +304,18 @@ static void ringbuf_subtest(void) err = ring_buffer__consume(ringbuf); CHECK(err < 0, "rb_consume", "failed: %d\b", err); + /* try to consume up to one item */ + err = ring_buffer__consume_n(ringbuf, 1); + CHECK(err < 0 || err > 1, "rb_consume_n", "failed: %d\b", err); + /* also consume using ring__consume to make sure it works the same */ err = ring__consume(ring); ASSERT_GE(err, 0, "ring_consume"); + /* try to consume up to one item */ + err = ring__consume_n(ring, 1); + CHECK(err < 0 || err > 1, "ring_consume_n", "failed: %d\b", err); + /* 3 rounds, 2 samples each */ cnt = atomic_xchg(&sample_cnt, 0); CHECK(cnt != 6, "cnt", "exp %d samples, got %d\n", 6, cnt); -- 2.43.0