• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/bash
2
3function run_test() {
4  # Generate test proto files.
5  $1 -Iprotos/src -I../../../src/ --csharp_out=src/Google.Protobuf.Test \
6    --csharp_opt=base_namespace=Google.Protobuf \
7    protos/src/google/protobuf/unittest_import_proto3.proto \
8    protos/src/google/protobuf/unittest_import_public_proto3.proto \
9    protos/src/google/protobuf/unittest_well_known_types.proto
10
11  $1 -Iprotos/csharp --csharp_out=src/Google.Protobuf.Test \
12    --csharp_opt=base_namespace=UnitTest.Issues \
13    protos/csharp/protos/unittest_issues.proto
14
15  $2 -Iprotos/src --csharp_out=src/Google.Protobuf.Test \
16    --csharp_opt=base_namespace=Google.Protobuf \
17    protos/src/google/protobuf/unittest_proto3.proto \
18    protos/src/google/protobuf/map_unittest_proto3.proto
19
20  # Build and test.
21  dotnet restore src/Google.Protobuf/Google.Protobuf.csproj
22  dotnet restore src/Google.Protobuf.Test/Google.Protobuf.Test.csproj
23  dotnet build -c Release src/Google.Protobuf/Google.Protobuf.csproj
24  dotnet build -c Release src/Google.Protobuf.Test/Google.Protobuf.Test.csproj
25  dotnet run -c Release -f netcoreapp2.1 -p src/Google.Protobuf.Test/Google.Protobuf.Test.csproj
26}
27
28set -ex
29
30# Change to the script's directory.
31cd $(dirname $0)
32
33# Version of the tests (i.e., the version of protobuf from where we extracted
34# these tests).
35TEST_VERSION=3.0.0
36
37# The old version of protobuf that we are testing compatibility against. This
38# is usually the same as TEST_VERSION (i.e., we use the tests extracted from
39# that version to test compatibility of the newest runtime against it), but it
40# is also possible to use this same test set to test the compatibiilty of the
41# latest version against other versions.
42case "$1" in
43  ""|3.0.0)
44    OLD_VERSION=3.0.0
45    OLD_VERSION_PROTOC=http://repo1.maven.org/maven2/com/google/protobuf/protoc/3.0.0/protoc-3.0.0-linux-x86_64.exe
46    ;;
47  3.0.2)
48    OLD_VERSION=3.0.2
49    OLD_VERSION_PROTOC=http://repo1.maven.org/maven2/com/google/protobuf/protoc/3.0.2/protoc-3.0.2-linux-x86_64.exe
50    ;;
51  3.1.0)
52    OLD_VERSION=3.1.0
53    OLD_VERSION_PROTOC=http://repo1.maven.org/maven2/com/google/protobuf/protoc/3.1.0/protoc-3.1.0-linux-x86_64.exe
54    ;;
55  *)
56    echo "[ERROR]: Unknown version number: $1"
57    exit 1
58    ;;
59esac
60
61echo "Running compatibility tests with $OLD_VERSION"
62
63# Check protoc
64[ -f ../../../src/protoc ] || {
65  echo "[ERROR]: Please build protoc first."
66  exit 1
67}
68
69# Download old version protoc compiler (for linux).
70wget $OLD_VERSION_PROTOC -O old_protoc
71chmod +x old_protoc
72
73# Test source compatibility. In these tests we recompile everything against
74# the new runtime (including old version generated code).
75# Copy the new runtime and keys.
76cp ../../src/Google.Protobuf src/Google.Protobuf -r
77cp ../../keys . -r
78
79# Test A.1:
80#   proto set 1: use old version
81#   proto set 2 which may import protos in set 1: use old version
82run_test "./old_protoc" "./old_protoc"
83
84# Test A.2:
85#   proto set 1: use new version
86#   proto set 2 which may import protos in set 1: use old version
87run_test "../../../src/protoc" "./old_protoc"
88
89# Test A.3:
90#   proto set 1: use old version
91#   proto set 2 which may import protos in set 1: use new version
92run_test "./old_protoc" "../../../src/protoc"
93
94rm old_protoc
95rm keys -r
96rm src/Google.Protobuf -r
97