[Fuego] [PATCH v2] libxml: Add test cases for command xmlcatalog/xmllint of libxml.

Tim.Bird at sony.com Tim.Bird at sony.com
Wed Apr 17 00:09:35 UTC 2019


Applied to fuegotest 'next' branch.

I really appreciate that this one does some actual functional testing of the command operation.
Thanks,
 -- Tim


> -----Original Message-----
> From: fuego-bounces at lists.linuxfoundation.org [mailto:fuego-
> bounces at lists.linuxfoundation.org] On Behalf Of Wang Mingyu
> Sent: Friday, March 15, 2019 6:56 AM
> To: fuego at lists.linuxfoundation.org
> Subject: [Fuego] [PATCH v2] libxml: Add test cases for command
> xmlcatalog/xmllint of libxml.
> 
> The libxml library is used to parse XML files.
> This test set is used to parse and manipulate XML or SGML files.
> 
> Signed-off-by: Wang Mingyu <wangmy at cn.fujitsu.com>
> ---
>  tests/Functional.libxml/fuego_test.sh              | 18 ++++++++++++
>  tests/Functional.libxml/libxml_test.sh             |  4 +++
>  tests/Functional.libxml/parser.py                  | 20 ++++++++++++++
>  tests/Functional.libxml/spec.json                  |  6 ++++
>  tests/Functional.libxml/tests/xmlcatalog_create.sh | 13 +++++++++
>  tests/Functional.libxml/tests/xmlcatalog_debug.sh  | 17 ++++++++++++
>  tests/Functional.libxml/tests/xmlcatalog_help.sh   | 13 +++++++++
>  tests/Functional.libxml/tests/xmllint_checkxml.sh  | 32
> ++++++++++++++++++++++
>  tests/Functional.libxml/tests/xmllint_debug.sh     | 32
> ++++++++++++++++++++++
>  tests/Functional.libxml/tests/xmllint_format.sh    | 19 +++++++++++++
>  tests/Functional.libxml/tests/xmllint_noout.sh     | 32
> ++++++++++++++++++++++
>  11 files changed, 206 insertions(+)
>  create mode 100644 tests/Functional.libxml/fuego_test.sh
>  create mode 100755 tests/Functional.libxml/libxml_test.sh
>  create mode 100644 tests/Functional.libxml/parser.py
>  create mode 100644 tests/Functional.libxml/spec.json
>  create mode 100644 tests/Functional.libxml/tests/xmlcatalog_create.sh
>  create mode 100644 tests/Functional.libxml/tests/xmlcatalog_debug.sh
>  create mode 100644 tests/Functional.libxml/tests/xmlcatalog_help.sh
>  create mode 100644 tests/Functional.libxml/tests/xmllint_checkxml.sh
>  create mode 100644 tests/Functional.libxml/tests/xmllint_debug.sh
>  create mode 100644 tests/Functional.libxml/tests/xmllint_format.sh
>  create mode 100644 tests/Functional.libxml/tests/xmllint_noout.sh
> 
> diff --git a/tests/Functional.libxml/fuego_test.sh
> b/tests/Functional.libxml/fuego_test.sh
> new file mode 100644
> index 0000000..0bb514d
> --- /dev/null
> +++ b/tests/Functional.libxml/fuego_test.sh
> @@ -0,0 +1,18 @@
> +function test_pre_check {
> +    assert_has_program xmlcatalog PROGRAM_XMLCATALOG
> +    assert_has_program xmllint PROGRAM_XMLLINT
> +}
> +
> +function test_deploy {
> +    put $TEST_HOME/libxml_test.sh $BOARD_TESTDIR/fuego.$TESTDIR/
> +    put -r $TEST_HOME/tests $BOARD_TESTDIR/fuego.$TESTDIR/
> +}
> +
> +function test_run {
> +    report "cd $BOARD_TESTDIR/fuego.$TESTDIR;\
> +    ./libxml_test.sh"
> +}
> +
> +function test_processing {
> +    log_compare "$TESTDIR" "0" "TEST-FAIL" "n"
> +}
> diff --git a/tests/Functional.libxml/libxml_test.sh
> b/tests/Functional.libxml/libxml_test.sh
> new file mode 100755
> index 0000000..dd5ce37
> --- /dev/null
> +++ b/tests/Functional.libxml/libxml_test.sh
> @@ -0,0 +1,4 @@
> +#!/bin/sh
> +for i in tests/*.sh; do
> +    sh $i
> +done
> diff --git a/tests/Functional.libxml/parser.py
> b/tests/Functional.libxml/parser.py
> new file mode 100644
> index 0000000..f25a608
> --- /dev/null
> +++ b/tests/Functional.libxml/parser.py
> @@ -0,0 +1,20 @@
> +#!/usr/bin/python
> +# See common.py for description of command-line arguments
> +
> +import os, sys, collections
> +import common as plib
> +
> +measurements = {}
> +measurements = collections.OrderedDict()
> +
> +regex_string = '^ -> (.*): TEST-(.*)$'
> +matches = plib.parse_log(regex_string)
> +
> +if matches:
> +    for m in matches:
> +        measurements['default.' + m[0]] = 'PASS' if m[1] == 'PASS' else 'FAIL'
> +
> +# split the output for each testcase
> +plib.split_output_per_testcase(regex_string, measurements)
> +
> +sys.exit(plib.process(measurements))
> diff --git a/tests/Functional.libxml/spec.json
> b/tests/Functional.libxml/spec.json
> new file mode 100644
> index 0000000..a610acb
> --- /dev/null
> +++ b/tests/Functional.libxml/spec.json
> @@ -0,0 +1,6 @@
> +{
> +    "testName": "Functional.libxml",
> +    "specs": {
> +        "default": {}
> +    }
> +}
> diff --git a/tests/Functional.libxml/tests/xmlcatalog_create.sh
> b/tests/Functional.libxml/tests/xmlcatalog_create.sh
> new file mode 100644
> index 0000000..f9426d1
> --- /dev/null
> +++ b/tests/Functional.libxml/tests/xmlcatalog_create.sh
> @@ -0,0 +1,13 @@
> +#!/bin/sh
> +
> +#  In the target to execute command xmlcatalog and confirm the result.
> +#  option : --create
> +
> +test="xmlcatalog2"
> +
> +if xmlcatalog --create | grep "DTD"
> +then
> +    echo " -> $test: TEST-PASS"
> +else
> +    echo " -> $test: TEST-FAIL"
> +fi
> diff --git a/tests/Functional.libxml/tests/xmlcatalog_debug.sh
> b/tests/Functional.libxml/tests/xmlcatalog_debug.sh
> new file mode 100644
> index 0000000..0cd8329
> --- /dev/null
> +++ b/tests/Functional.libxml/tests/xmlcatalog_debug.sh
> @@ -0,0 +1,17 @@
> +#!/bin/sh
> +
> +#  In the target to execute command xmlcatalog and confirm the result.
> +#  option : --create,--verbose
> +
> +test="xmlcatalog3"
> +
> +xmlcatalog --create > catalog
> +xmlcatalog --verbose catalog > log 2>&1
> +if cat log | grep "Catalogs cleanup"
> +then
> +    echo " -> $test: TEST-PASS"
> +else
> +    echo " -> $test: TEST-FAIL"
> +fi
> +rm -f catalog
> +rm log
> diff --git a/tests/Functional.libxml/tests/xmlcatalog_help.sh
> b/tests/Functional.libxml/tests/xmlcatalog_help.sh
> new file mode 100644
> index 0000000..7e1b1a8
> --- /dev/null
> +++ b/tests/Functional.libxml/tests/xmlcatalog_help.sh
> @@ -0,0 +1,13 @@
> +#!/bin/sh
> +
> +#  In the target to execute command xmlcatalog and confirm the result.
> +#  option : --help
> +
> +test="xmlcatalog1"
> +
> +if xmlcatalog --help | grep "Usage"
> +then
> +    echo " -> $test: TEST-PASS"
> +else
> +    echo " -> $test: TEST-FAIL"
> +fi
> diff --git a/tests/Functional.libxml/tests/xmllint_checkxml.sh
> b/tests/Functional.libxml/tests/xmllint_checkxml.sh
> new file mode 100644
> index 0000000..1cafb57
> --- /dev/null
> +++ b/tests/Functional.libxml/tests/xmllint_checkxml.sh
> @@ -0,0 +1,32 @@
> +#!/bin/sh
> +
> +#  In the target to execute command xmllint and confirm the result.
> +#  option : none
> +
> +test="xmllint1"
> +
> +cat >> sample01.xml <<EOF
> +<?xml version="1.0" encoding="Shift_JIS" ?>
> +
> +<!DOCTYPE linux[
> +<!ELEMENT linux (distribution)>
> +<!ELEMENT distribution (debian,redhat)>
> +<!ELEMENT debian (#PCDATA)>
> +<!ELEMENT redhat (#PCDATA)>
> +]>
> +
> +<linux>
> +  <distribution>
> +    <debian>favorit</debian>
> +    <redhat>interest</redhat>
> +  </distribution>
> +</linux>
> +EOF
> +
> +if xmllint sample01.xml
> +then
> +    echo " -> $test: TEST-PASS"
> +else
> +    echo " -> $test: TEST-FAIL"
> +fi
> +rm sample01.xml
> diff --git a/tests/Functional.libxml/tests/xmllint_debug.sh
> b/tests/Functional.libxml/tests/xmllint_debug.sh
> new file mode 100644
> index 0000000..6822234
> --- /dev/null
> +++ b/tests/Functional.libxml/tests/xmllint_debug.sh
> @@ -0,0 +1,32 @@
> +#!/bin/sh
> +
> +#  In the target to execute command xmllint and confirm the result.
> +#  option : --debug
> +
> +test="xmllint3"
> +
> +cat >> sample01.xml <<EOF
> +<?xml version="1.0" encoding="Shift_JIS" ?>
> +
> +<!DOCTYPE linux[
> +<!ELEMENT linux (distribution)>
> +<!ELEMENT distribution (debian,redhat)>
> +<!ELEMENT debian (#PCDATA)>
> +<!ELEMENT redhat (#PCDATA)>
> +]>
> +
> +<linux>
> +  <distribution>
> +    <debian>favorit</debian>
> +    <redhat>interest</redhat>
> +  </distribution>
> +</linux>
> +EOF
> +
> +if xmllint --debug sample01.xml | grep ".*DTD.*linux.*"
> +then
> +    echo " -> $test: TEST-PASS"
> +else
> +    echo " -> $test: TEST-FAIL"
> +fi
> +rm sample01.xml
> diff --git a/tests/Functional.libxml/tests/xmllint_format.sh
> b/tests/Functional.libxml/tests/xmllint_format.sh
> new file mode 100644
> index 0000000..c2ea653
> --- /dev/null
> +++ b/tests/Functional.libxml/tests/xmllint_format.sh
> @@ -0,0 +1,19 @@
> +#!/bin/sh
> +
> +#  In the target to execute command xmllint and confirm the result.
> +#  option : --format
> +
> +test="xmllint4"
> +
> +cat >> format.xml <<EOF
> +<root><parent><child><subchild>DOCUMENT</subchild></child><child>
> +<subchild>TEXT</subchild></child></parent></root>
> +EOF
> +
> +if xmllint --format format.xml | wc -l | grep 11
> +then
> +    echo " -> $test: TEST-PASS"
> +else
> +    echo " -> $test: TEST-FAIL"
> +fi
> +rm format.xml
> diff --git a/tests/Functional.libxml/tests/xmllint_noout.sh
> b/tests/Functional.libxml/tests/xmllint_noout.sh
> new file mode 100644
> index 0000000..959253d
> --- /dev/null
> +++ b/tests/Functional.libxml/tests/xmllint_noout.sh
> @@ -0,0 +1,32 @@
> +#!/bin/sh
> +
> +#  In the target to execute command xmllint and confirm the result.
> +#  option : --noout,--valid
> +
> +test="xmllint2"
> +
> +cat >> sample01.xml <<EOF
> +<?xml version="1.0" encoding="Shift_JIS" ?>
> +
> +<!DOCTYPE linux[
> +<!ELEMENT linux (distribution)>
> +<!ELEMENT distribution (debian,redhat)>
> +<!ELEMENT debian (#PCDATA)>
> +<!ELEMENT redhat (#PCDATA)>
> +]>
> +
> +<linux>
> +  <distribution>
> +    <debian>favorit</debian>
> +    <redhat>interest</redhat>
> +  </distribution>
> +</linux>
> +EOF
> +
> +if xmllint --noout --valid sample01.xml
> +then
> +    echo " -> $test: TEST-PASS"
> +else
> +    echo " -> $test: TEST-FAIL"
> +fi
> +rm sample01.xml
> --
> 1.8.3.1
> 
> 
> 
> _______________________________________________
> Fuego mailing list
> Fuego at lists.linuxfoundation.org
> https://lists.linuxfoundation.org/mailman/listinfo/fuego


More information about the Fuego mailing list