Anton Hansson | c02eb52 | 2020-12-30 11:33:31 +0000 | [diff] [blame] | 1 | #!/bin/bash -e |
| 2 | # |
| 3 | # Copyright (C) 2021 The Android Open Source Project |
| 4 | # |
| 5 | # Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | # you may not use this file except in compliance with the License. |
| 7 | # You may obtain a copy of the License at |
| 8 | # |
| 9 | # http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | # |
| 11 | # Unless required by applicable law or agreed to in writing, software |
| 12 | # distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | # See the License for the specific language governing permissions and |
| 15 | # limitations under the License. |
| 16 | |
| 17 | # Verifies the tool correctly prints the binary representation of a db. |
| 18 | function test_print_binary() { |
| 19 | # Golden binary rep generated with: |
| 20 | # $ gqui from textproto:testdata/test_extensions_db.textpb \ |
| 21 | # proto extensions_db.proto:ExtensionDatabase \ |
| 22 | # --outfile rawproto:- | xxd -p |
| 23 | cat > golden_binary << EOF |
| 24 | 0a0a080112060803120208010a1a08021206080312020801120608021202 |
| 25 | 080212060801120208020a1a080312060803120208031206080212020802 |
| 26 | 12060801120208020a220804120608031202080312060802120208021206 |
| 27 | 0801120208041206080512020804 |
| 28 | EOF |
| 29 | |
| 30 | diff golden_binary <(gen_sdk --action print_binary --database testdata/test_extensions_db.textpb | xxd -p) |
| 31 | } |
| 32 | test_print_binary |
Anton Hansson | c6328fe | 2020-12-30 11:33:31 +0000 | [diff] [blame^] | 33 | |
| 34 | # Verifies the tool is able to re-create the test DB correctly. |
| 35 | function test_new_sdk() { |
| 36 | rm -f extensions_db.textpb && touch extensions_db.textpb |
| 37 | gen_sdk --action new_sdk --sdk 1 --modules MEDIA_PROVIDER |
| 38 | gen_sdk --action new_sdk --sdk 2 --modules MEDIA,IPSEC |
| 39 | gen_sdk --action new_sdk --sdk 3 --modules MEDIA_PROVIDER |
| 40 | gen_sdk --action new_sdk --sdk 4 --modules SDK_EXTENSIONS,IPSEC |
| 41 | |
| 42 | diff -u0 testdata/test_extensions_db.textpb extensions_db.textpb |
| 43 | } |
| 44 | test_new_sdk |