Received: by 2002:a05:6a10:206:0:0:0:0 with SMTP id 6csp4630725pxj; Wed, 12 May 2021 09:37:09 -0700 (PDT) X-Google-Smtp-Source: ABdhPJyVlqIJyZUwetxKNk0ZNe9/5JZMXczOaC4wDsXAzh2jqefgxShxJNMio2ZK5cQFjwWGAaO+ X-Received: by 2002:a9d:e88:: with SMTP id 8mr30276720otj.239.1620837429199; Wed, 12 May 2021 09:37:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1620837429; cv=none; d=google.com; s=arc-20160816; b=jqwTyB1Qj8i/gPz71yDhn2hJ81M/5fI5xfCQcsGVdI3yrtUkEOpZs84DXVThl+T6oo B6HiGcFjxQCya2KMhlPARv2pTnTFyfZ+oorubMvG7P1Ih+Yw5UDoneh+GJT4es6e+Y3S fRRZGTBlYirztGbbZHzi+uy6JfRqG+FZ18efHVeOleSanM7J5fqdmy8n3P+5TzIs0LMM LCsh+G3SdygjuMesvy0Bsu79BP9AbQo6qBByq30tVKwEQnne9ObrP4wx/j2InVH0oLxP s35/fMncZJ+8jVpRThpxeHgyvj1RdzB2YRPLHIJ/rVacGuce1CM00XHsv+HW37jgQxqM gn+g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:content-transfer-encoding:mime-version :user-agent:references:in-reply-to:message-id:date:subject:cc:to :from:dkim-signature; bh=JQ5iKjw692i4avH4tMbDyl32LzNLVuPQwCKh9txQPMs=; b=W9Pyh3z+Wo+2ykAhNUMvPNOAz8f4jtN2Wg52MnXXBJ83IrfBg4/YScmUbfSAivlmUG cLgra7bjFwibQXFQmTKO4KQkCFu+pVZGCG3jPbLDXvRMZM+5P2BhTc2ivN6uqqSbenIg x8sbE1k8ElkcRXtxM27fyIfWCq1w7K5kZULVr1mYHFLM9Mgbj/MxLdt/hQ8ei8+nSZ9h gj4QztJ/4Ngfv74mrPo8dVTJyUhJ8EdRVNWDeG42rGEVwoDvZvH3cUHb8FrVBj6jrdkH 6lQD9RBM7yvK/bl7MsGfhXVHwbMyOoriXqvdtabGXTVr2yXmGsPTfret4qEjuCalnonV Vk0g== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linuxfoundation.org header.s=korg header.b=Rd89Tlp9; spf=pass (google.com: 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=linuxfoundation.org Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id e73si376936ote.166.2021.05.12.09.36.54; Wed, 12 May 2021 09:37:09 -0700 (PDT) Received-SPF: pass (google.com: 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=@linuxfoundation.org header.s=korg header.b=Rd89Tlp9; spf=pass (google.com: 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=linuxfoundation.org Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S243253AbhELQhA (ORCPT + 99 others); Wed, 12 May 2021 12:37:00 -0400 Received: from mail.kernel.org ([198.145.29.99]:42208 "EHLO mail.kernel.org" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236280AbhELPp1 (ORCPT ); Wed, 12 May 2021 11:45:27 -0400 Received: by mail.kernel.org (Postfix) with ESMTPSA id 0EC1261C98; Wed, 12 May 2021 15:23:13 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=linuxfoundation.org; s=korg; t=1620832994; bh=JGby09g0BWedKGj1rcmt/AfG9H7Gy+RFqYXm9dM5JP4=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=Rd89Tlp900fsX4XbJ7/hII8y1bB1ZBUs+zj44CD0cOIym5BLFA283+3qnmoRkOtTA Y9JdJL1vELemH+FI/5uP4/g8Jky88HBD9KDF3MiJJPwoWIjtiw2kEwIbBeqqRStbZh 2YO9mzYUkeGievufKTfRemLyvSd4P5628kHH+aKc= From: Greg Kroah-Hartman To: linux-kernel@vger.kernel.org Cc: Greg Kroah-Hartman , stable@vger.kernel.org, Lorenz Bauer , Andrii Nakryiko , Alexei Starovoitov , Sasha Levin Subject: [PATCH 5.10 506/530] selftests/bpf: Fix core_reloc test runner Date: Wed, 12 May 2021 16:50:16 +0200 Message-Id: <20210512144836.392400704@linuxfoundation.org> X-Mailer: git-send-email 2.31.1 In-Reply-To: <20210512144819.664462530@linuxfoundation.org> References: <20210512144819.664462530@linuxfoundation.org> User-Agent: quilt/0.66 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org From: Andrii Nakryiko [ Upstream commit bede0ebf0be87e9678103486a77f39e0334c6791 ] Fix failed tests checks in core_reloc test runner, which allowed failing tests to pass quietly. Also add extra check to make sure that expected to fail test cases with invalid names are caught as test failure anyway, as this is not an expected failure mode. Also fix mislabeled probed vs direct bitfield test cases. Fixes: 124a892d1c41 ("selftests/bpf: Test TYPE_EXISTS and TYPE_SIZE CO-RE relocations") Reported-by: Lorenz Bauer Signed-off-by: Andrii Nakryiko Signed-off-by: Alexei Starovoitov Acked-by: Lorenz Bauer Link: https://lore.kernel.org/bpf/20210426192949.416837-6-andrii@kernel.org Signed-off-by: Sasha Levin --- .../selftests/bpf/prog_tests/core_reloc.c | 20 +++++++++++-------- 1 file changed, 12 insertions(+), 8 deletions(-) diff --git a/tools/testing/selftests/bpf/prog_tests/core_reloc.c b/tools/testing/selftests/bpf/prog_tests/core_reloc.c index e15c0903fa4d..8b641c306f26 100644 --- a/tools/testing/selftests/bpf/prog_tests/core_reloc.c +++ b/tools/testing/selftests/bpf/prog_tests/core_reloc.c @@ -192,7 +192,7 @@ static int duration = 0; #define BITFIELDS_CASE(name, ...) { \ BITFIELDS_CASE_COMMON("test_core_reloc_bitfields_probed.o", \ - "direct:", name), \ + "probed:", name), \ .input = STRUCT_TO_CHAR_PTR(core_reloc_##name) __VA_ARGS__, \ .input_len = sizeof(struct core_reloc_##name), \ .output = STRUCT_TO_CHAR_PTR(core_reloc_bitfields_output) \ @@ -200,7 +200,7 @@ static int duration = 0; .output_len = sizeof(struct core_reloc_bitfields_output), \ }, { \ BITFIELDS_CASE_COMMON("test_core_reloc_bitfields_direct.o", \ - "probed:", name), \ + "direct:", name), \ .input = STRUCT_TO_CHAR_PTR(core_reloc_##name) __VA_ARGS__, \ .input_len = sizeof(struct core_reloc_##name), \ .output = STRUCT_TO_CHAR_PTR(core_reloc_bitfields_output) \ @@ -495,8 +495,7 @@ static struct core_reloc_test_case test_cases[] = { ARRAYS_ERR_CASE(arrays___err_too_small), ARRAYS_ERR_CASE(arrays___err_too_shallow), ARRAYS_ERR_CASE(arrays___err_non_array), - ARRAYS_ERR_CASE(arrays___err_wrong_val_type1), - ARRAYS_ERR_CASE(arrays___err_wrong_val_type2), + ARRAYS_ERR_CASE(arrays___err_wrong_val_type), ARRAYS_ERR_CASE(arrays___err_bad_zero_sz_arr), /* enum/ptr/int handling scenarios */ @@ -811,13 +810,20 @@ void test_core_reloc(void) "prog '%s' not found\n", probe_name)) goto cleanup; + + if (test_case->btf_src_file) { + err = access(test_case->btf_src_file, R_OK); + if (!ASSERT_OK(err, "btf_src_file")) + goto cleanup; + } + load_attr.obj = obj; load_attr.log_level = 0; load_attr.target_btf_path = test_case->btf_src_file; err = bpf_object__load_xattr(&load_attr); if (err) { if (!test_case->fails) - CHECK(false, "obj_load", "failed to load prog '%s': %d\n", probe_name, err); + ASSERT_OK(err, "obj_load"); goto cleanup; } @@ -851,10 +857,8 @@ void test_core_reloc(void) goto cleanup; } - if (test_case->fails) { - CHECK(false, "obj_load_fail", "should fail to load prog '%s'\n", probe_name); + if (!ASSERT_FALSE(test_case->fails, "obj_load_should_fail")) goto cleanup; - } equal = memcmp(data->out, test_case->output, test_case->output_len) == 0; -- 2.30.2