From patchwork Tue Dec 16 07:00:09 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yousong Zhou X-Patchwork-Id: 422460 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from arrakis.dune.hu (arrakis.dune.hu [78.24.191.176]) (using TLSv1.1 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id D7674140079 for ; Thu, 18 Dec 2014 13:56:11 +1100 (AEDT) Received: from arrakis.dune.hu (localhost [127.0.0.1]) by arrakis.dune.hu (Postfix) with ESMTP id 5868128BBE3; Thu, 18 Dec 2014 03:52:17 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.3.2 (2011-06-06) on arrakis.dune.hu X-Spam-Level: X-Spam-Status: No, score=-0.9 required=5.0 tests=BAYES_00, DATE_IN_PAST_24_48, FREEMAIL_FROM,T_DKIM_INVALID autolearn=no version=3.3.2 Received: from arrakis.dune.hu (localhost [127.0.0.1]) by arrakis.dune.hu (Postfix) with ESMTP id C3EDE2802B9 for ; Thu, 18 Dec 2014 03:51:48 +0100 (CET) X-policyd-weight: using cached result; rate: -8.5 Received: from mail-pd0-f179.google.com (mail-pd0-f179.google.com [209.85.192.179]) by arrakis.dune.hu (Postfix) with ESMTPS for ; Thu, 18 Dec 2014 03:51:45 +0100 (CET) Received: by mail-pd0-f179.google.com with SMTP id fp1so413275pdb.38 for ; Wed, 17 Dec 2014 18:53:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id:in-reply-to:references; bh=1JC9jXmPK+2QCPZxacyfzFt36jDPe61Lk1wtWz8b+iA=; b=ANQ1sQhVFVC0NxNQDuickzwpg+tZKSQUXgOSUkFxXhEnvuVTfva9vGaI4cM5+j7r2f VTSPMiuFmDrypYPrEzDyL00nae9QX6i22QXI/m/kYMuNR7ptnOnlMsiIHZrwSLI9thii PMUF1BCef3QzSgS4XaTzFErve5nh6FkL+dXx4/4sonkhQOHC+mKgmFwFJ3YG+eu0dqq9 Ll9VmeLxHwFqsGOszMTfrNEdj6xoiLISijznOXWZfoaCxdcoab+9Zureqev6WiyaxAPP QgzlUFtfTd1EiaJ93Hb1cRDRlt2ohkrr6smUs6m19bbw2/ASOYA3oF1WJhtTSop0DYv4 8oMw== X-Received: by 10.70.128.45 with SMTP id nl13mr75303522pdb.126.1418871214695; Wed, 17 Dec 2014 18:53:34 -0800 (PST) Received: from debian.lan ([103.29.140.56]) by mx.google.com with ESMTPSA id oy7sm5104495pbc.88.2014.12.17.18.53.31 (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 17 Dec 2014 18:53:33 -0800 (PST) From: Yousong Zhou To: nbd@openwrt.org Date: Tue, 16 Dec 2014 15:00:09 +0800 Message-Id: <1418713218-16300-8-git-send-email-yszhou4tech@gmail.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1418713218-16300-1-git-send-email-yszhou4tech@gmail.com> References: <1418713218-16300-1-git-send-email-yszhou4tech@gmail.com> Cc: openwrt-devel@lists.openwrt.org Subject: [OpenWrt-Devel] [PATCH v2 07/16] tests: add more test coverage for `uci show' command. X-BeenThere: openwrt-devel@lists.openwrt.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: OpenWrt Development List List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , MIME-Version: 1.0 Errors-To: openwrt-devel-bounces@lists.openwrt.org Sender: "openwrt-devel" Signed-off-by: Yousong Zhou --- test/references/show_parsing_multiline.data | 20 +++++++++++++ .../show_parsing_multiline_option.result | 12 ++++++++ .../show_parsing_multiline_package.result | 18 ++++++++++++ .../show_parsing_multiline_section.result | 16 ++++++++++ test/tests.d/050_show | 31 ++++++++++++++++++++ 5 files changed, 97 insertions(+) create mode 100644 test/references/show_parsing_multiline.data create mode 100644 test/references/show_parsing_multiline_option.result create mode 100644 test/references/show_parsing_multiline_package.result create mode 100644 test/references/show_parsing_multiline_section.result diff --git a/test/references/show_parsing_multiline.data b/test/references/show_parsing_multiline.data new file mode 100644 index 0000000..670e809 --- /dev/null +++ b/test/references/show_parsing_multiline.data @@ -0,0 +1,20 @@ +config main + option version 1.4.1 + +config sockd 'instance0' + option enabled 1 + list internal_network vpn + list external_network wan + + option extra_config ' + user.unprivileged: nobody + client pass { + from: 0.0.0.0/0 to: 0.0.0.0/0 + session.max: 64 + log: error + } + + socks pass { + from: 0.0.0.0/0 to: 0.0.0.0/0 + log: connect + } ' diff --git a/test/references/show_parsing_multiline_option.result b/test/references/show_parsing_multiline_option.result new file mode 100644 index 0000000..6f7aacf --- /dev/null +++ b/test/references/show_parsing_multiline_option.result @@ -0,0 +1,12 @@ +sockd.instance0.extra_config=' + user.unprivileged: nobody + client pass { + from: 0.0.0.0/0 to: 0.0.0.0/0 + session.max: 64 + log: error + } + + socks pass { + from: 0.0.0.0/0 to: 0.0.0.0/0 + log: connect + } ' diff --git a/test/references/show_parsing_multiline_package.result b/test/references/show_parsing_multiline_package.result new file mode 100644 index 0000000..218082d --- /dev/null +++ b/test/references/show_parsing_multiline_package.result @@ -0,0 +1,18 @@ +sockd.@main[0]=main +sockd.@main[0].version='1.4.1' +sockd.instance0=sockd +sockd.instance0.enabled='1' +sockd.instance0.internal_network='vpn' +sockd.instance0.external_network='wan' +sockd.instance0.extra_config=' + user.unprivileged: nobody + client pass { + from: 0.0.0.0/0 to: 0.0.0.0/0 + session.max: 64 + log: error + } + + socks pass { + from: 0.0.0.0/0 to: 0.0.0.0/0 + log: connect + } ' diff --git a/test/references/show_parsing_multiline_section.result b/test/references/show_parsing_multiline_section.result new file mode 100644 index 0000000..0506ac3 --- /dev/null +++ b/test/references/show_parsing_multiline_section.result @@ -0,0 +1,16 @@ +sockd.instance0=sockd +sockd.instance0.enabled='1' +sockd.instance0.internal_network='vpn' +sockd.instance0.external_network='wan' +sockd.instance0.extra_config=' + user.unprivileged: nobody + client pass { + from: 0.0.0.0/0 to: 0.0.0.0/0 + session.max: 64 + log: error + } + + socks pass { + from: 0.0.0.0/0 to: 0.0.0.0/0 + log: connect + } ' diff --git a/test/tests.d/050_show b/test/tests.d/050_show index 7d7e160..ce0eafc 100644 --- a/test/tests.d/050_show +++ b/test/tests.d/050_show @@ -9,3 +9,34 @@ test_get_parsing() assertFailWithNoReturn "${UCI_Q} show test.section.opt.val.qsdf.qsd" assertFailWithNoReturn "${UCI_Q} show test.section.opt.valqsqsd" } + +prepare_get_parsing_multiline() { + cp ${REF_DIR}/show_parsing_multiline.data ${CONFIG_DIR}/sockd +} + +test_get_parsing_multiline_package() +{ + prepare_get_parsing_multiline + + value=$(${UCI_Q} show sockd) + value_ref=$(cat ${REF_DIR}/show_parsing_multiline_package.result) + assertEquals "$value_ref" "$value" +} + +test_get_parsing_multiline_section() +{ + prepare_get_parsing_multiline + + value=$(${UCI_Q} show sockd.instance0) + value_ref=$(cat ${REF_DIR}/show_parsing_multiline_section.result) + assertEquals "$value_ref" "$value" +} + +test_get_parsing_multiline_option() +{ + prepare_get_parsing_multiline + + value=$(${UCI_Q} show sockd.instance0.extra_config) + value_ref=$(cat ${REF_DIR}/show_parsing_multiline_option.result) + assertEquals "$value_ref" "$value" +}