summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorP. J. McDermott <pjm@nac.net>2012-10-02 02:58:24 (EDT)
committer P. J. McDermott <pjm@nac.net>2012-10-02 02:58:24 (EDT)
commit84680dae703db9187fb076ab4065785a13206ff0 (patch)
tree5b23f99835340f080045134a9be4da724052aa9f /tests
parent2b1a9d8eb8c21ce2571e311168087f95f7a92f45 (diff)
Improve format of "ob_reduce_deps" test data.
Diffstat (limited to 'tests')
-rw-r--r--tests/ob_reduce_deps.data28
-rw-r--r--tests/ob_reduce_deps.rc71
-rw-r--r--tests/ob_reduce_deps.sh37
3 files changed, 88 insertions, 48 deletions
diff --git a/tests/ob_reduce_deps.data b/tests/ob_reduce_deps.data
deleted file mode 100644
index 5c853d9..0000000
--- a/tests/ob_reduce_deps.data
+++ /dev/null
@@ -1,28 +0,0 @@
-# dependencies ; reduced dependencies ; type ; host-arch
-
-foo, bar ;foo, bar \
- ;n;core-linux-eglibc
-foo,bar ;foo, bar \
- ;n;core-linux-eglibc
-foo, bar ;foo, bar \
- ;n;core-linux-eglibc
-foo, bar ;foo, bar \
- ;u;core-linux-eglibc
-foo,bar ;foo, bar \
- ;u;core-linux-eglibc
-foo, bar ;foo, bar \
- ;u;core-linux-eglibc
-
-foo | bar ;foo | bar \
- ;n;core-linux-eglibc
-foo|bar ;foo | bar \
- ;n;core-linux-eglibc
-foo | bar ;foo | bar \
- ;n;core-linux-eglibc
-
-foo [core-linux-eglibc], bar [!core-linux-eglibc] \
- ;foo \
- ;n;core-linux-eglibc
-foo [core-linux-eglibc], bar [!core-linux-eglibc] \
- ;foo \
- ;u;core-linux-eglibc
diff --git a/tests/ob_reduce_deps.rc b/tests/ob_reduce_deps.rc
new file mode 100644
index 0000000..ff1acfc
--- /dev/null
+++ b/tests/ob_reduce_deps.rc
@@ -0,0 +1,71 @@
+# Normal and union AND-lists.
+
+type='n'
+host_arch='core-linux-eglibc'
+deps='foo, bar'
+result='foo, bar'
+testcase
+
+type='n'
+host_arch='core-linux-eglibc'
+deps='foo,bar'
+result='foo, bar'
+testcase
+
+type='n'
+host_arch='core-linux-eglibc'
+deps='foo, bar'
+result='foo, bar'
+testcase
+
+type='u'
+host_arch='core-linux-eglibc'
+deps='foo, bar'
+result='foo, bar'
+testcase
+
+type='u'
+host_arch='core-linux-eglibc'
+deps='foo,bar'
+result='foo, bar'
+testcase
+
+type='u'
+host_arch='core-linux-eglibc'
+deps='foo, bar'
+result='foo, bar'
+testcase
+
+# Normal and union OR-lists.
+
+type='n'
+host_arch='core-linux-eglibc'
+deps='foo | bar'
+result='foo | bar'
+testcase
+
+type='n'
+host_arch='core-linux-eglibc'
+deps='foo|bar'
+result='foo | bar'
+testcase
+
+type='n'
+host_arch='core-linux-eglibc'
+deps='foo | bar'
+result='foo | bar'
+testcase
+
+# Normal and union AND-lists with arch specs.
+
+type='n'
+host_arch='core-linux-eglibc'
+deps='foo [core-linux-eglibc], bar [!core-linux-eglibc]'
+result='foo'
+testcase
+
+type='u'
+host_arch='core-linux-eglibc'
+deps='foo [core-linux-eglibc], bar [!core-linux-eglibc]'
+result='foo'
+testcase
diff --git a/tests/ob_reduce_deps.sh b/tests/ob_reduce_deps.sh
index 28d69e6..3f2afd7 100644
--- a/tests/ob_reduce_deps.sh
+++ b/tests/ob_reduce_deps.sh
@@ -22,36 +22,33 @@
ob_use deps
ret=0
+type=
+host_arch=
+deps=
+result=
-while read line; do
+main()
+{
+ . ./ob_reduce_deps.rc
- line="${line%%#*}"
- [ -z "${line}" ] && continue
-
- IFS=';' read -r test_deps good_deps type host_arch \
- <<EOF
-${line}
-EOF
-
- test_deps="$(echo "${test_deps}" | sed 's/^ *//;s/ *$//')"
- good_deps="$(echo "${good_deps}" | sed 's/^ *//;s/ *$//')"
- type="$(echo "${type}" | sed 's/^ *//;s/ *$//')"
- host_arch="$(echo "${host_arch}" | sed 's/^ *//;s/ *$//')"
+ exit ${ret}
+}
+testcase()
+{
if [ "${type}" != 'u' ]; then
- test_deps="$(ob_reduce_deps -a "${host_arch}" "${test_deps}")"
+ deps="$(ob_reduce_deps -a "${host_arch}" "${deps}")"
else
- test_deps="$(ob_reduce_deps -u -a "${host_arch}" "${test_deps}")"
+ deps="$(ob_reduce_deps -u -a "${host_arch}" "${deps}")"
fi
- if [ "${test_deps}" != "${good_deps}" ]; then
+ if [ "${deps}" != "${result}" ]; then
printf 'Dependency list of type "%s" for host arch "%s":\n' \
"${type}" "${host_arch}"
printf ' "%s" != "%s"\n' \
- "${test_deps}" "${good_deps}"
+ "${deps}" "${result}"
ret=1
fi
+}
-done <'ob_reduce_deps.data'
-
-exit ${ret}
+main "${@}"