1 /* 2 * Copyright (c) 2017 The WebRTC project authors. All Rights Reserved. 3 * 4 * Use of this source code is governed by a BSD-style license 5 * that can be found in the LICENSE file in the root of the source 6 * tree. An additional intellectual property rights grant can be found 7 * in the file PATENTS. All contributing project authors may 8 * be found in the AUTHORS file in the root of the source tree. 9 */ 10 11 #include <fstream> 12 #include <iostream> 13 14 #include "rtc_base/checks.h" 15 16 namespace webrtc { 17 namespace test { 18 namespace { 19 20 const char* const kErrorMessage = "-Out /path/to/output/file is mandatory"; 21 22 // Writes fake output intended to be parsed by 23 // quality_assessment.eval_scores.PolqaScore. WriteOutputFile(const std::string & output_file_path)24void WriteOutputFile(const std::string& output_file_path) { 25 RTC_CHECK_NE(output_file_path, ""); 26 std::ofstream out(output_file_path); 27 RTC_CHECK(!out.bad()); 28 out << "* Fake Polqa output" << std::endl; 29 out << "FakeField1\tPolqaScore\tFakeField2" << std::endl; 30 out << "FakeValue1\t3.25\tFakeValue2" << std::endl; 31 out.close(); 32 } 33 34 } // namespace 35 main(int argc,char * argv[])36int main(int argc, char* argv[]) { 37 // Find "-Out" and use its next argument as output file path. 38 RTC_CHECK_GE(argc, 3) << kErrorMessage; 39 const std::string kSoughtFlagName = "-Out"; 40 for (int i = 1; i < argc - 1; ++i) { 41 if (kSoughtFlagName.compare(argv[i]) == 0) { 42 WriteOutputFile(argv[i + 1]); 43 return 0; 44 } 45 } 46 FATAL() << kErrorMessage; 47 } 48 49 } // namespace test 50 } // namespace webrtc 51 main(int argc,char * argv[])52int main(int argc, char* argv[]) { 53 return webrtc::test::main(argc, argv); 54 } 55