Skip to content

Commit

Permalink
[libc][NFC] Switch nanosleep_test and getcwd_test to libc_errno.
Browse files Browse the repository at this point in the history
  • Loading branch information
Siva Chandra Reddy committed Mar 14, 2023
1 parent bb03705 commit 7e6462d
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion libc/src/time/nanosleep.cpp
Expand Up @@ -20,7 +20,7 @@ LLVM_LIBC_FUNCTION(int, nanosleep,
(const struct timespec *req, struct timespec *rem)) {
int ret = __llvm_libc::syscall_impl(SYS_nanosleep, req, rem);
if (ret < 0) {
errno = -ret;
libc_errno = -ret;
return -1;
}
return ret;
Expand Down
2 changes: 1 addition & 1 deletion libc/test/integration/src/unistd/CMakeLists.txt
Expand Up @@ -10,8 +10,8 @@ add_integration_test(
STARTUP
libc.startup.linux.crt1
DEPENDS
libc.include.errno
libc.src.__support.CPP.string_view
libc.src.errno.errno
libc.src.stdlib.getenv
libc.src.unistd.getcwd
)
Expand Down
8 changes: 4 additions & 4 deletions libc/test/integration/src/unistd/getcwd_test.cpp
Expand Up @@ -7,12 +7,12 @@
//===----------------------------------------------------------------------===//

#include "src/__support/CPP/string_view.h"
#include "src/errno/libc_errno.h"
#include "src/stdlib/getenv.h"
#include "src/unistd/getcwd.h"

#include "test/IntegrationTest/test.h"

#include <errno.h>
#include <stdlib.h> // For malloc and free

using __llvm_libc::cpp::string_view;
Expand All @@ -30,13 +30,13 @@ TEST_MAIN(int argc, char **argv, char **envp) {
// Bad size
cwd = __llvm_libc::getcwd(buffer, 0);
ASSERT_TRUE(cwd == nullptr);
ASSERT_EQ(errno, EINVAL);
errno = 0;
ASSERT_EQ(libc_errno, EINVAL);
libc_errno = 0;

// Insufficient size
cwd = __llvm_libc::getcwd(buffer, 2);
ASSERT_TRUE(cwd == nullptr);
int err = errno;
int err = libc_errno;
ASSERT_EQ(err, ERANGE);

return 0;
Expand Down

0 comments on commit 7e6462d

Please sign in to comment.