1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 23:07:35 +00:00

Tests: Use FileSystem instead of DeprecatedFile

This commit is contained in:
Cameron Youell 2023-03-27 00:37:51 +00:00 committed by Andrew Kaster
parent 1c54c8a01c
commit 03008ec4e0
6 changed files with 615 additions and 565 deletions

View file

@ -4,7 +4,7 @@
* SPDX-License-Identifier: BSD-2-Clause
*/
#include <LibCore/DeprecatedFile.h>
#include <LibFileSystem/FileSystem.h>
#include <LibTest/TestCase.h>
#include <elf.h>
#include <fcntl.h>
@ -58,10 +58,10 @@ TEST_CASE(test_interp_header_tiny_p_filesz)
int nwritten = write(fd, buffer, sizeof(buffer));
EXPECT(nwritten);
auto elf_path_or_error = Core::DeprecatedFile::read_link(DeprecatedString::formatted("/proc/{}/fd/{}", getpid(), fd));
auto elf_path_or_error = FileSystem::read_link(DeprecatedString::formatted("/proc/{}/fd/{}", getpid(), fd));
EXPECT(!elf_path_or_error.is_error());
auto elf_path = elf_path_or_error.release_value();
auto elf_path = elf_path_or_error.release_value().to_deprecated_string();
EXPECT(elf_path.characters());
int rc = execl(elf_path.characters(), "test-elf", nullptr);
@ -115,10 +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_or_error = Core::DeprecatedFile::read_link(DeprecatedString::formatted("/proc/{}/fd/{}", getpid(), fd));
auto elf_path_or_error = FileSystem::read_link(DeprecatedString::formatted("/proc/{}/fd/{}", getpid(), fd));
EXPECT(!elf_path_or_error.is_error());
auto elf_path = elf_path_or_error.release_value();
auto elf_path = elf_path_or_error.release_value().to_deprecated_string();
EXPECT(elf_path.characters());
int rc = execl(elf_path.characters(), "test-elf", nullptr);
@ -176,10 +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_or_error = Core::DeprecatedFile::read_link(DeprecatedString::formatted("/proc/{}/fd/{}", getpid(), fd));
auto elf_path_or_error = FileSystem::read_link(DeprecatedString::formatted("/proc/{}/fd/{}", getpid(), fd));
EXPECT(!elf_path_or_error.is_error());
auto elf_path = elf_path_or_error.release_value();
auto elf_path = elf_path_or_error.release_value().to_deprecated_string();
EXPECT(elf_path.characters());
int rc = execl(elf_path.characters(), "test-elf", nullptr);
@ -234,10 +234,10 @@ TEST_CASE(test_load_header_p_memsz_zero)
int nwritten = write(fd, buffer, sizeof(buffer));
EXPECT(nwritten);
auto elf_path_or_error = Core::DeprecatedFile::read_link(DeprecatedString::formatted("/proc/{}/fd/{}", getpid(), fd));
auto elf_path_or_error = FileSystem::read_link(DeprecatedString::formatted("/proc/{}/fd/{}", getpid(), fd));
EXPECT(!elf_path_or_error.is_error());
auto elf_path = elf_path_or_error.release_value();
auto elf_path = elf_path_or_error.release_value().to_deprecated_string();
EXPECT(elf_path.characters());
int rc = execl(elf_path.characters(), "test-elf", nullptr);
@ -292,10 +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_or_error = Core::DeprecatedFile::read_link(DeprecatedString::formatted("/proc/{}/fd/{}", getpid(), fd));
auto elf_path_or_error = FileSystem::read_link(DeprecatedString::formatted("/proc/{}/fd/{}", getpid(), fd));
EXPECT(!elf_path_or_error.is_error());
auto elf_path = elf_path_or_error.release_value();
auto elf_path = elf_path_or_error.release_value().to_deprecated_string();
EXPECT(elf_path.characters());
int rc = execl(elf_path.characters(), "test-elf", nullptr);