mirror of
https://github.com/RGBCube/serenity
synced 2025-07-26 01:37:35 +00:00
Userland+Tests: Convert File::read_link() from String to ErrorOr<String>
This converts the return value of File::read_link() from String to ErrorOr<String>. The rest of the change is to support the potential of an Error being returned and subsequent release of the value when no Error is returned. Unfortunately at this stage none of the places affected can utililize our TRY() macro.
This commit is contained in:
parent
10093a6773
commit
4a57be824c
12 changed files with 72 additions and 30 deletions
|
@ -58,7 +58,10 @@ TEST_CASE(test_interp_header_tiny_p_filesz)
|
|||
int nwritten = write(fd, buffer, sizeof(buffer));
|
||||
EXPECT(nwritten);
|
||||
|
||||
auto elf_path = Core::File::read_link(String::formatted("/proc/{}/fd/{}", getpid(), fd));
|
||||
auto elf_path_or_error = Core::File::read_link(String::formatted("/proc/{}/fd/{}", getpid(), fd));
|
||||
EXPECT(!elf_path_or_error.is_error());
|
||||
|
||||
auto elf_path = elf_path_or_error.release_value();
|
||||
EXPECT(elf_path.characters());
|
||||
|
||||
int rc = execl(elf_path.characters(), "test-elf", nullptr);
|
||||
|
@ -112,7 +115,10 @@ TEST_CASE(test_interp_header_p_filesz_larger_than_p_memsz)
|
|||
int nwritten = write(fd, buffer, sizeof(buffer));
|
||||
EXPECT(nwritten);
|
||||
|
||||
auto elf_path = Core::File::read_link(String::formatted("/proc/{}/fd/{}", getpid(), fd));
|
||||
auto elf_path_or_error = Core::File::read_link(String::formatted("/proc/{}/fd/{}", getpid(), fd));
|
||||
EXPECT(!elf_path_or_error.is_error());
|
||||
|
||||
auto elf_path = elf_path_or_error.release_value();
|
||||
EXPECT(elf_path.characters());
|
||||
|
||||
int rc = execl(elf_path.characters(), "test-elf", nullptr);
|
||||
|
@ -170,7 +176,10 @@ TEST_CASE(test_interp_header_p_filesz_plus_p_offset_overflow_p_memsz)
|
|||
int nwritten = write(fd, buffer, sizeof(buffer));
|
||||
EXPECT(nwritten);
|
||||
|
||||
auto elf_path = Core::File::read_link(String::formatted("/proc/{}/fd/{}", getpid(), fd));
|
||||
auto elf_path_or_error = Core::File::read_link(String::formatted("/proc/{}/fd/{}", getpid(), fd));
|
||||
EXPECT(!elf_path_or_error.is_error());
|
||||
|
||||
auto elf_path = elf_path_or_error.release_value();
|
||||
EXPECT(elf_path.characters());
|
||||
|
||||
int rc = execl(elf_path.characters(), "test-elf", nullptr);
|
||||
|
@ -225,7 +234,10 @@ TEST_CASE(test_load_header_p_memsz_zero)
|
|||
int nwritten = write(fd, buffer, sizeof(buffer));
|
||||
EXPECT(nwritten);
|
||||
|
||||
auto elf_path = Core::File::read_link(String::formatted("/proc/{}/fd/{}", getpid(), fd));
|
||||
auto elf_path_or_error = Core::File::read_link(String::formatted("/proc/{}/fd/{}", getpid(), fd));
|
||||
EXPECT(!elf_path_or_error.is_error());
|
||||
|
||||
auto elf_path = elf_path_or_error.release_value();
|
||||
EXPECT(elf_path.characters());
|
||||
|
||||
int rc = execl(elf_path.characters(), "test-elf", nullptr);
|
||||
|
@ -280,7 +292,10 @@ TEST_CASE(test_load_header_p_memsz_not_equal_to_p_align)
|
|||
int nwritten = write(fd, buffer, sizeof(buffer));
|
||||
EXPECT(nwritten);
|
||||
|
||||
auto elf_path = Core::File::read_link(String::formatted("/proc/{}/fd/{}", getpid(), fd));
|
||||
auto elf_path_or_error = Core::File::read_link(String::formatted("/proc/{}/fd/{}", getpid(), fd));
|
||||
EXPECT(!elf_path_or_error.is_error());
|
||||
|
||||
auto elf_path = elf_path_or_error.release_value();
|
||||
EXPECT(elf_path.characters());
|
||||
|
||||
int rc = execl(elf_path.characters(), "test-elf", nullptr);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue