Received: by 2002:ac0:a679:0:0:0:0:0 with SMTP id p54csp327383imp; Wed, 20 Feb 2019 00:39:27 -0800 (PST) X-Google-Smtp-Source: AHgI3IZ6/N4LAZVg1X9hZjAVGV3AkuuqWkbErhG8mXh+inDtohv10t+lxfGAR7pFwEf4sahTFqi/ X-Received: by 2002:a63:31d6:: with SMTP id x205mr1272186pgx.41.1550651967741; Wed, 20 Feb 2019 00:39:27 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1550651967; cv=none; d=google.com; s=arc-20160816; b=HpeRIp9jqkUfS8ZpiMj/pS3/Vn1Img2DHS86gRQv3L7PB28VleIaAS2u76KX1corjR 0SaQJoF34K2lEsGAdOOB6j8geDVX2QTrsBp3FMA7idb/ASyT/wY5TayW/ulB5w/nlZYi WiN2ZI60L4Cu0oOhnPD51UZD7V+7WHhtchzeh5mmXQ1ZobAPWoh/ksJiuAB9gXyXg5V/ 5/MTx5EKnJHX6ieRcoc/sBbe1r5fbQmB1IpEhIBmTZx9SqtkfBMe3Sbyr0cwhoaZcU2D +wmmd9QCusTA91amCCaxAXsI73tQGg/iCyWIIxsgja9sA2wyHW+Nv/yPqFnNXrntYOSd Ym9w== 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=h8Jakv2rwdIJxZ1EZQYZxhMJzsBuntGhtGEeTRSqGkEaCfQXvI/vpMqhFfZxe0iOtf 6/mhi5F+XsCVrrkMTqKZjfG6e66XRSZv5BoIvHVjZBdb+RNrXCsKNq60u01BWRbsuTrJ GVZPTUFLZ3h+uxBxcu/u1XeqqXRyXz4lEuAK0Iog+ZJ08tnW/UMXO/7zZOqA+6/q26sa apwLpv02zZIrjO+6hZNWxvyARXvo0rWRtSZ3QLAoWkiUzozbG+VK+2QTTIE7AoVKBNLg lz0KkU6hsX6qg/X+CtfR/oLgMXJLVqF/uvHS9OKruK7oyrDOPyQtMqTsJL2DYq99cIFH mQxQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@gmail.com header.s=20161025 header.b=K769gt+o; 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 i9si19309812plb.35.2019.02.20.00.39.12; Wed, 20 Feb 2019 00:39:27 -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; dkim=pass header.i=@gmail.com header.s=20161025 header.b=K769gt+o; 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 S1726520AbfBTIh1 (ORCPT + 99 others); Wed, 20 Feb 2019 03:37:27 -0500 Received: from mail-lf1-f67.google.com ([209.85.167.67]:44279 "EHLO mail-lf1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726427AbfBTIhY (ORCPT ); Wed, 20 Feb 2019 03:37:24 -0500 Received: by mail-lf1-f67.google.com with SMTP id g2so16881004lfh.11 for ; Wed, 20 Feb 2019 00:37:23 -0800 (PST) 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=K769gt+oYF4pZZc7mr61J1c6tumHP65tnvF2QGrNKqlnSvuXGB36KtOzD6RzIU0GkN IXZmM1s/lXZ3tisHJBa5V5nTalWncNKDBGKtKViYCgTWJ/BSgwF1q+5YSNRKBfdFNgWn HKBqXbGWY9BYmmxk6uhUMSzHYFW3gmQUZUBTW/eNQEOd6hzmdHcEYtaYZZvEwYAABnT2 +eXPYvjEaP6AL47g/AOF8TKNgX3SdNomeuvNmpc/lq9+OBzksMJzNeHnSERG5c4NCnyK CvkUegDa1Hwk27u/MQBqbJqbwM3wLW0cpBl/0NeS+2VOT7S41lkk/bTUWAvpvb+BoEfn bHMA== 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=uS4Uh7Q4CwyQgP2XTAz2O5vARLOd/cgAsWM7+qT8Ao5nIGDt7DO/CZ7sk0EIIM1IOs AGSudrDa+Q4M2LU+yCzyFxRC15lmnBRCU6K4qWonp2GDb+oNYhDZcqH7nWe/DthytvTc HmsTEHZtbToY5PJ//nCRFdZ/ms98nYW3D5/oSw8XERupUWKDn+fARN5uD14atfHW6eOc SvAXAMc98ih7QLRG9CyQWIiCb49Imu0/cT0Y2MpfWHSBJT2BrYHefeSpLEPThw8RBVP5 j/odzyibNLIDd2SQTzgy4Y05Aw5PsFDSxhf04cmUQOy6mbCnEz+RY8gSixVNe1rarBFr eLDQ== X-Gm-Message-State: AHQUAuZJqAhwzIaubvp20jJ+kslydMA7qP0GIzZmgEGjSQcjQSASAbBi daIaYBrQKlbK8/0VfAPKm4Q= X-Received: by 2002:a19:5504:: with SMTP id n4mr20280768lfe.43.1550651842316; Wed, 20 Feb 2019 00:37:22 -0800 (PST) Received: from localhost ([188.162.52.148]) by smtp.gmail.com with ESMTPSA id l16sm4971302lfh.58.2019.02.20.00.37.21 (version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256); Wed, 20 Feb 2019 00:37:21 -0800 (PST) From: Yury Norov X-Google-Original-From: Yury Norov To: Andrew Morton , Andy Shevchenko , Arnd Bergmann , Dmitry Torokhov , Kees Cook , Matthew Wilcox , Michael Ellerman , Rasmus Villemoes , Tetsuo Handa Cc: Yury Norov , linux-kernel@vger.kernel.org, Yury Norov Subject: [PATCH 5/6] lib/test_bitmap: add testcases for bitmap_parselist Date: Wed, 20 Feb 2019 11:37:04 +0300 Message-Id: <20190220083705.14050-6-ynorov@marvell.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190220083705.14050-1-ynorov@marvell.com> References: <20190220083705.14050-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