From patchwork Sun Jul 7 08:30:01 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Christian Couder X-Patchwork-Id: 11034077 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 76C3717D5 for ; Sun, 7 Jul 2019 08:30:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 658DA26E4A for ; Sun, 7 Jul 2019 08:30:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5A36827CEE; Sun, 7 Jul 2019 08:30:43 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 050E526E78 for ; Sun, 7 Jul 2019 08:30:43 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727271AbfGGIah (ORCPT ); Sun, 7 Jul 2019 04:30:37 -0400 Received: from mail-wm1-f67.google.com ([209.85.128.67]:55103 "EHLO mail-wm1-f67.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725822AbfGGIah (ORCPT ); Sun, 7 Jul 2019 04:30:37 -0400 Received: by mail-wm1-f67.google.com with SMTP id p74so9839194wme.4 for ; Sun, 07 Jul 2019 01:30:35 -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 :mime-version:content-transfer-encoding; bh=RetiA+W1eTThTCCBpHHqECn+7yMa7LOUJdodRMbCBtc=; b=U3JtNutTquWIHy7fWkqfmrPbKdfMlaHchOaBjUiKjVrxy2QO5uanOfdRXBhx+/upeV QYYEgvb/Ab96WJB6WnyNao6k/GqtVLvPbpFjyS3Jz8t7+qU54NjwTA88eFbGE5uU5Uzz D1qZ+oKN9sRjv/TVLyu9DOq/Um5zT7nRWilTvd7LQ7RJZs8zEcZ0nLODcfDgkHZE1yr6 l9dfarRlwy/VF7THc+kARigcYBRsFMLkh4q37UDesM7gEowBoPi3uAJ5AtfuEkr/SOEe AWRhh/pj6+ta2Cuv/8x+A/Ih8XGIvO0rTgzYMbSF3/sd1AolmdnjnxDk8pYfIqLO0wIT POMg== 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:mime-version:content-transfer-encoding; bh=RetiA+W1eTThTCCBpHHqECn+7yMa7LOUJdodRMbCBtc=; b=LTR9+/xRzM0lt3BuWYeUb1rpcUxJPzsygciE3N9GDiv9vZRnTB5T4uNpW99+YCJ8Zi BH2xsU8jNPngtqpLUgKKs2wPwRsdrnPW1L/1jbsF7++6eg+djpyNVWNKzopDjfO2g6GD UZBjz2LFitOvFf/TAXTUxWeWR7SPWsmVDyBLMD7bx9sZH3q51TNYbBdeErLRF30noRoK jWGJv8x7pkFSO7kH37WLgHZ3nPcsI8FABkMrV++aCVYuhgVxzNIcZ0AFSfwVh/XAPyCD y4zyyIvxzPnifxLIsBQ7aVvPp/KUbOxzdFErkyvgmNZ23cpws2N89AVgUC1sZaKED6E8 zM+Q== X-Gm-Message-State: APjAAAUSwD1Cv89Tyg3pznoQbdd9G/l+gD9WCUaY110WUxfCWR8YZ8tn OB7KMsspF0L7UzoCLLFvZ5ZdWw+vwDc= X-Google-Smtp-Source: APXvYqxBbMwTnlie8LuGkRzA5nZwQlTW4/lRuYmGyTuxDcU0bC7tEmKrGf6KfBNDs+4oOzQ1PAvq6w== X-Received: by 2002:a05:600c:2182:: with SMTP id e2mr11236699wme.104.1562488234473; Sun, 07 Jul 2019 01:30:34 -0700 (PDT) Received: from localhost.localdomain ([2a04:cec0:10c1:a195:f489:5ba4:f140:8c9a]) by smtp.gmail.com with ESMTPSA id u186sm9606319wmu.26.2019.07.07.01.30.33 (version=TLS1_3 cipher=AEAD-AES256-GCM-SHA384 bits=256/256); Sun, 07 Jul 2019 01:30:33 -0700 (PDT) From: Christian Couder X-Google-Original-From: Christian Couder To: git@vger.kernel.org Cc: Junio C Hamano , =?utf-8?b?w4Z2YXIgQXJuZmrDtnLDsCBC?= =?utf-8?b?amFybWFzb24=?= , Jonathan Tan , =?utf-8?q?SZEDER_G=C3=A1bor?= , Jeff King , Derrick Stolee , Christian Couder Subject: [RFC PATCH 4/5] test-oidmap: add 'get_all' subcommand Date: Sun, 7 Jul 2019 10:30:01 +0200 Message-Id: <20190707083002.7037-5-chriscool@tuxfamily.org> X-Mailer: git-send-email 2.22.0.514.g3228928bce.dirty In-Reply-To: <20190707083002.7037-1-chriscool@tuxfamily.org> References: <20190707083002.7037-1-chriscool@tuxfamily.org> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Let's make it possible to test oidmap_get_next() by adding a 'get_all' subcommand that calls oidmap_get() once first and then oidmap_get_next() several times until there is no more entry with the same oid key. Signed-off-by: Christian Couder --- t/helper/test-oidmap.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/t/helper/test-oidmap.c b/t/helper/test-oidmap.c index c19b41aa4f..5c4897ce59 100644 --- a/t/helper/test-oidmap.c +++ b/t/helper/test-oidmap.c @@ -95,6 +95,23 @@ int cmd__oidmap(int argc, const char **argv) /* print result */ puts(entry ? entry->name : "NULL"); + } else if (!strcmp("get_all", cmd) && p1) { + + if (get_oid(p1, &oid)) { + printf("Unknown oid: %s\n", p1); + continue; + } + + /* lookup entry in oidmap */ + entry = oidmap_get(&map, &oid); + + /* print result */ + puts(entry ? entry->name : "NULL"); + + if (entry) + while ((entry = oidmap_get_next(&map, entry))) + puts(entry ? entry->name : "NULL"); + } else if (!strcmp("remove", cmd) && p1) { if (get_oid(p1, &oid)) {