Commit dbad2a4c authored by Daniel Holbach's avatar Daniel Holbach Committed by Aron Xu

Add simple autopkgtest to the package

parent c0e37491
......@@ -10,6 +10,7 @@ Build-Depends: debhelper (>= 9), perl, dh-autoreconf, autotools-dev,
Homepage: http://xmlsoft.org/
Vcs-Git: git://git.debian.org/debian-xml-sgml/libxml2.git
Vcs-Browser: http://git.debian.org/?p=debian-xml-sgml/libxml2.git
XS-Testsuite: autopkgtest
Package: libxml2
Priority: standard
......@@ -143,4 +144,3 @@ Description: Python bindings for the GNOME XML library (debug extension)
.
This package contains the files needed to use the GNOME XML library
in Python programs for use with the Python debug interpreter.
#!/bin/sh
# autopkgtest check: Build and run a program against libxml2, to verify that the
# headers and pkg-config file are installed correctly
# (C) 2012 Canonical Ltd.
# Author: Daniel Holbach <daniel.holbach@ubuntu.com>
set -e
WORKDIR=$(mktemp -d)
trap "rm -rf $WORKDIR" 0 INT QUIT ABRT PIPE TERM
cd $WORKDIR
cat <<EOF > xmltest.c
#include <libxml/parser.h>
int
main(void)
{
xmlNodePtr n;
xmlDocPtr doc;
xmlNodePtr cur;
doc = xmlNewDoc(BAD_CAST "1.0");
n = xmlNewNode(NULL, BAD_CAST "root");
xmlNodeSetContent(n, BAD_CAST "content");
xmlDocSetRootElement(doc, n);
cur = xmlDocGetRootElement(doc);
if (xmlStrcmp(cur->name, (const xmlChar *) "root"))
return (1);
xmlFreeDoc(doc);
return (0);
}
EOF
gcc -o xmltest xmltest.c `pkg-config --cflags --libs libxml-2.0`
echo "build: OK"
[ -x xmltest ]
./xmltest
echo "run: OK"
Tests: build python
Depends: libxml2-dev, python-libxml2, build-essential, pkg-config
#!/bin/sh
python <<EOF
import libxml2
import sys
doc = libxml2.parseDoc(
"""<?xml version="1.0" encoding="iso-8859-1"?>
<!DOCTYPE test [
<!ELEMENT test (#PCDATA) >
<!ATTLIST test xmlns:abc CDATA #FIXED "http://abc.org" >
<!ATTLIST test abc:attr CDATA #FIXED "def" >
]>
<test />
""")
elem = doc.getRootElement()
attr = elem.hasNsProp('attr', 'http://abc.org')
if attr == None or attr.serialize()[:-1] != """<!ATTLIST test abc:attr CDATA #FIXED "def">""":
print("Failed to find defaulted attribute abc:attr")
sys.exit(1)
doc.freeDoc()
EOF
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment