kenton@google.com | d2fcbba | 2010-01-04 19:47:18 +0000 | [diff] [blame] | 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 | |
| 33 | # Author: kenton@google.com (Kenton Varda) |
| 34 | # |
| 35 | # Test protoc's zip output mode. |
| 36 | |
kenton@google.com | 38fcd39 | 2010-01-08 04:48:19 +0000 | [diff] [blame] | 37 | fail() { |
kenton@google.com | d2fcbba | 2010-01-04 19:47:18 +0000 | [diff] [blame] | 38 | echo "$@" >&2 |
| 39 | exit 1 |
| 40 | } |
| 41 | |
liujisi@google.com | 33165fe | 2010-11-02 13:14:58 +0000 | [diff] [blame^] | 42 | TEST_TMPDIR=. |
| 43 | PROTOC=./protoc |
| 44 | |
kenton@google.com | d2fcbba | 2010-01-04 19:47:18 +0000 | [diff] [blame] | 45 | echo ' |
liujisi@google.com | 33165fe | 2010-11-02 13:14:58 +0000 | [diff] [blame^] | 46 | syntax = "proto2"; |
kenton@google.com | d2fcbba | 2010-01-04 19:47:18 +0000 | [diff] [blame] | 47 | option java_multiple_files = true; |
| 48 | option java_package = "test.jar"; |
| 49 | option java_outer_classname = "Outer"; |
| 50 | message Foo {} |
| 51 | message Bar {} |
liujisi@google.com | 33165fe | 2010-11-02 13:14:58 +0000 | [diff] [blame^] | 52 | ' > $TEST_TMPDIR/testzip.proto |
kenton@google.com | d2fcbba | 2010-01-04 19:47:18 +0000 | [diff] [blame] | 53 | |
liujisi@google.com | 33165fe | 2010-11-02 13:14:58 +0000 | [diff] [blame^] | 54 | $PROTOC \ |
| 55 | --cpp_out=$TEST_TMPDIR/testzip.zip --python_out=$TEST_TMPDIR/testzip.zip \ |
| 56 | --java_out=$TEST_TMPDIR/testzip.jar -I$TEST_TMPDIR testzip.proto \ |
| 57 | || fail 'protoc failed.' |
kenton@google.com | d2fcbba | 2010-01-04 19:47:18 +0000 | [diff] [blame] | 58 | |
| 59 | echo "Testing output to zip..." |
| 60 | if unzip -h > /dev/null; then |
liujisi@google.com | 33165fe | 2010-11-02 13:14:58 +0000 | [diff] [blame^] | 61 | unzip -t $TEST_TMPDIR/testzip.zip > $TEST_TMPDIR/testzip.list || fail 'unzip failed.' |
kenton@google.com | d2fcbba | 2010-01-04 19:47:18 +0000 | [diff] [blame] | 62 | |
liujisi@google.com | 33165fe | 2010-11-02 13:14:58 +0000 | [diff] [blame^] | 63 | grep 'testing: testzip\.pb\.cc *OK$' $TEST_TMPDIR/testzip.list > /dev/null \ |
kenton@google.com | d2fcbba | 2010-01-04 19:47:18 +0000 | [diff] [blame] | 64 | || fail 'testzip.pb.cc not found in output zip.' |
liujisi@google.com | 33165fe | 2010-11-02 13:14:58 +0000 | [diff] [blame^] | 65 | grep 'testing: testzip\.pb\.h *OK$' $TEST_TMPDIR/testzip.list > /dev/null \ |
kenton@google.com | d2fcbba | 2010-01-04 19:47:18 +0000 | [diff] [blame] | 66 | || fail 'testzip.pb.h not found in output zip.' |
liujisi@google.com | 33165fe | 2010-11-02 13:14:58 +0000 | [diff] [blame^] | 67 | grep 'testing: testzip_pb2\.py *OK$' $TEST_TMPDIR/testzip.list > /dev/null \ |
kenton@google.com | d2fcbba | 2010-01-04 19:47:18 +0000 | [diff] [blame] | 68 | || fail 'testzip_pb2.py not found in output zip.' |
liujisi@google.com | 33165fe | 2010-11-02 13:14:58 +0000 | [diff] [blame^] | 69 | grep -i 'manifest' $TEST_TMPDIR/testzip.list > /dev/null \ |
kenton@google.com | d2fcbba | 2010-01-04 19:47:18 +0000 | [diff] [blame] | 70 | && fail 'Zip file contained manifest.' |
| 71 | else |
| 72 | echo "Warning: 'unzip' command not available. Skipping test." |
| 73 | fi |
| 74 | |
| 75 | echo "Testing output to jar..." |
liujisi@google.com | 33165fe | 2010-11-02 13:14:58 +0000 | [diff] [blame^] | 76 | if jar c $TEST_TMPDIR/testzip.proto > /dev/null; then |
| 77 | jar tf $TEST_TMPDIR/testzip.jar > $TEST_TMPDIR/testzip.list || fail 'jar failed.' |
kenton@google.com | d2fcbba | 2010-01-04 19:47:18 +0000 | [diff] [blame] | 78 | |
liujisi@google.com | 33165fe | 2010-11-02 13:14:58 +0000 | [diff] [blame^] | 79 | grep '^test/jar/Foo\.java$' $TEST_TMPDIR/testzip.list > /dev/null \ |
kenton@google.com | d2fcbba | 2010-01-04 19:47:18 +0000 | [diff] [blame] | 80 | || fail 'Foo.java not found in output jar.' |
liujisi@google.com | 33165fe | 2010-11-02 13:14:58 +0000 | [diff] [blame^] | 81 | grep '^test/jar/Bar\.java$' $TEST_TMPDIR/testzip.list > /dev/null \ |
kenton@google.com | d2fcbba | 2010-01-04 19:47:18 +0000 | [diff] [blame] | 82 | || fail 'Bar.java not found in output jar.' |
liujisi@google.com | 33165fe | 2010-11-02 13:14:58 +0000 | [diff] [blame^] | 83 | grep '^test/jar/Outer\.java$' $TEST_TMPDIR/testzip.list > /dev/null \ |
kenton@google.com | d2fcbba | 2010-01-04 19:47:18 +0000 | [diff] [blame] | 84 | || fail 'Outer.java not found in output jar.' |
liujisi@google.com | 33165fe | 2010-11-02 13:14:58 +0000 | [diff] [blame^] | 85 | grep '^META-INF/MANIFEST\.MF$' $TEST_TMPDIR/testzip.list > /dev/null \ |
| 86 | || fail 'Manifest not found in output jar.' |
kenton@google.com | d2fcbba | 2010-01-04 19:47:18 +0000 | [diff] [blame] | 87 | else |
| 88 | echo "Warning: 'jar' command not available. Skipping test." |
| 89 | fi |
| 90 | |
| 91 | echo PASS |