Make improvements

- Polyfill pselect() on Windows
- Add -O NOFILE flag to pledge.com
- Polyfill ppoll() on NetBSD, XNU, and Windows
- Support negative numbers and errno in sizetol()
- Add .RSS, .NOFILE, and .MAXCORE to Landlock Make
- Fix issue with .PLEDGE preventing touching of output files
- Add __watch() function (like ftrace) for logging memory changes
This commit is contained in:
Justine Tunney 2022-08-15 15:18:37 -07:00
parent d3b599a796
commit f0701d2a24
35 changed files with 635 additions and 340 deletions

View file

@ -16,6 +16,7 @@
TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
*/
#include "libc/errno.h"
#include "libc/fmt/conv.h"
#include "libc/testlib/testlib.h"
@ -24,7 +25,10 @@ TEST(sizetol, test) {
EXPECT_EQ(0, sizetol("0", 1000));
EXPECT_EQ(0, sizetol("0kb", 1000));
EXPECT_EQ(31337, sizetol("31337", 1000));
EXPECT_EQ(+123, sizetol("+123", 1000));
EXPECT_EQ(-123, sizetol("-123", 1000));
EXPECT_EQ(1000, sizetol("1kb", 1000));
EXPECT_EQ(-1000, sizetol("-1kb", 1000));
EXPECT_EQ(2000, sizetol("2k", 1000));
EXPECT_EQ(1024, sizetol("1kb", 1024));
EXPECT_EQ(2048, sizetol("2k", 1024));
@ -43,11 +47,13 @@ TEST(sizetol, test) {
EXPECT_EQ(100, sizetol("\t100\t", 1024));
}
TEST(sizetol, testNegative_notAllowed) {
EXPECT_EQ(-1, sizetol("-23", 1000));
}
TEST(sizetol, testOverflow_isDetected) {
EXPECT_EQ(9000000000000000000, sizetol("9eb", 1000));
EXPECT_EQ(-1, sizetol("10eb", 1000));
EXPECT_SYS(EOVERFLOW, -1, sizetol("10eb", 1000));
}
TEST(sizetol, badSyntax) {
EXPECT_SYS(EINVAL, -1, sizetol("- 1", 1000));
EXPECT_SYS(EINVAL, -1, sizetol("- 1", 1000));
EXPECT_SYS(EOVERFLOW, -1, sizetol("10eb", 1000));
}

View file

@ -56,17 +56,17 @@ o/$(MODE)/test/libc/sock/%.com.dbg: \
@$(APELINK)
o/$(MODE)/test/libc/sock/unix_test.com.runs: \
private .PLEDGE = stdio rpath wpath cpath proc unix
private .PLEDGE = stdio rpath wpath cpath fattr proc unix
o/$(MODE)/test/libc/sock/setsockopt_test.com.runs \
o/$(MODE)/test/libc/sock/sendfile_test.com.runs \
o/$(MODE)/test/libc/sock/poll_test.com.runs \
o/$(MODE)/test/libc/sock/pollfd_test.com.runs: \
private .PLEDGE = stdio rpath wpath cpath proc inet
private .PLEDGE = stdio rpath wpath cpath fattr proc inet
o/$(MODE)/test/libc/sock/sendrecvmsg_test.com.runs \
o/$(MODE)/test/libc/sock/nointernet_test.com.runs: \
private .PLEDGE = stdio rpath wpath cpath proc inet recvfd sendfd
private .PLEDGE = stdio rpath wpath cpath fattr proc inet recvfd sendfd
$(TEST_LIBC_SOCK_OBJS): test/libc/sock/test.mk