| 96 | } |
| 97 | |
| 98 | bool PresentMonCsv::Open(char const* file, int line, std::wstring const& path) |
| 99 | { |
| 100 | // Load the CSV |
| 101 | for (uint32_t i = 0; i < KnownHeaderCount; ++i) { |
| 102 | headerColumnIndex_[i] = SIZE_MAX; |
| 103 | } |
| 104 | |
| 105 | path_ = path; |
| 106 | line_ = 0; |
| 107 | |
| 108 | if (_wfopen_s(&fp_, path.c_str(), L"r")) { |
| 109 | AddTestFailure(file, line, "Failed to open file: %ls", path.c_str()); |
| 110 | return false; |
| 111 | } |
| 112 | |
| 113 | // Remove UTF-8 marker if there is one. |
| 114 | if (fread(row_, 3, 1, fp_) != 1 || |
| 115 | row_[0] != -17 || // 0xef |
| 116 | row_[1] != -69 || // 0xbb |
| 117 | row_[2] != -65) { // 0xbf |
| 118 | fseek(fp_, 0, SEEK_SET); |
| 119 | } |
| 120 | |
| 121 | // Read the header and ensure required columns are present |
| 122 | ReadRow(); |
| 123 | |
| 124 | for (size_t i = 0, n = cols_.size(); i < n; ++i) { |
| 125 | auto h = FindHeader(cols_[i]); |
| 126 | switch (h) { |
| 127 | case KnownHeaderCount: |
| 128 | case UnknownHeader: |
| 129 | AddTestFailure(Convert(path_).c_str(), (int) line_, "Unrecognised column: %s", cols_[i]); |
| 130 | break; |
| 131 | default: |
| 132 | if (headerColumnIndex_[(size_t) h] != SIZE_MAX) { |
| 133 | AddTestFailure(Convert(path_).c_str(), (int) line_, "Duplicate column: %s", cols_[i]); |
| 134 | } else { |
| 135 | headerColumnIndex_[(size_t) h] = i; |
| 136 | } |
| 137 | break; |
| 138 | } |
| 139 | } |
| 140 | |
| 141 | bool columnsOK = true; |
| 142 | |
| 143 | auto v1 = CheckAllIfAny(headerColumnIndex_, &columnsOK, { Header_Runtime, |
| 144 | Header_Dropped, |
| 145 | Header_TimeInSeconds, |
| 146 | Header_msBetweenPresents, |
| 147 | Header_msInPresentAPI }); |
| 148 | |
| 149 | auto v2 = CheckAllIfAny(headerColumnIndex_, &columnsOK, { Header_FrameTime, |
| 150 | Header_CPUBusy, |
| 151 | Header_CPUWait, |
| 152 | Header_GPULatency, |
| 153 | Header_GPUTime, |
| 154 | Header_GPUBusy, |
| 155 | Header_GPUWait, |
nothing calls this directly
no test coverage detected