sapling/eden/fs/testharness/TestChecks.h
Chad Austin 13dc5d1d51 minor prefactoring split out from later diffs
Summary: Also print the inode path if the assertions in EXPECT_FILE_INODE fail.

Reviewed By: simpkins

Differential Revision: D7035517

fbshipit-source-id: 6c50acb588d1c985c7e7a1586c06f04a657698f9
2018-04-24 18:53:19 -07:00

33 lines
1.3 KiB
C++

/*
* Copyright (c) 2004-present, Facebook, Inc.
* All rights reserved.
*
* This source code is licensed under the BSD-style license found in the
* LICENSE file in the root directory of this source tree. An additional grant
* of patent rights can be found in the PATENTS file in the same directory.
*
*/
#pragma once
#include <folly/Format.h>
#include <folly/Range.h>
#include <folly/io/IOBuf.h>
#include <gtest/gtest.h>
#include "eden/fs/inodes/FileInode.h"
/**
* Check that a FileInode has the expected contents and permissions.
*/
#define EXPECT_FILE_INODE(fileInode, expectedData, expectedPerms) \
do { \
EXPECT_EQ( \
expectedData, \
folly::StringPiece{ \
(fileInode)->readAll().get(std::chrono::seconds(20))}) \
<< " for inode path " << (fileInode)->getLogPath(); \
EXPECT_EQ( \
folly::sformat("{:#o}", (expectedPerms)), \
folly::sformat("{:#o}", (fileInode)->getPermissions())) \
<< " for inode path " << (fileInode)->getLogPath(); \
} while (0)