summaryrefslogtreecommitdiffstats
path: root/tests/grub_cmd_test.in
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 16:29:51 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 16:29:51 +0000
commit6e7a315eb67cb6c113cf37e1d66c4f11a51a2b3e (patch)
tree32451fa3cdd9321fb2591fada9891b2cb70a9cd1 /tests/grub_cmd_test.in
parentInitial commit. (diff)
downloadgrub2-6e7a315eb67cb6c113cf37e1d66c4f11a51a2b3e.tar.xz
grub2-6e7a315eb67cb6c113cf37e1d66c4f11a51a2b3e.zip
Adding upstream version 2.06.upstream/2.06upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
-rw-r--r--tests/grub_cmd_test.in67
1 files changed, 67 insertions, 0 deletions
diff --git a/tests/grub_cmd_test.in b/tests/grub_cmd_test.in
new file mode 100644
index 0000000..3399eb2
--- /dev/null
+++ b/tests/grub_cmd_test.in
@@ -0,0 +1,67 @@
+#! @BUILD_SHEBANG@
+
+# create a randome file
+empty="`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"`" || exit 1
+non_empty="`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"`" || exit 1
+cat >$non_empty <<EOF
+hello world!
+EOF
+
+. "@builddir@/grub-core/modinfo.sh"
+
+if [ x"${grub_modinfo_platform}" = xemu ]; then
+ grub_empty="(host)$empty"
+ grub_non_empty="(host)$non_empty"
+ grub_dir="(host)${TMPDIR:-/tmp}"
+else
+ grub_empty="/boot/empty"
+ grub_non_empty="/boot/non_empty"
+ grub_dir="/boot/grub"
+fi
+
+
+outfile="`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"`" || exit 1
+@builddir@/grub-shell --files=$grub_empty=$empty --files=$grub_non_empty=$non_empty>$outfile <<EOF
+if ! test -f $grub_empty; then
+ echo FAIL1
+fi
+if ! test -e $grub_empty; then
+ echo FAIL2
+fi
+if test -d $grub_empty; then
+ echo FAIL3
+fi
+if ! test -d $grub_dir; then
+ echo FAIL4
+fi
+if test -s $grub_empty; then
+ echo FAIL5
+fi
+if ! test -s $grub_non_empty; then
+ echo FAIL6
+fi
+if test -f $grub_empty -a foo = bar; then
+ echo FAIL7
+fi
+if test -e $grub_empty -a foo = bar; then
+ echo FAIL8
+fi
+if test -s $grub_non_empty -a foo = bar; then
+ echo FAIL9
+fi
+if test -d $grub_dir -a foo = bar; then
+ echo FAIL10
+fi
+
+EOF
+
+rm -f "$empty" "$non_empty"
+
+if grep FAIL "$outfile" > /dev/null 2>&1; then
+ echo "GRUB test command file tests failed."
+ cat "$outfile"
+ exit 1
+else
+ rm -f "${outfile}"
+ exit 0
+fi