Received: by 2002:ad5:474a:0:0:0:0:0 with SMTP id i10csp3237455imu; Sat, 24 Nov 2018 00:47:46 -0800 (PST) X-Google-Smtp-Source: AFSGD/VsObCp3QcSEshlzTV8NbZTkzQ+mHhx7BRZuoPGQrW1IDCKMJZOih3WAGg9HwQIXD5EfC2m X-Received: by 2002:a17:902:ba89:: with SMTP id k9mr19413209pls.189.1543049266150; Sat, 24 Nov 2018 00:47:46 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1543049266; cv=none; d=google.com; s=arc-20160816; b=yJGkgTj1xOefdMnHuhpr9CErDGKLwkGs80HMlrdXDgZ1wzKdgWSxfY/rvTazhK16cN ptc1xxideOTWB9sFYp/JrknSsQQdQctmNH8zEX8ljbdAx0SIPaSvXHihU7ATg94GZwSP S3sBgrAZo/6a56muZsjfvqDUx78wPhVkxCs8Wcjf+IPgmZy3Bx7LWLHyYcrgd33b+Um5 2htMlGwuwczO3uBuL2NnpQ8nEsl7pOSsC5r5VEGRY9zk7l1L+77F+U5fTWldUVYz61gR IMmH5YyiGVQCCDDtxVgcl4gmvzfxHHK5TgEzOLmshccB/ap5UqCuHv31hYQMaNPdBY3d Q47w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:user-agent:in-reply-to :content-disposition:mime-version:references:message-id:subject:cc :to:from:date; bh=mxmDHpYggyqTK9ukchWWGsH1PDCb4zf2Zbwodyu9FUM=; b=w02Xz+F3hd0oID6gHBcnVV1JKpXyTpXEbYYDvt7a1TLqkT+Qow83UbrBBpt+vv71u5 Khe5Z+PtLzNk+YkQd42o1TxQyM7cwUI5ptwZG/tTJYO9xSaGGAcjEJFGyh68tVJmLhFr RytZN7ZNzHlY09Aal5EkupTC6YstfttTAlE5yOuzHWPSS0H6gQTQl0AoVNiKQoDUbY+1 VoWG4KXo7t5Ok1o0Ww64ulToRarpUU+g2CIYz3BtobZTxdzc79afTodzMmHGl6pNh+Yc uo8TJ24UZbwhzcgpZSk4cXKTfshcxBLUG84TZBFTiMC1xXGY55CnW1bWVhQzVz8Routr w82Q== ARC-Authentication-Results: i=1; mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=codethink.co.uk Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id o125-v6si42992393pfb.35.2018.11.24.00.47.31; Sat, 24 Nov 2018 00:47:46 -0800 (PST) Received-SPF: pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) client-ip=209.132.180.67; Authentication-Results: mx.google.com; spf=pass (google.com: best guess record for domain of linux-kernel-owner@vger.kernel.org designates 209.132.180.67 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=codethink.co.uk Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S2395429AbeKXFUd (ORCPT + 99 others); Sat, 24 Nov 2018 00:20:33 -0500 Received: from imap1.codethink.co.uk ([176.9.8.82]:60761 "EHLO imap1.codethink.co.uk" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1728267AbeKXFUc (ORCPT ); Sat, 24 Nov 2018 00:20:32 -0500 Received: from cpc118554-reig6-2-0-cust775.6-3.cable.virginm.net ([86.18.95.8] helo=xylophone.i.decadent.org.uk) by imap1.codethink.co.uk with esmtpsa (Exim 4.84_2 #1 (Debian)) id 1gQGIC-0001Ki-Pf; Fri, 23 Nov 2018 18:35:04 +0000 Date: Fri, 23 Nov 2018 18:35:03 +0000 From: Ben Hutchings To: Alexei Starovoitov , Daniel Borkmann Cc: netdev@vger.kernel.org, linux-kernel@vger.kernel.org Subject: [PATCH 2/3] selftests/bpf: Add the ability to test for a log message on success Message-ID: <20181123183503.v3gl42innv4zbilw@xylophone.i.decadent.org.uk> References: <20181123183356.5q4bu47zpj5wdufb@xylophone.i.decadent.org.uk> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20181123183356.5q4bu47zpj5wdufb@xylophone.i.decadent.org.uk> User-Agent: NeoMutt/20170113 (1.7.2) Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org This is needed to test that code is being patched when it should be. Signed-off-by: Ben Hutchings --- tools/testing/selftests/bpf/test_verifier.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/tools/testing/selftests/bpf/test_verifier.c b/tools/testing/selftests/bpf/test_verifier.c index 0f3f97a401c9..e71b7f2e5f17 100644 --- a/tools/testing/selftests/bpf/test_verifier.c +++ b/tools/testing/selftests/bpf/test_verifier.c @@ -76,6 +76,8 @@ struct bpf_test { int fixup_percpu_cgroup_storage[MAX_FIXUPS]; const char *errstr; const char *errstr_unpriv; + const char *infostr; + const char *infostr_unpriv; uint32_t retval, retval_unpriv; enum { UNDEF, @@ -14232,7 +14234,7 @@ static void do_test_single(struct bpf_test *test, bool unpriv, int prog_len, prog_type = test->prog_type; struct bpf_insn *prog = test->insns; int map_fds[MAX_NR_MAPS]; - const char *expected_err; + const char *expected_err, *expected_info; uint32_t expected_val; uint32_t retval; int i, err; @@ -14253,6 +14255,8 @@ static void do_test_single(struct bpf_test *test, bool unpriv, test->result_unpriv : test->result; expected_err = unpriv && test->errstr_unpriv ? test->errstr_unpriv : test->errstr; + expected_info = unpriv && test->infostr_unpriv ? + test->infostr_unpriv : test->infostr; expected_val = unpriv && test->retval_unpriv ? test->retval_unpriv : test->retval; @@ -14272,6 +14276,11 @@ static void do_test_single(struct bpf_test *test, bool unpriv, strerror(errno)); goto fail_log; } + if (expected_info && !strstr(bpf_vlog, expected_info)) { + printf("FAIL\nMissing expected info message!\n\tEXP: %s\n\tRES: %s\n", + expected_info, bpf_vlog); + goto fail_log; + } } else { if (fd_prog >= 0) { printf("FAIL\nUnexpected success to load!\n"); -- Ben Hutchings, Software Developer Codethink Ltd https://www.codethink.co.uk/ Dale House, 35 Dale Street Manchester, M1 2HF, United Kingdom