Files
lix/tests/unit/libstore/path-tree.cc
T
Alois Wohlschlager 2090853b80 falsify the glibc store paths
Commits 205c59367c and
325e7e1824 introduced real glibc store paths from
current nixpkgs unstable into the source. Since nixpkgs `fetchFromGitea` (and
similar fixed-output derivations) depends on a C library, on x86_64-linux they
will fail with the forbidden reference error:

error: the fixed-output derivation '/nix/store/wnmnj3jzc82y89sfmyicr04kilg8zs2k-source.drv' must not reference store paths but 1 such references were found:
         /nix/store/q4wq65gl3r8fy746v9bbwgx4gzn0r2kl-glibc-2.40-66

Falsify the store path to prevent this failure.

Change-Id: I949033567bcad070f9a0a19cefdb33a79222e421
2025-07-13 10:56:47 +02:00

61 lines
2.0 KiB
C++

#include <gtest/gtest.h>
#include "lix/libstore/path-tree.hh"
#include "lix/libstore/path.hh"
#include "lix/libstore/store-api.hh"
#include "lix/libutil/async.hh"
namespace nix {
TEST(PathTree, simple)
{
AsyncIoRoot aio;
auto store = aio.blockOn(openStore("dummy://"));
auto parent = StorePath{"hr8lmmjmd1jk6s3p5ymggyk4am7n2lmb-openssh-10.0p2"};
auto child = StorePath{"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa-glibc-2.40-66"};
std::map<StorePath, StorePathSet> graph;
graph.insert({child, {}});
graph.insert({parent, {child}});
auto graph_data =
aio.blockOn(genGraphString(parent, child, graph, *store, false, false));
// clang-format off
ASSERT_EQ(
graph_data,
"/nix/store/hr8lmmjmd1jk6s3p5ymggyk4am7n2lmb-openssh-10.0p2\n"
"\x1B[1m└───/nix/store/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa-glibc-2.40-66\x1B[0m"
);
// clang-format on
}
TEST(PathTree, all)
{
AsyncIoRoot aio;
auto store = aio.blockOn(openStore("dummy://"));
auto parent = StorePath{"hr8lmmjmd1jk6s3p5ymggyk4am7n2lmb-openssh-10.0p2"};
auto child = StorePath{"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa-glibc-2.40-66"};
auto intermediate = StorePath{"6r4zqb04fq5l5l4zghq76wvcpz7dwd35-linux-pam-1.6.1"};
std::map<StorePath, StorePathSet> graph;
graph.insert({intermediate, {child}});
graph.insert({parent, {intermediate, child}});
graph.insert({child, {}});
// clang-format off
const std::string expected =
"/nix/store/hr8lmmjmd1jk6s3p5ymggyk4am7n2lmb-openssh-10.0p2\n"
"\x1B[1m├───/nix/store/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa-glibc-2.40-66\x1B[0m\n"
"└───/nix/store/6r4zqb04fq5l5l4zghq76wvcpz7dwd35-linux-pam-1.6.1\x1B[0m\n"
" \x1B[1m└───/nix/store/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa-glibc-2.40-66\x1B[0m";
// clang-format on
auto graph_data =
aio.blockOn(genGraphString(parent, child, graph, *store, true, false));
ASSERT_EQ(graph_data, expected);
}
}