summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Olbrich <m.olbrich@pengutronix.de>2020-08-28 16:29:48 +0200
committerMichael Olbrich <m.olbrich@pengutronix.de>2020-08-28 16:37:38 +0200
commit2b1f054ed1489c63db9f444af1b1a588937ba947 (patch)
treeda64d463a5bac9f12703c3445d88b7c5fa509c8a
parent419730f75b7bb630a2f77f5f61122c35ed42dfdc (diff)
downloadgenimage-2b1f054ed1489c63db9f444af1b1a588937ba947.tar.gz
genimage-2b1f054ed1489c63db9f444af1b1a588937ba947.tar.xz
test: add tests to check exec-* commands
Signed-off-by: Michael Olbrich <m.olbrich@pengutronix.de>
-rw-r--r--Makefile.am3
-rwxr-xr-xtest/basic-images.test19
-rwxr-xr-xtest/exec-check.sh33
-rw-r--r--test/exec-fail.config4
-rw-r--r--test/exec.config27
5 files changed, 85 insertions, 1 deletions
diff --git a/Makefile.am b/Makefile.am
index f0bad83..3c8c810 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -50,6 +50,9 @@ EXTRA_DIST += \
test/basic-images.test \
test/cpio.config \
test/cramfs.config \
+ test/exec-check.sh \
+ test/exec-fail.config \
+ test/exec.config \
test/ext2.config \
test/ext2test.dump \
test/ext2percent.config \
diff --git a/test/basic-images.test b/test/basic-images.test
index cb104c3..059a5dd 100755
--- a/test/basic-images.test
+++ b/test/basic-images.test
@@ -24,7 +24,7 @@ setup_data() {
find "${root_orig}" -print0 | xargs -0 touch -c -d "2011-11-11 UTC"
find "${root_orig}"/ -mindepth 1 -printf "%P\n" | sort > "${filelist_orig}"
- cp "${testdir}"/*.conf* .
+ cp "${testdir}"/*.conf* "${testdir}"/*.sh .
}
run_genimage() {
@@ -373,6 +373,23 @@ test_expect_success rauc "rauc" "
test_cmp '${testdir}/test2.raucb.info' test2.raucb.info
"
+setup_exec_files() {
+ rm -rf input &&
+ mkdir input &&
+ dd if=/dev/zero of=input/file1.img bs=512 count=7 &&
+ dd if=/dev/zero of=input/file2.img bs=512 count=7 &&
+ dd if=/dev/zero of=input/file3.img bs=512 count=7 &&
+ dd if=/dev/zero of=input/file4.img bs=512 count=7
+}
+
+test_expect_success "exec" "
+ setup_exec_files &&
+ run_genimage exec.config"
+
+test_expect_success "exec-fail" "
+ setup_exec_files &&
+ test_must_fail run_genimage exec-fail.config"
+
test_done
# vim: syntax=sh
diff --git a/test/exec-check.sh b/test/exec-check.sh
new file mode 100755
index 0000000..ad1373d
--- /dev/null
+++ b/test/exec-check.sh
@@ -0,0 +1,33 @@
+#!/bin/bash
+
+exec >&2
+
+name="${1}"
+empty="${2}"
+
+set -ex
+
+: OUTPUTPATH
+test "${OUTPUTPATH}" = "${PWD}/images"
+: INPUTPATH
+test "${INPUTPATH}" = "${PWD}/input"
+: ROOTPATH
+test "${ROOTPATH}" = "${PWD}/root"
+: TMPPATH
+test "${TMPPATH}" = "${PWD}/tmp"
+: IMAGE
+test "${IMAGE}" = "${name}"
+: IMAGEOUTFILE
+test "${IMAGEOUTFILE}" = "${PWD}/images/${name}"
+: IMAGENAME
+test "${IMAGENAME}" = "exec-test"
+: IMAGESIZE
+test "${IMAGESIZE}" = "3584"
+: IMAGEMOUNTPOINT
+test "${IMAGEMOUNTPOINT}" = ""
+: IMAGEMOUNTPATH
+if [ "${empty}" = "empty" ]; then
+ test "${IMAGEMOUNTPATH}" = ""
+else
+ test "${IMAGEMOUNTPATH}" = "${PWD}/tmp/root"
+fi
diff --git a/test/exec-fail.config b/test/exec-fail.config
new file mode 100644
index 0000000..dc223e5
--- /dev/null
+++ b/test/exec-fail.config
@@ -0,0 +1,4 @@
+image file1.img {
+ file {}
+ exec-pre = "false"
+}
diff --git a/test/exec.config b/test/exec.config
new file mode 100644
index 0000000..a261276
--- /dev/null
+++ b/test/exec.config
@@ -0,0 +1,27 @@
+image file1.img {
+ file {}
+ name = "exec-test"
+ exec-pre = "./exec-check.sh file1.img"
+}
+
+image file2.img {
+ file {}
+ name = "exec-test"
+ mountpoint = "/"
+ exec-post = "./exec-check.sh file2.img"
+}
+
+image file3.img {
+ file {}
+ name = "exec-test"
+ empty = true
+ exec-pre = "./exec-check.sh file3.img empty"
+}
+
+image file4.img {
+ file {}
+ name = "exec-test"
+ empty = true
+ mountpoint = "/"
+ exec-post = "./exec-check.sh file4.img empty"
+}