Skip to content

Commit a720921

Browse files
authored
Test an absolute symlink (#4528)
1 parent c59faea commit a720921

File tree

1 file changed

+16
-2
lines changed

1 file changed

+16
-2
lines changed

toolchain/install/busybox_info_test.cpp

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,9 +23,9 @@ class BusyboxInfoTest : public ::testing::Test {
2323
explicit BusyboxInfoTest() {
2424
const char* tmpdir = std::getenv("TEST_TMPDIR");
2525
CARBON_CHECK(tmpdir);
26-
dir_ = MakeDir(
26+
dir_ = MakeDir(std::filesystem::absolute(
2727
std::filesystem::path(tmpdir) /
28-
::testing::UnitTest::GetInstance()->current_test_info()->name());
28+
::testing::UnitTest::GetInstance()->current_test_info()->name()));
2929
}
3030

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

140+
TEST_F(BusyboxInfoTest, AbsoluteSymlink) {
141+
MakeDir(dir_ / "lib");
142+
MakeDir(dir_ / "lib/carbon");
143+
auto busybox = MakeFile(dir_ / "lib/carbon/carbon-busybox");
144+
ASSERT_TRUE(busybox.is_absolute());
145+
MakeDir(dir_ / "bin");
146+
auto target = MakeSymlink(dir_ / "bin/carbon", busybox);
147+
148+
auto info = GetBusyboxInfo(target.string());
149+
ASSERT_TRUE(info.ok()) << info.error();
150+
EXPECT_THAT(info->bin_path, Eq(busybox));
151+
EXPECT_THAT(info->mode, Eq("carbon"));
152+
}
153+
140154
TEST_F(BusyboxInfoTest, NotBusyboxFile) {
141155
auto target = MakeFile(dir_ / "file");
142156

0 commit comments

Comments
 (0)