Home | History | Annotate | Download | only in 112-dex-return-jsr-result
      1 #!/bin/bash
      2 #
      3 # Copyright (C) 2010 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 # The awk fun here tries to cull out all but the salient bits. The aim
     18 # is to check to see that there are two invoke-static instructions, each
     19 # followed directly by a move-result-object.
     20 
     21 dx --debug --dex --dump-to=- --dump-method=blort.zorch --dump-width=200 \
     22     blort.class | awk '
     23 
     24 BEGIN {
     25     invokeAt = -1;
     26     moveAt = -1;
     27     invokeCount = 0;
     28     failed = 0;
     29 }
     30 
     31 # Note: This has to be done before the test clause below.
     32 /move-result-object/ {
     33     moveAt = NR;
     34 }
     35 
     36 (invokeAt > 0) {
     37     if (moveAt != (invokeAt + 1)) {
     38         failed = 1;
     39     }
     40     invokeAt = -1;
     41     moveAt = -1;
     42 }
     43 
     44 # Note: This has to be done after the test clause above.
     45 /invoke-static/ {
     46     invokeAt = NR;
     47     invokeCount++;
     48 }
     49 
     50 END {
     51     printf("total invokes: %d\n", invokeCount);
     52     if (failed) {
     53         exit 1;
     54     }
     55 }
     56 '
     57 
     58 if [ "$?" = "1" ]; then
     59     # The test failed. Be helpful and print the entire method body.
     60     dx --debug --dex --dump-to=- --dump-method=blort.zorch --dump-width=200 \
     61         blort.class
     62 fi
     63