Coverage for /Syzygy/agent/asan/asan_shadow_unittest.cc

CoverageLines executed / instrumented / missingexe / inst / missLanguageGroup
100.0%22220.C++test

Line-by-line coverage:

   1    :  // Copyright 2012 Google Inc.
   2    :  //
   3    :  // Licensed under the Apache License, Version 2.0 (the "License");
   4    :  // you may not use this file except in compliance with the License.
   5    :  // You may obtain a copy of the License at
   6    :  //
   7    :  //     http://www.apache.org/licenses/LICENSE-2.0
   8    :  //
   9    :  // Unless required by applicable law or agreed to in writing, software
  10    :  // distributed under the License is distributed on an "AS IS" BASIS,
  11    :  // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12    :  // See the License for the specific language governing permissions and
  13    :  // limitations under the License.
  14    :  #include "syzygy/agent/asan/asan_shadow.h"
  15    :  
  16    :  #include "base/rand_util.h"
  17    :  #include "gtest/gtest.h"
  18    :  #include "syzygy/common/align.h"
  19    :  
  20    :  namespace agent {
  21    :  namespace asan {
  22    :  
  23  E :  TEST(ShadowTest, PoisonUnpoisonAccess) {
  24  E :    for (size_t i = 0; i < 100; ++i) {
  25    :      // Use a random 8-byte aligned end address.
  26  E :      const size_t size = base::RandInt(1, 16384);
  27    :      const uint8* end_addr =
  28  E :          reinterpret_cast<const uint8*>(base::RandInt(65536, 10*1024*1024) * 8);
  29  E :      const uint8* start_addr = end_addr - size;
  30    :  
  31  E :      for (size_t i = 0; i < size; ++i) {
  32  E :        EXPECT_TRUE(Shadow::IsAccessible(start_addr + i));
  33  E :      }
  34    :  
  35  E :      Shadow::Poison(start_addr, size);
  36  E :      for (size_t i = 0; i < size; ++i) {
  37  E :        EXPECT_FALSE(Shadow::IsAccessible(start_addr + i));
  38  E :      }
  39  E :      EXPECT_TRUE(Shadow::IsAccessible(start_addr - 1));
  40  E :      EXPECT_TRUE(Shadow::IsAccessible(start_addr + size));
  41    :  
  42  E :      const size_t aligned_size = common::AlignUp(size, 8);
  43  E :      const uint8* aligned_start_addr = end_addr - aligned_size;
  44  E :      Shadow::Unpoison(aligned_start_addr, aligned_size);
  45  E :      for (size_t i = 0; i < size; ++i) {
  46  E :        EXPECT_TRUE(Shadow::IsAccessible(start_addr + i));
  47  E :      }
  48  E :    }
  49  E :  }
  50    :  
  51    :  }  // namespace asan
  52    :  }  // namespace agent

Coverage information generated Thu Sep 06 11:30:46 2012.