summaryrefslogtreecommitdiffstats
path: root/tests/test_sha512sum.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/test_sha512sum.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 'tests/test_sha512sum.in')
-rw-r--r--tests/test_sha512sum.in36
1 files changed, 36 insertions, 0 deletions
diff --git a/tests/test_sha512sum.in b/tests/test_sha512sum.in
new file mode 100644
index 0000000..027092a
--- /dev/null
+++ b/tests/test_sha512sum.in
@@ -0,0 +1,36 @@
+#! @BUILD_SHEBANG@
+
+# create a randome file
+file="`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"`" || exit 1
+cat >$file <<EOF
+hello world!
+EOF
+
+. "@builddir@/grub-core/modinfo.sh"
+
+if [ x"${grub_modinfo_platform}" = xemu ]; then
+ grub_file="(host)$file"
+else
+ grub_file="/boot/grub/file"
+fi
+
+
+outfile1="`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"`" || exit 1
+@builddir@/grub-shell --files=/boot/grub/file=$file >$outfile1 <<EOF
+sha512sum $grub_file
+EOF
+
+outfile2="`mktemp "${TMPDIR:-/tmp}/tmp.XXXXXXXXXX"`" || exit 1
+sha512sum $file >$outfile2
+
+SHA1=`cat $outfile1 | tr -d '\n' | cut -f1 -d\ `
+SHA2=`cat $outfile2 | cut -f1 -d\ `
+
+if test "$SHA1" = "$SHA2"; then
+ rm -f ${outfile1} ${outfile2}
+ exit 0
+else
+ echo "GRUB sha512sum output did not match sha512sum output."
+ echo "See diff -u ${outfile1} ${outfile2}"
+ exit 1
+fi