| OLD | NEW |
| 1 #!/bin/sh | 1 #!/bin/sh |
| 2 | 2 |
| 3 # Copyright (c) 2008, Google Inc. | 3 # Copyright (c) 2008, Google Inc. |
| 4 # All rights reserved. | 4 # All rights reserved. |
| 5 # | 5 # |
| 6 # Redistribution and use in source and binary forms, with or without | 6 # Redistribution and use in source and binary forms, with or without |
| 7 # modification, are permitted provided that the following conditions are | 7 # modification, are permitted provided that the following conditions are |
| 8 # met: | 8 # met: |
| 9 # | 9 # |
| 10 # * Redistributions of source code must retain the above copyright | 10 # * Redistributions of source code must retain the above copyright |
| (...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 55 SAMPLING_TEST_BINARY=`"$SAMPLING_TEST" 2>&1 | awk '/USAGE/ {print $2; exit;}'` | 55 SAMPLING_TEST_BINARY=`"$SAMPLING_TEST" 2>&1 | awk '/USAGE/ {print $2; exit;}'` |
| 56 | 56 |
| 57 # A kludge for cygwin. Unfortunately, 'test -f' says that 'foo' exists | 57 # A kludge for cygwin. Unfortunately, 'test -f' says that 'foo' exists |
| 58 # even when it doesn't, and only foo.exe exists. Other unix utilities | 58 # even when it doesn't, and only foo.exe exists. Other unix utilities |
| 59 # (like nm) need you to say 'foo.exe'. We use one such utility, cat, to | 59 # (like nm) need you to say 'foo.exe'. We use one such utility, cat, to |
| 60 # see what the *real* binary name is. | 60 # see what the *real* binary name is. |
| 61 if ! cat "$SAMPLING_TEST_BINARY" >/dev/null 2>&1; then | 61 if ! cat "$SAMPLING_TEST_BINARY" >/dev/null 2>&1; then |
| 62 SAMPLING_TEST_BINARY="$SAMPLING_TEST_BINARY".exe | 62 SAMPLING_TEST_BINARY="$SAMPLING_TEST_BINARY".exe |
| 63 fi | 63 fi |
| 64 | 64 |
| 65 die() { # runs the command given as arguments, and then dies. | 65 die() { |
| 66 echo "FAILED. Output from $@" | 66 echo "FAILED" |
| 67 echo "----" | 67 echo "reason:" |
| 68 "$@" | 68 echo "$@" |
| 69 echo "----" | 69 echo "----" |
| 70 exit 1 | 70 exit 1 |
| 71 } | 71 } |
| 72 | 72 |
| 73 rm -rf "$OUTDIR" || die "Unable to delete $OUTDIR" | 73 rm -rf "$OUTDIR" || die "Unable to delete $OUTDIR" |
| 74 mkdir "$OUTDIR" || die "Unable to create $OUTDIR" | 74 mkdir "$OUTDIR" || die "Unable to create $OUTDIR" |
| 75 | 75 |
| 76 # This puts the output into out.heap and out.growth. It allocates | 76 # This puts the output into out.heap and out.growth. It allocates |
| 77 # 8*10^7 bytes of memory, which is 76M. Because we sample, the | 77 # 8*10^7 bytes of memory, which is 76M. Because we sample, the |
| 78 # estimate may be a bit high or a bit low: we accept anything from | 78 # estimate may be a bit high or a bit low: we accept anything from |
| 79 # 50M to 99M. | 79 # 50M to 99M. |
| 80 "$SAMPLING_TEST" "$OUTDIR/out" | 80 "$SAMPLING_TEST" "$OUTDIR/out" |
| 81 | 81 |
| 82 echo "Testing heap output..." | 82 echo -n "Testing heap output..." |
| 83 "$PPROF" --text "$SAMPLING_TEST_BINARY" "$OUTDIR/out.heap" \ | 83 "$PPROF" --text "$SAMPLING_TEST_BINARY" "$OUTDIR/out.heap" \ |
| 84 | grep '^ *[5-9][0-9]\.[0-9][ 0-9.%]*_*AllocateAllocate' >/dev/null \ | 84 | grep '^ *[5-9][0-9]\.[0-9][ 0-9.%]*_*AllocateAllocate' >/dev/null \ |
| 85 || die "$PPROF" --text "$SAMPLING_TEST_BINARY" "$OUTDIR/out.heap" | 85 || die `"$PPROF" --text "$SAMPLING_TEST_BINARY" "$OUTDIR/out.heap"` |
| 86 echo "OK" | 86 echo "OK" |
| 87 | 87 |
| 88 echo "Testing growth output..." | 88 echo -n "Testing growth output..." |
| 89 "$PPROF" --text "$SAMPLING_TEST_BINARY" "$OUTDIR/out.growth" \ | 89 "$PPROF" --text "$SAMPLING_TEST_BINARY" "$OUTDIR/out.growth" \ |
| 90 | grep '^ *[5-9][0-9]\.[0-9][ 0-9.%]*_*AllocateAllocate' >/dev/null \ | 90 | grep '^ *[5-9][0-9]\.[0-9][ 0-9.%]*_*AllocateAllocate' >/dev/null \ |
| 91 || die "$PPROF" --text "$SAMPLING_TEST_BINARY" "$OUTDIR/out.growth" | 91 || die `"$PPROF" --text "$SAMPLING_TEST_BINARY" "$OUTDIR/out.growth"` |
| 92 echo "OK" | 92 echo "OK" |
| 93 | 93 |
| 94 echo "PASS" | 94 echo "PASS" |
| OLD | NEW |