File: test.sh

package info (click to toggle)
chromium 138.0.7204.183-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 6,071,908 kB
  • sloc: cpp: 34,937,088; ansic: 7,176,967; javascript: 4,110,704; python: 1,419,953; asm: 946,768; xml: 739,971; pascal: 187,324; sh: 89,623; perl: 88,663; objc: 79,944; sql: 50,304; cs: 41,786; fortran: 24,137; makefile: 21,806; php: 13,980; tcl: 13,166; yacc: 8,925; ruby: 7,485; awk: 3,720; lisp: 3,096; lex: 1,327; ada: 727; jsp: 228; sed: 36
file content (82 lines) | stat: -rwxr-xr-x 2,872 bytes parent folder | download | duplicates (8)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
#!/bin/bash

function run_test() {
  # Generate test proto files.
  $1 -Iprotos/src -I../../../src/ --csharp_out=src/Google.Protobuf.Test \
    --csharp_opt=base_namespace=Google.Protobuf \
    protos/src/google/protobuf/unittest_import_proto3.proto \
    protos/src/google/protobuf/unittest_import_public_proto3.proto \
    protos/src/google/protobuf/unittest_well_known_types.proto

  $1 -Iprotos/csharp --csharp_out=src/Google.Protobuf.Test \
    --csharp_opt=base_namespace=UnitTest.Issues \
    protos/csharp/protos/unittest_issues.proto

  $2 -Iprotos/src --csharp_out=src/Google.Protobuf.Test \
    --csharp_opt=base_namespace=Google.Protobuf \
    protos/src/google/protobuf/unittest_proto3.proto \
    protos/src/google/protobuf/map_unittest_proto3.proto

  # Build and test.
  dotnet restore src/Google.Protobuf/Google.Protobuf.csproj
  dotnet restore src/Google.Protobuf.Test/Google.Protobuf.Test.csproj
  dotnet build -c Release src/Google.Protobuf/Google.Protobuf.csproj
  dotnet build -c Release src/Google.Protobuf.Test/Google.Protobuf.Test.csproj
  dotnet run -c Release -f net6.0 -p src/Google.Protobuf.Test/Google.Protobuf.Test.csproj
}

set -ex

PROTOC=$(realpath ${2:-../../../bazel-bin/protoc})

# Change to the script's directory.
cd $(dirname $0)

# Version of the tests (i.e., the version of protobuf from where we extracted
# these tests).
TEST_VERSION=3.0.0

# The old version of protobuf that we are testing compatibility against. This
# is usually the same as TEST_VERSION (i.e., we use the tests extracted from
# that version to test compatibility of the newest runtime against it), but it
# is also possible to use this same test set to test the compatibility of the
# latest version against other versions.
OLD_VERSION=$1
OLD_VERSION_PROTOC=https://repo1.maven.org/maven2/com/google/protobuf/protoc/$OLD_VERSION/protoc-$OLD_VERSION-linux-x86_64.exe

echo "Running compatibility tests with $OLD_VERSION"

# Check protoc
[ -f $PROTOC ] || {
  echo "[ERROR]: Please build protoc first."
  exit 1
}

# Download old version protoc compiler (for linux).
wget $OLD_VERSION_PROTOC -O old_protoc
chmod +x old_protoc

# Test source compatibility. In these tests we recompile everything against
# the new runtime (including old version generated code).
# Copy the new runtime and keys.
cp ../../src/Google.Protobuf src/Google.Protobuf -r
cp ../../keys . -r

# Test A.1:
#   proto set 1: use old version
#   proto set 2 which may import protos in set 1: use old version
run_test "./old_protoc" "./old_protoc"

# Test A.2:
#   proto set 1: use new version
#   proto set 2 which may import protos in set 1: use old version
run_test "$PROTOC" "./old_protoc"

# Test A.3:
#   proto set 1: use old version
#   proto set 2 which may import protos in set 1: use new version
run_test "./old_protoc" "$PROTOC"

rm old_protoc
rm keys -r
rm src/Google.Protobuf -r