1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-05-07 15:06:08 +02:00

t/helper: merge test-genrandom into test-tool

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Nguyễn Thái Ngọc Duy 2018-03-24 08:44:42 +01:00 committed by Junio C Hamano
parent dbceb3ecc5
commit c680668d1a
22 changed files with 38 additions and 35 deletions

View File

@ -661,13 +661,13 @@ TEST_BUILTINS_OBJS += test-drop-caches.o
TEST_BUILTINS_OBJS += test-dump-cache-tree.o
TEST_BUILTINS_OBJS += test-dump-split-index.o
TEST_BUILTINS_OBJS += test-example-decorate.o
TEST_BUILTINS_OBJS += test-genrandom.o
TEST_BUILTINS_OBJS += test-lazy-init-name-hash.o
TEST_BUILTINS_OBJS += test-sha1.o
TEST_PROGRAMS_NEED_X += test-dump-fsmonitor
TEST_PROGRAMS_NEED_X += test-dump-untracked-cache
TEST_PROGRAMS_NEED_X += test-fake-ssh
TEST_PROGRAMS_NEED_X += test-genrandom
TEST_PROGRAMS_NEED_X += test-hashmap
TEST_PROGRAMS_NEED_X += test-index-version
TEST_PROGRAMS_NEED_X += test-line-buffer

View File

@ -4,9 +4,10 @@
* Copyright (C) 2007 by Nicolas Pitre, licensed under the GPL version 2.
*/
#include "test-tool.h"
#include "git-compat-util.h"
int cmd_main(int argc, const char **argv)
int cmd__genrandom(int argc, const char **argv)
{
unsigned long count, next = 0;
unsigned char *c;

View File

@ -16,6 +16,7 @@ static struct test_cmd cmds[] = {
{ "dump-cache-tree", cmd__dump_cache_tree },
{ "dump-split-index", cmd__dump_split_index },
{ "example-decorate", cmd__example_decorate },
{ "genrandom", cmd__genrandom },
{ "lazy-init-name-hash", cmd__lazy_init_name_hash },
{ "sha1", cmd__sha1 },
};

View File

@ -10,6 +10,7 @@ int cmd__drop_caches(int argc, const char **argv);
int cmd__dump_cache_tree(int argc, const char **argv);
int cmd__dump_split_index(int argc, const char **argv);
int cmd__example_decorate(int argc, const char **argv);
int cmd__genrandom(int argc, const char **argv);
int cmd__lazy_init_name_hash(int argc, const char **argv);
int cmd__sha1(int argc, const char **argv);

View File

@ -36,7 +36,7 @@ large_git () {
}
test_expect_success 'create blob' '
test-genrandom foo 16384 >file &&
test-tool genrandom foo 16384 >file &&
git add file
'

View File

@ -19,7 +19,7 @@ write_script rot13-filter.pl "$PERL_PATH" \
generate_random_characters () {
LEN=$1
NAME=$2
test-genrandom some-seed $LEN |
test-tool genrandom some-seed $LEN |
perl -pe "s/./chr((ord($&) % 26) + ord('a'))/sge" >"$TEST_ROOT/$NAME"
}
@ -267,7 +267,7 @@ test_expect_success 'filtering large input to small output should use little mem
'
test_expect_success 'filter that does not read is fine' '
test-genrandom foo $((128 * 1024 + 1)) >big &&
test-tool genrandom foo $((128 * 1024 + 1)) >big &&
echo "big filter=epipe" >.gitattributes &&
test_config filter.epipe.clean "echo xyzzy" &&
git add big &&

View File

@ -282,7 +282,7 @@ test_expect_success "--batch-check with multiple sha1s gives correct format" '
'
test_expect_success 'setup blobs which are likely to delta' '
test-genrandom foo 10240 >foo &&
test-tool genrandom foo 10240 >foo &&
{ cat foo; echo plus; } >foo-plus &&
git add foo foo-plus &&
git commit -m foo &&

View File

@ -103,9 +103,9 @@ test_expect_success 'packsize limit' '
# mid1 and mid2 will fit within 256k limit but
# appending mid3 will bust the limit and will
# result in a separate packfile.
test-genrandom "a" $(( 66 * 1024 )) >mid1 &&
test-genrandom "b" $(( 80 * 1024 )) >mid2 &&
test-genrandom "c" $(( 128 * 1024 )) >mid3 &&
test-tool genrandom "a" $(( 66 * 1024 )) >mid1 &&
test-tool genrandom "b" $(( 80 * 1024 )) >mid2 &&
test-tool genrandom "c" $(( 128 * 1024 )) >mid3 &&
git add mid1 mid2 mid3 &&
count=0

View File

@ -101,7 +101,7 @@ test_expect_success \
ten=0123456789 && hundred=$ten$ten$ten$ten$ten$ten$ten$ten$ten$ten &&
echo long filename >a/four$hundred &&
mkdir a/bin &&
test-genrandom "frotz" 500000 >a/bin/sh &&
test-tool genrandom "frotz" 500000 >a/bin/sh &&
printf "A\$Format:%s\$O" "$SUBSTFORMAT" >a/substfile1 &&
printf "A not substituted O" >a/substfile2 &&
if test_have_prereq SYMLINKS; then

View File

@ -16,8 +16,8 @@ test_expect_success \
perl -e "print \"a\" x 4096;" > a &&
perl -e "print \"b\" x 4096;" > b &&
perl -e "print \"c\" x 4096;" > c &&
test-genrandom "seed a" 2097152 > a_big &&
test-genrandom "seed b" 2097152 > b_big &&
test-tool genrandom "seed a" 2097152 > a_big &&
test-tool genrandom "seed b" 2097152 > b_big &&
git update-index --add a a_big b b_big c &&
cat c >d && echo foo >>d && git update-index --add d &&
tree=$(git write-tree) &&

View File

@ -12,7 +12,7 @@ test_expect_success \
for i in a b c
do
echo $i >$i &&
test-genrandom "$i" 32768 >>$i &&
test-tool genrandom "$i" 32768 >>$i &&
git update-index --add $i || return 1
done &&
echo d >d && cat c >>d && git update-index --add d &&

View File

@ -15,17 +15,17 @@ test_expect_success \
while test $i -le 100
do
iii=$(printf '%03i' $i)
test-genrandom "bar" 200 > wide_delta_$iii &&
test-genrandom "baz $iii" 50 >> wide_delta_$iii &&
test-genrandom "foo"$i 100 > deep_delta_$iii &&
test-genrandom "foo"$(expr $i + 1) 100 >> deep_delta_$iii &&
test-genrandom "foo"$(expr $i + 2) 100 >> deep_delta_$iii &&
test-tool genrandom "bar" 200 > wide_delta_$iii &&
test-tool genrandom "baz $iii" 50 >> wide_delta_$iii &&
test-tool genrandom "foo"$i 100 > deep_delta_$iii &&
test-tool genrandom "foo"$(expr $i + 1) 100 >> deep_delta_$iii &&
test-tool genrandom "foo"$(expr $i + 2) 100 >> deep_delta_$iii &&
echo $iii >file_$iii &&
test-genrandom "$iii" 8192 >>file_$iii &&
test-tool genrandom "$iii" 8192 >>file_$iii &&
git update-index --add file_$iii deep_delta_$iii wide_delta_$iii &&
i=$(expr $i + 1) || return 1
done &&
{ echo 101 && test-genrandom 100 8192; } >file_101 &&
{ echo 101 && test-tool genrandom 100 8192; } >file_101 &&
git update-index --add file_101 &&
tree=$(git write-tree) &&
commit=$(git commit-tree $tree </dev/null) && {

View File

@ -19,14 +19,14 @@ test_description='resilience to pack corruptions with redundant objects'
# 3) object header is always 2 bytes.
create_test_files() {
test-genrandom "foo" 2000 > file_1 &&
test-genrandom "foo" 1800 > file_2 &&
test-genrandom "foo" 1800 > file_3 &&
test-tool genrandom "foo" 2000 > file_1 &&
test-tool genrandom "foo" 1800 > file_2 &&
test-tool genrandom "foo" 1800 > file_3 &&
echo " base " >> file_1 &&
echo " delta1 " >> file_2 &&
echo " delta delta2 " >> file_3 &&
test-genrandom "bar" 150 >> file_2 &&
test-genrandom "baz" 100 >> file_3
test-tool genrandom "bar" 150 >> file_2 &&
test-tool genrandom "baz" 100 >> file_3
}
create_new_pack() {

View File

@ -284,7 +284,7 @@ test_expect_success JGIT 'jgit can read our bitmaps' '
'
test_expect_success 'splitting packs does not generate bogus bitmaps' '
test-genrandom foo $((1024 * 1024)) >rand &&
test-tool genrandom foo $((1024 * 1024)) >rand &&
git add rand &&
git commit -m "commit with big file" &&
git -c pack.packSizeLimit=500k repack -adb &&

View File

@ -163,8 +163,8 @@ test_expect_success 'bogus offset inside v2 extended table' '
test_expect_success 'bogus OFS_DELTA in packfile' '
# Generate a pack with a delta in it.
base=$(test-genrandom foo 3000 | git hash-object --stdin -w) &&
delta=$(test-genrandom foo 2000 | git hash-object --stdin -w) &&
base=$(test-tool genrandom foo 3000 | git hash-object --stdin -w) &&
delta=$(test-tool genrandom foo 2000 | git hash-object --stdin -w) &&
do_pack "$base $delta" --delta-base-offset &&
rm -f .git/objects/??/* &&

View File

@ -73,7 +73,7 @@ make_pack () {
}
test_expect_success 'setup' '
test-genrandom base 4096 >base &&
test-tool genrandom base 4096 >base &&
for i in one two
do
# we want shared content here to encourage deltas...

View File

@ -47,7 +47,7 @@ test_description='pack-objects breaks long cross-pack delta chains'
# repeatedly-modified file to generate the delta chain).
test_expect_success 'create series of packs' '
test-genrandom foo 4096 >content &&
test-tool genrandom foo 4096 >content &&
prev= &&
for i in $(test_seq 1 10)
do

View File

@ -44,7 +44,7 @@ test_pack_input_limit () {
}
test_expect_success "create known-size (1024 bytes) commit" '
test-genrandom foo 1024 >one-k &&
test-tool genrandom foo 1024 >one-k &&
git add one-k &&
test_commit one-k
'

View File

@ -39,7 +39,7 @@ test_expect_success 'push to repo path with path separator (colon)' '
# so make it likely for us to generate a delta by having
# a non-trivial file with multiple versions.
test-genrandom foo 4096 >file.bin &&
test-tool genrandom foo 4096 >file.bin &&
git add file.bin &&
git commit -m bin &&

View File

@ -21,7 +21,7 @@ test_expect_success CLONE_2GB 'setup' '
do
printf "Generating blob $i/$blobcount\r" >&2 &&
printf "blob\nmark :$i\ndata $blobsize\n" &&
#test-genrandom $i $blobsize &&
#test-tool genrandom $i $blobsize &&
printf "%-${blobsize}s" $i &&
echo "M 100644 :$i $i" >> commit
i=$(($i+1)) ||

View File

@ -2654,7 +2654,7 @@ test_expect_success 'R: corrupt lines do not mess marks file' '
##
test_expect_success 'R: blob bigger than threshold' '
blobsize=$((2*1024*1024 + 53)) &&
test-genrandom bar $blobsize >expect &&
test-tool genrandom bar $blobsize >expect &&
cat >input <<-INPUT_END &&
commit refs/heads/big-file
committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE

View File

@ -237,7 +237,7 @@ test_expect_success 'ignore apple' '
build_gendouble &&
(
cd "$cli" &&
test-genrandom apple 1024 >double.png &&
test-tool genrandom apple 1024 >double.png &&
"$PYTHON_PATH" "$TRASH_DIRECTORY/gendouble.py" >%double.png &&
p4 add -t apple double.png &&
p4 submit -d appledouble