1 // Copyright (C) 2021 The Android Open Source Project
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 
15 #pragma once
16 
17 #include <cstdint>
18 #include <random>
19 
20 #include <ditto/instruction.h>
21 
22 namespace dittosuite {
23 
24 class ResizeFile : public Instruction {
25  public:
26   inline static const std::string kName = "resize_file";
27 
28   explicit ResizeFile(const Params& params, int64_t size, int input_fd_key);
29 
30  protected:
31   void RunSingle() override;
32 
33   int64_t size_;
34   int input_fd_key_;
35 };
36 
37 class ResizeFileRandom : public ResizeFile {
38  public:
39   explicit ResizeFileRandom(const Params& params, int64_t min, int64_t max, uint64_t seed,
40                             Reseeding reseeding, int input_fd_key);
41 
42  private:
43   void SetUp() override;
44   void SetUpSingle() override;
45 
46   int64_t min_;
47   int64_t max_;
48   std::mt19937_64 gen_;
49   uint64_t seed_;
50   Reseeding reseeding_;
51 };
52 
53 }  // namespace dittosuite
54