[PATCH 2/2] use test-genrandom in tests instead of /dev/urandom

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This way tests are completely deterministic and possibly more portable.

Signed-off-by: Nicolas Pitre <nico@xxxxxxx>
---
 t/t5301-sliding-window.sh |    2 +-
 t/t5302-pack-index.sh     |    9 ++++-----
 2 files changed, 5 insertions(+), 6 deletions(-)

diff --git a/t/t5301-sliding-window.sh b/t/t5301-sliding-window.sh
index a6dbb04..fce77f1 100755
--- a/t/t5301-sliding-window.sh
+++ b/t/t5301-sliding-window.sh
@@ -12,7 +12,7 @@ test_expect_success \
      for i in a b c
      do
          echo $i >$i &&
-         dd if=/dev/urandom bs=32k count=1 >>$i &&
+         test-genrandom "$i" 32768 >>$i &&
          git-update-index --add $i || return 1
      done &&
      echo d >d && cat c >>d && git-update-index --add d &&
diff --git a/t/t5302-pack-index.sh b/t/t5302-pack-index.sh
index 3371964..b863c17 100755
--- a/t/t5302-pack-index.sh
+++ b/t/t5302-pack-index.sh
@@ -13,15 +13,14 @@ test_expect_success \
      for i in `seq -w 100`
      do
          echo $i >file_$i &&
-         dd if=/dev/urandom bs=8k count=1 >>file_$i &&
+         test-genrandom "$i" 8192 >>file_$i &&
          git-update-index --add file_$i || return 1
      done &&
-     echo 101 >file_101 && tail -c 8k file_100 >>file_101 &&
+     echo 101 >file_101 && tail -c 8192 file_100 >>file_101 &&
      git-update-index --add file_101 &&
      tree=`git-write-tree` &&
      commit=`git-commit-tree $tree </dev/null` && {
 	 echo $tree &&
-	 echo $commit &&
 	 git-ls-tree $tree | sed -e "s/.* \\([0-9a-f]*\\)	.*/\\1/"
      } >obj-list &&
      git-update-ref HEAD $commit'
@@ -78,7 +77,7 @@ test_expect_success \
     '[index v1] 1) stream pack to repository' \
     'git-index-pack --index-version=1 --stdin < "test-1-${pack1}.pack" &&
      git-prune-packed &&
-     test "`git-count-objects`" = "0 objects, 0 kilobytes" &&
+     git-count-objects | ( read nr rest && test "$nr" -eq 1 ) &&
      cmp "test-1-${pack1}.pack" ".git/objects/pack/pack-${pack1}.pack" &&
      cmp "test-1-${pack1}.idx"  ".git/objects/pack/pack-${pack1}.idx"'
 
@@ -116,7 +115,7 @@ test_expect_success \
     'rm -f .git/objects/pack/* &&
      git-index-pack --index-version=2,0x40000 --stdin < "test-1-${pack1}.pack" &&
      git-prune-packed &&
-     test "`git-count-objects`" = "0 objects, 0 kilobytes" &&
+     git-count-objects | ( read nr rest && test "$nr" -eq 1 ) &&
      cmp "test-1-${pack1}.pack" ".git/objects/pack/pack-${pack1}.pack" &&
      cmp "test-3-${pack1}.idx"  ".git/objects/pack/pack-${pack1}.idx"'
 
-- 
1.5.1.777.gd14d3-dirty

-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]