Skip to content

Commit

Permalink
Test an absolute symlink (#4528)
Browse files Browse the repository at this point in the history
  • Loading branch information
jonmeow authored Nov 14, 2024
1 parent c59faea commit a720921
Showing 1 changed file with 16 additions and 2 deletions.
18 changes: 16 additions & 2 deletions toolchain/install/busybox_info_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@ class BusyboxInfoTest : public ::testing::Test {
explicit BusyboxInfoTest() {
const char* tmpdir = std::getenv("TEST_TMPDIR");
CARBON_CHECK(tmpdir);
dir_ = MakeDir(
dir_ = MakeDir(std::filesystem::absolute(
std::filesystem::path(tmpdir) /
::testing::UnitTest::GetInstance()->current_test_info()->name());
::testing::UnitTest::GetInstance()->current_test_info()->name()));
}

// Delete the test case's temp directory.
Expand Down Expand Up @@ -137,6 +137,20 @@ TEST_F(BusyboxInfoTest, RelativeSymlink) {
EXPECT_THAT(info->mode, Eq("carbon"));
}

TEST_F(BusyboxInfoTest, AbsoluteSymlink) {
MakeDir(dir_ / "lib");
MakeDir(dir_ / "lib/carbon");
auto busybox = MakeFile(dir_ / "lib/carbon/carbon-busybox");
ASSERT_TRUE(busybox.is_absolute());
MakeDir(dir_ / "bin");
auto target = MakeSymlink(dir_ / "bin/carbon", busybox);

auto info = GetBusyboxInfo(target.string());
ASSERT_TRUE(info.ok()) << info.error();
EXPECT_THAT(info->bin_path, Eq(busybox));
EXPECT_THAT(info->mode, Eq("carbon"));
}

TEST_F(BusyboxInfoTest, NotBusyboxFile) {
auto target = MakeFile(dir_ / "file");

Expand Down

0 comments on commit a720921

Please sign in to comment.