1 /* 2 * Copyright (C) 2017 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 #include "VtsTraceProcessor.h" 17 // Usage examples: 18 // To cleanup trace, <binary> --cleanup <trace file>/<trace file directory> 19 // To profile trace, <binary> --profiling <trace file> 20 // To dedup traces, <binary> --dedup <trace file directory> 21 // To select traces based on coverage data, 22 // <binary> --trace_selection <covreage file directory> 23 // To parse trace, <binary> --parse <trace file> 24 // Cleanup trace is used to generate trace for replay test, it will replace the 25 // old trace file with a new one of the same format (VtsProfilingRecord). 26 // 27 // Profile trace will calculate the latency of each API recorded in the trace 28 // and print them out with the format api:latency. e.g. 29 // open:150231474 30 // write:842604 31 // coreInitialized:30466722 32 // 33 // Dedup trace is used to remove all duplicate traces under the given directory. 34 // A trace is considered duplicated if there exists a trace that contains the 35 // same API call sequence as the given trace and the input parameters for each 36 // API call are all the same. 37 // 38 // Select trace is used to select a subset of trace files from a give trace set 39 // based on their corresponding coverage data, the goal is to pick up the 40 // minimal num of trace files that to maximize the total coverage. 41 // 42 // Parse trace is used to parse a binary trace file and print the text format of 43 // the proto (used of for debug). 44 int main(int argc, char* argv[]) { 45 android::vts::VtsTraceProcessor trace_processor; 46 if (argc == 3) { 47 if (!strcmp(argv[1], "--cleanup")) { 48 trace_processor.CleanupTraces(argv[2]); 49 } else if (!strcmp(argv[1], "--profiling")) { 50 trace_processor.ProcessTraceForLatencyProfiling(argv[2]); 51 } else if (!strcmp(argv[1], "--dedup")) { 52 trace_processor.DedupTraces(argv[2]); 53 } else if (!strcmp(argv[1], "--parse")) { 54 trace_processor.ParseTrace(argv[2]); 55 } else if (!strcmp(argv[1], "--convert")) { 56 trace_processor.ConvertTrace(argv[2]); 57 } else { 58 fprintf(stderr, "Invalid argument.\n"); 59 return -1; 60 } 61 } else if (argc == 4) { 62 if (!strcmp(argv[1], "--trace_selection")) { 63 trace_processor.SelectTraces(argv[2], argv[3]); 64 } else { 65 fprintf(stderr, "Invalid argument.\n"); 66 return -1; 67 } 68 } else { 69 fprintf(stderr, "Invalid argument.\n"); 70 return -1; 71 } 72 return 0; 73 } 74