From patchwork Mon Dec 15 08:46:44 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Yousong Zhou X-Patchwork-Id: 421032 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 44208140082 for ; Mon, 15 Dec 2014 20:26:10 +1100 (AEDT) Received: from arrakis.dune.hu (localhost [127.0.0.1]) by arrakis.dune.hu (Postfix) with ESMTP id 4203128ACF0; Mon, 15 Dec 2014 10:23:02 +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=-1.5 required=5.0 tests=BAYES_00,FREEMAIL_FROM, T_DKIM_INVALID autolearn=unavailable version=3.3.2 Received: from arrakis.dune.hu (localhost [127.0.0.1]) by arrakis.dune.hu (Postfix) with ESMTP id F0FC028A1AA for ; Mon, 15 Dec 2014 10:22:56 +0100 (CET) X-policyd-weight: using cached result; rate: -8.5 Received: from mail-pa0-f41.google.com (mail-pa0-f41.google.com [209.85.220.41]) by arrakis.dune.hu (Postfix) with ESMTPS for ; Mon, 15 Dec 2014 10:22:56 +0100 (CET) Received: by mail-pa0-f41.google.com with SMTP id rd3so11512906pab.28 for ; Mon, 15 Dec 2014 01:24:43 -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=FY55VHO2V+mH8/NRNE/u3ErtoNq0gzyVJiaZSy69fTmMtkKYN1JxtoukUCAtk4ueOI 9RU54FcN31YRNbwrBm2Fhvgz/Gi1q0Zu8IfV4VZt9/a7POJCndiwn1ea6AyLLV55mO0S 02UojlQXFhAb14M7koCTjkKE/FoH25lPY4g+8eAZhKhogfZPyTS4TjKDPMlFGf+6Zuwp gJ4mW6yHoI6etE5b1G0DcTOz3//tONnqxVE5ix734lETntKz5e/wRGREElyUZPCFrzeR SX2y058/C57FK/xCo3Ljkq5XbV4+NOvwklIhImjn29hGSUOd/HCF1ZphEatTfwTHc4kS xJ0g== X-Received: by 10.70.49.77 with SMTP id s13mr50215195pdn.24.1418635483364; Mon, 15 Dec 2014 01:24:43 -0800 (PST) Received: from debian.lan ([103.29.140.56]) by mx.google.com with ESMTPSA id rh11sm8631536pdb.66.2014.12.15.01.24.40 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Mon, 15 Dec 2014 01:24:42 -0800 (PST) From: Yousong Zhou To: nbd@openwrt.org Date: Mon, 15 Dec 2014 16:46:44 +0800 Message-Id: <1418633213-50491-4-git-send-email-yszhou4tech@gmail.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1418633213-50491-1-git-send-email-yszhou4tech@gmail.com> References: <1418633213-50491-1-git-send-email-yszhou4tech@gmail.com> Cc: openwrt-devel@lists.openwrt.org Subject: [OpenWrt-Devel] [PATCH 03/12] 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" +}