"Fossies" - the Fresh Open Source Software Archive 
Member "libisoburn-1.5.4/releng/auto_printsize" (8 Jul 2020, 3444 Bytes) of package /linux/misc/libisoburn-1.5.4.tar.gz:
As a special service "Fossies" has tried to format the requested source page into HTML format using (guessed) Bash source code syntax highlighting (style:
standard) with prefixed line numbers and
code folding option.
Alternatively you can here
view or
download the uninterpreted source code file.
1 #!/bin/bash
2
3 # Copyright 2011 George Danchev <danchev@spnet.net>
4 # Licensed under GNU GPL version 2 or later
5
6 set -e
7
8 not_in_releng_exit() {
9 printf "\nPlease execute the tests from releng directory.\n\n"
10 exit 1
11 }
12
13 # Include common bits
14 . inc/releng_getopts.inc || not_in_releng_exit
15
16 print_specific_help() {
17 cat << HLP
18 Specific options:
19 none yet.
20 Overview:
21 Test performance of print_size against various input tree.
22 Optionally compare with genisoimage and mkisofs.
23 HLP
24 }
25
26 if test "$SPECIFIC_HELP" = 1; then
27 print_specific_help
28 exit 0
29 fi
30
31 # Each test should decide whether or not it needs
32 # a xorriso binary to test, since some do compilations only.
33 if [ ! -x $RELENG_XORRISO ]; then
34 print_help
35 printf "\n${SELF}: -x absolute or relative path to binary to be run.\n\n"
36 exit 31
37 fi
38
39 # check data dir, if any and after checking -x xorriso
40 if [ -d "${GEN_DATA_DIR}" ]; then
41 printf "\n${SELF}: directory %s exists!" ${GEN_DATA_DIR}
42 printf "\n${SELF}: use '${SELF} -c' to remove.\n"
43 exit 8
44 else
45 mkdir "${GEN_DATA_DIR}"
46 fi
47
48 #
49 DIR_UPPER=32
50 FILE_UPPER=10
51
52 # All must be set at this point
53 # TODO: work out a smarter way to quickly generate different
54 # types of trees (long, deep, etc)
55 printf "\n${SELF}: Generating sample tree in ${GEN_DATA_DIR} :\n"
56 count=0
57 date
58
59 # Hopefully the for-loops are much faster than while-loops with arithmetics
60 # This needs 7/4*DIR_UPPER+FILE_UPPER (= 66) while-iterations
61 #
62 i1_list=
63 i1=0
64 o1=$(expr ${DIR_UPPER} / 4)
65 while test $i1 -lt $o1
66 do
67 i1_list="$i1_list $i1"
68 i1=$(expr $i1 + 1)
69 done
70 i2_list=
71 i2=0
72 o2=$(expr ${DIR_UPPER} / 2)
73 while test $i2 -lt $o2
74 do
75 i2_list="$i2_list $i2"
76 i2=$(expr $i2 + 1)
77 done
78 i3_list=
79 i3=0
80 while test $i3 -lt ${DIR_UPPER}
81 do
82 i3_list="$i3_list $i3"
83 i3=$(expr $i3 + 1)
84 done
85 i_file_list=
86 i_file=0
87 while test $i_file -lt ${FILE_UPPER}
88 do
89 i_file_list="$i_file_list $i_file"
90 i_file=$(expr $i_file + 1)
91 done
92 #
93 # plus 1/8*DIR_UPPER*DIR_UPPER*DIR_UPPER*FILE_UPPER (= 40960) for-iterations
94 #
95 for i1 in $i1_list
96 do
97 for i2 in $i2_list
98 do
99 for i3 in $i3_list
100 do
101 mkdir -p ${GEN_DATA_DIR}/DirOne$i1/DirTwo$i2/DirThree$i3
102 for i_file in $i_file_list
103 do
104 echo -n \
105 > ${GEN_DATA_DIR}/DirOne$i1/DirTwo$i2/DirThree$i3/File_${i_file}
106 count=$((count + 1))
107 done
108 done
109 done
110 echo " ${count} files created ..."
111 done
112
113 printf "done.\n"
114 date
115 du -s "${GEN_DATA_DIR}"
116
117 printf "\n${SELF}: Performing several print size runs to neutralize possible disk cache impact.\n"
118
119 # run xorriso
120 if [ -x ${RELENG_XORRISO} ]; then
121 for run in 1 2 3; do
122 printf "\n${SELF}: Running ${RELENG_XORRISO} -as mkisofs -quiet -print-size ${GEN_DATA_DIR}. Trial: ${run}.\n"
123 time ${RELENG_XORRISO} -as mkisofs -quiet -print-size ${GEN_DATA_DIR}
124 done
125 fi
126
127 # try to run genisoimage
128 if which genisoimage >/dev/null 2>&1; then
129 RELENG_GENISOIMAGE=`which genisoimage`
130 for run in 1 2 3; do
131 printf "\n${SELF}: Running ${RELENG_GENISOIMAGE} -quiet -print-size ${GEN_DATA_DIR}. Trial: ${run}.\n"
132 time ${RELENG_GENISOIMAGE} -quiet -print-size ${GEN_DATA_DIR}
133 done
134 fi
135
136 # try to run mkisofs
137 if which mkisofs >/dev/null 2>&1; then
138 RELENG_MKISOFS=`which mkisofs`
139 for run in 1 2 3; do
140 printf "\n${SELF}: Running ${RELENG_MKISOFS} -quiet -print-size ${GEN_DATA_DIR}. Trial: ${run}.\n"
141 time ${RELENG_MKISOFS} -quiet -print-size ${GEN_DATA_DIR}
142 done
143 fi
144
145 #
146 cleanup
147
148 #
149 exit 0