summaryrefslogtreecommitdiff
path: root/Tests
diff options
context:
space:
mode:
authorCameron Youell <cameronyouell@gmail.com>2023-03-27 00:37:51 +0000
committerAndrew Kaster <andrewdkaster@gmail.com>2023-04-09 20:58:54 -0600
commit03008ec4e0250d7ad8f2ed8db828536347c59738 (patch)
treea81e6d80446b21b58732817b56ecf72fe23bf53f /Tests
parent1c54c8a01cc64489faa007c502ab96f11482ee17 (diff)
downloadserenity-03008ec4e0250d7ad8f2ed8db828536347c59738.zip
Tests: Use `FileSystem` instead of `DeprecatedFile`
Diffstat (limited to 'Tests')
-rw-r--r--Tests/Kernel/TestKernelFilePermissions.cpp6
-rw-r--r--Tests/LibC/TestIo.cpp6
-rw-r--r--Tests/LibC/TestLibCMkTemp.cpp18
-rw-r--r--Tests/LibELF/test-elf.cpp22
4 files changed, 26 insertions, 26 deletions
diff --git a/Tests/Kernel/TestKernelFilePermissions.cpp b/Tests/Kernel/TestKernelFilePermissions.cpp
index ec58a1f10a..1dbab644bd 100644
--- a/Tests/Kernel/TestKernelFilePermissions.cpp
+++ b/Tests/Kernel/TestKernelFilePermissions.cpp
@@ -5,7 +5,7 @@
*/
#include <AK/DeprecatedString.h>
-#include <LibCore/DeprecatedFile.h>
+#include <LibFileSystem/FileSystem.h>
#include <LibTest/TestCase.h>
#include <fcntl.h>
#include <stdio.h>
@@ -81,10 +81,10 @@ TEST_CASE(test_change_file_location)
ftruncate(fd, 0);
EXPECT(fchmod(fd, 06755) != -1);
- auto suid_path_or_error = Core::DeprecatedFile::read_link(DeprecatedString::formatted("/proc/{}/fd/{}", getpid(), fd));
+ auto suid_path_or_error = FileSystem::read_link(DeprecatedString::formatted("/proc/{}/fd/{}", getpid(), fd));
EXPECT(!suid_path_or_error.is_error());
- auto suid_path = suid_path_or_error.release_value();
+ auto suid_path = suid_path_or_error.release_value().to_deprecated_string();
EXPECT(suid_path.characters());
auto new_path = DeprecatedString::formatted("{}.renamed", suid_path);
diff --git a/Tests/LibC/TestIo.cpp b/Tests/LibC/TestIo.cpp
index b7bcd58359..c111b2ab4d 100644
--- a/Tests/LibC/TestIo.cpp
+++ b/Tests/LibC/TestIo.cpp
@@ -7,7 +7,7 @@
#include <AK/Assertions.h>
#include <AK/Types.h>
-#include <LibCore/DeprecatedFile.h>
+#include <LibFileSystem/FileSystem.h>
#include <LibTest/TestCase.h>
#include <fcntl.h>
#include <stdio.h>
@@ -217,11 +217,11 @@ TEST_CASE(unlink_symlink)
perror("symlink");
}
- auto target_or_error = Core::DeprecatedFile::read_link("/tmp/linky");
+ auto target_or_error = FileSystem::read_link("/tmp/linky"sv);
EXPECT(!target_or_error.is_error());
auto target = target_or_error.release_value();
- EXPECT_EQ(target, "/proc/2/foo");
+ EXPECT_EQ(target.bytes_as_string_view(), "/proc/2/foo"sv);
rc = unlink("/tmp/linky");
EXPECT(rc >= 0);
diff --git a/Tests/LibC/TestLibCMkTemp.cpp b/Tests/LibC/TestLibCMkTemp.cpp
index 9f7eedac6f..81e4c61309 100644
--- a/Tests/LibC/TestLibCMkTemp.cpp
+++ b/Tests/LibC/TestLibCMkTemp.cpp
@@ -6,7 +6,7 @@
*/
#include <AK/DeprecatedString.h>
-#include <LibCore/DeprecatedFile.h>
+#include <LibFileSystem/FileSystem.h>
#include <LibTest/TestCase.h>
#include <fcntl.h>
#include <stdio.h>
@@ -86,10 +86,10 @@ TEST_CASE(test_mkstemp_unique_filename)
auto fd = mkstemp(path);
EXPECT_NE(fd, -1);
- auto temp_path_or_error = Core::DeprecatedFile::read_link(DeprecatedString::formatted("/proc/{}/fd/{}", getpid(), fd));
+ auto temp_path_or_error = FileSystem::read_link(DeprecatedString::formatted("/proc/{}/fd/{}", getpid(), fd));
EXPECT(!temp_path_or_error.is_error());
- auto temp_path = temp_path_or_error.release_value();
+ auto temp_path = temp_path_or_error.release_value().to_deprecated_string();
EXPECT(temp_path.characters());
close(fd);
@@ -107,10 +107,10 @@ TEST_CASE(test_mkstemp_unique_filename)
auto fd = mkstemp(path);
EXPECT(fd != -1);
- auto path2_or_error = Core::DeprecatedFile::read_link(DeprecatedString::formatted("/proc/{}/fd/{}", getpid(), fd));
+ auto path2_or_error = FileSystem::read_link(DeprecatedString::formatted("/proc/{}/fd/{}", getpid(), fd));
EXPECT(!path2_or_error.is_error());
- auto path2 = path2_or_error.release_value();
+ auto path2 = path2_or_error.release_value().to_deprecated_string();
EXPECT(path2.characters());
close(fd);
@@ -132,10 +132,10 @@ TEST_CASE(test_mkstemps_unique_filename)
auto fd = mkstemps(path, 6);
EXPECT_NE(fd, -1);
- auto temp_path_or_error = Core::DeprecatedFile::read_link(DeprecatedString::formatted("/proc/{}/fd/{}", getpid(), fd));
+ auto temp_path_or_error = FileSystem::read_link(DeprecatedString::formatted("/proc/{}/fd/{}", getpid(), fd));
EXPECT(!temp_path_or_error.is_error());
- auto temp_path = temp_path_or_error.release_value();
+ auto temp_path = temp_path_or_error.release_value().to_deprecated_string();
EXPECT(temp_path.characters());
close(fd);
@@ -157,10 +157,10 @@ TEST_CASE(test_mkstemps_unique_filename)
auto fd = mkstemps(path, 6);
EXPECT(fd != -1);
- auto path2_or_error = Core::DeprecatedFile::read_link(DeprecatedString::formatted("/proc/{}/fd/{}", getpid(), fd));
+ auto path2_or_error = FileSystem::read_link(DeprecatedString::formatted("/proc/{}/fd/{}", getpid(), fd));
EXPECT(!path2_or_error.is_error());
- auto path2 = path2_or_error.release_value();
+ auto path2 = path2_or_error.release_value().to_deprecated_string();
EXPECT(path2.characters());
close(fd);
diff --git a/Tests/LibELF/test-elf.cpp b/Tests/LibELF/test-elf.cpp
index 2cb187a6a3..2dc2590557 100644
--- a/Tests/LibELF/test-elf.cpp
+++ b/Tests/LibELF/test-elf.cpp
@@ -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);