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).
66 lines
1.9 KiB
C++
66 lines
1.9 KiB
C++
//===-- LLDBUtilsTest.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 "LLDBUtils.h"
|
|
#include "lldb/API/SBError.h"
|
|
#include "lldb/API/SBStructuredData.h"
|
|
#include "llvm/Support/Error.h"
|
|
#include "gtest/gtest.h"
|
|
|
|
using namespace llvm;
|
|
using namespace lldb;
|
|
using namespace lldb_dap;
|
|
|
|
TEST(LLDBUtilsTest, GetStringValue) {
|
|
// Create an SBStructuredData object from JSON.
|
|
const char *json_data = R"("test_string")";
|
|
SBStructuredData data;
|
|
SBError error = data.SetFromJSON(json_data);
|
|
|
|
// Ensure the JSON was parsed successfully.
|
|
ASSERT_TRUE(error.Success());
|
|
ASSERT_TRUE(data.IsValid());
|
|
|
|
// Call GetStringValue and verify the result.
|
|
std::string result = GetStringValue(data);
|
|
EXPECT_EQ(result, "test_string");
|
|
|
|
// Test with invalid SBStructuredData.
|
|
SBStructuredData invalid_data;
|
|
result = GetStringValue(invalid_data);
|
|
EXPECT_EQ(result, "");
|
|
|
|
// Test with empty JSON.
|
|
const char *empty_json = R"("")";
|
|
SBStructuredData empty_data;
|
|
error = empty_data.SetFromJSON(empty_json);
|
|
|
|
ASSERT_TRUE(error.Success());
|
|
ASSERT_TRUE(empty_data.IsValid());
|
|
|
|
result = GetStringValue(empty_data);
|
|
EXPECT_EQ(result, "");
|
|
}
|
|
|
|
TEST(LLDBUtilsTest, ToError) {
|
|
// Test with a successful SBError.
|
|
SBError success_error;
|
|
ASSERT_TRUE(success_error.Success());
|
|
llvm::Error llvm_error = ToError(success_error);
|
|
EXPECT_FALSE(llvm_error);
|
|
|
|
// Test with a failing SBError.
|
|
SBError fail_error;
|
|
fail_error.SetErrorString("Test error message");
|
|
ASSERT_TRUE(fail_error.Fail());
|
|
llvm_error = ToError(fail_error);
|
|
|
|
std::string error_message = toString(std::move(llvm_error));
|
|
EXPECT_EQ(error_message, "Test error message");
|
|
}
|