From 76d05aea8fa6c24eb9d5b7362a81fc092e64898a Mon Sep 17 00:00:00 2001
From: Iustin Pop <iustin@debian.org>
Date: Sat, 14 May 2016 22:26:43 +0200
Subject: [PATCH] Add autopkgtest testsuite

The actual tests are conditional on xattrs being enabled, hopefully
this works for debian's ci env.
---
 debian/tests/control                        |  3 +++
 debian/tests/run-testsuite-if-attrs-enabled | 17 +++++++++++++++++
 debian/tests/simple                         |  4 ++++
 3 files changed, 24 insertions(+)
 create mode 100644 debian/tests/control
 create mode 100755 debian/tests/run-testsuite-if-attrs-enabled
 create mode 100755 debian/tests/simple

diff --git a/debian/tests/control b/debian/tests/control
new file mode 100644
index 0000000..1a24a9b
--- /dev/null
+++ b/debian/tests/control
@@ -0,0 +1,3 @@
+Tests: simple run-testsuite-if-attrs-enabled
+Depends: @, attr
+Restrictions: allow-stderr
diff --git a/debian/tests/run-testsuite-if-attrs-enabled b/debian/tests/run-testsuite-if-attrs-enabled
new file mode 100755
index 0000000..04cb2ec
--- /dev/null
+++ b/debian/tests/run-testsuite-if-attrs-enabled
@@ -0,0 +1,17 @@
+#!/bin/sh
+
+TESTFILE="$ADTTMP/foo"
+
+touch "$TESTFILE"
+
+if setfattr -n user.foo -v bar "$TESTFILE"; then
+  echo "Temporary directory '$ADTTMP' has extended attributes, running tests"
+  export TEST_DIR="$ADTTMP"
+  echo "* testing Python 2"
+  python2 test/test_xattr.py
+  echo "* testing Python 3"
+  python3 test/test_xattr.py
+else
+  echo "Temporary directory '$ADTTMP' doesn't have extended attributes enabled"
+  echo "Skipping the tests :("
+fi
diff --git a/debian/tests/simple b/debian/tests/simple
new file mode 100755
index 0000000..8212962
--- /dev/null
+++ b/debian/tests/simple
@@ -0,0 +1,4 @@
+#!/bin/sh
+
+python2 -c 'import xattr; print xattr; print xattr.__version__'
+python3 -c 'import xattr; print(xattr); print(xattr.__version__)'
-- 
2.39.5