944 lines
39 KiB
C++
944 lines
39 KiB
C++
#include <Void/Update/Update.hpp>
|
|
#include <Void/System/TempDir.hpp>
|
|
#include <Void/Testing/Assert.hpp>
|
|
#include <Void/Testing/Test.hpp>
|
|
#include <Void/Text/Base64.hpp>
|
|
#include <Void/Text/Hex.hpp>
|
|
|
|
#include <array>
|
|
#include <cstring>
|
|
#include <filesystem>
|
|
#include <format>
|
|
#include <fstream>
|
|
#include <iterator>
|
|
#include <memory>
|
|
|
|
#include <openssl/evp.h>
|
|
|
|
namespace
|
|
{
|
|
constexpr std::string_view payload = R"json({
|
|
"schemaVersion": 1,
|
|
"feedId": "vendor-main",
|
|
"sequence": 7,
|
|
"generatedAt": "2026-01-01T00:00:00Z",
|
|
"expiresAt": "2099-01-01T00:00:00Z",
|
|
"releases": [{
|
|
"component": "service",
|
|
"artifactId": "main",
|
|
"channel": "stable",
|
|
"version": "1.2.0",
|
|
"cohort": "linux-abi-2",
|
|
"platform": "linux",
|
|
"arch": "x86_64",
|
|
"url": "https://updates.example.invalid/service-1.2.0.tar.zst",
|
|
"size": 1234,
|
|
"sha256": "1111111111111111111111111111111111111111111111111111111111111111",
|
|
"packageType": "tar.zst",
|
|
"compatibility": {
|
|
"versionContracts": {"host.api": ">=1.0.0 <2.0.0"},
|
|
"exactContracts": {"plugin.abi": "2"}
|
|
},
|
|
"releaseManifestSha256": "2222222222222222222222222222222222222222222222222222222222222222"
|
|
}]
|
|
})json";
|
|
|
|
std::string sign(std::string_view message)
|
|
{
|
|
const auto seedText = Void::Encoding::Hex::decode(
|
|
"9d61b19deffd5a60ba844af492ec2cc44449c5697b326919703bac031cae7f60");
|
|
Void::Testing::require(seedText.has_value());
|
|
using Key = std::unique_ptr<EVP_PKEY, decltype(&EVP_PKEY_free)>;
|
|
using Context = std::unique_ptr<EVP_MD_CTX, decltype(&EVP_MD_CTX_free)>;
|
|
Key key{EVP_PKEY_new_raw_private_key(
|
|
EVP_PKEY_ED25519, nullptr,
|
|
reinterpret_cast<const unsigned char*>(seedText->data()),
|
|
seedText->size()),
|
|
&EVP_PKEY_free};
|
|
Void::Testing::require(static_cast<bool>(key));
|
|
Context context{EVP_MD_CTX_new(), &EVP_MD_CTX_free};
|
|
Void::Testing::require(static_cast<bool>(context));
|
|
Void::Testing::require(EVP_DigestSignInit(context.get(), nullptr,
|
|
nullptr, nullptr,
|
|
key.get()) == 1);
|
|
std::string signature(64, '\0');
|
|
std::size_t size = signature.size();
|
|
Void::Testing::require(
|
|
EVP_DigestSign(
|
|
context.get(),
|
|
reinterpret_cast<unsigned char*>(signature.data()), &size,
|
|
reinterpret_cast<const unsigned char*>(message.data()),
|
|
message.size()) == 1);
|
|
signature.resize(size);
|
|
return signature;
|
|
}
|
|
|
|
Void::Update::Keyring keyring()
|
|
{
|
|
const auto publicText = Void::Encoding::Hex::decode(
|
|
"d75a980182b10ab7d54bfed3c964073a0ee172f3daa62325af021a68f707511a");
|
|
Void::Testing::require(publicText.has_value());
|
|
Void::Update::Ed25519PublicKey key{};
|
|
std::memcpy(key.data(), publicText->data(), key.size());
|
|
return {{"test-key", key}};
|
|
}
|
|
|
|
std::string envelope(std::string signature)
|
|
{
|
|
return std::format("{{\"schemaVersion\":1,\"keyId\":\"test-key\","
|
|
"\"payload\":\"{}\",\"signature\":\"{}\"}}",
|
|
Void::Encoding::Base64::encode_url(payload),
|
|
Void::Encoding::Base64::encode_url(signature));
|
|
}
|
|
|
|
std::string signedEnvelope(std::string_view message,
|
|
std::uint32_t schemaVersion)
|
|
{
|
|
return std::format("{{\"schemaVersion\":{},\"keyId\":\"test-key\","
|
|
"\"payload\":\"{}\",\"signature\":\"{}\"}}",
|
|
schemaVersion,
|
|
Void::Encoding::Base64::encode_url(message),
|
|
Void::Encoding::Base64::encode_url(sign(message)));
|
|
}
|
|
|
|
constexpr std::string_view componentCatalogPayload = R"json({
|
|
"schemaVersion": 2,
|
|
"document": "echoion-component-catalog",
|
|
"channel": "stable",
|
|
"sequence": 11,
|
|
"generatedAt": "2026-01-01T00:00:00Z",
|
|
"expiresAt": "2099-01-01T00:00:00Z",
|
|
"productVersion": "2.0.0",
|
|
"components": [{
|
|
"componentId": "Host",
|
|
"pluginId": null,
|
|
"kind": "runtime-module",
|
|
"componentVersion": "2.0.1",
|
|
"activation": "restart-required",
|
|
"dependencies": {"Api": ">=2.0.0 <3.0.0"},
|
|
"sequence": 11,
|
|
"latestUrl": "https://updates.invalid/feeds/stable/host/latest.json",
|
|
"artifactSha256": "1111111111111111111111111111111111111111111111111111111111111111"
|
|
}, {
|
|
"componentId": "Api",
|
|
"pluginId": null,
|
|
"kind": "sdk",
|
|
"componentVersion": "2.0.0",
|
|
"activation": "restart-required",
|
|
"dependencies": {},
|
|
"sequence": 11,
|
|
"latestUrl": "https://updates.invalid/feeds/stable/api/latest.json",
|
|
"artifactSha256": "2222222222222222222222222222222222222222222222222222222222222222"
|
|
}]
|
|
})json";
|
|
|
|
std::string componentReleasePayload(std::string_view componentId,
|
|
std::string_view version,
|
|
std::string_view artifactHash,
|
|
std::string_view dependencies)
|
|
{
|
|
return std::format(
|
|
R"json({{
|
|
"schemaVersion": 2,
|
|
"document": "echoion-component-release",
|
|
"channel": "stable",
|
|
"sequence": 11,
|
|
"generatedAt": "2026-01-01T00:00:00Z",
|
|
"expiresAt": "2099-01-01T00:00:00Z",
|
|
"productVersion": "2.0.0",
|
|
"componentId": "{}",
|
|
"pluginId": null,
|
|
"kind": "{}",
|
|
"componentVersion": "{}",
|
|
"sourceSha": "aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa",
|
|
"sourceTreeHash": "bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb",
|
|
"abiHash": "cccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc",
|
|
"artifactIdentity": "{}-{}-linux-x86_64",
|
|
"activation": "restart-required",
|
|
"dependencies": {},
|
|
"artifact": {{
|
|
"name": "{}-{}.tar.zst",
|
|
"url": "https://updates.invalid/{}-{}.tar.zst",
|
|
"sha256": "{}",
|
|
"size": 42,
|
|
"manifestSha256": "dddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddddd",
|
|
"packageType": "tar.zst"
|
|
}}
|
|
}})json",
|
|
componentId, componentId == "Api" ? "sdk" : "runtime-module",
|
|
version, componentId, version, dependencies, componentId, version,
|
|
componentId, version, artifactHash);
|
|
}
|
|
} // namespace
|
|
|
|
Void::Testing::Test update_feed_verifies_before_parsing()
|
|
{
|
|
auto verified =
|
|
Void::Update::verifyFeedEnvelope(envelope(sign(payload)), keyring());
|
|
Void::Testing::require(verified.has_value());
|
|
Void::Testing::expect_eq(verified->feed.feedId, std::string{"vendor-main"});
|
|
Void::Testing::expect_eq(verified->feed.sequence, std::uint64_t{7});
|
|
Void::Testing::expect_eq(verified->feed.releases.size(), std::size_t{1});
|
|
Void::Testing::expect_eq(verified->signedPayload, std::string{payload});
|
|
|
|
auto badSignature = sign(payload);
|
|
badSignature.front() ^= 1;
|
|
Void::Testing::expect(!Void::Update::verifyFeedEnvelope(
|
|
envelope(std::move(badSignature)), keyring())
|
|
.has_value());
|
|
}
|
|
|
|
Void::Testing::Test update_feed_unsigned_parse_replay_and_selection()
|
|
{
|
|
auto parsed = Void::Update::parseFeedPayload(payload);
|
|
Void::Testing::require(parsed.has_value());
|
|
Void::Update::VerificationPolicy replay;
|
|
replay.minimumSequence = 7;
|
|
Void::Testing::expect(
|
|
!Void::Update::parseFeedPayload(payload, replay).has_value());
|
|
|
|
auto newer = parsed->releases.front();
|
|
newer.version = *Void::Semver::parse("1.3.0");
|
|
parsed->releases.push_back(newer);
|
|
Void::Update::SelectionRequest request{
|
|
.component = "service",
|
|
.artifactId = "main",
|
|
.channel = "stable",
|
|
.environment = {.versionContracts = {{"host.api",
|
|
*Void::Semver::parse("1.5.0")}},
|
|
.exactContracts = {{"plugin.abi", "2"}},
|
|
.platform = "linux",
|
|
.architecture = "x86_64"},
|
|
.currentVersion = *Void::Semver::parse("1.1.0")};
|
|
auto selected = Void::Update::selectRelease(*parsed, request);
|
|
Void::Testing::require(selected.has_value());
|
|
Void::Testing::expect_eq(selected->version.to_string(),
|
|
std::string{"1.3.0"});
|
|
request.environment.exactContracts["plugin.abi"] = "3";
|
|
Void::Testing::expect(
|
|
!Void::Update::selectRelease(*parsed, request).has_value());
|
|
}
|
|
|
|
Void::Testing::Test component_feed_verifies_and_resolves_complete_set()
|
|
{
|
|
auto envelope = Void::Update::verifyEnvelope(
|
|
signedEnvelope(componentCatalogPayload, 2), keyring());
|
|
Void::Testing::require(envelope.has_value());
|
|
Void::Testing::expect_eq(envelope->schemaVersion, std::uint32_t{2});
|
|
auto catalog =
|
|
Void::Update::parseComponentCatalogPayload(envelope->signedPayload);
|
|
Void::Testing::require(catalog.has_value());
|
|
Void::Testing::expect_eq(catalog->components.size(), std::size_t{2});
|
|
|
|
auto host =
|
|
Void::Update::parseComponentReleasePayload(componentReleasePayload(
|
|
"Host", "2.0.1",
|
|
"1111111111111111111111111111111111111111111111111111111111111111",
|
|
R"json({"Api":">=2.0.0 <3.0.0"})json"));
|
|
auto api =
|
|
Void::Update::parseComponentReleasePayload(componentReleasePayload(
|
|
"Api", "2.0.0",
|
|
"2222222222222222222222222222222222222222222222222222222222222222",
|
|
"{}"));
|
|
Void::Testing::require(host.has_value());
|
|
Void::Testing::require(api.has_value());
|
|
std::map<std::string, Void::Update::ComponentRelease> releases;
|
|
releases.emplace("Api", *api);
|
|
releases.emplace("Host", *host);
|
|
Void::Testing::expect(
|
|
Void::Update::validateComponentSet(*catalog, releases).has_value());
|
|
|
|
releases.at("Api").componentVersion = *Void::Semver::parse("3.0.0");
|
|
Void::Testing::expect(
|
|
!Void::Update::validateComponentSet(*catalog, releases).has_value());
|
|
}
|
|
|
|
Void::Testing::Test update_feed_rejects_empty_fractional_timestamp()
|
|
{
|
|
std::string malformed{payload};
|
|
const auto timestamp = malformed.find("2026-01-01T00:00:00Z");
|
|
Void::Testing::require(timestamp != std::string::npos);
|
|
malformed.replace(timestamp,
|
|
std::string_view{"2026-01-01T00:00:00Z"}.size(),
|
|
"2026-01-01T00:00:00.Z");
|
|
Void::Testing::expect(
|
|
!Void::Update::parseFeedPayload(malformed).has_value());
|
|
}
|
|
|
|
Void::Testing::Test update_feed_rejects_noncanonical_sha256()
|
|
{
|
|
std::string uppercaseArtifactHash{payload};
|
|
const auto artifactHash = uppercaseArtifactHash.find(std::string(64, '1'));
|
|
Void::Testing::require(artifactHash != std::string::npos);
|
|
uppercaseArtifactHash[artifactHash] = 'A';
|
|
Void::Testing::expect(
|
|
!Void::Update::parseFeedPayload(uppercaseArtifactHash).has_value());
|
|
|
|
std::string uppercaseManifestHash{payload};
|
|
const auto manifestHash = uppercaseManifestHash.find(std::string(64, '2'));
|
|
Void::Testing::require(manifestHash != std::string::npos);
|
|
uppercaseManifestHash[manifestHash] = 'B';
|
|
Void::Testing::expect(
|
|
!Void::Update::parseFeedPayload(uppercaseManifestHash).has_value());
|
|
}
|
|
|
|
Void::Testing::Test update_feed_accepts_generic_artifact_kinds()
|
|
{
|
|
std::string sharedLibrary{payload};
|
|
constexpr std::string_view packageField{"\"packageType\": \"tar.zst\""};
|
|
const auto package = sharedLibrary.find(packageField);
|
|
Void::Testing::require(package != std::string::npos);
|
|
sharedLibrary.replace(package, packageField.size(),
|
|
"\"packageType\": \"shared-library\"");
|
|
const auto manifest = sharedLibrary.find(
|
|
",\n \"releaseManifestSha256\": "
|
|
"\"2222222222222222222222222222222222222222222222222222222222222222\"");
|
|
Void::Testing::require(manifest != std::string::npos);
|
|
sharedLibrary.erase(manifest,
|
|
std::string_view{",\n \"releaseManifestSha256\": "
|
|
"\"22222222222222222222222222222222222"
|
|
"22222222222222222222222222222\""}
|
|
.size());
|
|
|
|
auto parsed = Void::Update::parseFeedPayload(sharedLibrary);
|
|
Void::Testing::require(parsed.has_value());
|
|
Void::Testing::require(parsed->releases.size() == 1);
|
|
Void::Testing::expect_eq(parsed->releases.front().packageType,
|
|
std::string{"shared-library"});
|
|
Void::Testing::expect(
|
|
parsed->releases.front().releaseManifestSha256.empty());
|
|
|
|
const Void::Update::SelectionRequest request{
|
|
.component = "service",
|
|
.artifactId = "main",
|
|
.channel = "stable",
|
|
.environment = {.versionContracts = {{"host.api",
|
|
*Void::Semver::parse("1.5.0")}},
|
|
.exactContracts = {{"plugin.abi", "2"}},
|
|
.platform = "linux",
|
|
.architecture = "x86_64"},
|
|
.currentVersion = std::nullopt,
|
|
.requiredCohort = std::nullopt,
|
|
.allowDowngrade = false,
|
|
.includeCurrent = false};
|
|
const auto selected = Void::Update::selectRelease(*parsed, request);
|
|
Void::Testing::require(selected.has_value());
|
|
Void::Testing::expect_eq(selected->packageType,
|
|
std::string{"shared-library"});
|
|
|
|
const auto packageType = sharedLibrary.find("shared-library");
|
|
Void::Testing::require(packageType != std::string::npos);
|
|
sharedLibrary.replace(packageType,
|
|
std::string_view{"shared-library"}.size(), "file");
|
|
const auto fileFeed = Void::Update::parseFeedPayload(sharedLibrary);
|
|
Void::Testing::require(fileFeed.has_value());
|
|
Void::Testing::expect_eq(fileFeed->releases.front().packageType,
|
|
std::string{"file"});
|
|
|
|
const auto filePackageType = sharedLibrary.find("file");
|
|
Void::Testing::require(filePackageType != std::string::npos);
|
|
sharedLibrary.replace(filePackageType, std::string_view{"file"}.size(),
|
|
"wasm-module");
|
|
const auto wasmFeed = Void::Update::parseFeedPayload(sharedLibrary);
|
|
Void::Testing::require(wasmFeed.has_value());
|
|
Void::Testing::expect_eq(wasmFeed->releases.front().packageType,
|
|
std::string{"wasm-module"});
|
|
}
|
|
|
|
Void::Testing::Test version_store_commits_and_reconciles_activation()
|
|
{
|
|
Void::FileSystem::TempDir temporary{"void_versions_"};
|
|
Void::Update::VersionStore store{temporary.path() / "store"};
|
|
Void::Testing::require(store.initialize().has_value());
|
|
const auto version1 = *Void::Semver::parse("1.0.0");
|
|
const auto version2 = *Void::Semver::parse("2.0.0");
|
|
auto staging1 = store.prepare(version1);
|
|
Void::Testing::require(staging1.has_value());
|
|
std::ofstream{*staging1 / "marker"} << "one";
|
|
Void::Testing::require(store.publish(version1, *staging1).has_value());
|
|
Void::Testing::require(store.activate(version1).has_value());
|
|
Void::Testing::require(store.commit().has_value());
|
|
|
|
auto staging2 = store.prepare(version2);
|
|
Void::Testing::require(staging2.has_value());
|
|
std::ofstream{*staging2 / "marker"} << "two";
|
|
Void::Testing::require(store.publish(version2, *staging2).has_value());
|
|
Void::Testing::require(store.activate(version2).has_value());
|
|
Void::Testing::expect(!store.recordHealthy(version2).has_value());
|
|
auto current = store.currentVersion();
|
|
Void::Testing::require(current.has_value() && current->has_value());
|
|
Void::Testing::expect_eq((*current)->to_string(), std::string{"2.0.0"});
|
|
Void::Testing::require(store.reconcile().has_value());
|
|
current = store.currentVersion();
|
|
Void::Testing::require(current.has_value() && current->has_value());
|
|
Void::Testing::expect_eq((*current)->to_string(), std::string{"1.0.0"});
|
|
Void::Testing::expect(!store.pendingActivation()->has_value());
|
|
}
|
|
|
|
Void::Testing::Test version_store_commit_point_is_unambiguous_and_idempotent()
|
|
{
|
|
Void::FileSystem::TempDir temporary{"void_versions_commit_point_"};
|
|
Void::Update::VersionStore store{temporary.path() / "store"};
|
|
Void::Testing::require(store.initialize().has_value());
|
|
const auto version = *Void::Semver::parse("2.1.0");
|
|
auto staging = store.prepare(version);
|
|
Void::Testing::require(staging.has_value());
|
|
std::ofstream{*staging / "marker"} << "candidate";
|
|
Void::Testing::require(store.publish(version, *staging).has_value());
|
|
Void::Testing::require(store.activate(version).has_value());
|
|
|
|
Void::Testing::require(store.commit().has_value());
|
|
|
|
Void::Testing::expect(
|
|
!std::filesystem::exists(store.root() / "activation.json"));
|
|
Void::Testing::require(store.commit().has_value());
|
|
std::ifstream healthInput{store.root() / "health.log"};
|
|
const std::string healthHistory{std::istreambuf_iterator<char>{healthInput},
|
|
std::istreambuf_iterator<char>{}};
|
|
const auto healthyRecord = healthHistory.find("H 2.1.0\n");
|
|
Void::Testing::require(healthyRecord != std::string::npos);
|
|
Void::Testing::expect(healthHistory.find("H 2.1.0\n", healthyRecord + 1) ==
|
|
std::string::npos);
|
|
Void::Testing::require(store.rollback().has_value());
|
|
const auto current = store.currentVersion();
|
|
Void::Testing::require(current.has_value() && current->has_value());
|
|
Void::Testing::expect_eq((*current)->to_string(), std::string{"2.1.0"});
|
|
}
|
|
|
|
Void::Testing::Test version_store_reconciles_durable_commit_marker()
|
|
{
|
|
#ifndef _WIN32
|
|
Void::FileSystem::TempDir temporary{"void_versions_commit_marker_"};
|
|
Void::Update::VersionStore store{temporary.path() / "store"};
|
|
Void::Testing::require(store.initialize().has_value());
|
|
const auto version = *Void::Semver::parse("2.2.0");
|
|
auto staging = store.prepare(version);
|
|
Void::Testing::require(staging.has_value());
|
|
std::ofstream{*staging / "marker"} << "candidate";
|
|
Void::Testing::require(store.publish(version, *staging).has_value());
|
|
Void::Testing::require(store.activate(version).has_value());
|
|
|
|
std::ifstream healthInput{store.root() / "health.log"};
|
|
std::string healthHistory{std::istreambuf_iterator<char>{healthInput},
|
|
std::istreambuf_iterator<char>{}};
|
|
healthHistory += "H 2.2.0\n";
|
|
const auto replacement = store.root() / "health.replacement";
|
|
std::ofstream{replacement, std::ios::binary | std::ios::trunc}
|
|
<< healthHistory;
|
|
std::filesystem::rename(replacement, store.root() / "health.log");
|
|
Void::Testing::expect(
|
|
std::filesystem::exists(store.root() / "activation.json"));
|
|
|
|
const auto healthyRecord = healthHistory.find("H 2.2.0\n");
|
|
Void::Testing::require(healthyRecord != std::string::npos);
|
|
Void::Testing::expect(healthHistory.find("H 2.2.0\n", healthyRecord + 1) ==
|
|
std::string::npos);
|
|
Void::Testing::require(store.rollback().has_value());
|
|
const auto committedCurrent = store.currentVersion();
|
|
Void::Testing::require(committedCurrent.has_value() &&
|
|
committedCurrent->has_value());
|
|
Void::Testing::expect_eq((*committedCurrent)->to_string(),
|
|
std::string{"2.2.0"});
|
|
Void::Testing::require(store.reconcile().has_value());
|
|
Void::Testing::expect(
|
|
!std::filesystem::exists(store.root() / "activation.json"));
|
|
const auto reconciledCurrent = store.currentVersion();
|
|
Void::Testing::require(reconciledCurrent.has_value() &&
|
|
reconciledCurrent->has_value());
|
|
Void::Testing::expect_eq((*reconciledCurrent)->to_string(),
|
|
std::string{"2.2.0"});
|
|
#endif
|
|
}
|
|
|
|
Void::Testing::Test version_store_reactivation_refreshes_health_order()
|
|
{
|
|
Void::FileSystem::TempDir temporary{"void_versions_reactivation_"};
|
|
Void::Update::VersionStore store{temporary.path() / "store"};
|
|
Void::Testing::require(store.initialize().has_value());
|
|
for (const std::string_view text : {"1.0.0", "2.0.0", "3.0.0"}) {
|
|
const auto version = *Void::Semver::parse(text);
|
|
auto staging = store.prepare(version);
|
|
Void::Testing::require(staging.has_value());
|
|
std::ofstream{*staging / "marker"} << text;
|
|
Void::Testing::require(store.publish(version, *staging).has_value());
|
|
Void::Testing::require(store.activate(version).has_value());
|
|
Void::Testing::require(store.commit().has_value());
|
|
}
|
|
const auto reactivated = *Void::Semver::parse("1.0.0");
|
|
Void::Testing::require(store.activate(reactivated).has_value());
|
|
Void::Testing::require(store.commit().has_value());
|
|
|
|
const auto removed = store.prune(1);
|
|
Void::Testing::require(removed.has_value());
|
|
Void::Testing::expect_eq(removed->size(), std::size_t{1});
|
|
Void::Testing::expect_eq(removed->front().to_string(),
|
|
std::string{"2.0.0"});
|
|
Void::Testing::expect(
|
|
std::filesystem::is_directory(store.versionPath(reactivated)));
|
|
Void::Testing::expect(std::filesystem::is_directory(
|
|
store.versionPath(*Void::Semver::parse("3.0.0"))));
|
|
}
|
|
|
|
Void::Testing::Test version_store_records_external_lifecycle_without_staging()
|
|
{
|
|
Void::FileSystem::TempDir temporary{"void_versions_external_lifecycle_"};
|
|
Void::Update::VersionStore store{temporary.path() / "store"};
|
|
std::filesystem::create_directories(store.root() / "versions");
|
|
for (const std::string_view text :
|
|
{"1.0.0", "2.0.0", "3.0.0", "4.0.0", "5.0.0"}) {
|
|
std::filesystem::create_directories(
|
|
store.versionPath(*Void::Semver::parse(text)));
|
|
}
|
|
const auto version1 = *Void::Semver::parse("1.0.0");
|
|
const auto version2 = *Void::Semver::parse("2.0.0");
|
|
const auto version3 = *Void::Semver::parse("3.0.0");
|
|
const auto version4 = *Void::Semver::parse("4.0.0");
|
|
const auto version5 = *Void::Semver::parse("5.0.0");
|
|
Void::Testing::require(store.recordHealthy(version1).has_value());
|
|
Void::Testing::require(store.recordHealthy(version2).has_value());
|
|
Void::Testing::require(store.recordHealthy(version3).has_value());
|
|
Void::Testing::require(store.recordHealthy(version1).has_value());
|
|
Void::Testing::require(store.recordFailed(version2).has_value());
|
|
Void::Testing::require(store.recordFailed(version4).has_value());
|
|
Void::Testing::expect(!std::filesystem::exists(store.root() / "staging"));
|
|
|
|
std::ifstream healthInput{store.root() / "health.log"};
|
|
const std::string healthHistory{std::istreambuf_iterator<char>{healthInput},
|
|
std::istreambuf_iterator<char>{}};
|
|
Void::Testing::expect(healthHistory.find("F 2.0.0\n") == std::string::npos);
|
|
Void::Testing::expect(healthHistory.find("F 4.0.0\n") != std::string::npos);
|
|
|
|
#ifndef _WIN32
|
|
const auto external = temporary.path() / "external";
|
|
std::filesystem::create_directories(external);
|
|
const auto linkedVersion = *Void::Semver::parse("6.0.0");
|
|
std::filesystem::create_directory_symlink(external,
|
|
store.versionPath(linkedVersion));
|
|
Void::Testing::expect(!store.recordHealthy(linkedVersion).has_value());
|
|
std::filesystem::create_directory_symlink(
|
|
std::filesystem::path{"versions"} / version1.to_string(),
|
|
store.root() / "current");
|
|
|
|
const auto removed = store.prune(1);
|
|
Void::Testing::require(removed.has_value());
|
|
Void::Testing::expect_eq(removed->size(), std::size_t{2});
|
|
Void::Testing::expect(
|
|
!std::filesystem::exists(store.versionPath(version2)));
|
|
Void::Testing::expect(
|
|
!std::filesystem::exists(store.versionPath(version4)));
|
|
Void::Testing::expect(
|
|
std::filesystem::is_directory(store.versionPath(version1)));
|
|
Void::Testing::expect(
|
|
std::filesystem::is_directory(store.versionPath(version3)));
|
|
Void::Testing::expect(
|
|
std::filesystem::is_directory(store.versionPath(version5)));
|
|
Void::Testing::expect(std::filesystem::is_directory(external));
|
|
Void::Testing::expect(
|
|
std::filesystem::is_symlink(store.versionPath(linkedVersion)));
|
|
Void::Testing::expect(!std::filesystem::exists(store.root() / "staging"));
|
|
#else
|
|
(void)version5;
|
|
#endif
|
|
}
|
|
|
|
Void::Testing::Test version_store_prunes_without_an_active_version()
|
|
{
|
|
Void::FileSystem::TempDir temporary{"void_versions_no_current_"};
|
|
Void::Update::VersionStore store{temporary.path() / "store"};
|
|
std::filesystem::create_directories(store.root() / "versions");
|
|
for (const std::string_view text : {"1.0.0", "2.0.0", "3.0.0", "4.0.0"}) {
|
|
std::filesystem::create_directories(
|
|
store.versionPath(*Void::Semver::parse(text)));
|
|
}
|
|
const auto version1 = *Void::Semver::parse("1.0.0");
|
|
const auto version2 = *Void::Semver::parse("2.0.0");
|
|
const auto version3 = *Void::Semver::parse("3.0.0");
|
|
const auto version4 = *Void::Semver::parse("4.0.0");
|
|
Void::Testing::require(store.recordHealthy(version1).has_value());
|
|
Void::Testing::require(store.recordHealthy(version2).has_value());
|
|
Void::Testing::require(store.recordFailed(version3).has_value());
|
|
|
|
auto removed = store.prune(1);
|
|
Void::Testing::require(removed.has_value());
|
|
Void::Testing::expect_eq(removed->size(), std::size_t{2});
|
|
Void::Testing::expect(
|
|
!std::filesystem::exists(store.versionPath(version1)));
|
|
Void::Testing::expect(
|
|
std::filesystem::is_directory(store.versionPath(version2)));
|
|
Void::Testing::expect(
|
|
!std::filesystem::exists(store.versionPath(version3)));
|
|
Void::Testing::expect(
|
|
std::filesystem::is_directory(store.versionPath(version4)));
|
|
|
|
// A retired SemVer may be republished by an external lifecycle owner. Its
|
|
// earlier healthy event belongs to the retired publication, so a failure in
|
|
// the new publication must still be recorded and prunable.
|
|
std::filesystem::create_directories(store.versionPath(version1));
|
|
Void::Testing::require(store.recordFailed(version1).has_value());
|
|
std::ifstream healthInput{store.root() / "health.log"};
|
|
const std::string healthHistory{std::istreambuf_iterator<char>{healthInput},
|
|
std::istreambuf_iterator<char>{}};
|
|
const auto retired = healthHistory.find("D 1.0.0\n");
|
|
Void::Testing::require(retired != std::string::npos);
|
|
Void::Testing::expect(healthHistory.find("F 1.0.0\n", retired) !=
|
|
std::string::npos);
|
|
removed = store.prune(1);
|
|
Void::Testing::require(removed.has_value());
|
|
Void::Testing::expect_eq(removed->size(), std::size_t{1});
|
|
Void::Testing::expect(
|
|
!std::filesystem::exists(store.versionPath(version1)));
|
|
}
|
|
|
|
Void::Testing::Test version_store_reports_healthy_publications_in_event_order()
|
|
{
|
|
Void::FileSystem::TempDir temporary{"void_versions_healthy_query_"};
|
|
Void::Update::VersionStore store{temporary.path() / "store"};
|
|
std::filesystem::create_directories(store.root() / "versions");
|
|
const auto version1 = *Void::Semver::parse("1.0.0");
|
|
const auto version2 = *Void::Semver::parse("2.0.0");
|
|
const auto version3 = *Void::Semver::parse("3.0.0");
|
|
const auto version4 = *Void::Semver::parse("4.0.0");
|
|
const auto version5 = *Void::Semver::parse("5.0.0");
|
|
for (const auto& version :
|
|
{version1, version2, version3, version4, version5}) {
|
|
std::filesystem::create_directories(store.versionPath(version));
|
|
}
|
|
|
|
Void::Testing::require(store.recordHealthy(version1).has_value());
|
|
Void::Testing::require(store.recordHealthy(version2).has_value());
|
|
Void::Testing::require(store.recordHealthy(version3).has_value());
|
|
Void::Testing::require(store.recordHealthy(version1).has_value());
|
|
Void::Testing::require(store.recordFailed(version4).has_value());
|
|
#ifndef _WIN32
|
|
const auto readable = std::filesystem::perms::owner_read |
|
|
std::filesystem::perms::group_read |
|
|
std::filesystem::perms::others_read;
|
|
Void::Testing::expect(
|
|
(std::filesystem::status(store.root() / ".update.lock").permissions() &
|
|
readable) == readable);
|
|
Void::Testing::expect(
|
|
(std::filesystem::status(store.root() / "health.log").permissions() &
|
|
readable) == readable);
|
|
#endif
|
|
auto healthy = store.healthyPublishedVersions();
|
|
Void::Testing::require(healthy.has_value());
|
|
Void::Testing::expect_eq(healthy->size(), std::size_t{3});
|
|
Void::Testing::expect_eq((*healthy)[0].to_string(), std::string{"1.0.0"});
|
|
Void::Testing::expect_eq((*healthy)[1].to_string(), std::string{"3.0.0"});
|
|
Void::Testing::expect_eq((*healthy)[2].to_string(), std::string{"2.0.0"});
|
|
|
|
// Pruning retires an older healthy lifecycle and excludes failed and
|
|
// retired publications. Unknown publications remain on disk but are not
|
|
// reported as rollback candidates.
|
|
Void::Testing::require(store.prune(2).has_value());
|
|
healthy = store.healthyPublishedVersions();
|
|
Void::Testing::require(healthy.has_value());
|
|
Void::Testing::expect_eq(healthy->size(), std::size_t{2});
|
|
Void::Testing::expect_eq((*healthy)[0].to_string(), std::string{"1.0.0"});
|
|
Void::Testing::expect_eq((*healthy)[1].to_string(), std::string{"3.0.0"});
|
|
Void::Testing::expect(
|
|
std::filesystem::is_directory(store.versionPath(version5)));
|
|
|
|
std::filesystem::create_directories(store.versionPath(version2));
|
|
Void::Testing::require(store.recordFailed(version2).has_value());
|
|
healthy = store.healthyPublishedVersions();
|
|
Void::Testing::require(healthy.has_value());
|
|
Void::Testing::expect_eq(healthy->size(), std::size_t{2});
|
|
Void::Testing::require(store.recordHealthy(version2).has_value());
|
|
healthy = store.healthyPublishedVersions();
|
|
Void::Testing::require(healthy.has_value());
|
|
Void::Testing::expect_eq(healthy->size(), std::size_t{3});
|
|
Void::Testing::expect_eq((*healthy)[0].to_string(), std::string{"2.0.0"});
|
|
|
|
std::filesystem::remove_all(store.versionPath(version1));
|
|
healthy = store.healthyPublishedVersions();
|
|
Void::Testing::require(healthy.has_value());
|
|
Void::Testing::expect_eq(healthy->size(), std::size_t{2});
|
|
Void::Testing::expect_eq((*healthy)[0].to_string(), std::string{"2.0.0"});
|
|
Void::Testing::expect_eq((*healthy)[1].to_string(), std::string{"3.0.0"});
|
|
}
|
|
|
|
Void::Testing::Test version_store_prune_never_synthesizes_health()
|
|
{
|
|
#ifndef _WIN32
|
|
Void::FileSystem::TempDir temporary{"void_versions_prune_health_"};
|
|
Void::Update::VersionStore store{temporary.path() / "store"};
|
|
std::filesystem::create_directories(store.root() / "versions");
|
|
const auto failed = *Void::Semver::parse("1.0.0");
|
|
const auto healthy = *Void::Semver::parse("2.0.0");
|
|
std::filesystem::create_directories(store.versionPath(failed));
|
|
std::filesystem::create_directories(store.versionPath(healthy));
|
|
Void::Testing::require(store.recordFailed(failed).has_value());
|
|
Void::Testing::require(store.recordHealthy(healthy).has_value());
|
|
std::filesystem::create_directory_symlink(
|
|
std::filesystem::path{"versions"} / failed.to_string(),
|
|
store.root() / "current");
|
|
|
|
Void::Testing::require(store.prune(1).has_value());
|
|
std::ifstream healthInput{store.root() / "health.log"};
|
|
const std::string healthHistory{std::istreambuf_iterator<char>{healthInput},
|
|
std::istreambuf_iterator<char>{}};
|
|
Void::Testing::expect(healthHistory.find("H 1.0.0\n") == std::string::npos);
|
|
|
|
std::filesystem::remove(store.root() / "current");
|
|
std::filesystem::create_directory_symlink(
|
|
std::filesystem::path{"versions"} / healthy.to_string(),
|
|
store.root() / "current");
|
|
const auto removed = store.prune(0);
|
|
Void::Testing::require(removed.has_value());
|
|
Void::Testing::expect_eq(removed->size(), std::size_t{1});
|
|
Void::Testing::expect(!std::filesystem::exists(store.versionPath(failed)));
|
|
#endif
|
|
}
|
|
|
|
Void::Testing::Test version_store_compacts_health_history_atomically()
|
|
{
|
|
Void::FileSystem::TempDir temporary{"void_versions_health_compaction_"};
|
|
Void::Update::VersionStore store{temporary.path() / "store"};
|
|
std::filesystem::create_directories(store.root() / "versions");
|
|
const auto version1 = *Void::Semver::parse("1.0.0");
|
|
const auto version2 = *Void::Semver::parse("2.0.0");
|
|
std::filesystem::create_directories(store.versionPath(version1));
|
|
std::filesystem::create_directories(store.versionPath(version2));
|
|
{
|
|
std::ofstream history{store.root() / "health.log",
|
|
std::ios::binary | std::ios::trunc};
|
|
for (std::size_t index = 0; index < 100'000; ++index) {
|
|
history << "H 1.0.0\n";
|
|
}
|
|
}
|
|
Void::Testing::require(store.recordHealthy(version2).has_value());
|
|
Void::Testing::expect(
|
|
std::filesystem::file_size(store.root() / "health.log") < 1024);
|
|
|
|
const auto removed = store.prune(1);
|
|
Void::Testing::require(removed.has_value());
|
|
Void::Testing::expect_eq(removed->size(), std::size_t{1});
|
|
Void::Testing::expect_eq(removed->front().to_string(),
|
|
std::string{"1.0.0"});
|
|
Void::Testing::expect(
|
|
std::filesystem::is_directory(store.versionPath(version2)));
|
|
}
|
|
|
|
Void::Testing::Test version_store_rejects_unsafe_activation_journal()
|
|
{
|
|
#ifndef _WIN32
|
|
Void::FileSystem::TempDir temporary{"void_versions_journal_safety_"};
|
|
Void::Update::VersionStore store{temporary.path() / "store"};
|
|
Void::Testing::require(store.initialize().has_value());
|
|
const auto external = temporary.path() / "external-activation.json";
|
|
std::ofstream{external}
|
|
<< R"({"schemaVersion":1,"previousVersion":null,"candidateVersion":"1.0.0"})";
|
|
std::filesystem::create_symlink(external, store.root() / "activation.json");
|
|
Void::Testing::expect(!store.pendingActivation().has_value());
|
|
Void::Testing::expect(std::filesystem::is_regular_file(external));
|
|
|
|
std::filesystem::remove(store.root() / "activation.json");
|
|
{
|
|
std::ofstream oversized{store.root() / "activation.json",
|
|
std::ios::binary | std::ios::trunc};
|
|
oversized.seekp(128 * 1024);
|
|
oversized.put('\0');
|
|
}
|
|
Void::Testing::expect(!store.pendingActivation().has_value());
|
|
|
|
std::filesystem::remove(store.root() / "activation.json");
|
|
std::ofstream{store.root() / "activation.json"}
|
|
<< R"({"schemaVersion":1,"previousVersion":null,"candidateVersion":"1.0.0"})";
|
|
Void::Testing::expect(!store.pendingActivation().has_value());
|
|
#endif
|
|
}
|
|
|
|
Void::Testing::Test version_store_prunes_only_unprotected_real_versions()
|
|
{
|
|
Void::FileSystem::TempDir temporary{"void_versions_prune_"};
|
|
Void::Update::VersionStore store{temporary.path() / "store"};
|
|
Void::Testing::require(store.initialize().has_value());
|
|
|
|
const std::array versionTexts{"1.0.0", "2.0.0", "3.0.0", "4.0.0"};
|
|
for (const std::string_view text : versionTexts) {
|
|
const auto version = *Void::Semver::parse(text);
|
|
auto staging = store.prepare(version);
|
|
Void::Testing::require(staging.has_value());
|
|
std::ofstream{*staging / "marker"} << text;
|
|
Void::Testing::require(store.publish(version, *staging).has_value());
|
|
Void::Testing::require(store.activate(version).has_value());
|
|
Void::Testing::require(store.commit().has_value());
|
|
}
|
|
const auto active = *Void::Semver::parse("4.0.0");
|
|
|
|
const auto staged = store.prepare(*Void::Semver::parse("8.0.0"));
|
|
Void::Testing::require(staged.has_value());
|
|
std::ofstream{*staged / "keep"} << "staging";
|
|
const auto uncommitted = *Void::Semver::parse("7.0.0");
|
|
auto uncommittedStaging = store.prepare(uncommitted);
|
|
Void::Testing::require(uncommittedStaging.has_value());
|
|
std::ofstream{*uncommittedStaging / "marker"} << "uncommitted";
|
|
Void::Testing::require(
|
|
store.publish(uncommitted, *uncommittedStaging).has_value());
|
|
|
|
#ifndef _WIN32
|
|
const auto external = temporary.path() / "external";
|
|
std::filesystem::create_directories(external);
|
|
std::ofstream{external / "keep"} << "outside";
|
|
std::filesystem::create_directory_symlink(
|
|
external, store.versionPath(*Void::Semver::parse("1.0.0")) / "linked");
|
|
std::filesystem::create_directory_symlink(
|
|
external, store.versionPath(*Void::Semver::parse("9.0.0")));
|
|
const auto orphanedQuarantine = store.root() / "versions" / ".prune.orphan";
|
|
std::filesystem::create_directories(orphanedQuarantine);
|
|
std::filesystem::create_directory_symlink(external,
|
|
orphanedQuarantine / "linked");
|
|
#endif
|
|
|
|
auto removed = store.prune(2);
|
|
Void::Testing::require(removed.has_value());
|
|
Void::Testing::expect_eq(removed->size(), std::size_t{1});
|
|
Void::Testing::expect_eq(removed->front().to_string(),
|
|
std::string{"1.0.0"});
|
|
Void::Testing::expect(!std::filesystem::exists(
|
|
store.versionPath(*Void::Semver::parse("1.0.0"))));
|
|
for (const std::string_view text : {"2.0.0", "3.0.0", "4.0.0"}) {
|
|
Void::Testing::expect(std::filesystem::is_directory(
|
|
store.versionPath(*Void::Semver::parse(text))));
|
|
}
|
|
Void::Testing::expect(std::filesystem::exists(*staged / "keep"));
|
|
Void::Testing::expect(
|
|
std::filesystem::is_directory(store.versionPath(uncommitted)));
|
|
#ifndef _WIN32
|
|
Void::Testing::expect(std::filesystem::exists(external / "keep"));
|
|
Void::Testing::expect(!std::filesystem::exists(orphanedQuarantine));
|
|
Void::Testing::expect(std::filesystem::is_symlink(
|
|
store.versionPath(*Void::Semver::parse("9.0.0"))));
|
|
#endif
|
|
|
|
const auto candidate = *Void::Semver::parse("5.0.0");
|
|
auto candidateStaging = store.prepare(candidate);
|
|
Void::Testing::require(candidateStaging.has_value());
|
|
std::ofstream{*candidateStaging / "marker"} << "candidate";
|
|
Void::Testing::require(
|
|
store.publish(candidate, *candidateStaging).has_value());
|
|
Void::Testing::require(store.activate(candidate).has_value());
|
|
removed = store.prune(0);
|
|
Void::Testing::require(removed.has_value());
|
|
Void::Testing::expect_eq(removed->size(), std::size_t{2});
|
|
Void::Testing::expect(
|
|
std::filesystem::is_directory(store.versionPath(candidate)));
|
|
Void::Testing::expect(
|
|
std::filesystem::is_directory(store.versionPath(active)));
|
|
Void::Testing::expect(std::filesystem::exists(*staged / "keep"));
|
|
Void::Testing::expect(
|
|
std::filesystem::is_directory(store.versionPath(uncommitted)));
|
|
Void::Testing::require(store.rollback().has_value());
|
|
const auto current = store.currentVersion();
|
|
Void::Testing::require(current.has_value() && current->has_value());
|
|
Void::Testing::expect_eq((*current)->to_string(), std::string{"4.0.0"});
|
|
removed = store.prune(0);
|
|
Void::Testing::require(removed.has_value());
|
|
Void::Testing::expect_eq(removed->size(), std::size_t{1});
|
|
Void::Testing::expect_eq(removed->front().to_string(),
|
|
std::string{"5.0.0"});
|
|
Void::Testing::expect(
|
|
!std::filesystem::exists(store.versionPath(candidate)));
|
|
Void::Testing::expect(
|
|
std::filesystem::is_directory(store.versionPath(uncommitted)));
|
|
}
|
|
|
|
Void::Testing::Test version_store_rejects_symlink_layout()
|
|
{
|
|
#ifndef _WIN32
|
|
Void::FileSystem::TempDir temporary{"void_versions_links_"};
|
|
const auto target = temporary.path() / "target";
|
|
std::filesystem::create_directories(target);
|
|
|
|
const auto linkedRoot = temporary.path() / "linked-store";
|
|
std::filesystem::create_directory_symlink(target, linkedRoot);
|
|
Void::Update::VersionStore rootStore{linkedRoot};
|
|
Void::Testing::expect(!rootStore.initialize().has_value());
|
|
|
|
const auto versionsRoot = temporary.path() / "versions-store";
|
|
std::filesystem::create_directories(versionsRoot / "staging");
|
|
std::filesystem::create_directory_symlink(target,
|
|
versionsRoot / "versions");
|
|
Void::Update::VersionStore versionsStore{versionsRoot};
|
|
Void::Testing::expect(!versionsStore.initialize().has_value());
|
|
|
|
const auto stagingRoot = temporary.path() / "staging-store";
|
|
std::filesystem::create_directories(stagingRoot / "versions");
|
|
std::filesystem::create_directory_symlink(target, stagingRoot / "staging");
|
|
Void::Update::VersionStore stagingStore{stagingRoot};
|
|
Void::Testing::expect(!stagingStore.initialize().has_value());
|
|
#endif
|
|
}
|
|
|
|
Void::Testing::Test version_store_publish_requires_immediate_real_child()
|
|
{
|
|
Void::FileSystem::TempDir temporary{"void_versions_publish_"};
|
|
Void::Update::VersionStore store{temporary.path() / "store"};
|
|
Void::Testing::require(store.initialize().has_value());
|
|
|
|
const auto nested = store.root() / "staging" / "nested" / "candidate";
|
|
std::filesystem::create_directories(nested);
|
|
const auto version1 = *Void::Semver::parse("3.0.0");
|
|
Void::Testing::expect(!store.publish(version1, nested).has_value());
|
|
|
|
#ifndef _WIN32
|
|
const auto external = temporary.path() / "external-candidate";
|
|
std::filesystem::create_directories(external);
|
|
const auto linked = store.root() / "staging" / "linked-candidate";
|
|
std::filesystem::create_directory_symlink(external, linked);
|
|
const auto version2 = *Void::Semver::parse("3.1.0");
|
|
Void::Testing::expect(!store.publish(version2, linked).has_value());
|
|
#endif
|
|
}
|
|
|
|
Void::Testing::Test version_store_activate_rejects_symlink_version()
|
|
{
|
|
#ifndef _WIN32
|
|
Void::FileSystem::TempDir temporary{"void_versions_activate_"};
|
|
Void::Update::VersionStore store{temporary.path() / "store"};
|
|
Void::Testing::require(store.initialize().has_value());
|
|
const auto external = temporary.path() / "external-version";
|
|
std::filesystem::create_directories(external);
|
|
const auto version = *Void::Semver::parse("4.0.0");
|
|
std::filesystem::create_directory_symlink(external,
|
|
store.versionPath(version));
|
|
Void::Testing::expect(!store.activate(version).has_value());
|
|
Void::Testing::expect(
|
|
!std::filesystem::exists(store.root() / "activation.json"));
|
|
#endif
|
|
}
|
|
|
|
Void::Testing::Test version_store_rollback_revalidates_previous_version()
|
|
{
|
|
#ifndef _WIN32
|
|
Void::FileSystem::TempDir temporary{"void_versions_rollback_links_"};
|
|
Void::Update::VersionStore store{temporary.path() / "store"};
|
|
Void::Testing::require(store.initialize().has_value());
|
|
const auto version1 = *Void::Semver::parse("1.0.0");
|
|
const auto version2 = *Void::Semver::parse("2.0.0");
|
|
for (const auto& version : {version1, version2}) {
|
|
auto staging = store.prepare(version);
|
|
Void::Testing::require(staging.has_value());
|
|
std::ofstream{*staging / "marker"} << version.to_string();
|
|
Void::Testing::require(store.publish(version, *staging).has_value());
|
|
}
|
|
Void::Testing::require(store.activate(version1).has_value());
|
|
Void::Testing::require(store.commit().has_value());
|
|
Void::Testing::require(store.activate(version2).has_value());
|
|
|
|
const auto external = temporary.path() / "external-previous";
|
|
std::filesystem::create_directories(external);
|
|
std::filesystem::remove_all(store.versionPath(version1));
|
|
std::filesystem::create_directory_symlink(external,
|
|
store.versionPath(version1));
|
|
Void::Testing::expect(!store.rollback().has_value());
|
|
Void::Testing::expect(
|
|
std::filesystem::exists(store.root() / "activation.json"));
|
|
const auto current = store.currentVersion();
|
|
Void::Testing::require(current.has_value() && current->has_value());
|
|
Void::Testing::expect_eq((*current)->to_string(), std::string{"2.0.0"});
|
|
Void::Testing::expect(std::filesystem::is_directory(external));
|
|
#endif
|
|
}
|