From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) (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 978FF3BBFC4 for ; Wed, 17 Jun 2026 07:49:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=170.10.133.124 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781682577; cv=none; b=pIqOf9eXP7qqq7/nQOYiBdPLcnPtvoW8jbFHTEc6bz51+v+2Tp+XDg97nFeDQL7v7+kocEWl3+usRehci1ndfU4jqum25tHsfJHVnTfk8g4v+f1znLeRJGXrXjoGMR9Ip8Zkxdict3idu+fNe6Icha5FNnMQkebWcRI6J6aUUOk= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1781682577; c=relaxed/simple; bh=ZSGN8jsvXHS16KvqaQEfTKW/bSA9DNtkSmSIod2fPl4=; h=Message-ID:Subject:From:To:Cc:Date:In-Reply-To:References: Content-Type:MIME-Version; b=S/hRjPxYipuPqVO+QRt7FcSEXz0/AU4P15gXCbwa2ODmvf3xV0NuLHrqT/yx/bQ4g+cyU4z/ByRwfxNj9g2wxenYXUo95QPcZfDmw6E/GJ3r7/HZflLAbm1d6SCrgCuNyGU4pszKct/S/OQltBb4E4rXpqDE6E4QHEo82Vd3PVM= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com; spf=pass smtp.mailfrom=redhat.com; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b=AWvfjnYP; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b=pUPGX/DN; arc=none smtp.client-ip=170.10.133.124 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=quarantine dis=none) header.from=redhat.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=redhat.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (1024-bit key) header.d=redhat.com header.i=@redhat.com header.b="AWvfjnYP"; dkim=pass (2048-bit key) header.d=redhat.com header.i=@redhat.com header.b="pUPGX/DN" DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=mimecast20190719; t=1781682575; 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=qnrC2V4pS2DHv+kF7P0/Ub99li8+YXaNw21vBBSsAJc=; b=AWvfjnYPZc8EaPOoewhOZhzHdO4npEGImGmhzznaKkt533SUaRxP8jpbARos6EHPUrzdao R5IQGK7fnw7wu+J9TQjeUayf6OJTV/ynWrYrLOt8LIG2ci1y+0PvKav90xYB6XmIBkt9C9 KE6oAIz/a5jTO5KtscXv5gUoMjoisJ4= Received: from mail-wr1-f72.google.com (mail-wr1-f72.google.com [209.85.221.72]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.3, cipher=TLS_AES_256_GCM_SHA384) id us-mta-438-WfTH7TXENm61Dn33Slsaew-1; Wed, 17 Jun 2026 03:49:34 -0400 X-MC-Unique: WfTH7TXENm61Dn33Slsaew-1 X-Mimecast-MFC-AGG-ID: WfTH7TXENm61Dn33Slsaew_1781682573 Received: by mail-wr1-f72.google.com with SMTP id ffacd0b85a97d-45ef616db45so4319264f8f.2 for ; Wed, 17 Jun 2026 00:49:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=redhat.com; s=google; t=1781682573; x=1782287373; darn=vger.kernel.org; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:cc:to:from:subject:message-id:from:to:cc:subject :date:message-id:reply-to; bh=qnrC2V4pS2DHv+kF7P0/Ub99li8+YXaNw21vBBSsAJc=; b=pUPGX/DNr6Cn+jTPvgx+SXZ8v5ZK8do13NuQtTpV3e9TCnlzkZBzcatThEan/e3x64 twaVLyQI27XZAOMc0b8/gE76w1VnaydAPIc6hB4pL2UKHcFdqnlwZ8ObCQoNVJaOVU/a wl5ZMM27MkXlq9T+6x2dq91ulNq7sqJxIZVyjy8PQUXJy0Jw9TfnQwTqSIo97IMKP0qj MmHJk3YtNZyKmIqe7A+l3oh2YXeRAh6aRzXzmhTI2ihc0pH7V+nsyfT5yYmCNrKNBIUn 9SxxDyOFXcLzir9JBkoWn0zz8YCQHMdRTSQaUeQ8ke1rCuUlRTlNXd536UjwUvtRRVzY BKNg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1781682573; x=1782287373; h=mime-version:user-agent:content-transfer-encoding:references :in-reply-to:date:cc:to:from:subject:message-id:x-gm-gg :x-gm-message-state:from:to:cc:subject:date:message-id:reply-to; bh=qnrC2V4pS2DHv+kF7P0/Ub99li8+YXaNw21vBBSsAJc=; b=HflgTetSOUrhpBm4TSjPMoKxj+Jcm+YqaehGqxk1toweq80UZ28YAbXztF5cqhx09f hlEPnRB126O5vpf3gLxI6MqcRMmrA4f8wGX8ZGlYdrPge0+olxKeGWv5fI0hu8vkUNdZ rJzSauDE3E8xqyqvV9JxaeVp/QixiAydHw6g0CdsjGmVN3RztbfG8Snqm8hqKH0jCtxE yLfO4B17JKnOaKEtj79ZLg+SdukOMhXhNiZwv7uZIHp7boxDab1FkM+d8bmw+53SeA0X zk3PECbWJW1uNkBEXZYZpB653yMnSM9og6LGoo2K1PeL6fkIRxf3w2v5UDQ5uG1AzZMb 4Fwg== X-Forwarded-Encrypted: i=1; AFNElJ8fXvG/PaonnzI5H19HiXE3m9T4U68qn+vaHAUVizPHfMqPpBB1eJNefkc8v6zIgLqPljD/B1lFsQTin8c=@vger.kernel.org X-Gm-Message-State: AOJu0YxpdhcKj1T+IfDboUe4KCLCRIxc56VqnIbJkIQRD8pVoogEuJ1P 0Rdo1nwjp1FMAIJz5YJYxshQNLkKCamVGLi+x8tC0F3rEJmXbGa29YYqFJqbDej2BV/3tGOUqio +baajuv4RMHctGVkayg1/KJxAOpH7+RhsVQ9650Un5+5OiWqvWBcoGQksqHB2TSzOSw== X-Gm-Gg: Acq92OEhF215PCQt2rQAXihUFa2bcWwnRskILEiDshP7jBT19Ho0A/4jz+F8RtAu4HV 94SF+WAOvH+6ZtjNSXPRad0HyVbblScILdlTfyMT2ma/y5fB/sczHGZhzrc63aWt86ImNzD8HsL gjHUWSLEWCXkoBK1PUumKaifm2Yrzs13hYczbPdwB7qz80hBTTiPZi2MLlx4/b2unQaXmnpB3Jq rStCjaLViF87KWkZewtfHMI1MuT4D0KkFF3hC7ZD+UgXtH4tv+pSSH5/0exe2vKYz9fGCxrgk1F c8PTtrZOPqPlFZw6T1dCZ+2RqOz+r0pMhqbJuB3IaXvI720e44hlXc5byBf+5MR3s1DDgth66fN F505MbSMvav8pMeY= X-Received: by 2002:a05:600c:a143:b0:490:4b89:5362 with SMTP id 5b1f17b1804b1-492333e2f05mr33180835e9.24.1781682573015; Wed, 17 Jun 2026 00:49:33 -0700 (PDT) X-Received: by 2002:a05:600c:a143:b0:490:4b89:5362 with SMTP id 5b1f17b1804b1-492333e2f05mr33180605e9.24.1781682572547; Wed, 17 Jun 2026 00:49:32 -0700 (PDT) Received: from [192.168.1.167] ([185.168.96.228]) by smtp.gmail.com with ESMTPSA id ffacd0b85a97d-4606f2c473bsm55865403f8f.28.2026.06.17.00.49.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 17 Jun 2026 00:49:32 -0700 (PDT) Message-ID: Subject: Re: [PATCH v3 7/9] rv/tlob: add KUnit tests for the tlob monitor From: Gabriele Monaco To: wen.yang@linux.dev Cc: Steven Rostedt , linux-trace-kernel@vger.kernel.org, linux-kernel@vger.kernel.org Date: Wed, 17 Jun 2026 09:49:30 +0200 In-Reply-To: References: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable User-Agent: Evolution 3.60.2 (3.60.2-1.fc44) Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 On Mon, 2026-06-08 at 00:13 +0800, wen.yang@linux.dev wrote: > +/* > + * Valid add lines return -ENOENT (kern_path() finds no such file in > the test > + * environment) rather than 0; a non-(-EINVAL) return confirms the > format was > + * accepted by the parser. > + */ > +static void tlob_parse_valid_accepted(struct kunit *test) > +{ > + char buf[128]; > + int i; > + > + for (i =3D 0; i < ARRAY_SIZE(tlob_parse_valid); i++) { > + strscpy(buf, tlob_parse_valid[i], sizeof(buf)); > + KUNIT_EXPECT_NE(test, > tlob_create_or_delete_uprobe(buf), -EINVAL); Can you perhaps add those uprobes for real from this test case? Unit tests should not touch the system, you usually do that by:=C2=A0 1. stubbing the tested function when it starts doing bad things 2. test with dummy data not attaching anything (not applicable here) 3. test a different function not affecting the system I think the cleanest here is 3. so you could just kunit test tlob_parse_uprobe_line() and tlob_parse_remove_line(). Alternatively just stub the entirety of tlob_add_uprobe() tlob_remove_uprobe_by_key() and maybe even check that they're called when expected and not called on failure (right now you aren't testing valid removals, probably because that's going to break). I believe a good unit test should be validating the parsing logic only /or/ the add/remove logic (but that's hard, you can skip it or even check in selftests). Right now your tests are trying to do both, so you don't know if failures came from the uprobes subsystem or allocation (you shouln't even get there from the unit test). Then you can just check for success and not for ! EINVAL , which is confusing. Thanks, Gabriele > + } > +} > + > +static void tlob_parse_invalid_rejected(struct kunit *test) > +{ > + char buf[128]; > + int i; > + > + for (i =3D 0; i < ARRAY_SIZE(tlob_parse_invalid); i++) { > + strscpy(buf, tlob_parse_invalid[i], sizeof(buf)); > + KUNIT_EXPECT_EQ(test, > tlob_create_or_delete_uprobe(buf), -EINVAL); > + } > +} > + > +static void tlob_parse_out_of_range_rejected(struct kunit *test) > +{ > + char buf[128]; > + int i; > + > + for (i =3D 0; i < ARRAY_SIZE(tlob_parse_out_of_range); i++) { > + strscpy(buf, tlob_parse_out_of_range[i], > sizeof(buf)); > + KUNIT_EXPECT_EQ(test, > tlob_create_or_delete_uprobe(buf), -ERANGE); > + } > +} > + > +static struct kunit_case tlob_parse_cases[] =3D { > + KUNIT_CASE(tlob_parse_valid_accepted), > + KUNIT_CASE(tlob_parse_invalid_rejected), > + KUNIT_CASE(tlob_parse_out_of_range_rejected), > + {} > +}; > + > +static struct kunit_suite tlob_parse_suite =3D { > + .name=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0=C2=A0 =3D "tlob_parse", > + .test_cases =3D tlob_parse_cases, > +}; > + > +kunit_test_suite(tlob_parse_suite); > + > +MODULE_DESCRIPTION("KUnit tests for the tlob RV monitor"); > +MODULE_LICENSE("GPL");