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>
Nguyễn Thái Ngọc Duy committed
Mar 24, 2018 at 08:44 UTC
c680668d1aa6abf7e970355428838f8dc0ca4c1c
22 files changed
+38
-35
Makefile
+1
-1
@@ -661,13 +661,13 @@ TEST_BUILTINS_OBJS += test-drop-caches.o
661
TEST_BUILTINS_OBJS += test-dump-cache-tree.o
662
TEST_BUILTINS_OBJS += test-dump-split-index.o
663
TEST_BUILTINS_OBJS += test-example-decorate.o
664
+TEST_BUILTINS_OBJS += test-genrandom.o
665
TEST_BUILTINS_OBJS += test-lazy-init-name-hash.o
666
TEST_BUILTINS_OBJS += test-sha1.o
667
668
TEST_PROGRAMS_NEED_X += test-dump-fsmonitor
669
TEST_PROGRAMS_NEED_X += test-dump-untracked-cache
670
TEST_PROGRAMS_NEED_X += test-fake-ssh
670
-TEST_PROGRAMS_NEED_X += test-genrandom
671
TEST_PROGRAMS_NEED_X += test-hashmap
672
TEST_PROGRAMS_NEED_X += test-index-version
673
TEST_PROGRAMS_NEED_X += test-line-buffer
t/helper/test-genrandom.c
+2
-1
@@ -4,9 +4,10 @@
4
* Copyright (C) 2007 by Nicolas Pitre, licensed under the GPL version 2.
5
*/
6
7
+#include "test-tool.h"
8
#include "git-compat-util.h"
9
9
-int cmd_main(int argc, const char **argv)
10
+int cmd__genrandom(int argc, const char **argv)
11
{
12
unsigned long count, next = 0;
13
unsigned char *c;
t/helper/test-tool.c
+1
@@ -16,6 +16,7 @@ static struct test_cmd cmds[] = {
16
{ "dump-cache-tree", cmd__dump_cache_tree },
17
{ "dump-split-index", cmd__dump_split_index },
18
{ "example-decorate", cmd__example_decorate },
19
+ { "genrandom", cmd__genrandom },
20
{ "lazy-init-name-hash", cmd__lazy_init_name_hash },
21
{ "sha1", cmd__sha1 },
22
};
t/helper/test-tool.h
+1
@@ -10,6 +10,7 @@ int cmd__drop_caches(int argc, const char **argv);
10
int cmd__dump_cache_tree(int argc, const char **argv);
11
int cmd__dump_split_index(int argc, const char **argv);
12
int cmd__example_decorate(int argc, const char **argv);
13
+int cmd__genrandom(int argc, const char **argv);
14
int cmd__lazy_init_name_hash(int argc, const char **argv);
15
int cmd__sha1(int argc, const char **argv);
16
t/t0005-signals.sh
+1
-1
@@ -36,7 +36,7 @@ large_git () {
36
}
37
38
test_expect_success 'create blob' '
39
- test-genrandom foo 16384 >file &&
39
+ test-tool genrandom foo 16384 >file &&
40
git add file
41
'
42
t/t0021-conversion.sh
+2
-2
@@ -19,7 +19,7 @@ write_script rot13-filter.pl "$PERL_PATH" \
19
generate_random_characters () {
20
LEN=$1
21
NAME=$2
22
- test-genrandom some-seed $LEN |
22
+ test-tool genrandom some-seed $LEN |
23
perl -pe "s/./chr((ord($&) % 26) + ord('a'))/sge" >"$TEST_ROOT/$NAME"
24
}
25
@@ -267,7 +267,7 @@ test_expect_success 'filtering large input to small output should use little mem
267
'
268
269
test_expect_success 'filter that does not read is fine' '
270
- test-genrandom foo $((128 * 1024 + 1)) >big &&
270
+ test-tool genrandom foo $((128 * 1024 + 1)) >big &&
271
echo "big filter=epipe" >.gitattributes &&
272
test_config filter.epipe.clean "echo xyzzy" &&
273
git add big &&
t/t1006-cat-file.sh
+1
-1
@@ -282,7 +282,7 @@ test_expect_success "--batch-check with multiple sha1s gives correct format" '
282
'
283
284
test_expect_success 'setup blobs which are likely to delta' '
285
- test-genrandom foo 10240 >foo &&
285
+ test-tool genrandom foo 10240 >foo &&
286
{ cat foo; echo plus; } >foo-plus &&
287
git add foo foo-plus &&
288
git commit -m foo &&
t/t1050-large.sh
+3
-3
@@ -103,9 +103,9 @@ test_expect_success 'packsize limit' '
103
# mid1 and mid2 will fit within 256k limit but
104
# appending mid3 will bust the limit and will
105
# result in a separate packfile.
106
- test-genrandom "a" $(( 66 * 1024 )) >mid1 &&
107
- test-genrandom "b" $(( 80 * 1024 )) >mid2 &&
108
- test-genrandom "c" $(( 128 * 1024 )) >mid3 &&
106
+ test-tool genrandom "a" $(( 66 * 1024 )) >mid1 &&
107
+ test-tool genrandom "b" $(( 80 * 1024 )) >mid2 &&
108
+ test-tool genrandom "c" $(( 128 * 1024 )) >mid3 &&
109
git add mid1 mid2 mid3 &&
110
111
count=0
t/t5000-tar-tree.sh
+1
-1
@@ -101,7 +101,7 @@ test_expect_success \
101
ten=0123456789 && hundred=$ten$ten$ten$ten$ten$ten$ten$ten$ten$ten &&
102
echo long filename >a/four$hundred &&
103
mkdir a/bin &&
104
- test-genrandom "frotz" 500000 >a/bin/sh &&
104
+ test-tool genrandom "frotz" 500000 >a/bin/sh &&
105
printf "A\$Format:%s\$O" "$SUBSTFORMAT" >a/substfile1 &&
106
printf "A not substituted O" >a/substfile2 &&
107
if test_have_prereq SYMLINKS; then
t/t5300-pack-object.sh
+2
-2
@@ -16,8 +16,8 @@ test_expect_success \
16
perl -e "print \"a\" x 4096;" > a &&
17
perl -e "print \"b\" x 4096;" > b &&
18
perl -e "print \"c\" x 4096;" > c &&
19
- test-genrandom "seed a" 2097152 > a_big &&
20
- test-genrandom "seed b" 2097152 > b_big &&
19
+ test-tool genrandom "seed a" 2097152 > a_big &&
20
+ test-tool genrandom "seed b" 2097152 > b_big &&
21
git update-index --add a a_big b b_big c &&
22
cat c >d && echo foo >>d && git update-index --add d &&
23
tree=$(git write-tree) &&
t/t5301-sliding-window.sh
+1
-1
@@ -12,7 +12,7 @@ test_expect_success \
12
for i in a b c
13
do
14
echo $i >$i &&
15
- test-genrandom "$i" 32768 >>$i &&
15
+ test-tool genrandom "$i" 32768 >>$i &&
16
git update-index --add $i || return 1
17
done &&
18
echo d >d && cat c >>d && git update-index --add d &&
t/t5302-pack-index.sh
+7
-7
@@ -15,17 +15,17 @@ test_expect_success \
15
while test $i -le 100
16
do
17
iii=$(printf '%03i' $i)
18
- test-genrandom "bar" 200 > wide_delta_$iii &&
19
- test-genrandom "baz $iii" 50 >> wide_delta_$iii &&
20
- test-genrandom "foo"$i 100 > deep_delta_$iii &&
21
- test-genrandom "foo"$(expr $i + 1) 100 >> deep_delta_$iii &&
22
- test-genrandom "foo"$(expr $i + 2) 100 >> deep_delta_$iii &&
18
+ test-tool genrandom "bar" 200 > wide_delta_$iii &&
19
+ test-tool genrandom "baz $iii" 50 >> wide_delta_$iii &&
20
+ test-tool genrandom "foo"$i 100 > deep_delta_$iii &&
21
+ test-tool genrandom "foo"$(expr $i + 1) 100 >> deep_delta_$iii &&
22
+ test-tool genrandom "foo"$(expr $i + 2) 100 >> deep_delta_$iii &&
23
echo $iii >file_$iii &&
24
- test-genrandom "$iii" 8192 >>file_$iii &&
24
+ test-tool genrandom "$iii" 8192 >>file_$iii &&
25
git update-index --add file_$iii deep_delta_$iii wide_delta_$iii &&
26
i=$(expr $i + 1) || return 1
27
done &&
28
- { echo 101 && test-genrandom 100 8192; } >file_101 &&
28
+ { echo 101 && test-tool genrandom 100 8192; } >file_101 &&
29
git update-index --add file_101 &&
30
tree=$(git write-tree) &&
31
commit=$(git commit-tree $tree </dev/null) && {
t/t5303-pack-corruption-resilience.sh
+5
-5
@@ -19,14 +19,14 @@ test_description='resilience to pack corruptions with redundant objects'
19
# 3) object header is always 2 bytes.
20
21
create_test_files() {
22
- test-genrandom "foo" 2000 > file_1 &&
23
- test-genrandom "foo" 1800 > file_2 &&
24
- test-genrandom "foo" 1800 > file_3 &&
22
+ test-tool genrandom "foo" 2000 > file_1 &&
23
+ test-tool genrandom "foo" 1800 > file_2 &&
24
+ test-tool genrandom "foo" 1800 > file_3 &&
25
echo " base " >> file_1 &&
26
echo " delta1 " >> file_2 &&
27
echo " delta delta2 " >> file_3 &&
28
- test-genrandom "bar" 150 >> file_2 &&
29
- test-genrandom "baz" 100 >> file_3
28
+ test-tool genrandom "bar" 150 >> file_2 &&
29
+ test-tool genrandom "baz" 100 >> file_3
30
}
31
32
create_new_pack() {
t/t5310-pack-bitmaps.sh
+1
-1
@@ -284,7 +284,7 @@ test_expect_success JGIT 'jgit can read our bitmaps' '
284
'
285
286
test_expect_success 'splitting packs does not generate bogus bitmaps' '
287
- test-genrandom foo $((1024 * 1024)) >rand &&
287
+ test-tool genrandom foo $((1024 * 1024)) >rand &&
288
git add rand &&
289
git commit -m "commit with big file" &&
290
git -c pack.packSizeLimit=500k repack -adb &&
t/t5313-pack-bounds-checks.sh
+2
-2
@@ -163,8 +163,8 @@ test_expect_success 'bogus offset inside v2 extended table' '
163
164
test_expect_success 'bogus OFS_DELTA in packfile' '
165
# Generate a pack with a delta in it.
166
- base=$(test-genrandom foo 3000 | git hash-object --stdin -w) &&
167
- delta=$(test-genrandom foo 2000 | git hash-object --stdin -w) &&
166
+ base=$(test-tool genrandom foo 3000 | git hash-object --stdin -w) &&
167
+ delta=$(test-tool genrandom foo 2000 | git hash-object --stdin -w) &&
168
do_pack "$base $delta" --delta-base-offset &&
169
rm -f .git/objects/??/* &&
170
t/t5314-pack-cycle-detection.sh
+1
-1
@@ -73,7 +73,7 @@ make_pack () {
73
}
74
75
test_expect_success 'setup' '
76
- test-genrandom base 4096 >base &&
76
+ test-tool genrandom base 4096 >base &&
77
for i in one two
78
do
79
# we want shared content here to encourage deltas...
t/t5316-pack-delta-depth.sh
+1
-1
@@ -47,7 +47,7 @@ test_description='pack-objects breaks long cross-pack delta chains'
47
# repeatedly-modified file to generate the delta chain).
48
49
test_expect_success 'create series of packs' '
50
- test-genrandom foo 4096 >content &&
50
+ test-tool genrandom foo 4096 >content &&
51
prev= &&
52
for i in $(test_seq 1 10)
53
do
t/t5546-receive-limits.sh
+1
-1
@@ -44,7 +44,7 @@ test_pack_input_limit () {
44
}
45
46
test_expect_success "create known-size (1024 bytes) commit" '
47
- test-genrandom foo 1024 >one-k &&
47
+ test-tool genrandom foo 1024 >one-k &&
48
git add one-k &&
49
test_commit one-k
50
'
t/t5547-push-quarantine.sh
+1
-1
@@ -39,7 +39,7 @@ test_expect_success 'push to repo path with path separator (colon)' '
39
# so make it likely for us to generate a delta by having
40
# a non-trivial file with multiple versions.
41
42
- test-genrandom foo 4096 >file.bin &&
42
+ test-tool genrandom foo 4096 >file.bin &&
43
git add file.bin &&
44
git commit -m bin &&
45
t/t5608-clone-2gb.sh
+1
-1
@@ -21,7 +21,7 @@ test_expect_success CLONE_2GB 'setup' '
21
do
22
printf "Generating blob $i/$blobcount\r" >&2 &&
23
printf "blob\nmark :$i\ndata $blobsize\n" &&
24
- #test-genrandom $i $blobsize &&
24
+ #test-tool genrandom $i $blobsize &&
25
printf "%-${blobsize}s" $i &&
26
echo "M 100644 :$i $i" >> commit
27
i=$(($i+1)) ||
t/t9300-fast-import.sh
+1
-1
@@ -2654,7 +2654,7 @@ test_expect_success 'R: corrupt lines do not mess marks file' '
2654
##
2655
test_expect_success 'R: blob bigger than threshold' '
2656
blobsize=$((2*1024*1024 + 53)) &&
2657
- test-genrandom bar $blobsize >expect &&
2657
+ test-tool genrandom bar $blobsize >expect &&
2658
cat >input <<-INPUT_END &&
2659
commit refs/heads/big-file
2660
committer $GIT_COMMITTER_NAME <$GIT_COMMITTER_EMAIL> $GIT_COMMITTER_DATE
t/t9802-git-p4-filetype.sh
+1
-1
@@ -237,7 +237,7 @@ test_expect_success 'ignore apple' '
237
build_gendouble &&
238
(
239
cd "$cli" &&
240
- test-genrandom apple 1024 >double.png &&
240
+ test-tool genrandom apple 1024 >double.png &&
241
"$PYTHON_PATH" "$TRASH_DIRECTORY/gendouble.py" >%double.png &&
242
p4 add -t apple double.png &&
243
p4 submit -d appledouble