cb424d7448
verify-patch-sanity.py validates every active recipe .patch has internally- consistent hunk line counts — catching the 'malformed patch at line N' failure at commit/CI/preflight time instead of hours into a cook. This cycle hit that class three times (qtwaylandscanner, sddm, xwayland), each only discovered when cookbook tried to apply the patch. Running it across the repo found 29 latent malformed patches (validated against GNU patch: e.g. relibc/P3-sysv-ipc reproduces 'malformed patch at line 22'). They were harmless only because they sit in vendored recipes (baked, not re- applied) — but would fail on any version-bump re-derivation. --fix recounts the hunk headers (body untouched) and repaired all 29. Wired into build-preflight.sh (Phase 1.0D) and redbear-ci.yml, with a unit test (test-patch-sanity.sh). Skips archived/legacy trees and unvalidatable formats (empty placeholders, bare-@@ git hunks).
96 lines
3.0 KiB
C++
96 lines
3.0 KiB
C++
//===- unittests/Support/SymbolRemappingReaderTest.cpp --------------------===//
|
|
//
|
|
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
|
|
// See https://llvm.org/LICENSE.txt for license information.
|
|
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
|
|
//
|
|
//===----------------------------------------------------------------------===//
|
|
|
|
#include "llvm/ProfileData/SymbolRemappingReader.h"
|
|
#include "llvm/Support/MemoryBuffer.h"
|
|
#include "gtest/gtest.h"
|
|
|
|
using namespace llvm;
|
|
|
|
namespace {
|
|
class SymbolRemappingReaderTest : public testing::Test {
|
|
public:
|
|
std::unique_ptr<MemoryBuffer> Buffer;
|
|
SymbolRemappingReader Reader;
|
|
|
|
std::string readWithErrors(StringRef Text, StringRef BufferName) {
|
|
Buffer = MemoryBuffer::getMemBuffer(Text, BufferName);
|
|
Error E = Reader.read(*Buffer);
|
|
EXPECT_TRUE((bool)E);
|
|
return toString(std::move(E));
|
|
}
|
|
|
|
void read(StringRef Text, StringRef BufferName) {
|
|
Buffer = MemoryBuffer::getMemBuffer(Text, BufferName);
|
|
Error E = Reader.read(*Buffer);
|
|
EXPECT_FALSE((bool)E);
|
|
}
|
|
};
|
|
} // unnamed namespace
|
|
|
|
TEST_F(SymbolRemappingReaderTest, ParseErrors) {
|
|
EXPECT_EQ(readWithErrors("error", "foo.map"),
|
|
"foo.map:1: Expected 'kind mangled_name mangled_name', "
|
|
"found 'error'");
|
|
|
|
EXPECT_EQ(readWithErrors("error m1 m2", "foo.map"),
|
|
"foo.map:1: Invalid kind, expected 'name', 'type', or 'encoding', "
|
|
"found 'error'");
|
|
}
|
|
|
|
TEST_F(SymbolRemappingReaderTest, DemanglingErrors) {
|
|
EXPECT_EQ(readWithErrors("type i banana", "foo.map"),
|
|
"foo.map:1: Could not demangle 'banana' as a <type>; "
|
|
"invalid mangling?");
|
|
EXPECT_EQ(readWithErrors("name i 1X", "foo.map"),
|
|
"foo.map:1: Could not demangle 'i' as a <name>; "
|
|
"invalid mangling?");
|
|
EXPECT_EQ(readWithErrors("name 1X 1fv", "foo.map"),
|
|
"foo.map:1: Could not demangle '1fv' as a <name>; "
|
|
"invalid mangling?");
|
|
EXPECT_EQ(readWithErrors("encoding 1fv 1f1gE", "foo.map"),
|
|
"foo.map:1: Could not demangle '1f1gE' as a <encoding>; "
|
|
"invalid mangling?");
|
|
}
|
|
|
|
TEST_F(SymbolRemappingReaderTest, BadMappingOrder) {
|
|
StringRef Map = R"(
|
|
# N::foo == M::bar
|
|
name N1N3fooE N1M3barE
|
|
|
|
# N:: == M::
|
|
name 1N 1M
|
|
)";
|
|
EXPECT_EQ(readWithErrors(Map, "foo.map"),
|
|
"foo.map:6: Manglings '1N' and '1M' have both been used in prior "
|
|
"remappings. Move this remapping earlier in the file.");
|
|
}
|
|
|
|
TEST_F(SymbolRemappingReaderTest, RemappingsAdded) {
|
|
StringRef Map = R"(
|
|
# A::foo == B::bar
|
|
name N1A3fooE N1B3barE
|
|
|
|
# int == long
|
|
type i l
|
|
|
|
# void f<int>() = void g<int>()
|
|
encoding 1fIiEvv 1gIiEvv
|
|
)";
|
|
|
|
read(Map, "foo.map");
|
|
auto Key = Reader.insert("_ZN1B3bar3bazIiEEvv");
|
|
EXPECT_NE(Key, SymbolRemappingReader::Key());
|
|
EXPECT_EQ(Key, Reader.lookup("_ZN1A3foo3bazIlEEvv"));
|
|
EXPECT_NE(Key, Reader.lookup("_ZN1C3foo3bazIlEEvv"));
|
|
|
|
Key = Reader.insert("_Z1fIiEvv");
|
|
EXPECT_NE(Key, SymbolRemappingReader::Key());
|
|
EXPECT_EQ(Key, Reader.lookup("_Z1gIlEvv"));
|
|
}
|