summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMike Frysinger <vapier@gentoo.org>2008-09-17 07:21:26 -0400
committerMike Frysinger <vapier@gentoo.org>2008-09-17 07:21:26 -0400
commitac8fa9736c5d1614a7ea4da552b9d70b6971598a (patch)
tree32849cc8f82d6919c385f79866a92d40e357bfe6
parentrpmoffset: fix boundary bug (diff)
downloadrpm2targz-9.0.0.3g.tar.gz
rpm2targz-9.0.0.3g.tar.bz2
rpm2targz-9.0.0.3g.zip
rpmoffset: simple brute force test script for offset checkingv9.0.0.3g
Signed-off-by: Mike Frysinger <vapier@gentoo.org>
-rwxr-xr-xbrute-test.sh34
1 files changed, 34 insertions, 0 deletions
diff --git a/brute-test.sh b/brute-test.sh
new file mode 100755
index 0000000..1e222f8
--- /dev/null
+++ b/brute-test.sh
@@ -0,0 +1,34 @@
+#!/bin/bash -e
+
+sparse_file()
+{
+ rm -f $1
+ dd \
+ if=.$1 ibs=3 count=1 \
+ of=$1 obs=1 seek=$2 \
+ 2>/dev/null || exit $?
+}
+
+echo BZh > .test.bz2.rpm
+echo $'\037\213\010' > .test.gz.rpm
+
+for n in {0..30000} ; do
+ sparse_file test.bz2.rpm ${n}
+ if [[ $(./rpmoffset < test.bz2.rpm) != ${n} ]] ; then
+ echo "FAIL: bz2 size ${n}"
+ false
+ fi
+
+ sparse_file test.gz.rpm ${n}
+ if [[ $(./rpmoffset < test.gz.rpm) != ${n} ]] ; then
+ echo "FAIL: gz size ${n}"
+ false
+ fi
+
+ if [[ $((n % 100)) -eq 0 ]] ; then
+ echo "${n} offsets passed ..."
+ fi
+done
+
+rm -f {,.}test.{bz2,gz}.rpm
+echo "DONE! :)"