summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--tests/.gitignore1
-rwxr-xr-xtests/exe/ob-buildopk.sh75
-rw-r--r--tests/local.mk3
3 files changed, 78 insertions, 1 deletions
diff --git a/tests/.gitignore b/tests/.gitignore
index 51e3f3a..c359063 100644
--- a/tests/.gitignore
+++ b/tests/.gitignore
@@ -2,3 +2,4 @@
*.trs
/pkg/foo-1.0.orig.tar.gz
/pkg/tmp/
+/*.opk
diff --git a/tests/exe/ob-buildopk.sh b/tests/exe/ob-buildopk.sh
new file mode 100755
index 0000000..bfcc103
--- /dev/null
+++ b/tests/exe/ob-buildopk.sh
@@ -0,0 +1,75 @@
+# Tests for ob-buildopk
+#
+# Copyright (C) 2019 Patrick McDermott
+#
+# This file is part of opkbuild.
+#
+# opkbuild is free software: you can redistribute it and/or modify it
+# under the terms of the GNU General Public License as published by
+# the Free Software Foundation, either version 3 of the License, or
+# (at your option) any later version.
+#
+# opkbuild is distributed in the hope that it will be useful,
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+# GNU General Public License for more details.
+#
+# You should have received a copy of the GNU General Public License
+# along with opkbuild. If not, see <http://www.gnu.org/licenses/>.
+
+set -eu
+
+. "${TOP_SRCDIR}/tests/aux/tap-functions.sh"
+. "${TOP_SRCDIR}/tests/aux/common.sh"
+
+ls_outer()
+{
+ local opk="${1}"
+ shift 1
+
+ tar -tzf "${opk}" | LC_ALL=POSIX sort
+}
+
+ls_inner()
+{
+ local opk="${1}"
+ local mbr="${2}"
+ shift 2
+
+ tar -xzOf "${opk}" "${mbr}" | tar -tz | LC_ALL=POSIX sort
+}
+
+plan_ 9
+
+rm -Rf *'.data/' *'.control/'
+mkdir -p 'foo.data/usr/bin/' 'bar.data/' 'foo.control/' 'bar.control/'
+cp -p '../../src/src/foo.sh' 'foo.data/usr/bin/'
+touch 'foo.control/control' 'foo.control/md5sums' \
+ 'bar.control/control' 'bar.control/md5sums'
+
+command_ok_ 'ob-buildopk exit status' -- ob-buildopk
+for opk in '../../foo_1.0-1_i686-linux-glibc_all.opk' \
+ '../../bar_1.0-1_all_all.opk'; do
+ command_ok_ 'opk exists' -- [ -f "${opk}" ]
+ cmd_is 'outer archive contents' ls_outer "${opk}" <<-EOF
+ control.tar.gz
+ data.tar.gz
+ debian-binary
+ EOF
+ cmd_is 'control.tar.gz contents' ls_inner "${opk}" control.tar.gz <<-EOF
+ ./
+ ./control
+ ./md5sums
+ EOF
+done
+cmd_is 'data.tar.gz contents' \
+ ls_inner '../../foo_1.0-1_i686-linux-glibc_all.opk' data.tar.gz <<-EOF
+ ./
+ ./usr/
+ ./usr/bin/
+ ./usr/bin/foo.sh
+ EOF
+cmd_is 'data.tar.gz contents' \
+ ls_inner '../../bar_1.0-1_all_all.opk' data.tar.gz <<-EOF
+ ./
+ EOF
diff --git a/tests/local.mk b/tests/local.mk
index 178a91e..f425471 100644
--- a/tests/local.mk
+++ b/tests/local.mk
@@ -10,7 +10,8 @@ TESTS = \
%reldir%/exe/ob-unpacksource.sh \
%reldir%/exe/ob-applypatches.sh \
%reldir%/exe/ob-installdocs.sh \
- %reldir%/exe/ob-gencontrol.sh
+ %reldir%/exe/ob-gencontrol.sh \
+ %reldir%/exe/ob-buildopk.sh
TEST_EXTENSIONS = .sh
SH_LOG_DRIVER = \
AM_TAP_AWK='$(AWK)' \