| OLD | NEW | 
| (Empty) |  | 
 |   1 // Copyright 2013 the V8 project authors. All rights reserved. | 
 |   2 // Redistribution and use in source and binary forms, with or without | 
 |   3 // modification, are permitted provided that the following conditions are met: | 
 |   4 // | 
 |   5 //   * Redistributions of source code must retain the above copyright notice, | 
 |   6 //     this list of conditions and the following disclaimer. | 
 |   7 //   * Redistributions in binary form must reproduce the above copyright notice, | 
 |   8 //     this list of conditions and the following disclaimer in the documentation | 
 |   9 //     and/or other materials provided with the distribution. | 
 |  10 //   * Neither the name of ARM Limited nor the names of its contributors may be | 
 |  11 //     used to endorse or promote products derived from this software without | 
 |  12 //     specific prior written permission. | 
 |  13 // | 
 |  14 // THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS CONTRIBUTORS "AS IS" AND | 
 |  15 // ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | 
 |  16 // WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | 
 |  17 // DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE | 
 |  18 // FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL | 
 |  19 // DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR | 
 |  20 // SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER | 
 |  21 // CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | 
 |  22 // OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | 
 |  23 // OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | 
 |  24  | 
 |  25 #include <stdlib.h> | 
 |  26 #include "cctest.h" | 
 |  27  | 
 |  28 #include "a64/decoder-a64.h" | 
 |  29 #include "a64/disasm-a64.h" | 
 |  30  | 
 |  31 using namespace v8::internal; | 
 |  32  | 
 |  33 TEST(FUZZ_decoder) { | 
 |  34   // Feed noise into the decoder to check that it doesn't crash. | 
 |  35   // 43 million = ~1% of the instruction space. | 
 |  36   static const int instruction_count = 43 * 1024 * 1024; | 
 |  37  | 
 |  38   uint16_t seed[3] = {1, 2, 3}; | 
 |  39   seed48(seed); | 
 |  40  | 
 |  41   Decoder decoder; | 
 |  42   Instruction buffer[kInstructionSize]; | 
 |  43  | 
 |  44   for (int i = 0; i < instruction_count; i++) { | 
 |  45     uint32_t instr = mrand48(); | 
 |  46     buffer->SetInstructionBits(instr); | 
 |  47     decoder.Decode(buffer); | 
 |  48   } | 
 |  49 } | 
 |  50  | 
 |  51  | 
 |  52 TEST(FUZZ_disasm) { | 
 |  53   // Feed noise into the disassembler to check that it doesn't crash. | 
 |  54   // 9 million = ~0.2% of the instruction space. | 
 |  55   static const int instruction_count = 9 * 1024 * 1024; | 
 |  56  | 
 |  57   uint16_t seed[3] = {42, 43, 44}; | 
 |  58   seed48(seed); | 
 |  59  | 
 |  60   Decoder decoder; | 
 |  61   Disassembler disasm; | 
 |  62   Instruction buffer[kInstructionSize]; | 
 |  63  | 
 |  64   decoder.AppendVisitor(&disasm); | 
 |  65   for (int i = 0; i < instruction_count; i++) { | 
 |  66     uint32_t instr = mrand48(); | 
 |  67     buffer->SetInstructionBits(instr); | 
 |  68     decoder.Decode(buffer); | 
 |  69   } | 
 |  70 } | 
| OLD | NEW |