1 | ## @file
|
---|
2 | # Small test script generator for OrderedCollectionTest.
|
---|
3 | #
|
---|
4 | # Usage:
|
---|
5 | # - generate script: sh gentest.sh >input.txt
|
---|
6 | # - run script with tester: OrderedCollectionTest -i input.txt -o output.txt
|
---|
7 | #
|
---|
8 | # Copyright (C) 2014, Red Hat, Inc.
|
---|
9 | #
|
---|
10 | # This program and the accompanying materials are licensed and made available
|
---|
11 | # under the terms and conditions of the BSD License which accompanies this
|
---|
12 | # distribution. The full text of the license may be found at
|
---|
13 | # http://opensource.org/licenses/bsd-license.
|
---|
14 | #
|
---|
15 | # THE PROGRAM IS DISTRIBUTED UNDER THE BSD LICENSE ON AN "AS IS" BASIS,
|
---|
16 | # WITHOUT WARRANTIES OR REPRESENTATIONS OF ANY KIND, EITHER EXPRESS OR
|
---|
17 | # IMPLIED.
|
---|
18 | ##
|
---|
19 |
|
---|
20 | set -e -u -C
|
---|
21 |
|
---|
22 | RANGE_START=0
|
---|
23 | RANGE_STOP=9999
|
---|
24 |
|
---|
25 | gen_rnd_insert()
|
---|
26 | {
|
---|
27 | shuf --input-range=$RANGE_START-$RANGE_STOP | sed 's/^/insert /'
|
---|
28 | }
|
---|
29 |
|
---|
30 | gen_rnd_delete()
|
---|
31 | {
|
---|
32 | shuf --input-range=$RANGE_START-$RANGE_STOP | sed 's/^/delete /'
|
---|
33 | }
|
---|
34 |
|
---|
35 | gen_mon_inc_insert()
|
---|
36 | {
|
---|
37 | seq $RANGE_START $RANGE_STOP | sed 's/^/insert /'
|
---|
38 | }
|
---|
39 |
|
---|
40 | gen_mon_inc_delete()
|
---|
41 | {
|
---|
42 | seq $RANGE_START $RANGE_STOP | sed 's/^/delete /'
|
---|
43 | }
|
---|
44 |
|
---|
45 | gen_mon_dec_delete()
|
---|
46 | {
|
---|
47 | seq $RANGE_START $RANGE_STOP | tac | sed 's/^/delete /'
|
---|
48 | }
|
---|
49 |
|
---|
50 | {
|
---|
51 | echo '# populate the tree in random order and empty it iterating forward'
|
---|
52 | gen_rnd_insert
|
---|
53 | echo forward-empty
|
---|
54 |
|
---|
55 | echo
|
---|
56 | echo '# populate the tree in random order and empty it iterating backward'
|
---|
57 | gen_rnd_insert
|
---|
58 | echo backward-empty
|
---|
59 |
|
---|
60 | echo
|
---|
61 | echo '# populate the tree in random order, list it in increasing and'
|
---|
62 | echo '# decreasing order, then empty it in random order'
|
---|
63 | gen_rnd_insert
|
---|
64 | echo forward-list
|
---|
65 | echo backward-list
|
---|
66 | gen_rnd_delete
|
---|
67 |
|
---|
68 | echo
|
---|
69 | echo '# populate the tree in monotonically increasing order, then undo it'
|
---|
70 | echo '# piecewise in the same order'
|
---|
71 | gen_mon_inc_insert
|
---|
72 | gen_mon_inc_delete
|
---|
73 |
|
---|
74 | echo
|
---|
75 | echo '# populate the tree in monotonically increasing order, then undo it'
|
---|
76 | echo '# piecewise in reverse order'
|
---|
77 | gen_mon_inc_insert
|
---|
78 | gen_mon_dec_delete
|
---|
79 |
|
---|
80 | echo
|
---|
81 | echo '# populate the tree randomly, trigger a run of collisions, then exit'
|
---|
82 | echo '# and let CmdForwardEmpty() empty the tree'
|
---|
83 | gen_rnd_insert
|
---|
84 | gen_mon_inc_insert
|
---|
85 | } \
|
---|
86 | | unix2dos
|
---|