workflows/release-binaries: Add missing output variable
[llvm-project.git] / bolt / unittests / Profile / DataAggregator.cpp
bloba27dd82de68e121158592c2701005e4b9bfba165
1 //===- bolt/unittests/Profile/DataAggregator.cpp --------------------------===//
2 //
3 // Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 // See https://llvm.org/LICENSE.txt for license information.
5 // SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
6 //
7 //===----------------------------------------------------------------------===//
9 #include "bolt/Profile/DataAggregator.h"
10 #include "llvm/Support/CommandLine.h"
11 #include "gtest/gtest.h"
13 using namespace llvm;
14 using namespace llvm::bolt;
16 namespace opts {
17 extern cl::opt<bool> ReadPreAggregated;
20 TEST(DataAggregatorTest, buildID) {
21 // Avoid looking for perf tool.
22 opts::ReadPreAggregated = true;
24 DataAggregator DA("<pseudo input>");
25 std::optional<StringRef> FileName;
27 DA.setParsingBuffer("");
28 ASSERT_FALSE(DA.hasAllBuildIDs());
29 FileName = DA.getFileNameForBuildID("1234");
30 ASSERT_FALSE(FileName);
32 StringRef PartialValidBuildIDs = " File0\n"
33 "1111 File1\n"
34 " File2\n";
35 DA.setParsingBuffer(PartialValidBuildIDs);
36 ASSERT_FALSE(DA.hasAllBuildIDs());
37 FileName = DA.getFileNameForBuildID("0000");
38 ASSERT_FALSE(FileName);
39 FileName = DA.getFileNameForBuildID("1111");
40 ASSERT_EQ(*FileName, "File1");
42 StringRef AllValidBuildIDs = "0000 File0\n"
43 "1111 File1\n"
44 "2222 File2\n"
45 "333 File3\n";
46 DA.setParsingBuffer(AllValidBuildIDs);
47 ASSERT_TRUE(DA.hasAllBuildIDs());
48 FileName = DA.getFileNameForBuildID("1234");
49 ASSERT_FALSE(FileName);
50 FileName = DA.getFileNameForBuildID("2222");
51 ASSERT_EQ(*FileName, "File2");
52 FileName = DA.getFileNameForBuildID("333");
53 ASSERT_EQ(*FileName, "File3");