common/bin/compare.sh

Thu, 31 Aug 2017 15:40:18 +0800

author
aoqi
date
Thu, 31 Aug 2017 15:40:18 +0800
changeset 1133
50aaf272884f
parent 912
a667caba1e84
parent 0
75a576e87639
child 2316
64a3eeabf6e5
permissions
-rw-r--r--

merge

aoqi@0 1 #!/bin/bash
aoqi@0 2 #
aoqi@0 3 # Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved.
aoqi@0 4 # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
aoqi@0 5 #
aoqi@0 6 # This code is free software; you can redistribute it and/or modify it
aoqi@0 7 # under the terms of the GNU General Public License version 2 only, as
aoqi@0 8 # published by the Free Software Foundation.
aoqi@0 9 #
aoqi@0 10 # This code is distributed in the hope that it will be useful, but WITHOUT
aoqi@0 11 # ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
aoqi@0 12 # FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
aoqi@0 13 # version 2 for more details (a copy is included in the LICENSE file that
aoqi@0 14 # accompanied this code).
aoqi@0 15 #
aoqi@0 16 # You should have received a copy of the GNU General Public License version
aoqi@0 17 # 2 along with this work; if not, write to the Free Software Foundation,
aoqi@0 18 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
aoqi@0 19 #
aoqi@0 20 # Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
aoqi@0 21 # or visit www.oracle.com if you need additional information or have any
aoqi@0 22 # questions.
aoqi@0 23 #
aoqi@0 24
aoqi@0 25 # This script is processed by configure before it's usable. It is run from
aoqi@0 26 # the root of the build directory.
aoqi@0 27
aoqi@0 28
aoqi@0 29 ##########################################################################################
aoqi@0 30
aoqi@0 31 # Check that we are run via the wrapper generated by configure
aoqi@0 32 if [ -z "$SRC_ROOT" ]; then
aoqi@0 33 echo "Error: You must run this script using build/[conf]/compare.sh"
aoqi@0 34 exit 1
aoqi@0 35 fi
aoqi@0 36
aoqi@0 37 if [ "$OPENJDK_TARGET_OS" = "macosx" ]; then
aoqi@0 38 FULLDUMP_CMD="$OTOOL -v -V -h -X -t -d"
aoqi@0 39 LDD_CMD="$OTOOL -L"
aoqi@0 40 DIS_CMD="$OTOOL -v -t"
aoqi@0 41 STAT_PRINT_SIZE="-f %z"
aoqi@0 42 elif [ "$OPENJDK_TARGET_OS" = "windows" ]; then
aoqi@0 43 FULLDUMP_CMD="$DUMPBIN -all"
aoqi@0 44 LDD_CMD="$DUMPBIN -dependants | $GREP .dll"
aoqi@0 45 DIS_CMD="$DUMPBIN -disasm:nobytes"
aoqi@0 46 STAT_PRINT_SIZE="-c %s"
aoqi@0 47 else
aoqi@0 48 FULLDUMP_CMD="$READELF -a"
aoqi@0 49 LDD_CMD="$LDD"
aoqi@0 50 DIS_CMD="$OBJDUMP -d"
aoqi@0 51 STAT_PRINT_SIZE="-c %s"
aoqi@0 52 fi
aoqi@0 53
aoqi@0 54 UNARCHIVE="$UNZIP -q"
aoqi@0 55
aoqi@0 56 COMPARE_EXCEPTIONS_INCLUDE="$SRC_ROOT/common/bin/compare_exceptions.sh.incl"
aoqi@0 57 if [ ! -e "$COMPARE_EXCEPTIONS_INCLUDE" ]; then
aoqi@0 58 echo "Error: Cannot locate the exceptions file, it should have been here: $COMPARE_EXCEPTIONS_INCLUDE"
aoqi@0 59 exit 1
aoqi@0 60 fi
aoqi@0 61 # Include exception definitions
aoqi@0 62 . "$COMPARE_EXCEPTIONS_INCLUDE"
aoqi@0 63
aoqi@0 64 ##########################################################################################
aoqi@0 65 # Compare text files and ignore specific differences:
aoqi@0 66 #
aoqi@0 67 # * Timestamps in Java sources generated by idl2java
aoqi@0 68 # * Sorting order and cleanup style in .properties files
aoqi@0 69
aoqi@0 70 diff_text() {
aoqi@0 71 OTHER_FILE=$1
aoqi@0 72 THIS_FILE=$2
aoqi@0 73
aoqi@0 74 SUFFIX="${THIS_FILE##*.}"
aoqi@0 75
aoqi@0 76 TMP=1
aoqi@0 77
aoqi@0 78 if [[ "$THIS_FILE" = *"META-INF/MANIFEST.MF" ]]; then
aoqi@0 79 TMP=$(LC_ALL=C $DIFF $OTHER_FILE $THIS_FILE | \
aoqi@0 80 $GREP '^[<>]' | \
aoqi@0 81 $SED -e '/[<>] Ant-Version: Apache Ant .*/d' \
aoqi@0 82 -e '/[<>] Created-By: .* (Oracle Corporation).*/d')
aoqi@0 83 fi
aoqi@0 84 if test "x$SUFFIX" = "xjava"; then
aoqi@0 85 TMP=$(LC_ALL=C $DIFF $OTHER_FILE $THIS_FILE | \
aoqi@0 86 $GREP '^[<>]' | \
aoqi@0 87 $SED -e '/[<>] \* from.*\.idl/d' \
aoqi@0 88 -e '/[<>] \*.*[0-9]\{4\}_[0-9]\{2\}_[0-9]\{2\}_[0-9]\{2\}_[0-9]\{2\}-b[0-9]\{2\}.*/d' \
aoqi@0 89 -e '/[<>] \*.*[0-9]\{4\} [0-9][0-9]*:[0-9]\{2\}:[0-9]\{2\}.*/d' \
aoqi@0 90 -e '/\/\/ Generated from input file.*/d' \
aoqi@0 91 -e '/\/\/ This file was generated AUTOMATICALLY from a template file.*/d' \
aoqi@0 92 -e '/\/\/ java GenerateCharacter.*/d')
aoqi@0 93 fi
aoqi@0 94 # Ignore date strings in class files.
aoqi@0 95 # On Macosx the system sources for generated java classes produce different output on
aoqi@0 96 # consequtive invokations seemingly randomly.
aoqi@0 97 # For example a method parameter randomly named "thePoint" or "aPoint". Ignore this.
aoqi@0 98 if test "x$SUFFIX" = "xclass"; then
aoqi@0 99 # To improve performance when large diffs are found, do a rough filtering of classes
aoqi@0 100 # elibeble for these exceptions
aoqi@0 101 if $GREP -R -e '[0-9]\{4\}_[0-9]\{2\}_[0-9]\{2\}_[0-9]\{2\}_[0-9]\{2\}-b[0-9]\{2\}' \
aoqi@0 102 -e '[0-9]\{2\}/[0-9]\{2\}/[0-9]\{4\}' \
aoqi@0 103 -e thePoint -e aPoint -e setItemsPtr ${THIS_FILE} > /dev/null; then
aoqi@0 104 $JAVAP -c -constants -l -p ${OTHER_FILE} > ${OTHER_FILE}.javap
aoqi@0 105 $JAVAP -c -constants -l -p ${THIS_FILE} > ${THIS_FILE}.javap
aoqi@0 106 TMP=$($DIFF ${OTHER_FILE}.javap ${THIS_FILE}.javap | \
aoqi@0 107 $GREP '^[<>]' | \
aoqi@0 108 $SED -e '/[<>].*[0-9]\{4\}_[0-9]\{2\}_[0-9]\{2\}_[0-9]\{2\}_[0-9]\{2\}-b[0-9]\{2\}.*/d' \
aoqi@0 109 -e '/[0-9]\{2\}\/[0-9]\{2\}\/[0-9]\{4\}/d' \
aoqi@0 110 -e '/[<>].*Point Lcom\/apple\/jobjc\/foundation\/NSPoint;/d' \
aoqi@0 111 -e '/[<>].*public com\.apple\.jobjc\.Pointer<com\.apple\.jobjc\..*itemsPtr();/d' \
aoqi@0 112 -e '/[<>].*public void setItemsPtr(com\.apple\.jobjc\.Pointer<com\.apple\.jobjc\..*);/d')
aoqi@0 113 fi
aoqi@0 114 fi
aoqi@0 115 if test "x$SUFFIX" = "xproperties"; then
aoqi@0 116 # Run through nawk to add possibly missing newline at end of file.
aoqi@0 117 $CAT $OTHER_FILE | $NAWK '{ print }' > $OTHER_FILE.cleaned
aoqi@0 118 # Disable this exception since we aren't changing the properties cleaning method yet.
aoqi@0 119 # $CAT $OTHER_FILE | $SED -e 's/\([^\\]\):/\1\\:/g' -e 's/\([^\\]\)=/\1\\=/g' -e 's/#.*/#/g' \
aoqi@0 120 # | $SED -f "$SRC_ROOT/common/makefiles/support/unicode2x.sed" \
aoqi@0 121 # | $SED -e '/^#/d' -e '/^$/d' \
aoqi@0 122 # -e :a -e '/\\$/N; s/\\\n//; ta' \
aoqi@0 123 # -e 's/^[ \t]*//;s/[ \t]*$//' \
aoqi@0 124 # -e 's/\\=/=/' | LC_ALL=C $SORT > $OTHER_FILE.cleaned
aoqi@0 125 TMP=$(LC_ALL=C $DIFF $OTHER_FILE.cleaned $THIS_FILE)
aoqi@0 126 fi
aoqi@0 127 if test -n "$TMP"; then
aoqi@0 128 echo Files $OTHER_FILE and $THIS_FILE differ
aoqi@0 129 return 1
aoqi@0 130 fi
aoqi@0 131
aoqi@0 132 return 0
aoqi@0 133 }
aoqi@0 134
aoqi@0 135 ##########################################################################################
aoqi@0 136 # Compare directory structure
aoqi@0 137
aoqi@0 138 compare_dirs() {
aoqi@0 139 THIS_DIR=$1
aoqi@0 140 OTHER_DIR=$2
aoqi@0 141 WORK_DIR=$3
aoqi@0 142
aoqi@0 143 mkdir -p $WORK_DIR
aoqi@0 144
aoqi@0 145 (cd $OTHER_DIR && $FIND . -type d | $SORT > $WORK_DIR/dirs_other)
aoqi@0 146 (cd $THIS_DIR && $FIND . -type d | $SORT > $WORK_DIR/dirs_this)
aoqi@0 147
aoqi@0 148 $DIFF $WORK_DIR/dirs_other $WORK_DIR/dirs_other > $WORK_DIR/dirs_diff
aoqi@0 149
aoqi@0 150 echo -n Directory structure...
aoqi@0 151 if [ -s $WORK_DIR/dirs_diff ]; then
aoqi@0 152 echo Differences found.
aoqi@0 153 REGRESSIONS=true
aoqi@0 154 # Differences in directories found.
aoqi@0 155 ONLY_OTHER=$($GREP '<' $WORK_DIR/dirs_diff)
aoqi@0 156 if [ "$ONLY_OTHER" ]; then
aoqi@0 157 echo Only in $OTHER
aoqi@0 158 $GREP '<' $WORK_DIR/dirs_diff | $SED 's|< ./| |g'
aoqi@0 159 fi
aoqi@0 160 ONLY_THIS=$($GREP '>' $WORK_DIR/dirs_diff)
aoqi@0 161 if [ "$ONLY_THIS" ]; then
aoqi@0 162 echo Only in $THIS
aoqi@0 163 $GREP '>' $WORK_DIR/dirs_diff | $SED 's|> ./| |g'
aoqi@0 164 fi
aoqi@0 165 else
aoqi@0 166 echo Identical!
aoqi@0 167 fi
aoqi@0 168 }
aoqi@0 169
aoqi@0 170
aoqi@0 171 ##########################################################################################
aoqi@0 172 # Compare file structure
aoqi@0 173
aoqi@0 174 compare_files() {
aoqi@0 175 THIS_DIR=$1
aoqi@0 176 OTHER_DIR=$2
aoqi@0 177 WORK_DIR=$3
aoqi@0 178
aoqi@0 179 $MKDIR -p $WORK_DIR
aoqi@0 180
aoqi@0 181 (cd $OTHER_DIR && $FIND . ! -type d | $SORT > $WORK_DIR/files_other)
aoqi@0 182 (cd $THIS_DIR && $FIND . ! -type d | $SORT > $WORK_DIR/files_this)
aoqi@0 183
aoqi@0 184 $DIFF $WORK_DIR/files_other $WORK_DIR/files_this > $WORK_DIR/files_diff
aoqi@0 185
aoqi@0 186 echo -n File names...
aoqi@0 187 if [ -s $WORK_DIR/files_diff ]; then
aoqi@0 188 echo Differences found.
aoqi@0 189 REGRESSIONS=true
aoqi@0 190 # Differences in files found.
aoqi@0 191 ONLY_OTHER=$($GREP '<' $WORK_DIR/files_diff)
aoqi@0 192 if [ "$ONLY_OTHER" ]; then
aoqi@0 193 echo Only in $OTHER
aoqi@0 194 $GREP '<' $WORK_DIR/files_diff | $SED 's|< ./| |g'
aoqi@0 195 fi
aoqi@0 196 ONLY_THIS=$($GREP '>' $WORK_DIR/files_diff)
aoqi@0 197 if [ "$ONLY_THIS" ]; then
aoqi@0 198 echo Only in $THIS
aoqi@0 199 $GREP '>' $WORK_DIR/files_diff | $SED 's|> ./| |g'
aoqi@0 200 fi
aoqi@0 201 else
aoqi@0 202 echo Identical!
aoqi@0 203 fi
aoqi@0 204 }
aoqi@0 205
aoqi@0 206
aoqi@0 207 ##########################################################################################
aoqi@0 208 # Compare permissions
aoqi@0 209
aoqi@0 210 compare_permissions() {
aoqi@0 211 THIS_DIR=$1
aoqi@0 212 OTHER_DIR=$2
aoqi@0 213 WORK_DIR=$3
aoqi@0 214
aoqi@0 215 mkdir -p $WORK_DIR
aoqi@0 216
aoqi@0 217 echo -n Permissions...
aoqi@0 218 found=""
aoqi@0 219 for f in `cd $OTHER_DIR && $FIND . -type f`
aoqi@0 220 do
aoqi@0 221 if [ ! -f ${OTHER_DIR}/$f ]; then continue; fi
aoqi@0 222 if [ ! -f ${THIS_DIR}/$f ]; then continue; fi
aoqi@0 223 OP=`ls -l ${OTHER_DIR}/$f | awk '{printf("%.10s\n", $1);}'`
aoqi@0 224 TP=`ls -l ${THIS_DIR}/$f | awk '{printf("%.10s\n", $1);}'`
aoqi@0 225 if [ "$OP" != "$TP" ]
aoqi@0 226 then
aoqi@0 227 if [ -z "$found" ]; then echo ; found="yes"; fi
aoqi@0 228 $PRINTF "\told: ${OP} new: ${TP}\t$f\n"
aoqi@0 229 fi
aoqi@0 230 done
aoqi@0 231 if [ -z "$found" ]; then
aoqi@0 232 echo "Identical!"
aoqi@0 233 else
aoqi@0 234 REGRESSIONS=true
aoqi@0 235 fi
aoqi@0 236 }
aoqi@0 237
aoqi@0 238 ##########################################################################################
aoqi@0 239 # Compare file command output
aoqi@0 240
aoqi@0 241 compare_file_types() {
aoqi@0 242 THIS_DIR=$1
aoqi@0 243 OTHER_DIR=$2
aoqi@0 244 WORK_DIR=$3
aoqi@0 245
aoqi@0 246 $MKDIR -p $WORK_DIR
aoqi@0 247
aoqi@0 248 echo -n File types...
aoqi@0 249 found=""
aoqi@0 250 for f in `cd $OTHER_DIR && $FIND . ! -type d`
aoqi@0 251 do
aoqi@0 252 if [ ! -f ${OTHER_DIR}/$f ]; then continue; fi
aoqi@0 253 if [ ! -f ${THIS_DIR}/$f ]; then continue; fi
aoqi@0 254 OF=`cd ${OTHER_DIR} && $FILE -h $f`
aoqi@0 255 TF=`cd ${THIS_DIR} && $FILE -h $f`
aoqi@0 256 if [ "$f" = "./src.zip" ] || [[ "$f" = *"/Home/src.zip" ]] || [[ "$f" = *"/lib/JObjC.jar" ]]
aoqi@0 257 then
aoqi@0 258 if [ "`echo $OF | $GREP -ic zip`" -gt 0 -a "`echo $TF | $GREP -ic zip`" -gt 0 ]
aoqi@0 259 then
aoqi@0 260 # the way we produces zip-files make it so that directories are stored in old file
aoqi@0 261 # but not in new (only files with full-path)
aoqi@0 262 # this makes file-5.09 report them as different
aoqi@0 263 continue;
aoqi@0 264 fi
aoqi@0 265 fi
aoqi@0 266
aoqi@0 267 if [ "$OF" != "$TF" ]
aoqi@0 268 then
aoqi@0 269 if [ -z "$found" ]; then echo ; found="yes"; fi
aoqi@0 270 $PRINTF "\tother: ${OF}\n\tthis : ${TF}\n"
aoqi@0 271 fi
aoqi@0 272 done
aoqi@0 273 if [ -z "$found" ]; then
aoqi@0 274 echo "Identical!"
aoqi@0 275 else
aoqi@0 276 REGRESSIONS=true
aoqi@0 277 fi
aoqi@0 278 }
aoqi@0 279
aoqi@0 280 ##########################################################################################
aoqi@0 281 # Compare the rest of the files
aoqi@0 282
aoqi@0 283 compare_general_files() {
aoqi@0 284 THIS_DIR=$1
aoqi@0 285 OTHER_DIR=$2
aoqi@0 286 WORK_DIR=$3
aoqi@0 287
aoqi@0 288 GENERAL_FILES=$(cd $THIS_DIR && $FIND . -type f ! -name "*.so" ! -name "*.jar" ! -name "*.zip" \
aoqi@0 289 ! -name "*.debuginfo" ! -name "*.dylib" ! -name "jexec" \
aoqi@0 290 ! -name "ct.sym" ! -name "*.diz" ! -name "*.dll" \
aoqi@0 291 ! -name "*.pdb" ! -name "*.exp" ! -name "*.ilk" \
aoqi@0 292 ! -name "*.lib" ! -name "*.war" ! -name "JavaControlPanel" \
aoqi@0 293 | $GREP -v "./bin/" | $SORT | $FILTER)
aoqi@0 294
aoqi@0 295 echo General files...
aoqi@0 296 for f in $GENERAL_FILES
aoqi@0 297 do
aoqi@0 298 if [ -e $OTHER_DIR/$f ]; then
aoqi@0 299 SUFFIX="${f##*.}"
aoqi@0 300 if [ "$(basename $f)" = "release" ]; then
aoqi@0 301 # Ignore differences in change numbers in release file.
aoqi@0 302 OTHER_FILE=$WORK_DIR/$f.other
aoqi@0 303 THIS_FILE=$WORK_DIR/$f.this
aoqi@0 304 $MKDIR -p $(dirname $OTHER_FILE)
aoqi@0 305 $MKDIR -p $(dirname $THIS_FILE)
aoqi@0 306 $CAT $OTHER_DIR/$f | $SED 's/\:[0-9a-f]\{12,12\}/:CHANGE/g' > $OTHER_FILE
aoqi@0 307 $CAT $THIS_DIR/$f | $SED 's/\:[0-9a-f]\{12,12\}/:CHANGE/g' > $THIS_FILE
aoqi@0 308 elif [ "x$SUFFIX" = "xhtml" ]; then
aoqi@0 309 # Ignore time stamps in docs files
aoqi@0 310 OTHER_FILE=$WORK_DIR/$f.other
aoqi@0 311 THIS_FILE=$WORK_DIR/$f.this
aoqi@0 312 $MKDIR -p $(dirname $OTHER_FILE)
aoqi@0 313 $MKDIR -p $(dirname $THIS_FILE)
aoqi@0 314 #Note that | doesn't work on mac sed.
aoqi@0 315 $CAT $OTHER_DIR/$f | $SED -e 's/\(-- Generated by javadoc \).*\( --\)/\1(removed)\2/' \
aoqi@0 316 -e 's/\(<meta name="date" content="\).*\(">\)/\1(removed)\2/' \
aoqi@0 317 -e 's/[A-Z][a-z]*, [A-Z][a-z]* [0-9][0-9]*, [12][0-9]* [0-9][0-9:]* [AMP]\{2,2\} [A-Z][A-Z]*/(removed)/' \
aoqi@0 318 -e 's/[A-Z][a-z]* [A-Z][a-z]* [0-9][0-9] [0-9][0-9:]* [A-Z][A-Z]* [12][0-9]*/(removed)/' \
aoqi@0 319 -e 's/^\( from \).*\(\.idl\)$/\1(removed)\2/' \
aoqi@0 320 > $OTHER_FILE
aoqi@0 321 $CAT $THIS_DIR/$f | $SED -e 's/\(-- Generated by javadoc \).*\( --\)/\1(removed)\2/' \
aoqi@0 322 -e 's/\(<meta name="date" content="\).*\(">\)/\1(removed)\2/' \
aoqi@0 323 -e 's/[A-Z][a-z]*, [A-Z][a-z]* [0-9][0-9]*, [12][0-9]* [0-9][0-9:]* [AMP]\{2,2\} [A-Z][A-Z]*/(removed)/' \
aoqi@0 324 -e 's/[A-Z][a-z]* [A-Z][a-z]* [0-9][0-9] [0-9][0-9:]* [A-Z][A-Z]* [12][0-9]*/(removed)/' \
aoqi@0 325 -e 's/^\( from \).*\(\.idl\)$/\1(removed)\2/' \
aoqi@0 326 > $THIS_FILE
aoqi@0 327 else
aoqi@0 328 OTHER_FILE=$OTHER_DIR/$f
aoqi@0 329 THIS_FILE=$THIS_DIR/$f
aoqi@0 330 fi
aoqi@0 331 DIFF_OUT=$($DIFF $OTHER_FILE $THIS_FILE 2>&1)
aoqi@0 332 if [ -n "$DIFF_OUT" ]; then
aoqi@0 333 echo $f
aoqi@0 334 REGRESSIONS=true
aoqi@0 335 if [ "$SHOW_DIFFS" = "true" ]; then
aoqi@0 336 echo "$DIFF_OUT"
aoqi@0 337 fi
aoqi@0 338 fi
aoqi@0 339 fi
aoqi@0 340 done
aoqi@0 341
aoqi@0 342
aoqi@0 343 }
aoqi@0 344
aoqi@0 345 ##########################################################################################
aoqi@0 346 # Compare zip file
aoqi@0 347
aoqi@0 348 compare_zip_file() {
aoqi@0 349 THIS_DIR=$1
aoqi@0 350 OTHER_DIR=$2
aoqi@0 351 WORK_DIR=$3
aoqi@0 352 ZIP_FILE=$4
aoqi@0 353 # Optionally provide different name for other zipfile
aoqi@0 354 OTHER_ZIP_FILE=$5
aoqi@0 355
aoqi@0 356 THIS_ZIP=$THIS_DIR/$ZIP_FILE
aoqi@0 357 if [ -n "$OTHER_ZIP_FILE" ]; then
aoqi@0 358 OTHER_ZIP=$OTHER_DIR/$OTHER_ZIP_FILE
aoqi@0 359 else
aoqi@0 360 OTHER_ZIP=$OTHER_DIR/$ZIP_FILE
aoqi@0 361 fi
aoqi@0 362
aoqi@0 363 THIS_SUFFIX="${THIS_ZIP##*.}"
aoqi@0 364 OTHER_SUFFIX="${OTHER_ZIP##*.}"
aoqi@0 365 if [ "$THIS_SUFFIX" != "$OTHER_SUFFIX" ]; then
aoqi@0 366 echo The files do not have the same suffix type!
aoqi@0 367 return 2
aoqi@0 368 fi
aoqi@0 369
aoqi@0 370 TYPE="$THIS_SUFFIX"
aoqi@0 371
aoqi@0 372 if $CMP $OTHER_ZIP $THIS_ZIP > /dev/null
aoqi@0 373 then
aoqi@0 374 return 0
aoqi@0 375 fi
aoqi@0 376 # Not quite identical, the might still contain the same data.
aoqi@0 377 # Unpack the jar/zip files in temp dirs
aoqi@0 378
aoqi@0 379 THIS_UNZIPDIR=$WORK_DIR/$ZIP_FILE.this
aoqi@0 380 OTHER_UNZIPDIR=$WORK_DIR/$ZIP_FILE.other
aoqi@0 381 $RM -rf $THIS_UNZIPDIR $OTHER_UNZIPDIR
aoqi@0 382 $MKDIR -p $THIS_UNZIPDIR
aoqi@0 383 $MKDIR -p $OTHER_UNZIPDIR
aoqi@0 384 (cd $THIS_UNZIPDIR && $UNARCHIVE $THIS_ZIP)
aoqi@0 385 (cd $OTHER_UNZIPDIR && $UNARCHIVE $OTHER_ZIP)
aoqi@0 386
aoqi@0 387 # Find all archives inside and unzip them as well to compare the contents rather than
aoqi@0 388 # the archives. pie.jar.pack.gz i app3.war is corrupt, skip it.
aoqi@0 389 EXCEPTIONS="pie.jar.pack.gz"
aoqi@0 390 for pack in $($FIND $THIS_UNZIPDIR \( -name "*.pack" -o -name "*.pack.gz" \) -a ! -name pie.jar.pack.gz); do
aoqi@0 391 ($UNPACK200 $pack $pack.jar)
aoqi@0 392 # Filter out the unzipped archives from the diff below.
aoqi@0 393 EXCEPTIONS="$EXCEPTIONS $pack $pack.jar"
aoqi@0 394 done
aoqi@0 395 for pack in $($FIND $OTHER_UNZIPDIR \( -name "*.pack" -o -name "*.pack.gz" \) -a ! -name pie.jar.pack.gz); do
aoqi@0 396 ($UNPACK200 $pack $pack.jar)
aoqi@0 397 EXCEPTIONS="$EXCEPTIONS $pack $pack.jar"
aoqi@0 398 done
aoqi@0 399 for zip in $($FIND $THIS_UNZIPDIR -name "*.jar" -o -name "*.zip"); do
aoqi@0 400 $MKDIR $zip.unzip
aoqi@0 401 (cd $zip.unzip && $UNARCHIVE $zip)
aoqi@0 402 EXCEPTIONS="$EXCEPTIONS $zip"
aoqi@0 403 done
aoqi@0 404 for zip in $($FIND $OTHER_UNZIPDIR -name "*.jar" -o -name "*.zip"); do
aoqi@0 405 $MKDIR $zip.unzip
aoqi@0 406 (cd $zip.unzip && $UNARCHIVE $zip)
aoqi@0 407 EXCEPTIONS="$EXCEPTIONS $zip"
aoqi@0 408 done
aoqi@0 409
aoqi@0 410 CONTENTS_DIFF_FILE=$WORK_DIR/$ZIP_FILE.diff
aoqi@0 411 # On solaris, there is no -q option.
aoqi@0 412 if [ "$OPENJDK_TARGET_OS" = "solaris" ]; then
aoqi@0 413 LC_ALL=C $DIFF -r $OTHER_UNZIPDIR $THIS_UNZIPDIR \
aoqi@0 414 | $GREP -v -e "^<" -e "^>" -e "^Common subdirectories:" \
aoqi@0 415 > $CONTENTS_DIFF_FILE
aoqi@0 416 else
aoqi@0 417 LC_ALL=C $DIFF -rq $OTHER_UNZIPDIR $THIS_UNZIPDIR > $CONTENTS_DIFF_FILE
aoqi@0 418 fi
aoqi@0 419
aoqi@0 420 ONLY_OTHER=$($GREP "^Only in $OTHER_UNZIPDIR" $CONTENTS_DIFF_FILE)
aoqi@0 421 ONLY_THIS=$($GREP "^Only in $THIS_UNZIPDIR" $CONTENTS_DIFF_FILE)
aoqi@0 422
aoqi@0 423 return_value=0
aoqi@0 424
aoqi@0 425 if [ -n "$ONLY_OTHER" ]; then
aoqi@0 426 echo " Only OTHER $ZIP_FILE contains:"
aoqi@0 427 echo "$ONLY_OTHER" | sed "s|Only in $OTHER_UNZIPDIR| |"g | sed 's|: |/|g'
aoqi@0 428 return_value=1
aoqi@0 429 fi
aoqi@0 430
aoqi@0 431 if [ -n "$ONLY_THIS" ]; then
aoqi@0 432 echo " Only THIS $ZIP_FILE contains:"
aoqi@0 433 echo "$ONLY_THIS" | sed "s|Only in $THIS_UNZIPDIR| |"g | sed 's|: |/|g'
aoqi@0 434 return_value=1
aoqi@0 435 fi
aoqi@0 436
aoqi@0 437 if [ "$OPENJDK_TARGET_OS" = "solaris" ]; then
aoqi@0 438 DIFFING_FILES=$($GREP -e "differ$" -e "^diff " $CONTENTS_DIFF_FILE \
aoqi@0 439 | $CUT -f 3 -d ' ' | $SED "s|$OTHER_UNZIPDIR/||g")
aoqi@0 440 else
aoqi@0 441 DIFFING_FILES=$($GREP -e "differ$" $CONTENTS_DIFF_FILE \
aoqi@0 442 | $CUT -f 2 -d ' ' | $SED "s|$OTHER_UNZIPDIR/||g")
aoqi@0 443 fi
aoqi@0 444
aoqi@0 445 $RM -f $WORK_DIR/$ZIP_FILE.diffs
aoqi@0 446 for file in $DIFFING_FILES; do
aoqi@0 447 if [[ "$ACCEPTED_JARZIP_CONTENTS $EXCEPTIONS" != *"$file"* ]]; then
aoqi@0 448 diff_text $OTHER_UNZIPDIR/$file $THIS_UNZIPDIR/$file >> $WORK_DIR/$ZIP_FILE.diffs
aoqi@0 449 fi
aoqi@0 450 done
aoqi@0 451
aoqi@0 452 if [ -s "$WORK_DIR/$ZIP_FILE.diffs" ]; then
aoqi@0 453 return_value=1
aoqi@0 454 echo " Differing files in $ZIP_FILE"
aoqi@0 455 $CAT $WORK_DIR/$ZIP_FILE.diffs | $GREP differ | cut -f 2 -d ' ' | \
aoqi@0 456 $SED "s|$OTHER_UNZIPDIR| |g" > $WORK_DIR/$ZIP_FILE.difflist
aoqi@0 457 $CAT $WORK_DIR/$ZIP_FILE.difflist
aoqi@0 458
aoqi@0 459 if [ -n "$SHOW_DIFFS" ]; then
aoqi@0 460 for i in $(cat $WORK_DIR/$ZIP_FILE.difflist) ; do
aoqi@0 461 if [ -f "${OTHER_UNZIPDIR}/$i.javap" ]; then
aoqi@0 462 LC_ALL=C $DIFF ${OTHER_UNZIPDIR}/$i.javap ${THIS_UNZIPDIR}/$i.javap
aoqi@0 463 elif [ -f "${OTHER_UNZIPDIR}/$i.cleaned" ]; then
aoqi@0 464 LC_ALL=C $DIFF ${OTHER_UNZIPDIR}/$i.cleaned ${THIS_UNZIPDIR}/$i
aoqi@0 465 else
aoqi@0 466 LC_ALL=C $DIFF ${OTHER_UNZIPDIR}/$i ${THIS_UNZIPDIR}/$i
aoqi@0 467 fi
aoqi@0 468 done
aoqi@0 469 fi
aoqi@0 470 fi
aoqi@0 471
aoqi@0 472 return $return_value
aoqi@0 473 }
aoqi@0 474
aoqi@0 475
aoqi@0 476 ##########################################################################################
aoqi@0 477 # Compare all zip files
aoqi@0 478
aoqi@0 479 compare_all_zip_files() {
aoqi@0 480 THIS_DIR=$1
aoqi@0 481 OTHER_DIR=$2
aoqi@0 482 WORK_DIR=$3
aoqi@0 483
aoqi@0 484 ZIPS=$(cd $THIS_DIR && $FIND . -type f -name "*.zip" | $SORT | $FILTER )
aoqi@0 485
aoqi@0 486 if [ -n "$ZIPS" ]; then
aoqi@0 487 echo Zip files...
aoqi@0 488
aoqi@0 489 return_value=0
aoqi@0 490 for f in $ZIPS; do
aoqi@0 491 if [ -f "$OTHER_DIR/$f" ]; then
aoqi@0 492 compare_zip_file $THIS_DIR $OTHER_DIR $WORK_DIR $f
aoqi@0 493 if [ "$?" != "0" ]; then
aoqi@0 494 return_value=1
aoqi@0 495 REGRESSIONS=true
aoqi@0 496 fi
aoqi@0 497 fi
aoqi@0 498 done
aoqi@0 499 fi
aoqi@0 500
aoqi@0 501 return $return_value
aoqi@0 502 }
aoqi@0 503
aoqi@0 504 ##########################################################################################
aoqi@0 505 # Compare all jar files
aoqi@0 506
aoqi@0 507 compare_all_jar_files() {
aoqi@0 508 THIS_DIR=$1
aoqi@0 509 OTHER_DIR=$2
aoqi@0 510 WORK_DIR=$3
aoqi@0 511
aoqi@0 512 # TODO filter?
aoqi@0 513 ZIPS=$(cd $THIS_DIR && $FIND . -type f -name "*.jar" -o -name "*.war" | $SORT | $FILTER)
aoqi@0 514
aoqi@0 515 if [ -n "$ZIPS" ]; then
aoqi@0 516 echo Jar files...
aoqi@0 517
aoqi@0 518 return_value=0
aoqi@0 519 for f in $ZIPS; do
aoqi@0 520 if [ -f "$OTHER_DIR/$f" ]; then
aoqi@0 521 compare_zip_file $THIS_DIR $OTHER_DIR $WORK_DIR $f
aoqi@0 522 if [ "$?" != "0" ]; then
aoqi@0 523 return_value=1
aoqi@0 524 REGRESSIONS=true
aoqi@0 525 fi
aoqi@0 526 fi
aoqi@0 527 done
aoqi@0 528 fi
aoqi@0 529
aoqi@0 530 return $return_value
aoqi@0 531 }
aoqi@0 532
aoqi@0 533 ##########################################################################################
aoqi@0 534 # Compare binary (executable/library) file
aoqi@0 535
aoqi@0 536 compare_bin_file() {
aoqi@0 537 THIS_DIR=$1
aoqi@0 538 OTHER_DIR=$2
aoqi@0 539 WORK_DIR=$3
aoqi@0 540 BIN_FILE=$4
aoqi@0 541
aoqi@0 542 THIS_FILE=$THIS_DIR/$BIN_FILE
aoqi@0 543 OTHER_FILE=$OTHER_DIR/$BIN_FILE
aoqi@0 544 NAME=$(basename $BIN_FILE)
aoqi@0 545 WORK_FILE_BASE=$WORK_DIR/$BIN_FILE
aoqi@0 546 FILE_WORK_DIR=$(dirname $WORK_FILE_BASE)
aoqi@0 547
aoqi@0 548 $MKDIR -p $FILE_WORK_DIR
aoqi@0 549
aoqi@0 550 ORIG_THIS_FILE="$THIS_FILE"
aoqi@0 551 ORIG_OTHER_FILE="$OTHER_FILE"
aoqi@0 552
aoqi@0 553 if [[ "$STRIP_BEFORE_COMPARE" = *"$BIN_FILE"* ]]; then
aoqi@0 554 THIS_STRIPPED_FILE=$FILE_WORK_DIR/this/$NAME
aoqi@0 555 OTHER_STRIPPED_FILE=$FILE_WORK_DIR/other/$NAME
aoqi@0 556 $MKDIR -p $FILE_WORK_DIR/this $FILE_WORK_DIR/other
aoqi@0 557 $CP $THIS_FILE $THIS_STRIPPED_FILE
aoqi@0 558 $CP $OTHER_FILE $OTHER_STRIPPED_FILE
aoqi@0 559 $STRIP $THIS_STRIPPED_FILE
aoqi@0 560 $STRIP $OTHER_STRIPPED_FILE
aoqi@0 561 THIS_FILE="$THIS_STRIPPED_FILE"
aoqi@0 562 OTHER_FILE="$OTHER_STRIPPED_FILE"
aoqi@0 563 fi
aoqi@0 564
aoqi@0 565 if [ "$OPENJDK_TARGET_OS" = "windows" ]; then
aoqi@0 566 unset _NT_SYMBOL_PATH
aoqi@0 567 # On windows we need to unzip the debug symbols, if present
aoqi@0 568 OTHER_FILE_BASE=${OTHER_FILE/.dll/}
aoqi@0 569 OTHER_FILE_BASE=${OTHER_FILE_BASE/.exe/}
aoqi@0 570 DIZ_NAME=$(basename $OTHER_FILE_BASE).diz
aoqi@0 571 # java.exe and java.dll diz files will have the same name. Have to
aoqi@0 572 # make sure java.exe gets the right one. This is only needed for
aoqi@0 573 # OTHER since in the new build, all pdb files are left around.
aoqi@0 574 if [ "$NAME" = "java.exe" ] && [ -f "$OTHER/tmp/java/java/obj64/java.diz" ]; then
aoqi@0 575 OTHER_DIZ_FILE="$OTHER/tmp/java/java/obj64/java.diz"
aoqi@0 576 elif [ -f "${OTHER_FILE_BASE}.diz" ]; then
aoqi@0 577 OTHER_DIZ_FILE=${OTHER_FILE_BASE}.diz
aoqi@0 578 else
aoqi@0 579 # Some files, jli.dll, appears twice in the image but only one of
aoqi@0 580 # thme has a diz file next to it.
aoqi@0 581 OTHER_DIZ_FILE="$($FIND $OTHER_DIR -name $DIZ_NAME | $SED 1q)"
aoqi@0 582 if [ ! -f "$OTHER_DIZ_FILE" ]; then
aoqi@0 583 # As a last resort, look for diz file in the whole build output
aoqi@0 584 # dir.
aoqi@0 585 OTHER_DIZ_FILE="$($FIND $OTHER -name $DIZ_NAME | $SED 1q)"
aoqi@0 586 fi
aoqi@0 587 fi
aoqi@0 588 if [ -n "$OTHER_DIZ_FILE" ]; then
aoqi@0 589 $MKDIR -p $FILE_WORK_DIR/other
aoqi@0 590 (cd $FILE_WORK_DIR/other ; $UNARCHIVE -o $OTHER_DIZ_FILE)
aoqi@0 591 export _NT_SYMBOL_PATH="$FILE_WORK_DIR/other"
aoqi@0 592 fi
aoqi@0 593 THIS_FILE_BASE=${THIS_FILE/.dll/}
aoqi@0 594 THIS_FILE_BASE=${THIS_FILE_BASE/.exe/}
aoqi@0 595 if [ -f "${THIS_FILE/.dll/}.diz" ]; then
aoqi@0 596 THIS_DIZ_FILE=${THIS_FILE/.dll/}.diz
aoqi@0 597 else
aoqi@0 598 THIS_DIZ_FILE="$($FIND $THIS_DIR -name $DIZ_NAME | $SED 1q)"
aoqi@0 599 if [ ! -f "$THIS_DIZ_FILE" ]; then
aoqi@0 600 # As a last resort, look for diz file in the whole build output
aoqi@0 601 # dir.
aoqi@0 602 THIS_DIZ_FILE="$($FIND $THIS -name $DIZ_NAME | $SED 1q)"
aoqi@0 603 fi
aoqi@0 604 fi
aoqi@0 605 if [ -n "$THIS_DIZ_FILE" ]; then
aoqi@0 606 $MKDIR -p $FILE_WORK_DIR/this
aoqi@0 607 (cd $FILE_WORK_DIR/this ; $UNARCHIVE -o $THIS_DIZ_FILE)
aoqi@0 608 export _NT_SYMBOL_PATH="$_NT_SYMBOL_PATH;$FILE_WORK_DIR/this"
aoqi@0 609 fi
aoqi@0 610 fi
aoqi@0 611
aoqi@0 612 if [ -z "$SKIP_BIN_DIFF" ]; then
aoqi@0 613 if cmp $OTHER_FILE $THIS_FILE > /dev/null; then
aoqi@0 614 # The files were bytewise identical.
aoqi@0 615 if [ -n "$VERBOSE" ]; then
aoqi@0 616 echo " : : : : : $BIN_FILE"
aoqi@0 617 fi
aoqi@0 618 return 0
aoqi@0 619 fi
aoqi@0 620 BIN_MSG=" diff "
aoqi@0 621 if [[ "$ACCEPTED_BIN_DIFF" != *"$BIN_FILE"* ]]; then
aoqi@0 622 DIFF_BIN=true
aoqi@0 623 if [[ "$KNOWN_BIN_DIFF" != *"$BIN_FILE"* ]]; then
aoqi@0 624 BIN_MSG="*$BIN_MSG*"
aoqi@0 625 REGRESSIONS=true
aoqi@0 626 else
aoqi@0 627 BIN_MSG=" $BIN_MSG "
aoqi@0 628 fi
aoqi@0 629 else
aoqi@0 630 BIN_MSG="($BIN_MSG)"
aoqi@0 631 DIFF_BIN=
aoqi@0 632 fi
aoqi@0 633 fi
aoqi@0 634
aoqi@0 635 if [ -n "$STAT" ]; then
aoqi@0 636 THIS_SIZE=$($STAT $STAT_PRINT_SIZE "$THIS_FILE")
aoqi@0 637 OTHER_SIZE=$($STAT $STAT_PRINT_SIZE "$OTHER_FILE")
aoqi@0 638 else
aoqi@0 639 THIS_SIZE=$(ls -l "$THIS_FILE" | awk '{ print $5 }')
aoqi@0 640 OTHER_SIZE=$(ls -l "$OTHER_FILE" | awk '{ print $5 }')
aoqi@0 641 fi
aoqi@0 642 if [ $THIS_SIZE -ne $OTHER_SIZE ]; then
aoqi@0 643 DIFF_SIZE_NUM=$($EXPR $THIS_SIZE - $OTHER_SIZE)
aoqi@0 644 DIFF_SIZE_REL=$($EXPR $THIS_SIZE \* 100 / $OTHER_SIZE)
aoqi@0 645 SIZE_MSG=$($PRINTF "%3d%% %4d" $DIFF_SIZE_REL $DIFF_SIZE_NUM)
aoqi@0 646 if [[ "$ACCEPTED_SMALL_SIZE_DIFF" = *"$BIN_FILE"* ]] && [ "$DIFF_SIZE_REL" -gt 98 ] \
aoqi@0 647 && [ "$DIFF_SIZE_REL" -lt 102 ]; then
aoqi@0 648 SIZE_MSG="($SIZE_MSG)"
aoqi@0 649 DIFF_SIZE=
aoqi@0 650 elif [ "$OPENJDK_TARGET_OS" = "windows" ] \
aoqi@0 651 && [[ "$ACCEPTED_SMALL_SIZE_DIFF" = *"$BIN_FILE"* ]] \
aoqi@0 652 && [ "$DIFF_SIZE_NUM" = 512 ]; then
aoqi@0 653 # On windows, size of binaries increase in 512 increments.
aoqi@0 654 SIZE_MSG="($SIZE_MSG)"
aoqi@0 655 DIFF_SIZE=
aoqi@0 656 elif [ "$OPENJDK_TARGET_OS" = "windows" ] \
aoqi@0 657 && [[ "$ACCEPTED_SMALL_SIZE_DIFF" = *"$BIN_FILE"* ]] \
aoqi@0 658 && [ "$DIFF_SIZE_NUM" = -512 ]; then
aoqi@0 659 # On windows, size of binaries increase in 512 increments.
aoqi@0 660 SIZE_MSG="($SIZE_MSG)"
aoqi@0 661 DIFF_SIZE=
aoqi@0 662 else
aoqi@0 663 if [[ "$ACCEPTED_SIZE_DIFF" != *"$BIN_FILE"* ]]; then
aoqi@0 664 DIFF_SIZE=true
aoqi@0 665 if [[ "$KNOWN_SIZE_DIFF" != *"$BIN_FILE"* ]]; then
aoqi@0 666 SIZE_MSG="*$SIZE_MSG*"
aoqi@0 667 REGRESSIONS=true
aoqi@0 668 else
aoqi@0 669 SIZE_MSG=" $SIZE_MSG "
aoqi@0 670 fi
aoqi@0 671 else
aoqi@0 672 SIZE_MSG="($SIZE_MSG)"
aoqi@0 673 DIFF_SIZE=
aoqi@0 674 fi
aoqi@0 675 fi
aoqi@0 676 else
aoqi@0 677 SIZE_MSG=" "
aoqi@0 678 DIFF_SIZE=
aoqi@0 679 if [[ "$KNOWN_SIZE_DIFF $ACCEPTED_SIZE_DIFF" = *"$BIN_FILE"* ]]; then
aoqi@0 680 SIZE_MSG=" ! "
aoqi@0 681 fi
aoqi@0 682 fi
aoqi@0 683
aoqi@0 684 if [[ "$SORT_SYMBOLS" = *"$BIN_FILE"* ]]; then
aoqi@0 685 SYM_SORT_CMD="sort"
aoqi@0 686 else
aoqi@0 687 SYM_SORT_CMD="cat"
aoqi@0 688 fi
aoqi@0 689
aoqi@0 690 # Check symbols
aoqi@0 691 if [ "$OPENJDK_TARGET_OS" = "windows" ]; then
aoqi@0 692 # The output from dumpbin on windows differs depending on if the debug symbol
aoqi@0 693 # files are still around at the location the binary is pointing too. Need
aoqi@0 694 # to filter out that extra information.
aoqi@0 695 $DUMPBIN -exports $OTHER_FILE | $GREP -E '^ +[0-9A-F]+ +[0-9A-F]+ [0-9A-F]+' | sed 's/ = .*//g' | cut -c27- | $SYM_SORT_CMD > $WORK_FILE_BASE.symbols.other
aoqi@0 696 $DUMPBIN -exports $THIS_FILE | $GREP -E '^ +[0-9A-F]+ +[0-9A-F]+ [0-9A-F]+' | sed 's/ = .*//g' | cut -c27- | $SYM_SORT_CMD > $WORK_FILE_BASE.symbols.this
aoqi@0 697 elif [ "$OPENJDK_TARGET_OS" = "solaris" ]; then
aoqi@0 698 # Some symbols get seemingly random 15 character prefixes. Filter them out.
aoqi@0 699 $NM -a $ORIG_OTHER_FILE 2> /dev/null | $GREP -v $NAME | $AWK '{print $2, $3, $4, $5}' | $SED 's/^\([a-zA-Z] [\.\$]\)[a-zA-Z0-9_\$]\{15,15\}\./\1./g' | $SYM_SORT_CMD > $WORK_FILE_BASE.symbols.other
aoqi@0 700 $NM -a $ORIG_THIS_FILE 2> /dev/null | $GREP -v $NAME | $AWK '{print $2, $3, $4, $5}' | $SED 's/^\([a-zA-Z] [\.\$]\)[a-zA-Z0-9_\$]\{15,15\}\./\1./g' | $SYM_SORT_CMD > $WORK_FILE_BASE.symbols.this
aoqi@0 701 else
aoqi@0 702 $NM -a $ORIG_OTHER_FILE 2> /dev/null | $GREP -v $NAME | $AWK '{print $2, $3, $4, $5}' | $SYM_SORT_CMD > $WORK_FILE_BASE.symbols.other
aoqi@0 703 $NM -a $ORIG_THIS_FILE 2> /dev/null | $GREP -v $NAME | $AWK '{print $2, $3, $4, $5}' | $SYM_SORT_CMD > $WORK_FILE_BASE.symbols.this
aoqi@0 704 fi
aoqi@0 705
aoqi@0 706 LC_ALL=C $DIFF $WORK_FILE_BASE.symbols.other $WORK_FILE_BASE.symbols.this > $WORK_FILE_BASE.symbols.diff
aoqi@0 707 if [ -s $WORK_FILE_BASE.symbols.diff ]; then
aoqi@0 708 SYM_MSG=" diff "
aoqi@0 709 if [[ "$ACCEPTED_SYM_DIFF" != *"$BIN_FILE"* ]]; then
aoqi@0 710 DIFF_SYM=true
aoqi@0 711 if [[ "$KNOWN_SYM_DIFF" != *"$BIN_FILE"* ]]; then
aoqi@0 712 SYM_MSG="*$SYM_MSG*"
aoqi@0 713 REGRESSIONS=true
aoqi@0 714 else
aoqi@0 715 SYM_MSG=" $SYM_MSG "
aoqi@0 716 fi
aoqi@0 717 else
aoqi@0 718 SYM_MSG="($SYM_MSG)"
aoqi@0 719 DIFF_SYM=
aoqi@0 720 fi
aoqi@0 721 else
aoqi@0 722 SYM_MSG=" "
aoqi@0 723 DIFF_SYM=
aoqi@0 724 if [[ "$KNOWN_SYM_DIFF $ACCEPTED_SYM_DIFF" = *"$BIN_FILE"* ]]; then
aoqi@0 725 SYM_MSG=" ! "
aoqi@0 726 fi
aoqi@0 727 fi
aoqi@0 728
aoqi@0 729 # Check dependencies
aoqi@0 730 if [ -n "$LDD_CMD" ]; then
aoqi@0 731 (cd $FILE_WORK_DIR && $CP $OTHER_FILE . && $LDD_CMD $NAME 2>/dev/null | $AWK '{ print $1;}' | $SORT | $TEE $WORK_FILE_BASE.deps.other | $UNIQ > $WORK_FILE_BASE.deps.other.uniq)
aoqi@0 732 (cd $FILE_WORK_DIR && $CP $THIS_FILE . && $LDD_CMD $NAME 2</dev/null | $AWK '{ print $1;}' | $SORT | $TEE $WORK_FILE_BASE.deps.this | $UNIQ > $WORK_FILE_BASE.deps.this.uniq)
aoqi@0 733 (cd $FILE_WORK_DIR && $RM -f $NAME)
aoqi@0 734
aoqi@0 735 LC_ALL=C $DIFF $WORK_FILE_BASE.deps.other $WORK_FILE_BASE.deps.this > $WORK_FILE_BASE.deps.diff
aoqi@0 736 LC_ALL=C $DIFF $WORK_FILE_BASE.deps.other.uniq $WORK_FILE_BASE.deps.this.uniq > $WORK_FILE_BASE.deps.diff.uniq
aoqi@0 737
aoqi@0 738 if [ -s $WORK_FILE_BASE.deps.diff ]; then
aoqi@0 739 if [ -s $WORK_FILE_BASE.deps.diff.uniq ]; then
aoqi@0 740 DEP_MSG=" diff "
aoqi@0 741 else
aoqi@0 742 DEP_MSG=" redun "
aoqi@0 743 fi
aoqi@0 744 if [[ "$ACCEPTED_DEP_DIFF" != *"$BIN_FILE"* ]]; then
aoqi@0 745 DIFF_DEP=true
aoqi@0 746 if [[ "$KNOWN_DEP_DIFF" != *"$BIN_FILE"* ]]; then
aoqi@0 747 DEP_MSG="*$DEP_MSG*"
aoqi@0 748 REGRESSIONS=true
aoqi@0 749 else
aoqi@0 750 DEP_MSG=" $DEP_MSG "
aoqi@0 751 fi
aoqi@0 752 else
aoqi@0 753 DEP_MSG="($DEP_MSG)"
aoqi@0 754 DIFF_DEP=
aoqi@0 755 fi
aoqi@0 756 else
aoqi@0 757 DEP_MSG=" "
aoqi@0 758 DIFF_DEP=
aoqi@0 759 if [[ "$KNOWN_DEP_DIFF $ACCEPTED_DEP_DIFF" = *"$BIN_FILE"* ]]; then
aoqi@0 760 DEP_MSG=" ! "
aoqi@0 761 fi
aoqi@0 762 fi
aoqi@0 763 else
aoqi@0 764 DEP_MSG=" - "
aoqi@0 765 fi
aoqi@0 766
aoqi@0 767 # Compare fulldump output
aoqi@0 768 if [ -n "$FULLDUMP_CMD" ] && [ -z "$SKIP_FULLDUMP_DIFF" ]; then
aoqi@0 769 $FULLDUMP_CMD $OTHER_FILE > $WORK_FILE_BASE.fulldump.other 2>&1
aoqi@0 770 $FULLDUMP_CMD $THIS_FILE > $WORK_FILE_BASE.fulldump.this 2>&1
aoqi@0 771 LC_ALL=C $DIFF $WORK_FILE_BASE.fulldump.other $WORK_FILE_BASE.fulldump.this > $WORK_FILE_BASE.fulldump.diff
aoqi@0 772
aoqi@0 773 if [ -s $WORK_FILE_BASE.fulldump.diff ]; then
aoqi@0 774 ELF_DIFF_SIZE=$(ls -n $WORK_FILE_BASE.fulldump.diff | awk '{print $5}')
aoqi@0 775 ELF_MSG=$($PRINTF "%8d" $ELF_DIFF_SIZE)
aoqi@0 776 if [[ "$ACCEPTED_ELF_DIFF" != *"$BIN_FILE"* ]]; then
aoqi@0 777 DIFF_ELF=true
aoqi@0 778 if [[ "$KNOWN_ELF_DIFF" != *"$BIN_FILE"* ]]; then
aoqi@0 779 ELF_MSG="*$ELF_MSG*"
aoqi@0 780 REGRESSIONS=true
aoqi@0 781 else
aoqi@0 782 ELF_MSG=" $ELF_MSG "
aoqi@0 783 fi
aoqi@0 784 else
aoqi@0 785 ELF_MSG="($ELF_MSG)"
aoqi@0 786 DIFF_ELF=
aoqi@0 787 fi
aoqi@0 788 else
aoqi@0 789 ELF_MSG=" "
aoqi@0 790 DIFF_ELF=
aoqi@0 791 if [[ "$KNOWN_DEP_DIFF $ACCEPTED_DEP_DIFF" = *"$BIN_FILE"* ]]; then
aoqi@0 792 ELF_MSG=" ! "
aoqi@0 793 fi
aoqi@0 794 fi
aoqi@0 795 fi
aoqi@0 796
aoqi@0 797 # Compare disassemble output
aoqi@0 798 if [ -n "$DIS_CMD" ] && [ -z "$SKIP_DIS_DIFF" ]; then
aoqi@0 799 if [ -z "$DIS_DIFF_FILTER" ]; then
aoqi@0 800 DIS_DIFF_FILTER="$CAT"
aoqi@0 801 fi
aoqi@0 802 $DIS_CMD $OTHER_FILE | $GREP -v $NAME | $DIS_DIFF_FILTER > $WORK_FILE_BASE.dis.other 2>&1
aoqi@0 803 $DIS_CMD $THIS_FILE | $GREP -v $NAME | $DIS_DIFF_FILTER > $WORK_FILE_BASE.dis.this 2>&1
aoqi@0 804
aoqi@0 805 LC_ALL=C $DIFF $WORK_FILE_BASE.dis.other $WORK_FILE_BASE.dis.this > $WORK_FILE_BASE.dis.diff
aoqi@0 806
aoqi@0 807 if [ -s $WORK_FILE_BASE.dis.diff ]; then
aoqi@0 808 DIS_DIFF_SIZE=$(ls -n $WORK_FILE_BASE.dis.diff | awk '{print $5}')
aoqi@0 809 DIS_MSG=$($PRINTF "%8d" $DIS_DIFF_SIZE)
aoqi@0 810 if [[ "$ACCEPTED_DIS_DIFF" != *"$BIN_FILE"* ]]; then
aoqi@0 811 DIFF_DIS=true
aoqi@0 812 if [[ "$KNOWN_DIS_DIFF" != *"$BIN_FILE"* ]]; then
aoqi@0 813 DIS_MSG="*$DIS_MSG*"
aoqi@0 814 REGRESSIONS=true
aoqi@0 815 else
aoqi@0 816 DIS_MSG=" $DIS_MSG "
aoqi@0 817 fi
aoqi@0 818 else
aoqi@0 819 DIS_MSG="($DIS_MSG)"
aoqi@0 820 DIFF_DIS=
aoqi@0 821 fi
aoqi@0 822 else
aoqi@0 823 DIS_MSG=" "
aoqi@0 824 DIFF_DIS=
aoqi@0 825 if [[ "$KNOWN_DEP_DIFF $ACCEPTED_DEP_DIFF" = *"$BIN_FILE"* ]]; then
aoqi@0 826 DIS_MSG=" ! "
aoqi@0 827 fi
aoqi@0 828 fi
aoqi@0 829 fi
aoqi@0 830
aoqi@0 831
aoqi@0 832 if [ -n "$DIFF_BIN$DIFF_SIZE$DIFF_SYM$DIFF_DEP$DIFF_ELF$DIFF_DIS" ] || [ -n "$VERBOSE" ]; then
aoqi@0 833 if [ -n "$BIN_MSG" ]; then echo -n "$BIN_MSG:"; fi
aoqi@0 834 if [ -n "$SIZE_MSG" ]; then echo -n "$SIZE_MSG:"; fi
aoqi@0 835 if [ -n "$SYM_MSG" ]; then echo -n "$SYM_MSG:"; fi
aoqi@0 836 if [ -n "$DEP_MSG" ]; then echo -n "$DEP_MSG:"; fi
aoqi@0 837 if [ -n "$ELF_MSG" ]; then echo -n "$ELF_MSG:"; fi
aoqi@0 838 if [ -n "$DIS_MSG" ]; then echo -n "$DIS_MSG:"; fi
aoqi@0 839 echo " $BIN_FILE"
aoqi@0 840 if [ "$SHOW_DIFFS" = "true" ]; then
aoqi@0 841 if [ -s "$WORK_FILE_BASE.symbols.diff" ]; then
aoqi@0 842 echo "Symbols diff:"
aoqi@0 843 $CAT $WORK_FILE_BASE.symbols.diff
aoqi@0 844 fi
aoqi@0 845 if [ -s "$WORK_FILE_BASE.deps.diff" ]; then
aoqi@0 846 echo "Deps diff:"
aoqi@0 847 $CAT $WORK_FILE_BASE.deps.diff
aoqi@0 848 fi
aoqi@0 849 if [ -s "$WORK_FILE_BASE.fulldump.diff" ]; then
aoqi@0 850 echo "Fulldump diff:"
aoqi@0 851 $CAT $WORK_FILE_BASE.fulldump.diff
aoqi@0 852 fi
aoqi@0 853 if [ -s "$WORK_FILE_BASE.dis.diff" ]; then
aoqi@0 854 echo "Disassembly diff:"
aoqi@0 855 $CAT $WORK_FILE_BASE.dis.diff
aoqi@0 856 fi
aoqi@0 857 fi
aoqi@0 858 return 1
aoqi@0 859 fi
aoqi@0 860 return 0
aoqi@0 861 }
aoqi@0 862
aoqi@0 863 ##########################################################################################
aoqi@0 864 # Print binary diff header
aoqi@0 865
aoqi@0 866 print_binary_diff_header() {
aoqi@0 867 if [ -z "$SKIP_BIN_DIFF" ]; then echo -n " Binary :"; fi
aoqi@0 868 if [ -z "$SKIP_SIZE_DIFF" ]; then echo -n " Size :"; fi
aoqi@0 869 if [ -z "$SKIP_SYM_DIFF" ]; then echo -n " Symbols :"; fi
aoqi@0 870 if [ -z "$SKIP_DEP_DIFF" ]; then echo -n " Deps :"; fi
aoqi@0 871 if [ -z "$SKIP_FULLDUMP_DIFF" ]; then echo -n " Fulldump :"; fi
aoqi@0 872 if [ -z "$SKIP_DIS_DIFF" ]; then echo -n " Disass :"; fi
aoqi@0 873 echo
aoqi@0 874 }
aoqi@0 875
aoqi@0 876 ##########################################################################################
aoqi@0 877 # Compare all libraries
aoqi@0 878
aoqi@0 879 compare_all_libs() {
aoqi@0 880 THIS_DIR=$1
aoqi@0 881 OTHER_DIR=$2
aoqi@0 882 WORK_DIR=$3
aoqi@0 883
aoqi@0 884 LIBS=$(cd $THIS_DIR && $FIND . -type f \( -name 'lib*.so' -o -name '*.dylib' -o -name '*.dll' -o -name 'JavaControlPanel' \) | $SORT | $FILTER)
aoqi@0 885
aoqi@0 886 if [ -n "$LIBS" ]; then
aoqi@0 887 echo Libraries...
aoqi@0 888 print_binary_diff_header
aoqi@0 889 for l in $LIBS; do
aoqi@0 890 if [ -f "$OTHER_DIR/$l" ]; then
aoqi@0 891 compare_bin_file $THIS_DIR $OTHER_DIR $WORK_DIR $l
aoqi@0 892 if [ "$?" != "0" ]; then
aoqi@0 893 return_value=1
aoqi@0 894 fi
aoqi@0 895 fi
aoqi@0 896 done
aoqi@0 897 fi
aoqi@0 898
aoqi@0 899 return $return_value
aoqi@0 900 }
aoqi@0 901
aoqi@0 902 ##########################################################################################
aoqi@0 903 # Compare all executables
aoqi@0 904
aoqi@0 905 compare_all_execs() {
aoqi@0 906 THIS_DIR=$1
aoqi@0 907 OTHER_DIR=$2
aoqi@0 908 WORK_DIR=$3
aoqi@0 909
aoqi@0 910 if [ "$OPENJDK_TARGET_OS" = "windows" ]; then
aoqi@0 911 EXECS=$(cd $THIS_DIR && $FIND . -type f -name '*.exe' | $SORT | $FILTER)
aoqi@0 912 else
aoqi@0 913 EXECS=$(cd $THIS_DIR && $FIND . -name db -prune -o -type f -perm -100 \! \
aoqi@0 914 \( -name '*.so' -o -name '*.dylib' -o -name '*.dll' -o -name '*.cgi' \
aoqi@0 915 -o -name '*.jar' -o -name '*.diz' -o -name 'jcontrol' -o -name '*.properties' \
aoqi@0 916 -o -name '*.data' -o -name '*.bfc' -o -name '*.src' -o -name '*.txt' \
aoqi@0 917 -o -name '*.cfg' -o -name 'meta-index' -o -name '*.properties.ja' \
aoqi@0 918 -o -name 'classlist' \) | $SORT | $FILTER)
aoqi@0 919 fi
aoqi@0 920
aoqi@0 921 if [ -n "$EXECS" ]; then
aoqi@0 922 echo Executables...
aoqi@0 923 print_binary_diff_header
aoqi@0 924 for e in $EXECS; do
aoqi@0 925 if [ -f "$OTHER_DIR/$e" ]; then
aoqi@0 926 compare_bin_file $THIS_DIR $OTHER_DIR $WORK_DIR $e
aoqi@0 927 if [ "$?" != "0" ]; then
aoqi@0 928 return_value=1
aoqi@0 929 fi
aoqi@0 930 fi
aoqi@0 931 done
aoqi@0 932 fi
aoqi@0 933
aoqi@0 934 return $return_value
aoqi@0 935 }
aoqi@0 936
aoqi@0 937 ##########################################################################################
aoqi@0 938 # Initiate configuration
aoqi@0 939
aoqi@0 940 COMPARE_ROOT=/tmp/cimages.$USER
aoqi@0 941 $MKDIR -p $COMPARE_ROOT
aoqi@0 942 if [ "$OPENJDK_TARGET_OS" = "windows" ]; then
aoqi@0 943 if [ "$(uname -o)" = "Cygwin" ]; then
aoqi@0 944 COMPARE_ROOT=$(cygpath -msa $COMPARE_ROOT)
aoqi@0 945 fi
aoqi@0 946 fi
aoqi@0 947
aoqi@0 948 THIS="$( cd "$( dirname "$0" )" && pwd )"
aoqi@0 949 echo "$THIS"
aoqi@0 950 THIS_SCRIPT="$0"
aoqi@0 951
aoqi@0 952 if [ -z "$1" ] || [ "$1" = "-h" ] || [ "$1" = "-?" ] || [ "$1" = "/h" ] || [ "$1" = "/?" ] || [ "$1" = "-help" ] || [ "$1" = "--help" ]; then
aoqi@0 953 echo "bash ./compare.sh [OPTIONS] [FILTER]"
aoqi@0 954 echo ""
aoqi@0 955 echo "-all Compare all files in all known ways"
aoqi@0 956 echo "-names Compare the file names and directory structure"
aoqi@0 957 echo "-perms Compare the permission bits on all files and directories"
aoqi@0 958 echo "-types Compare the output of the file command on all files"
aoqi@0 959 echo "-general Compare the files not convered by the specialized comparisons"
aoqi@0 960 echo "-zips Compare the contents of all zip files"
aoqi@0 961 echo "-jars Compare the contents of all jar files"
aoqi@0 962 echo "-libs Compare all native libraries"
aoqi@0 963 echo "-execs Compare all executables"
aoqi@0 964 echo "-v Verbose output, does not hide known differences"
aoqi@0 965 echo "-vv More verbose output, shows diff output of all comparisons"
aoqi@0 966 echo "-o [OTHER] Compare with build in other directory. Will default to the old build directory"
aoqi@0 967 echo ""
aoqi@0 968 echo "[FILTER] List filenames in the image to compare, works for jars, zips, libs and execs"
aoqi@0 969 echo "Example:"
aoqi@0 970 echo "bash ./common/bin/compareimages.sh CodePointIM.jar"
aoqi@0 971 echo ""
aoqi@0 972 echo "-2zips <file1> <file2> Compare two zip files only"
aoqi@0 973 echo ""
aoqi@0 974 exit 10
aoqi@0 975 fi
aoqi@0 976
aoqi@0 977 CMP_NAMES=false
aoqi@0 978 CMP_PERMS=false
aoqi@0 979 CMP_TYPES=false
aoqi@0 980 CMP_GENERAL=false
aoqi@0 981 CMP_ZIPS=false
aoqi@0 982 CMP_JARS=false
aoqi@0 983 CMP_LIBS=false
aoqi@0 984 CMP_EXECS=false
aoqi@0 985
aoqi@0 986 while [ -n "$1" ]; do
aoqi@0 987 case "$1" in
aoqi@0 988 -v)
aoqi@0 989 VERBOSE=true
aoqi@0 990 ;;
aoqi@0 991 -vv)
aoqi@0 992 VERBOSE=true
aoqi@0 993 SHOW_DIFFS=true
aoqi@0 994 ;;
aoqi@0 995 -o)
aoqi@0 996 OTHER="$2"
aoqi@0 997 shift
aoqi@0 998 ;;
aoqi@0 999 -all)
aoqi@0 1000 CMP_NAMES=true
aoqi@0 1001 if [ "$OPENJDK_TARGET_OS" != "windows" ]; then
aoqi@0 1002 CMP_PERMS=true
aoqi@0 1003 fi
aoqi@0 1004 CMP_TYPES=true
aoqi@0 1005 CMP_GENERAL=true
aoqi@0 1006 CMP_ZIPS=true
aoqi@0 1007 CMP_JARS=true
aoqi@0 1008 CMP_LIBS=true
aoqi@0 1009 CMP_EXECS=true
aoqi@0 1010 ;;
aoqi@0 1011 -names)
aoqi@0 1012 CMP_NAMES=true
aoqi@0 1013 ;;
aoqi@0 1014 -perms)
aoqi@0 1015 CMP_PERMS=true
aoqi@0 1016 ;;
aoqi@0 1017 -types)
aoqi@0 1018 CMP_TYPES=true
aoqi@0 1019 ;;
aoqi@0 1020 -general)
aoqi@0 1021 CMP_GENERAL=true
aoqi@0 1022 ;;
aoqi@0 1023 -zips)
aoqi@0 1024 CMP_ZIPS=true
aoqi@0 1025 ;;
aoqi@0 1026 -jars)
aoqi@0 1027 CMP_JARS=true
aoqi@0 1028 ;;
aoqi@0 1029 -libs)
aoqi@0 1030 CMP_LIBS=true
aoqi@0 1031 ;;
aoqi@0 1032 -execs)
aoqi@0 1033 CMP_EXECS=true
aoqi@0 1034 ;;
aoqi@0 1035 -2zips)
aoqi@0 1036 CMP_2_ZIPS=true
aoqi@0 1037 THIS_FILE=$2
aoqi@0 1038 OTHER_FILE=$3
aoqi@0 1039 shift
aoqi@0 1040 shift
aoqi@0 1041 ;;
aoqi@0 1042 *)
aoqi@0 1043 CMP_NAMES=false
aoqi@0 1044 CMP_PERMS=false
aoqi@0 1045 CMP_TYPES=false
aoqi@0 1046 CMP_ZIPS=true
aoqi@0 1047 CMP_JARS=true
aoqi@0 1048 CMP_LIBS=true
aoqi@0 1049 CMP_EXECS=true
aoqi@0 1050
aoqi@0 1051 if [ -z "$FILTER" ]; then
aoqi@0 1052 FILTER="$GREP"
aoqi@0 1053 fi
aoqi@0 1054 FILTER="$FILTER -e $1"
aoqi@0 1055 ;;
aoqi@0 1056 esac
aoqi@0 1057 shift
aoqi@0 1058 done
aoqi@0 1059
aoqi@0 1060 if [ "$CMP_2_ZIPS" = "true" ]; then
aoqi@0 1061 THIS_DIR="$(dirname $THIS_FILE)"
aoqi@0 1062 THIS_DIR="$(cd "$THIS_DIR" && pwd )"
aoqi@0 1063 OTHER_DIR="$(dirname $OTHER_FILE)"
aoqi@0 1064 OTHER_DIR="$(cd "$OTHER_DIR" && pwd )"
aoqi@0 1065 THIS_FILE_NAME="$(basename $THIS_FILE)"
aoqi@0 1066 OTHER_FILE_NAME="$(basename $OTHER_FILE)"
aoqi@0 1067 echo Comparing $THIS_DIR/$THIS_FILE_NAME and $OTHER_DIR/$OTHER_FILE_NAME
aoqi@0 1068 compare_zip_file $THIS_DIR $OTHER_DIR $COMPARE_ROOT/2zips $THIS_FILE_NAME $OTHER_FILE_NAME
aoqi@0 1069 exit
aoqi@0 1070 fi
aoqi@0 1071
aoqi@0 1072 if [ "$CMP_NAMES" = "false" ] && [ "$CMP_TYPES" = "false" ] && [ "$CMP_PERMS" = "false" ] && [ "$CMP_GENERAL" = "false" ] && [ "$CMP_ZIPS" = "false" ] && [ "$CMP_JARS" = "false" ] && [ "$CMP_LIBS" = "false" ] && [ "$CMP_EXECS" = "false" ]; then
aoqi@0 1073 CMP_NAMES=true
aoqi@0 1074 CMP_PERMS=true
aoqi@0 1075 CMP_TYPES=true
aoqi@0 1076 CMP_GENERAL=true
aoqi@0 1077 CMP_ZIPS=true
aoqi@0 1078 CMP_JARS=true
aoqi@0 1079 CMP_LIBS=true
aoqi@0 1080 CMP_EXECS=true
aoqi@0 1081 fi
aoqi@0 1082
aoqi@0 1083 if [ -z "$FILTER" ]; then
aoqi@0 1084 FILTER="$CAT"
aoqi@0 1085 fi
aoqi@0 1086
aoqi@0 1087 if [ -z "$OTHER" ]; then
aoqi@0 1088 OTHER="$THIS/../$LEGACY_BUILD_DIR"
aoqi@0 1089 if [ -d "$OTHER" ]; then
aoqi@0 1090 OTHER="$( cd "$OTHER" && pwd )"
aoqi@0 1091 else
aoqi@0 1092 echo "Default old build directory does not exist:"
aoqi@0 1093 echo "$OTHER"
aoqi@0 1094 exit 1
aoqi@0 1095 fi
aoqi@0 1096 echo "Comparing to default old build:"
aoqi@0 1097 echo "$OTHER"
aoqi@0 1098 echo
aoqi@0 1099 else
aoqi@0 1100 if [ ! -d "$OTHER" ]; then
aoqi@0 1101 echo "Other build directory does not exist:"
aoqi@0 1102 echo "$OTHER"
aoqi@0 1103 exit 1
aoqi@0 1104 fi
aoqi@0 1105 OTHER="$( cd "$OTHER" && pwd )"
aoqi@0 1106 echo "Comparing to:"
aoqi@0 1107 echo "$OTHER"
aoqi@0 1108 echo
aoqi@0 1109 fi
aoqi@0 1110
aoqi@0 1111
aoqi@0 1112 # Figure out the layout of the this build. Which kinds of images have been produced
aoqi@0 1113 if [ -d "$THIS/install/j2sdk-image" ]; then
aoqi@0 1114 THIS_J2SDK="$THIS/install/j2sdk-image"
aoqi@0 1115 THIS_J2RE="$THIS/install/j2re-image"
aoqi@0 1116 echo "Selecting install images in this build"
aoqi@0 1117 elif [ -d "$THIS/deploy/j2sdk-image" ]; then
aoqi@0 1118 THIS_J2SDK="$THIS/deploy/j2sdk-image"
aoqi@0 1119 THIS_J2RE="$THIS/deploy/j2re-image"
aoqi@0 1120 echo "Selecting deploy images in this build"
aoqi@0 1121 elif [ -d "$THIS/images/j2sdk-image" ]; then
aoqi@0 1122 THIS_J2SDK="$THIS/images/j2sdk-image"
aoqi@0 1123 THIS_J2RE="$THIS/images/j2re-image"
aoqi@0 1124 echo "Selecting jdk images in this build"
aoqi@0 1125 fi
aoqi@0 1126
aoqi@0 1127 if [ -d "$THIS/images/j2sdk-overlay-image" ]; then
aoqi@0 1128 if [ -d "$THIS/install/j2sdk-image" ]; then
aoqi@0 1129 # If there is an install image, prefer that, it's also overlay
aoqi@0 1130 THIS_J2SDK_OVERLAY="$THIS/install/j2sdk-image"
aoqi@0 1131 THIS_J2RE_OVERLAY="$THIS/install/j2re-image"
aoqi@0 1132 echo "Selecting install overlay images in this build"
aoqi@0 1133 else
aoqi@0 1134 THIS_J2SDK_OVERLAY="$THIS/images/j2sdk-overlay-image"
aoqi@0 1135 THIS_J2RE_OVERLAY="$THIS/images/j2re-overlay-image"
aoqi@0 1136 echo "Selecting jdk overlay images in this build"
aoqi@0 1137 fi
aoqi@0 1138 fi
aoqi@0 1139
aoqi@0 1140 if [ -d "$THIS/images/j2sdk-bundle" ]; then
aoqi@0 1141 THIS_J2SDK_BUNDLE="$THIS/images/j2sdk-bundle"
aoqi@0 1142 THIS_J2RE_BUNDLE="$THIS/images/j2re-bundle"
aoqi@0 1143 echo "Selecting bundles in this build"
aoqi@0 1144 fi
aoqi@0 1145
aoqi@0 1146 # Figure out the layout of the other build (old or new, normal or overlay image)
aoqi@0 1147 if [ -d "$OTHER/j2sdk-image" ]; then
aoqi@0 1148 if [ -f "$OTHER/j2sdk-image/LICENSE" ]; then
aoqi@0 1149 OTHER_J2SDK="$OTHER/j2sdk-image"
aoqi@0 1150 OTHER_J2RE="$OTHER/j2re-image"
aoqi@0 1151 echo "Selecting old-style images in other build"
aoqi@0 1152 else
aoqi@0 1153 OTHER_J2SDK_OVERLAY="$OTHER/j2sdk-image"
aoqi@0 1154 OTHER_J2RE_OVERLAY="$OTHER/j2re-image"
aoqi@0 1155 echo "Selecting overlay images in other build"
aoqi@0 1156 fi
aoqi@0 1157 elif [ -d "$OTHER/install/j2sdk-image" ]; then
aoqi@0 1158 OTHER_J2SDK="$OTHER/install/j2sdk-image"
aoqi@0 1159 OTHER_J2RE="$OTHER/install/j2re-image"
aoqi@0 1160 echo "Selecting install images in other build"
aoqi@0 1161 elif [ -d "$OTHER/deploy/j2sdk-image" ]; then
aoqi@0 1162 OTHER_J2SDK="$OTHER/deploy/j2sdk-image"
aoqi@0 1163 OTHER_J2RE="$OTHER/deploy/j2re-image"
aoqi@0 1164 echo "Selecting deploy images in other build"
aoqi@0 1165 elif [ -d "$OTHER/images/j2sdk-image" ]; then
aoqi@0 1166 OTHER_J2SDK="$OTHER/images/j2sdk-image"
aoqi@0 1167 OTHER_J2RE="$OTHER/images/j2re-image"
aoqi@0 1168 echo "Selecting jdk images in other build"
aoqi@0 1169 fi
aoqi@0 1170
aoqi@0 1171 if [ -d "$OTHER/j2sdk-bundle" ]; then
aoqi@0 1172 OTHER_J2SDK_BUNDLE="$OTHER/j2sdk-bundle"
aoqi@0 1173 OTHER_J2RE_BUNDLE="$OTHER/j2re-bundle"
aoqi@0 1174 echo "Selecting bundles in other build"
aoqi@0 1175 elif [ -d "$OTHER/images/j2sdk-bundle" ]; then
aoqi@0 1176 OTHER_J2SDK_BUNDLE="$OTHER/images/j2sdk-bundle"
aoqi@0 1177 OTHER_J2RE_BUNDLE="$OTHER/images/j2re-bundle"
aoqi@0 1178 echo "Selecting jdk bundles in other build"
aoqi@0 1179 fi
aoqi@0 1180
aoqi@0 1181 if [ -z "$THIS_J2SDK" ] || [ -z "$THIS_J2RE" ]; then
aoqi@0 1182 if [ -z "$THIS_J2SDK_OVERLAY" ]; then
aoqi@0 1183 echo "Cannot locate images for this build. Are you sure you have run 'make images'?"
aoqi@0 1184 exit 1
aoqi@0 1185 fi
aoqi@0 1186 fi
aoqi@0 1187
aoqi@0 1188 if [ -z "$OTHER_J2SDK" ] && [ -n "$OTHER_J2SDK_OVERLAY" ] && [ -z "$THIS_J2SDK_OVERLAY" ]; then
aoqi@0 1189 echo "OTHER build only has an overlay image while this build does not. Nothing to compare!"
aoqi@0 1190 exit 1
aoqi@0 1191 fi
aoqi@0 1192
aoqi@0 1193 if [ -z "$THIS_J2SDK_BUNDLE" ] && [ -n "$OTHER_J2SDK_BUNDLE" ]; then
aoqi@0 1194 echo "WARNING! OTHER build has bundles built while this build does not."
aoqi@0 1195 echo "Skipping bundle compare!"
aoqi@0 1196 fi
aoqi@0 1197
aoqi@0 1198 if [ -d "$THIS/docs" ]; then
aoqi@0 1199 THIS_DOCS="$THIS/docs"
aoqi@0 1200 fi
aoqi@0 1201
aoqi@0 1202 if [ -d "$OTHER/docs" ]; then
aoqi@0 1203 OTHER_DOCS="$OTHER/docs"
aoqi@0 1204 fi
aoqi@0 1205
aoqi@0 1206 if [ -z "$THIS_DOCS" ]; then
aoqi@0 1207 echo "WARNING! Docs haven't been built and won't be compared."
aoqi@0 1208 fi
aoqi@0 1209
aoqi@0 1210 if [ -z "$OTHER_DOCS" ]; then
aoqi@0 1211 echo "WARNING! Other build doesn't contain docs, skipping doc compare."
aoqi@0 1212 fi
aoqi@0 1213
aoqi@0 1214 if [ -d "$OTHER/images" ]; then
aoqi@0 1215 OTHER_SEC_DIR="$OTHER/images"
aoqi@0 1216 else
aoqi@0 1217 OTHER_SEC_DIR="$OTHER/tmp"
aoqi@0 1218 fi
aoqi@0 1219 OTHER_SEC_BIN="$OTHER_SEC_DIR/sec-bin.zip"
aoqi@0 1220 THIS_SEC_DIR="$THIS/images"
aoqi@0 1221 THIS_SEC_BIN="$THIS_SEC_DIR/sec-bin.zip"
aoqi@0 1222 if [ "$OPENJDK_TARGET_OS" = "windows" ]; then
aoqi@0 1223 if [ "$OPENJDK_TARGET_CPU" = "x86_64" ]; then
aoqi@0 1224 JGSS_WINDOWS_BIN="jgss-windows-x64-bin.zip"
aoqi@0 1225 else
aoqi@0 1226 JGSS_WINDOWS_BIN="jgss-windows-i586-bin.zip"
aoqi@0 1227 fi
aoqi@0 1228 OTHER_SEC_WINDOWS_BIN="$OTHER_SEC_DIR/sec-windows-bin.zip"
aoqi@0 1229 OTHER_JGSS_WINDOWS_BIN="$OTHER_SEC_DIR/$JGSS_WINDOWS_BIN"
aoqi@0 1230 THIS_SEC_WINDOWS_BIN="$THIS_SEC_DIR/sec-windows-bin.zip"
aoqi@0 1231 THIS_JGSS_WINDOWS_BIN="$THIS_SEC_DIR/$JGSS_WINDOWS_BIN"
aoqi@0 1232 fi
aoqi@0 1233
aoqi@0 1234 ##########################################################################################
aoqi@0 1235 # Do the work
aoqi@0 1236
aoqi@0 1237 if [ "$CMP_NAMES" = "true" ]; then
aoqi@0 1238 if [ -n "$THIS_J2SDK" ] && [ -n "$OTHER_J2SDK" ]; then
aoqi@0 1239 echo -n "J2SDK "
aoqi@0 1240 compare_dirs $THIS_J2SDK $OTHER_J2SDK $COMPARE_ROOT/j2sdk
aoqi@0 1241 echo -n "J2RE "
aoqi@0 1242 compare_dirs $THIS_J2RE $OTHER_J2RE $COMPARE_ROOT/j2re
aoqi@0 1243
aoqi@0 1244 echo -n "J2SDK "
aoqi@0 1245 compare_files $THIS_J2SDK $OTHER_J2SDK $COMPARE_ROOT/j2sdk
aoqi@0 1246 echo -n "J2RE "
aoqi@0 1247 compare_files $THIS_J2RE $OTHER_J2RE $COMPARE_ROOT/j2re
aoqi@0 1248 fi
aoqi@0 1249 if [ -n "$THIS_J2SDK_OVERLAY" ] && [ -n "$OTHER_J2SDK_OVERLAY" ]; then
aoqi@0 1250 echo -n "J2SDK Overlay "
aoqi@0 1251 compare_dirs $THIS_J2SDK_OVERLAY $OTHER_J2SDK_OVERLAY $COMPARE_ROOT/j2sdk-overlay
aoqi@0 1252 echo -n "J2RE Overlay "
aoqi@0 1253 compare_dirs $THIS_J2RE_OVERLAY $OTHER_J2RE_OVERLAY $COMPARE_ROOT/j2re-overlay
aoqi@0 1254
aoqi@0 1255 echo -n "J2SDK Overlay "
aoqi@0 1256 compare_files $THIS_J2SDK_OVERLAY $OTHER_J2SDK_OVERLAY $COMPARE_ROOT/j2sdk-overlay
aoqi@0 1257 echo -n "J2RE Overlay "
aoqi@0 1258 compare_files $THIS_J2RE_OVERLAY $OTHER_J2RE_OVERLAY $COMPARE_ROOT/j2re-overlay
aoqi@0 1259 fi
aoqi@0 1260 if [ -n "$THIS_J2SDK_BUNDLE" ] && [ -n "$OTHER_J2SDK_BUNDLE" ]; then
aoqi@0 1261 echo -n "J2SDK Bundle "
aoqi@0 1262 compare_dirs $THIS_J2SDK_BUNDLE $OTHER_J2SDK_BUNDLE $COMPARE_ROOT/j2sdk-bundle
aoqi@0 1263 echo -n "J2RE Bundle "
aoqi@0 1264 compare_dirs $THIS_J2RE_BUNDLE $OTHER_J2RE_BUNDLE $COMPARE_ROOT/j2re-bundle
aoqi@0 1265
aoqi@0 1266 echo -n "J2SDK Bundle "
aoqi@0 1267 compare_files $THIS_J2SDK_BUNDLE $OTHER_J2SDK_BUNDLE $COMPARE_ROOT/j2sdk-bundle
aoqi@0 1268 echo -n "J2RE Bundle "
aoqi@0 1269 compare_files $THIS_J2RE_BUNDLE $OTHER_J2RE_BUNDLE $COMPARE_ROOT/j2re-bundle
aoqi@0 1270 fi
aoqi@0 1271 if [ -n "$THIS_DOCS" ] && [ -n "$OTHER_DOCS" ]; then
aoqi@0 1272 echo -n "Docs "
aoqi@0 1273 compare_dirs $THIS_DOCS $OTHER_DOCS $COMPARE_ROOT/docs
aoqi@0 1274 echo -n "Docs "
aoqi@0 1275 compare_files $THIS_DOCS $OTHER_DOCS $COMPARE_ROOT/docs
aoqi@0 1276 fi
aoqi@0 1277 fi
aoqi@0 1278
aoqi@0 1279 if [ "$CMP_PERMS" = "true" ]; then
aoqi@0 1280 if [ -n "$THIS_J2SDK" ] && [ -n "$OTHER_J2SDK" ]; then
aoqi@0 1281 echo -n "J2SDK "
aoqi@0 1282 compare_permissions $THIS_J2SDK $OTHER_J2SDK $COMPARE_ROOT/j2sdk
aoqi@0 1283 echo -n "J2RE "
aoqi@0 1284 compare_permissions $THIS_J2RE $OTHER_J2RE $COMPARE_ROOT/j2re
aoqi@0 1285 fi
aoqi@0 1286 if [ -n "$THIS_J2SDK_OVERLAY" ] && [ -n "$OTHER_J2SDK_OVERLAY" ]; then
aoqi@0 1287 echo -n "J2SDK Overlay "
aoqi@0 1288 compare_permissions $THIS_J2SDK_OVERLAY $OTHER_J2SDK_OVERLAY $COMPARE_ROOT/j2sdk-overlay
aoqi@0 1289 echo -n "J2RE Overlay "
aoqi@0 1290 compare_permissions $THIS_J2RE_OVERLAY $OTHER_J2RE_OVERLAY $COMPARE_ROOT/j2re-overlay
aoqi@0 1291 fi
aoqi@0 1292 if [ -n "$THIS_J2SDK_BUNDLE" ] && [ -n "$OTHER_J2SDK_BUNDLE" ]; then
aoqi@0 1293 echo -n "J2SDK Bundle "
aoqi@0 1294 compare_permissions $THIS_J2SDK_BUNDLE $OTHER_J2SDK_BUNDLE $COMPARE_ROOT/j2sdk-bundle
aoqi@0 1295 echo -n "J2RE Bundle "
aoqi@0 1296 compare_permissions $THIS_J2RE_BUNDLE $OTHER_J2RE_BUNDLE $COMPARE_ROOT/j2re-bundle
aoqi@0 1297 fi
aoqi@0 1298 fi
aoqi@0 1299
aoqi@0 1300 if [ "$CMP_TYPES" = "true" ]; then
aoqi@0 1301 if [ -n "$THIS_J2SDK" ] && [ -n "$OTHER_J2SDK" ]; then
aoqi@0 1302 echo -n "J2SDK "
aoqi@0 1303 compare_file_types $THIS_J2SDK $OTHER_J2SDK $COMPARE_ROOT/j2sdk
aoqi@0 1304 echo -n "J2RE "
aoqi@0 1305 compare_file_types $THIS_J2RE $OTHER_J2RE $COMPARE_ROOT/j2re
aoqi@0 1306 fi
aoqi@0 1307 if [ -n "$THIS_J2SDK_OVERLAY" ] && [ -n "$OTHER_J2SDK_OVERLAY" ]; then
aoqi@0 1308 echo -n "J2SDK Overlay "
aoqi@0 1309 compare_file_types $THIS_J2SDK_OVERLAY $OTHER_J2SDK_OVERLAY $COMPARE_ROOT/j2sdk-overlay
aoqi@0 1310 echo -n "J2RE Overlay "
aoqi@0 1311 compare_file_types $THIS_J2RE_OVERLAY $OTHER_J2RE_OVERLAY $COMPARE_ROOT/j2re-overlay
aoqi@0 1312 fi
aoqi@0 1313 if [ -n "$THIS_J2SDK_BUNDLE" ] && [ -n "$OTHER_J2SDK_BUNDLE" ]; then
aoqi@0 1314 echo -n "J2SDK Bundle "
aoqi@0 1315 compare_file_types $THIS_J2SDK_BUNDLE $OTHER_J2SDK_BUNDLE $COMPARE_ROOT/j2sdk-bundle
aoqi@0 1316 echo -n "J2RE Bundle "
aoqi@0 1317 compare_file_types $THIS_J2RE_BUNDLE $OTHER_J2RE_BUNDLE $COMPARE_ROOT/j2re-bundle
aoqi@0 1318 fi
aoqi@0 1319 fi
aoqi@0 1320
aoqi@0 1321 if [ "$CMP_GENERAL" = "true" ]; then
aoqi@0 1322 if [ -n "$THIS_J2SDK" ] && [ -n "$OTHER_J2SDK" ]; then
aoqi@0 1323 echo -n "J2SDK "
aoqi@0 1324 compare_general_files $THIS_J2SDK $OTHER_J2SDK $COMPARE_ROOT/j2sdk
aoqi@0 1325 echo -n "J2RE "
aoqi@0 1326 compare_general_files $THIS_J2RE $OTHER_J2RE $COMPARE_ROOT/j2re
aoqi@0 1327 fi
aoqi@0 1328 if [ -n "$THIS_J2SDK_OVERLAY" ] && [ -n "$OTHER_J2SDK_OVERLAY" ]; then
aoqi@0 1329 echo -n "J2SDK Overlay "
aoqi@0 1330 compare_general_files $THIS_J2SDK_OVERLAY $OTHER_J2SDK_OVERLAY $COMPARE_ROOT/j2sdk-overlay
aoqi@0 1331 echo -n "J2RE Overlay "
aoqi@0 1332 compare_general_files $THIS_J2RE_OVERLAY $OTHER_J2RE_OVERLAY $COMPARE_ROOT/j2re-overlay
aoqi@0 1333 fi
aoqi@0 1334 if [ -n "$THIS_J2SDK_BUNDLE" ] && [ -n "$OTHER_J2SDK_BUNDLE" ]; then
aoqi@0 1335 echo -n "J2SDK Bundle "
aoqi@0 1336 compare_general_files $THIS_J2SDK_BUNDLE $OTHER_J2SDK_BUNDLE $COMPARE_ROOT/j2sdk-bundle
aoqi@0 1337 echo -n "J2RE Bundle "
aoqi@0 1338 compare_general_files $THIS_J2RE_BUNDLE $OTHER_J2RE_BUNDLE $COMPARE_ROOT/j2re-bundle
aoqi@0 1339 fi
aoqi@0 1340 if [ -n "$THIS_DOCS" ] && [ -n "$OTHER_DOCS" ]; then
aoqi@0 1341 echo -n "Docs "
aoqi@0 1342 compare_general_files $THIS_DOCS $OTHER_DOCS $COMPARE_ROOT/docs
aoqi@0 1343 fi
aoqi@0 1344 fi
aoqi@0 1345
aoqi@0 1346 if [ "$CMP_ZIPS" = "true" ]; then
aoqi@0 1347 if [ -n "$THIS_J2SDK" ] && [ -n "$OTHER_J2SDK" ]; then
aoqi@0 1348 compare_all_zip_files $THIS_J2SDK $OTHER_J2SDK $COMPARE_ROOT/j2sdk
aoqi@0 1349 fi
aoqi@0 1350 if [ -n "$THIS_SEC_BIN" ] && [ -n "$OTHER_SEC_BIN" ]; then
aoqi@0 1351 if [ -n "$(echo $THIS_SEC_BIN | $FILTER)" ]; then
aoqi@0 1352 echo "sec-bin.zip..."
aoqi@0 1353 compare_zip_file $THIS_SEC_DIR $OTHER_SEC_DIR $COMPARE_ROOT/sec-bin sec-bin.zip
aoqi@0 1354 fi
aoqi@0 1355 fi
aoqi@0 1356 if [ -n "$THIS_SEC_WINDOWS_BIN" ] && [ -n "$OTHER_SEC_WINDOWS_BIN" ]; then
aoqi@0 1357 if [ -n "$(echo $THIS_SEC_WINDOWS_BIN | $FILTER)" ]; then
aoqi@0 1358 echo "sec-windows-bin.zip..."
aoqi@0 1359 compare_zip_file $THIS_SEC_DIR $OTHER_SEC_DIR $COMPARE_ROOT/sec-bin sec-windows-bin.zip
aoqi@0 1360 fi
aoqi@0 1361 fi
aoqi@0 1362 if [ -n "$THIS_JGSS_WINDOWS_BIN" ] && [ -n "$OTHER_JGSS_WINDOWS_BIN" ]; then
aoqi@0 1363 if [ -n "$(echo $THIS_JGSS_WINDOWS_BIN | $FILTER)" ]; then
aoqi@0 1364 echo "$JGSS_WINDOWS_BIN..."
aoqi@0 1365 compare_zip_file $THIS_SEC_DIR $OTHER_SEC_DIR $COMPARE_ROOT/sec-bin $JGSS_WINDOWS_BIN
aoqi@0 1366 fi
aoqi@0 1367 fi
aoqi@0 1368 fi
aoqi@0 1369
aoqi@0 1370 if [ "$CMP_JARS" = "true" ]; then
aoqi@0 1371 if [ -n "$THIS_J2SDK" ] && [ -n "$OTHER_J2SDK" ]; then
aoqi@0 1372 compare_all_jar_files $THIS_J2SDK $OTHER_J2SDK $COMPARE_ROOT/j2sdk
aoqi@0 1373 fi
aoqi@0 1374 fi
aoqi@0 1375
aoqi@0 1376 if [ "$CMP_LIBS" = "true" ]; then
aoqi@0 1377 if [ -n "$THIS_J2SDK" ] && [ -n "$OTHER_J2SDK" ]; then
aoqi@0 1378 echo -n "J2SDK "
aoqi@0 1379 compare_all_libs $THIS_J2SDK $OTHER_J2SDK $COMPARE_ROOT/j2sdk
aoqi@0 1380 if [ "$OPENJDK_TARGET_OS" = "macosx" ]; then
aoqi@0 1381 echo -n "J2RE "
aoqi@0 1382 compare_all_libs $THIS_J2RE $OTHER_J2RE $COMPARE_ROOT/j2re
aoqi@0 1383 fi
aoqi@0 1384 fi
aoqi@0 1385 if [ -n "$THIS_J2SDK_OVERLAY" ] && [ -n "$OTHER_J2SDK_OVERLAY" ]; then
aoqi@0 1386 echo -n "Bundle "
aoqi@0 1387 compare_all_libs $THIS_J2SDK_OVERLAY $OTHER_J2SDK_OVERLAY $COMPARE_ROOT/j2sdk-overlay
aoqi@0 1388 fi
aoqi@0 1389 fi
aoqi@0 1390
aoqi@0 1391 if [ "$CMP_EXECS" = "true" ]; then
aoqi@0 1392 if [ -n "$THIS_J2SDK" ] && [ -n "$OTHER_J2SDK" ]; then
aoqi@0 1393 compare_all_execs $THIS_J2SDK $OTHER_J2SDK $COMPARE_ROOT/j2sdk
aoqi@0 1394 fi
aoqi@0 1395 if [ -n "$THIS_J2SDK_OVERLAY" ] && [ -n "$OTHER_J2SDK_OVERLAY" ]; then
aoqi@0 1396 echo -n "Overlay "
aoqi@0 1397 compare_all_execs $THIS_J2SDK_OVERLAY $OTHER_J2SDK_OVERLAY $COMPARE_ROOT/j2sdk-overlay
aoqi@0 1398 fi
aoqi@0 1399 fi
aoqi@0 1400
aoqi@0 1401 echo
aoqi@0 1402
aoqi@0 1403 if [ -n "$REGRESSIONS" ]; then
aoqi@0 1404 echo "REGRESSIONS FOUND!"
aoqi@0 1405 echo
aoqi@0 1406 exit 1
aoqi@0 1407 else
aoqi@0 1408 echo "No regressions found"
aoqi@0 1409 echo
aoqi@0 1410 exit 0
aoqi@0 1411 fi

mercurial