sapling/eden/fs/testharness/TestUtil.h
Andrew Milas 464b402226 Add template to ActivityBuffer
Summary:
While before the ActivityBuffer only supported storing InodeTraceEvents, it is now time that we generalize this support by allowing the ActivityBuffer to store multiple types of trace events. This diff makes the transition with three main changes
1. Adding a template type to what event an ActivityBuffer can store
2. Modifying current uses of the ActivityBuffer to specify the InodeTraceEvent type (or int type in the ActivityBufferTest)
3. Moves the InodeTraceEvent type from ActivityBuffer.h to EdenMount.h and clarifies that the ActivityBuffer used in EdenMount is for Inode trace events.

Reviewed By: MichaelCuevas

Differential Revision: D38276534

fbshipit-source-id: ddfdae44b514a6e2066ebfbb7d843ef1280a6559
2022-08-02 13:41:53 -07:00

44 lines
1.3 KiB
C++

/*
* Copyright (c) Meta Platforms, Inc. and affiliates.
*
* This software may be used and distributed according to the terms of the
* GNU General Public License version 2.
*/
#pragma once
#include <folly/Range.h>
#include <folly/concurrency/UnboundedQueue.h>
#include "eden/fs/inodes/EdenMount.h"
#include "eden/fs/inodes/InodeNumber.h"
#include "eden/fs/service/gen-cpp2/eden_types.h"
namespace facebook::eden {
class ObjectId;
class Hash20;
/**
* Helper function for creating Hash values to use in tests.
*
* The input should be an ASCII hex string. It may be less than 40-bytes long,
* in which case it will be sign-extended to 40 bytes.
*/
ObjectId makeTestHash(folly::StringPiece value);
Hash20 makeTestHash20(folly::StringPiece value);
/**
* Helper function for ensuring an inode finished materializing and events
* to record this are correctly stored in a folly::UnboundedQueue in the right
* order. Waits until a timeout of 1000ms to dequeue the next event off the
* queue and checks thats its progress (START vs END) and inode number are as
* given.
*/
bool isInodeMaterializedInQueue(
folly::UnboundedQueue<InodeTraceEvent, true, true, false>&
materializationQueue,
InodeEventProgress progress,
InodeNumber ino);
} // namespace facebook::eden