Received: by 2002:ac0:bc90:0:0:0:0:0 with SMTP id a16csp3620859img; Mon, 25 Mar 2019 14:10:11 -0700 (PDT) X-Google-Smtp-Source: APXvYqynw0gd3O8TO9FGPQ4eAi7zKu0oLWqUU/IfDfTInTaRaWbysVKVtnwnysQHUqXofeBjpjBm X-Received: by 2002:a63:d302:: with SMTP id b2mr25509356pgg.13.1553548211469; Mon, 25 Mar 2019 14:10:11 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1553548211; cv=none; d=google.com; s=arc-20160816; b=WDvwaayudLrMCc13sqHqQSVmFmRhqjhkFDy6y37HB+HVdI0Gf5ap8/BgQIV6IZIzHf uGsVZDasx2cRw3k8Xl6XCHmc5eEVFp+YLJYxrEGkCqv34XRvVOJWtLwE5S09qfss/CB8 3L8nR39s7z39KPEvwXjV3C9CHH/Kamr1YAiGXSX/jej2i7ycmTUPwf60z/VLIYy7VJ1e uvbYduwAeKwTCZrICNunPNLbjI97di8TZv44DCe1jWOhBK9NJTGn3i4JcNYACmK0+PNY g1Xo/vWZ5sXelyvhkUdjHxuT/xT6HnyTDRgp7aWqPlgW17t9ivlcoiAHzVFeMzaHgoWQ v2Hw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:references:in-reply-to:message-id:date :subject:cc:to:from:dkim-signature; bh=23+V50N6WAn/6uQttan8JvUAP338C9/jI8+NG3yi1Us=; b=qyz8N6tI8i63vLMETsyUHTeN2xq5qZN5PCF3x18oq6dNQgHiHUEk2E9fl6HHY0mWkz Zm459HKiSyxNxfzBgY82scXnuZcutcc4fFtOykCAOR7QHx0yFsYwBU1drRzeXHZMAKxf XLBnzGfyOLvHpPi3Wihn/nczMbUoSxQFyfzLyINAGYbSjT8vzUEUHdW0RzBmMMsa/7JL tcGyo3QWIs3lRZxl83srjX6aRfxXgK8W8IVLVgZZWfPdm4ULLC7dEDNzaGHHYM54UIiO gsnzUEj5V/GERrhDcD58wiQ0NDx9Tz2HX46nle3hG33NyidZ+mO9xTWQ72LoA9BP499l +mmw== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=rKsWkQeo; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [209.132.180.67]) by mx.google.com with ESMTP id i70si14881245pfj.236.2019.03.25.14.09.56; Mon, 25 Mar 2019 14:10:11 -0700 (PDT) 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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=rKsWkQeo; 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=pass (p=NONE sp=QUARANTINE dis=NONE) header.from=gmail.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730442AbfCYVIC (ORCPT + 99 others); Mon, 25 Mar 2019 17:08:02 -0400 Received: from mail-pf1-f195.google.com ([209.85.210.195]:34632 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730409AbfCYVIA (ORCPT ); Mon, 25 Mar 2019 17:08:00 -0400 Received: by mail-pf1-f195.google.com with SMTP id b3so5644197pfd.1 for ; Mon, 25 Mar 2019 14:08:00 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=23+V50N6WAn/6uQttan8JvUAP338C9/jI8+NG3yi1Us=; b=rKsWkQeo+Hq6vtEudzMYqCxLP7tbv68zDMryIGFxpXRTHsV+Tz8f6tjQHv0DYbDtjg a1QhbOtdpNVLi0L4zyWnMbMee9ceDguBQMHYYeK3LGM6pQAMPedvhObl7pM9Cf1ZkNpO 3gy+C3H/q9NsuWRZHSGdw+5bfQkYCaDh7G6QzjBvF102HEqFO2+daad7uOKUbkf/1u45 WchvcSBnjg8OjneX3ohW8n+y40wFXk1sPGmyBm2O64+D0h+06k4gbbUJ4HLx8C3Wb50e uUjXoPQvPmW/HiBURdtjn1hJbLwNH8kQF1MfMMyqI9kGj/edtvLYiiRlhaqURIa34dGg rm2g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references; bh=23+V50N6WAn/6uQttan8JvUAP338C9/jI8+NG3yi1Us=; b=XCttfu3h3l7YWlaSRxUrnmxfQFtBs9OrMA+s3FvJ7hlbM6WiOjZECrDTf/norUxqCe NvoW23D6TWsI0aEYCsXmQSNmpSAnHgX5OatwRyvtEQnwwJopVFzbKiRgB1zoRrxDzftj 07WzwmTixgWDLaCmXQbg4zhohFuFbMbNJvDYC+IIyJvojyOs1ScSGN9XEtsUXReQB3kN p6k33vReuqNqF+P3I91fgnUwtSktsX0+OBJbLvFAt5N6691c3z9s39c/R+0GxGYKSlLC jviAFj8Uidl4t4dKeU48I7weI2J/Bbglcpngb+OU9+dtINRzO5eaKL6HxYBPX0xmSkUz I0zQ== X-Gm-Message-State: APjAAAUNpRam1CtwJ4+fetGPuXKdTADdcv6HHqpAvrDS4q5anagEAjBc SkfoLfh4QuIgHkc5IVYZFgw= X-Received: by 2002:a65:6203:: with SMTP id d3mr25439307pgv.109.1553548079643; Mon, 25 Mar 2019 14:07:59 -0700 (PDT) Received: from localhost ([169.229.22.206]) by smtp.gmail.com with ESMTPSA id i1sm1145752pgc.63.2019.03.25.14.07.58 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Mon, 25 Mar 2019 14:07:59 -0700 (PDT) From: Yury Norov X-Google-Original-From: Yury Norov To: Andrew Morton , Andy Shevchenko , Rasmus Villemoes , Arnd Bergmann , Kees Cook , Matthew Wilcox , Tetsuo Handa Cc: Yury Norov , Yury Norov , linux-kernel@vger.kernel.org Subject: [PATCH 5/6] lib/test_bitmap: add testcases for bitmap_parselist Date: Tue, 26 Mar 2019 00:07:47 +0300 Message-Id: <20190325210748.6571-6-ynorov@marvell.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190325210748.6571-1-ynorov@marvell.com> References: <20190325210748.6571-1-ynorov@marvell.com> Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Add tests for non-number character, empty regions, integer overflow. Signed-off-by: Yury Norov --- lib/test_bitmap.c | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/lib/test_bitmap.c b/lib/test_bitmap.c index b06e0fd3811b..709424a788ee 100644 --- a/lib/test_bitmap.c +++ b/lib/test_bitmap.c @@ -224,7 +224,8 @@ static const unsigned long exp[] __initconst = { BITMAP_FROM_U64(0xffffffff), BITMAP_FROM_U64(0xfffffffe), BITMAP_FROM_U64(0x3333333311111111ULL), - BITMAP_FROM_U64(0xffffffff77777777ULL) + BITMAP_FROM_U64(0xffffffff77777777ULL), + BITMAP_FROM_U64(0), }; static const unsigned long exp2[] __initconst = { @@ -247,19 +248,34 @@ static const struct test_bitmap_parselist parselist_tests[] __initconst = { {0, "1-31:4/4", &exp[9 * step], 32, 0}, {0, "0-31:1/4,32-63:2/4", &exp[10 * step], 64, 0}, {0, "0-31:3/4,32-63:4/4", &exp[11 * step], 64, 0}, + {0, " ,, 0-31:3/4 ,, 32-63:4/4 ,, ", &exp[11 * step], 64, 0}, {0, "0-31:1/4,32-63:2/4,64-95:3/4,96-127:4/4", exp2, 128, 0}, {0, "0-2047:128/256", NULL, 2048, PARSE_TIME}, + {0, "", &exp[12], 8, 0}, + {0, "\n", &exp[12], 8, 0}, + {0, ",, ,, , , ,", &exp[12], 8, 0}, + {0, " , ,, , , ", &exp[12], 8, 0}, + {0, " , ,, , , \n", &exp[12], 8, 0}, + {-EINVAL, "-1", NULL, 8, 0}, {-EINVAL, "-0", NULL, 8, 0}, {-EINVAL, "10-1", NULL, 8, 0}, {-EINVAL, "0-31:", NULL, 8, 0}, {-EINVAL, "0-31:0", NULL, 8, 0}, + {-EINVAL, "0-31:0/", NULL, 8, 0}, {-EINVAL, "0-31:0/0", NULL, 8, 0}, {-EINVAL, "0-31:1/0", NULL, 8, 0}, {-EINVAL, "0-31:10/1", NULL, 8, 0}, + {-EOVERFLOW, "0-98765432123456789:10/1", NULL, 8, 0}, + + {-EINVAL, "a-31", NULL, 8, 0}, + {-EINVAL, "0-a1", NULL, 8, 0}, + {-EINVAL, "a-31:10/1", NULL, 8, 0}, + {-EINVAL, "0-31:a/1", NULL, 8, 0}, + {-EINVAL, "0-\n", NULL, 8, 0}, }; static void __init test_bitmap_parselist(void) -- 2.17.1