Skip to content

Commit 1ae0dae

Browse files
[libc] Clean up skipped and failing cmake (#115400)
I normally run my cmake with LIBC_CMAKE_VERBOSE_LOGGING set to ON so I can debug build issues more easily. One of the effects of this is I see which tests/entrypoints are skipped on my machine. This patch fixes up the tests and entrypoints that were skipped, but easily fixed. These were: libc.src.pthread.pthread_spin_destroy libc.src.pthread.pthread_spin_init libc.src.pthread.pthread_spin_lock libc.src.pthread.pthread_spin_trylock libc.src.pthread.pthread_spin_unlock (entrypoints were just missing) libc.src.wchar.btowc (I forgot to finish it) libc.test.src.sys.statvfs.linux.statvfs_test libc.test.src.sys.statvfs.linux.fstatvfs_test (Incorrect includes for rmdir, needed some cleanup) libc.test.integration.src.unistd.execve_test (wrong dep for errno) libc.test.src.math.smoke.fmaf_test (add_fp_unittest doesn't support flags) libc.test.src.stdio.scanf_core.converter_test (needed to be moved away from string_reader, further cleanup needed)
1 parent 36cbc09 commit 1ae0dae

File tree

12 files changed

+39
-24
lines changed

12 files changed

+39
-24
lines changed

libc/config/linux/x86_64/entrypoints.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -347,6 +347,7 @@ set(TARGET_LIBC_ENTRYPOINTS
347347

348348
# wchar.h entrypoints
349349
libc.src.wchar.wctob
350+
libc.src.wchar.btowc
350351
)
351352

352353
if(LLVM_LIBC_INCLUDE_SCUDO)
@@ -949,6 +950,11 @@ if(LLVM_LIBC_FULL_BUILD)
949950
libc.src.pthread.pthread_rwlockattr_init
950951
libc.src.pthread.pthread_rwlockattr_setkind_np
951952
libc.src.pthread.pthread_rwlockattr_setpshared
953+
libc.src.pthread.pthread_spin_destroy
954+
libc.src.pthread.pthread_spin_init
955+
libc.src.pthread.pthread_spin_lock
956+
libc.src.pthread.pthread_spin_trylock
957+
libc.src.pthread.pthread_spin_unlock
952958
libc.src.pthread.pthread_self
953959
libc.src.pthread.pthread_setname_np
954960
libc.src.pthread.pthread_setspecific

libc/src/stdio/scanf_core/reader.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ using StreamUngetc = void (*)(int, void *);
2222
// This is intended to be either a raw string or a buffer syncronized with the
2323
// file's internal buffer.
2424
struct ReadBuffer {
25-
char *buffer;
25+
const char *buffer;
2626
size_t buff_len;
2727
size_t buff_cur = 0;
2828
};
@@ -32,6 +32,7 @@ class Reader {
3232

3333
void *input_stream = nullptr;
3434

35+
// TODO: Remove these unnecessary function pointers
3536
StreamGetc stream_getc = nullptr;
3637
StreamUngetc stream_ungetc = nullptr;
3738

libc/src/stdio/sscanf.cpp

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@ LLVM_LIBC_FUNCTION(int, sscanf,
2929
// and pointer semantics, as well as handling
3030
// destruction automatically.
3131
va_end(vlist);
32-
scanf_core::ReadBuffer rb{const_cast<char *>(buffer),
33-
cpp::numeric_limits<size_t>::max()};
32+
scanf_core::ReadBuffer rb{buffer, cpp::numeric_limits<size_t>::max()};
3433
scanf_core::Reader reader(&rb);
3534
int ret_val = scanf_core::scanf_main(&reader, format, args);
3635
// This is done to avoid including stdio.h in the internals. On most systems

libc/src/wchar/CMakeLists.txt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,18 @@ add_entrypoint_object(
77
wctob.h
88
DEPENDS
99
libc.hdr.types.wint_t
10+
libc.hdr.stdio_macros
11+
libc.src.__support.wctype_utils
12+
)
13+
14+
add_entrypoint_object(
15+
btowc
16+
SRCS
17+
btowc.cpp
18+
HDRS
19+
btowc.h
20+
DEPENDS
21+
libc.hdr.types.wint_t
22+
libc.hdr.wchar_macros
1023
libc.src.__support.wctype_utils
1124
)

libc/src/wchar/btowc.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,12 +11,12 @@
1111
#include "src/__support/macros/config.h"
1212
#include "src/__support/wctype_utils.h"
1313

14-
#include "hdr/stdio_macros.h" // for EOF.
1514
#include "hdr/types/wint_t.h"
15+
#include "hdr/wchar_macros.h" // for WEOF.
1616

1717
namespace LIBC_NAMESPACE_DECL {
1818

19-
LLVM_LIBC_FUNCTION(int, btowc, (wint_t c)) {
19+
LLVM_LIBC_FUNCTION(wint_t, btowc, (int c)) {
2020
auto result = internal::btowc(c);
2121
if (result.has_value()) {
2222
return result.value();

libc/test/integration/src/unistd/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ add_integration_test(
111111
DEPENDS
112112
libc_execv_test_normal_exit
113113
libc_execv_test_signal_exit
114-
libc.errno.errno
114+
libc.src.errno.errno
115115
libc.src.sys.wait.waitpid
116116
libc.src.unistd.execve
117117
libc.src.unistd.fork

libc/test/src/math/smoke/CMakeLists.txt

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3524,8 +3524,6 @@ add_fp_unittest(
35243524
DEPENDS
35253525
libc.src.math.fmaf
35263526
libc.src.__support.macros.properties.types
3527-
FLAGS
3528-
FMA_OPT__ONLY
35293527
)
35303528

35313529
add_fp_unittest(

libc/test/src/stdio/scanf_core/CMakeLists.txt

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ add_libc_unittest(
3838
converter_test.cpp
3939
DEPENDS
4040
libc.src.stdio.scanf_core.reader
41-
libc.src.stdio.scanf_core.string_reader
4241
libc.src.stdio.scanf_core.converter
4342
libc.src.__support.CPP.string_view
4443
)

libc/test/src/stdio/scanf_core/converter_test.cpp

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,12 @@
1010
#include "src/stdio/scanf_core/converter.h"
1111
#include "src/stdio/scanf_core/core_structs.h"
1212
#include "src/stdio/scanf_core/reader.h"
13-
#include "src/stdio/scanf_core/string_reader.h"
1413

1514
#include "test/UnitTest/Test.h"
1615

1716
TEST(LlvmLibcScanfConverterTest, RawMatchBasic) {
1817
const char *str = "abcdef";
19-
LIBC_NAMESPACE::scanf_core::StringReader str_reader(str);
18+
LIBC_NAMESPACE::scanf_core::ReadBuffer str_reader{str, sizeof(str)};
2019
LIBC_NAMESPACE::scanf_core::Reader reader(&str_reader);
2120

2221
// Reading "abc" should succeed.
@@ -52,7 +51,7 @@ TEST(LlvmLibcScanfConverterTest, RawMatchBasic) {
5251

5352
TEST(LlvmLibcScanfConverterTest, RawMatchSpaces) {
5453
const char *str = " a \t\n b cd";
55-
LIBC_NAMESPACE::scanf_core::StringReader str_reader(str);
54+
LIBC_NAMESPACE::scanf_core::ReadBuffer str_reader{str, sizeof(str)};
5655
LIBC_NAMESPACE::scanf_core::Reader reader(&str_reader);
5756

5857
// Reading "a" should fail and not advance.
@@ -99,7 +98,7 @@ TEST(LlvmLibcScanfConverterTest, RawMatchSpaces) {
9998
TEST(LlvmLibcScanfConverterTest, StringConvSimple) {
10099
const char *str = "abcDEF123 654LKJihg";
101100
char result[20];
102-
LIBC_NAMESPACE::scanf_core::StringReader str_reader(str);
101+
LIBC_NAMESPACE::scanf_core::ReadBuffer str_reader{str, sizeof(str)};
103102
LIBC_NAMESPACE::scanf_core::Reader reader(&str_reader);
104103

105104
LIBC_NAMESPACE::scanf_core::FormatSection conv;
@@ -121,7 +120,7 @@ TEST(LlvmLibcScanfConverterTest, StringConvSimple) {
121120

122121
TEST(LlvmLibcScanfConverterTest, StringConvNoWrite) {
123122
const char *str = "abcDEF123 654LKJihg";
124-
LIBC_NAMESPACE::scanf_core::StringReader str_reader(str);
123+
LIBC_NAMESPACE::scanf_core::ReadBuffer str_reader{str, sizeof(str)};
125124
LIBC_NAMESPACE::scanf_core::Reader reader(&str_reader);
126125

127126
LIBC_NAMESPACE::scanf_core::FormatSection conv;
@@ -142,7 +141,7 @@ TEST(LlvmLibcScanfConverterTest, StringConvNoWrite) {
142141
TEST(LlvmLibcScanfConverterTest, StringConvWidth) {
143142
const char *str = "abcDEF123 654LKJihg";
144143
char result[6];
145-
LIBC_NAMESPACE::scanf_core::StringReader str_reader(str);
144+
LIBC_NAMESPACE::scanf_core::ReadBuffer str_reader{str, sizeof(str)};
146145
LIBC_NAMESPACE::scanf_core::Reader reader(&str_reader);
147146

148147
LIBC_NAMESPACE::scanf_core::FormatSection conv;
@@ -176,7 +175,7 @@ TEST(LlvmLibcScanfConverterTest, StringConvWidth) {
176175
TEST(LlvmLibcScanfConverterTest, CharsConv) {
177176
const char *str = "abcDEF123 654LKJihg MNOpqr&*(";
178177
char result[20];
179-
LIBC_NAMESPACE::scanf_core::StringReader str_reader(str);
178+
LIBC_NAMESPACE::scanf_core::ReadBuffer str_reader{str, sizeof(str)};
180179
LIBC_NAMESPACE::scanf_core::Reader reader(&str_reader);
181180

182181
LIBC_NAMESPACE::scanf_core::FormatSection conv;
@@ -231,7 +230,7 @@ TEST(LlvmLibcScanfConverterTest, CharsConv) {
231230
TEST(LlvmLibcScanfConverterTest, ScansetConv) {
232231
const char *str = "abcDEF[123] 654LKJihg";
233232
char result[20];
234-
LIBC_NAMESPACE::scanf_core::StringReader str_reader(str);
233+
LIBC_NAMESPACE::scanf_core::ReadBuffer str_reader{str, sizeof(str)};
235234
LIBC_NAMESPACE::scanf_core::Reader reader(&str_reader);
236235

237236
LIBC_NAMESPACE::scanf_core::FormatSection conv;

libc/test/src/sys/statvfs/linux/CMakeLists.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ add_libc_unittest(
1010
libc.src.errno.errno
1111
libc.src.sys.statvfs.statvfs
1212
libc.src.sys.stat.mkdirat
13-
libc.src.sys.stat.rmdir
13+
libc.src.unistd.rmdir
1414
libc.test.UnitTest.ErrnoSetterMatcher
1515
)
1616

@@ -24,7 +24,7 @@ add_libc_unittest(
2424
libc.src.errno.errno
2525
libc.src.sys.statvfs.fstatvfs
2626
libc.src.sys.stat.mkdirat
27-
libc.src.sys.stat.rmdir
27+
libc.src.unistd.rmdir
2828
libc.src.fcntl.open
2929
libc.src.unistd.close
3030
libc.test.UnitTest.ErrnoSetterMatcher

libc/test/src/sys/statvfs/linux/fstatvfs_test.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ TEST(LlvmLibcSysFStatvfsTest, FStatvfsBasic) {
3333
TEST(LlvmLibcSysFStatvfsTest, FStatvfsInvalidPath) {
3434
struct statvfs buf;
3535

36-
constexpr const char *FILENAME = "testdata/statvfs.testdir";
36+
constexpr const char *FILENAME = "statvfs.testdir";
3737
auto TEST_DIR = libc_make_test_file_path(FILENAME);
3838

3939
ASSERT_THAT(LIBC_NAMESPACE::mkdirat(AT_FDCWD, TEST_DIR, S_IRWXU),
@@ -47,10 +47,9 @@ TEST(LlvmLibcSysFStatvfsTest, FStatvfsInvalidPath) {
4747
// exist anymore.
4848

4949
ASSERT_THAT(LIBC_NAMESPACE::fstatvfs(fd, &buf), Succeeds());
50+
ASSERT_THAT(LIBC_NAMESPACE::close(fd), Succeeds(0));
5051

5152
ASSERT_THAT(LIBC_NAMESPACE::rmdir(TEST_DIR), Succeeds(0));
5253

53-
ASSERT_THAT(LIBC_NAMESPACE::fstatvfs(fd, &buf), Fails(ENOENT));
54-
ASSERT_THAT(LIBC_NAMESPACE::close(fd), Succeeds(0));
55-
ASSERT_THAT(LIBC_NAMESPACE::fstatvfs(fd, &buf), Fails(ENOENT));
54+
ASSERT_THAT(LIBC_NAMESPACE::fstatvfs(fd, &buf), Fails(EBADF));
5655
}

libc/test/src/sys/statvfs/linux/statvfs_test.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
#include "hdr/fcntl_macros.h"
1010
#include "src/__support/macros/config.h"
11+
#include "src/errno/libc_errno.h"
1112
#include "src/sys/stat/mkdirat.h"
1213
#include "src/sys/statvfs/statvfs.h"
1314
#include "src/unistd/rmdir.h"
@@ -29,7 +30,7 @@ TEST(LlvmLibcSysStatvfsTest, StatvfsInvalidPath) {
2930

3031
// create the file, assert it exists, then delete it and assert it doesn't
3132
// exist anymore.
32-
constexpr const char *FILENAME = "testdata/statvfs.testdir";
33+
constexpr const char *FILENAME = "statvfs.testdir";
3334
auto TEST_DIR = libc_make_test_file_path(FILENAME);
3435

3536
ASSERT_THAT(LIBC_NAMESPACE::mkdirat(AT_FDCWD, TEST_DIR, S_IRWXU),

0 commit comments

Comments
 (0)