1/*
2 * Copyright (C) 2014 The Android Open Source Project
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 *      http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17package dexfuzz.fuzzers;
18
19import dexfuzz.Options;
20import dexfuzz.listeners.BaseListener;
21
22/**
23 * Superclass for fuzzing strategies that perform multiple fuzzes, and want
24 * their inputs to come from the input list in a round-robin fashion.
25 */
26public abstract class FuzzerMultiple extends Fuzzer {
27  protected int iterations;
28
29  protected FuzzerMultiple(BaseListener listener) {
30    super(listener);
31  }
32
33  @Override
34  protected String getNextInputFilename() {
35    String inputFile = Options.inputFileList.get(0);
36    if (Options.inputFileList.size() > 1) {
37      int nextIndex = iterations % Options.inputFileList.size();
38      inputFile = Options.inputFileList.get(nextIndex);
39    }
40    listener.handleFuzzingFile(inputFile);
41    return inputFile;
42  }
43}
44