1 /* 2 ** Copyright 2021 Centreon 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 ** For more information : contact@centreon.com 17 */ 18 19 #include <cstdlib> 20 #include <cstring> 21 #include <iostream> 22 #include "com/centreon/clib.hh" 23 #include "com/centreon/exceptions/basic.hh" 24 #include "com/centreon/process.hh" 25 26 using namespace com::centreon; 27 28 /** 29 * Check class process (environement). 30 * 31 * @return EXIT_SUCCESS on success. 32 */ main()33int main() { 34 constexpr int count = 10; 35 int sum = 0; 36 int ret(EXIT_SUCCESS); 37 try { 38 for (int i = 0; i < count; i++) { 39 process p(nullptr, false, true, false); 40 p.exec("./bin_test_process_output check_stdout 0"); 41 std::string output; 42 p.read(output); 43 p.wait(); 44 sum += strcmp(output.c_str(), "check_stdout\n"); 45 } 46 if (sum != 0) 47 throw basic_error() << "check environment failed"; 48 } catch (std::exception const& e) { 49 ret = EXIT_FAILURE; 50 std::cerr << "error: " << e.what() << std::endl; 51 } 52 return ret; 53 } 54