From patchwork Wed Nov 4 19:36:37 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yang Shi X-Patchwork-Id: 56005 Delivered-To: patch@linaro.org Received: by 10.112.61.134 with SMTP id p6csp2610182lbr; Wed, 4 Nov 2015 11:54:56 -0800 (PST) X-Received: by 10.68.179.228 with SMTP id dj4mr4178753pbc.112.1446666896834; Wed, 04 Nov 2015 11:54:56 -0800 (PST) Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id di2si4189447pbd.158.2015.11.04.11.54.56; Wed, 04 Nov 2015 11:54:56 -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; dkim=neutral (body hash did not verify) header.i=@linaro_org.20150623.gappssmtp.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756291AbbKDTyy (ORCPT + 28 others); Wed, 4 Nov 2015 14:54:54 -0500 Received: from mail-pa0-f53.google.com ([209.85.220.53]:33716 "EHLO mail-pa0-f53.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1754519AbbKDTyw (ORCPT ); Wed, 4 Nov 2015 14:54:52 -0500 Received: by pabfh17 with SMTP id fh17so61937294pab.0 for ; Wed, 04 Nov 2015 11:54:52 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro_org.20150623.gappssmtp.com; s=20150623; h=from:to:cc:subject:date:message-id; bh=nnOIKeY6P5R19yHEQ5sLHkjnTMwthecTC3YdMTopxzY=; b=ikOAJMI2gWgH5kpN+1XTq6Im5b09VYzxevthCDk9fuP67VJkwgPaJPRuZfkjoOnhiW q8KtcUpXe6BEgLNDl8GDD9c/sMffPCnC0ASajyw6kup6C0IxiMp/aurAGVZB5HNZolGt TfcjuT52WCpDG5iXJ5Da3bCyWu0i0NH9F4rnkqgDpkL+87eWihF4BbPAHDfgi0+A93go 6DyrVBLpS7tvEZBX4GjIXeURuS7H04qPFHOZuTf0YLakBCmfNS+2xXcyy+KZXx1qri/+ 5AK+HUjgNUfUcIDbPte9QTuYBDqdMUM/2md1Q6fY78abtFFcG+c+IDA0opJ+6FibXsOh VeCA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=nnOIKeY6P5R19yHEQ5sLHkjnTMwthecTC3YdMTopxzY=; b=PFncO7pJtgTbWZvN8JrNU5zMffaOhNvvLE25jZbauuI9eYs6eURIMQRTGAWwXXpe8Y CJM7qQQsvA6l7vNup1xf75+UexFXm+iI6zplR630Fexj+77B0ewtV8eou5vnDKoMbvz0 E8ZxweB0n3ypuI1jDLsgsejEcWHo+tfoZSoY5wEasC7hdFJaP1fm9bDeY8zxjNVAjEgi mpDKSJcf1z4GKTKMsqCgVQpCVH2xRdkUUjwxR8l34JDKHcI6vD58tcXR4MJYSlcx2cJ8 nkSZ3TTZysC+OHk+6PVQvqbbl+uHQ5erSN8BHBGV0J1FB1r+enAARDYnpG56AlxuVvtd Zk3A== X-Gm-Message-State: ALoCoQnEewE+6dPXKQOIiSjac6KgZQCpHC3fZD+Za0YPvwxjlKMf3Pv1WTWGeCMtHKII+9YaoMcC X-Received: by 10.68.57.235 with SMTP id l11mr4275301pbq.26.1446666892091; Wed, 04 Nov 2015 11:54:52 -0800 (PST) Received: from yshi-Precision-T5600.corp.ad.wrs.com (unknown-216-82.windriver.com. [147.11.216.82]) by smtp.gmail.com with ESMTPSA id ea1sm3535603pbb.76.2015.11.04.11.54.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 04 Nov 2015 11:54:51 -0800 (PST) From: Yang Shi To: ast@kernel.org, daniel@iogearbox.net Cc: zlim.lnx@gmail.com, xi.wang@gmail.com, linux-kernel@vger.kernel.org, netdev@vger.kernel.org, linaro-kernel@lists.linaro.org, yang.shi@linaro.org Subject: [PATCH] bpf: add mod default A and X test cases Date: Wed, 4 Nov 2015 11:36:37 -0800 Message-Id: <1446665797-21400-1-git-send-email-yang.shi@linaro.org> X-Mailer: git-send-email 2.0.2 Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org When running "mod X" operation, if X is 0 the filter has to be halt. Add new test cases to cover A = A mod X if X is 0, and A = A mod 1. CC: Xi Wang CC: Zi Shen Lim Signed-off-by: Yang Shi --- lib/test_bpf.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) -- 2.0.2 -- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/ Acked-by: Zi Shen Lim diff --git a/lib/test_bpf.c b/lib/test_bpf.c index d137739..10cd186 100644 --- a/lib/test_bpf.c +++ b/lib/test_bpf.c @@ -5056,6 +5056,36 @@ static struct bpf_test tests[] = { { {0x1, 0x0 } }, }, { + "MOD default X", + .u.insns = { + /* + * A = 0x42 + * A = A mod X ; this halt the filter execution if X is 0 + * ret 0x42 + */ + BPF_STMT(BPF_LD | BPF_IMM, 0x42), + BPF_STMT(BPF_ALU | BPF_MOD | BPF_X, 0), + BPF_STMT(BPF_RET | BPF_K, 0x42), + }, + CLASSIC | FLAG_NO_DATA, + {}, + { {0x1, 0x0 } }, + }, + { + "MOD default A", + .u.insns = { + /* + * A = A mod 1 + * ret A + */ + BPF_STMT(BPF_ALU | BPF_MOD | BPF_K, 0x1), + BPF_STMT(BPF_RET | BPF_A, 0x0), + }, + CLASSIC | FLAG_NO_DATA, + {}, + { {0x1, 0x0 } }, + }, + { "JMP EQ default A", .u.insns = { /*