/thirdparty/breakpad/third_party/protobuf/protobuf/src/google/protobuf/compiler/zip_output_unittest.sh

http://github.com/tomahawk-player/tomahawk · Shell · 91 lines · 47 code · 10 blank · 34 comment · 13 complexity · 7edd5523c9535893ac792ac396ef4315 MD5 · raw file

  1. #!/bin/sh
  2. #
  3. # Protocol Buffers - Google's data interchange format
  4. # Copyright 2009 Google Inc. All rights reserved.
  5. # http://code.google.com/p/protobuf/
  6. #
  7. # Redistribution and use in source and binary forms, with or without
  8. # modification, are permitted provided that the following conditions are
  9. # met:
  10. #
  11. # * Redistributions of source code must retain the above copyright
  12. # notice, this list of conditions and the following disclaimer.
  13. # * Redistributions in binary form must reproduce the above
  14. # copyright notice, this list of conditions and the following disclaimer
  15. # in the documentation and/or other materials provided with the
  16. # distribution.
  17. # * Neither the name of Google Inc. nor the names of its
  18. # contributors may be used to endorse or promote products derived from
  19. # this software without specific prior written permission.
  20. #
  21. # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  22. # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  23. # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  24. # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  25. # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  26. # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  27. # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  28. # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  29. # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  30. # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  31. # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  32. # Author: kenton@google.com (Kenton Varda)
  33. #
  34. # Test protoc's zip output mode.
  35. fail() {
  36. echo "$@" >&2
  37. exit 1
  38. }
  39. TEST_TMPDIR=.
  40. PROTOC=./protoc
  41. echo '
  42. syntax = "proto2";
  43. option java_multiple_files = true;
  44. option java_package = "test.jar";
  45. option java_outer_classname = "Outer";
  46. message Foo {}
  47. message Bar {}
  48. ' > $TEST_TMPDIR/testzip.proto
  49. $PROTOC \
  50. --cpp_out=$TEST_TMPDIR/testzip.zip --python_out=$TEST_TMPDIR/testzip.zip \
  51. --java_out=$TEST_TMPDIR/testzip.jar -I$TEST_TMPDIR testzip.proto \
  52. || fail 'protoc failed.'
  53. echo "Testing output to zip..."
  54. if unzip -h > /dev/null; then
  55. unzip -t $TEST_TMPDIR/testzip.zip > $TEST_TMPDIR/testzip.list || fail 'unzip failed.'
  56. grep 'testing: testzip\.pb\.cc *OK$' $TEST_TMPDIR/testzip.list > /dev/null \
  57. || fail 'testzip.pb.cc not found in output zip.'
  58. grep 'testing: testzip\.pb\.h *OK$' $TEST_TMPDIR/testzip.list > /dev/null \
  59. || fail 'testzip.pb.h not found in output zip.'
  60. grep 'testing: testzip_pb2\.py *OK$' $TEST_TMPDIR/testzip.list > /dev/null \
  61. || fail 'testzip_pb2.py not found in output zip.'
  62. grep -i 'manifest' $TEST_TMPDIR/testzip.list > /dev/null \
  63. && fail 'Zip file contained manifest.'
  64. else
  65. echo "Warning: 'unzip' command not available. Skipping test."
  66. fi
  67. echo "Testing output to jar..."
  68. if jar c $TEST_TMPDIR/testzip.proto > /dev/null; then
  69. jar tf $TEST_TMPDIR/testzip.jar > $TEST_TMPDIR/testzip.list || fail 'jar failed.'
  70. grep '^test/jar/Foo\.java$' $TEST_TMPDIR/testzip.list > /dev/null \
  71. || fail 'Foo.java not found in output jar.'
  72. grep '^test/jar/Bar\.java$' $TEST_TMPDIR/testzip.list > /dev/null \
  73. || fail 'Bar.java not found in output jar.'
  74. grep '^test/jar/Outer\.java$' $TEST_TMPDIR/testzip.list > /dev/null \
  75. || fail 'Outer.java not found in output jar.'
  76. grep '^META-INF/MANIFEST\.MF$' $TEST_TMPDIR/testzip.list > /dev/null \
  77. || fail 'Manifest not found in output jar.'
  78. else
  79. echo "Warning: 'jar' command not available. Skipping test."
  80. fi
  81. echo PASS