From be753ee863d7ab8246c213b6ad178077c4f770ff Mon Sep 17 00:00:00 2001 From: Alexander Boettcher Date: Tue, 5 Sep 2017 23:05:43 +0200 Subject: [PATCH] tool: add genode xml schema to xmllint check Fixes #2513 --- repos/ports/run/noux_tool_chain.inc | 2 +- repos/ports/run/vbox_share.inc | 2 +- repos/ports/run/virtualbox_auto.inc | 2 +- tool/run/genode.xsd | 141 ++++++++++++++++++++++++++++ tool/run/run | 24 ++++- 5 files changed, 166 insertions(+), 5 deletions(-) create mode 100644 tool/run/genode.xsd diff --git a/repos/ports/run/noux_tool_chain.inc b/repos/ports/run/noux_tool_chain.inc index ef87714fb..ca96c434a 100644 --- a/repos/ports/run/noux_tool_chain.inc +++ b/repos/ports/run/noux_tool_chain.inc @@ -32,7 +32,7 @@ set build_components { # specified using an '' node but it is no valid XML. I.e., xmllint # complains about the sequence '&&'. # -proc check_xml_syntax {xml_file} { } +proc check_xml_with_schema {xml_file} { } source ${genode_dir}/repos/base/run/platform_drv.inc append_platform_drv_build_components diff --git a/repos/ports/run/vbox_share.inc b/repos/ports/run/vbox_share.inc index 8253767f7..c64209c2a 100644 --- a/repos/ports/run/vbox_share.inc +++ b/repos/ports/run/vbox_share.inc @@ -142,7 +142,7 @@ set config_of_app { - + diff --git a/repos/ports/run/virtualbox_auto.inc b/repos/ports/run/virtualbox_auto.inc index 41b0e546f..d53e60a88 100644 --- a/repos/ports/run/virtualbox_auto.inc +++ b/repos/ports/run/virtualbox_auto.inc @@ -209,7 +209,7 @@ append_if [expr $use_cpu_load] config { - + diff --git a/tool/run/genode.xsd b/tool/run/genode.xsd new file mode 100644 index 000000000..2154f0131 --- /dev/null +++ b/tool/run/genode.xsd @@ -0,0 +1,141 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/tool/run/run b/tool/run/run index 77ffd2001..543db76c0 100755 --- a/tool/run/run +++ b/tool/run/run @@ -106,14 +106,34 @@ proc check_xml_syntax {xml_file} { ## -# Install content of specfied variable as init config file +# Validate file to match Genode's XML schema using xmllint +# +proc check_xml_with_schema {xml_file} { + + if {![have_installed xmllint]} { + puts "Warning: Cannot validate config syntax (please install xmllint)" + return; + } + + if {[catch {exec xmllint --noout -schema [genode_dir]/tool/run/genode.xsd $xml_file} result]} { + if {$result != "$xml_file validates"} { + puts stderr "$result" + puts stderr "Error: Invalid XML syntax in $xml_file" + exit 1 + } + } +} + + +## +# Install content of specified variable as init config file # proc install_config { args } { set fh [open "[run_dir]/genode/config" "WRONLY CREAT TRUNC"] puts $fh [join $args {}] close $fh - check_xml_syntax [run_dir]/genode/config + check_xml_with_schema [run_dir]/genode/config }