(self, case, label, raw, function)
| 139 | return sorted(names) |
| 140 | |
| 141 | def count(self, case, label, raw, function): |
| 142 | self.admit(raw) |
| 143 | require(self.common.regular_nonempty(raw), "raw profile is absent/unreadable") |
| 144 | indexed = case / (label + ".profdata") |
| 145 | self.run(case, label + "-merge", [self.tool, "merge", "--instr", |
| 146 | "--output=" + str(indexed), str(raw)], |
| 147 | self.environment, success=True) |
| 148 | require(self.common.regular_nonempty(indexed), "merge produced no indexed profile") |
| 149 | self.admit(indexed) |
| 150 | shown = self.run(case, label + "-count", |
| 151 | [self.tool, "show", "--counts", "--function=" + function, str(indexed)], |
| 152 | self.environment, success=True) |
| 153 | blocks, current = [], None |
| 154 | for line in self.log(case, shown, "stdout").splitlines(): |
| 155 | heading = re.fullmatch(r" (.+):", line) |
| 156 | if heading: |
| 157 | current = {"name": heading.group(1), "counts": []} |
| 158 | blocks.append(current) |
| 159 | elif current is not None: |
| 160 | value = re.fullmatch(r" Function count: ([0-9]+)", line) |
| 161 | if value: |
| 162 | current["counts"].append(int(value.group(1))) |
| 163 | exact = [block for block in blocks if block["name"] == function |
| 164 | or block["name"].endswith(":" + function)] |
| 165 | require(len(exact) == 1 and len(exact[0]["counts"]) == 1, |
| 166 | "missing/ambiguous exact function record: " + function) |
| 167 | return {"raw": str(raw), "indexed": str(indexed), "function": exact[0]["name"], |
| 168 | "count": exact[0]["counts"][0]} |
| 169 | |
| 170 | def reduce(self, case, directory, code): |
| 171 | # The pinned reducer invokes exactly one profdata reader per admitted raw |
no test coverage detected