// Copyright 2022 Google LLC // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. #ifndef FUZZTEST_FUZZTEST_INTERNAL_SUBPROCESS_H_ #define FUZZTEST_FUZZTEST_INTERNAL_SUBPROCESS_H_ #include <iostream> #include <string> #include <variant> #include <vector> #include "absl/container/flat_hash_map.h" #include "absl/time/time.h" namespace fuzztest::internal { enum class ExitCodeT : int; inline ExitCodeT ExitCode(int i) { … } inline std::ostream& operator<<(std::ostream& os, ExitCodeT code) { … } enum class SignalT : int; inline SignalT Signal(int i) { … } inline std::ostream& operator<<(std::ostream& os, SignalT code) { … } // Represents the termination status of a process. class TerminationStatus { … }; struct RunResults { … }; // Runs `command_line` in a subprocess. Environment variables can be set via // `environment`. If optional `timeout` is provided, the process is terminated // after the given timeout. The timeout will be rounded up to seconds. RunResults RunCommand( const std::vector<std::string>& command_line, const absl::flat_hash_map<std::string, std::string>& environment = {}, absl::Duration timeout = absl::InfiniteDuration()); } // namespace fuzztest::internal #endif // FUZZTEST_FUZZTEST_INTERNAL_SUBPROCESS_H_