Fix bugs and make improvements

- Get clone() working on FreeBSD
- Increase some Python build quotas
- Add more atomic builtins to chibicc
- Fix ASAN poisoning of alloca() memory
- Make MODE= mandatory link path tinier
- Improve the examples folder a little bit
- Start working on some more resource limits
- Make the linenoise auto-complete UI as good as GNU readline
- Update compile.com, avoiding AVX codegen on non-AVX systems
- Make sure empty path to syscalls like opendir raises ENOENT
- Correctly polyfill ENOENT vs. ENOTDIR on the New Technology
- Port bestline's paredit features to //third_party/linenoise
- Remove workarounds for RHEL 5.0 bugs that were fixed in 5.1
This commit is contained in:
Justine Tunney 2022-04-20 09:56:53 -07:00
parent c3fb624647
commit ae638c0850
181 changed files with 2994 additions and 1367 deletions

View file

@ -18,11 +18,13 @@
*/
#include "libc/calls/calls.h"
#include "libc/calls/struct/dirent.h"
#include "libc/dce.h"
#include "libc/errno.h"
#include "libc/rand/rand.h"
#include "libc/runtime/gc.internal.h"
#include "libc/runtime/runtime.h"
#include "libc/str/str.h"
#include "libc/sysv/consts/dt.h"
#include "libc/testlib/testlib.h"
#include "libc/x/x.h"
@ -31,6 +33,44 @@ STATIC_YOINK("usr/share/zoneinfo/New_York");
char testlib_enable_tmp_setup_teardown;
TEST(opendir, efault) {
ASSERT_SYS(EFAULT, NULL, opendir(0));
if (!IsAsan()) return; // not possible
ASSERT_SYS(EFAULT, NULL, opendir((void *)77));
}
TEST(opendir, enoent) {
ASSERT_SYS(ENOENT, NULL, opendir(""));
ASSERT_SYS(ENOENT, NULL, opendir("o/foo"));
}
TEST(opendir, enotdir) {
ASSERT_SYS(0, 0, close(creat("yo", 0644)));
ASSERT_SYS(ENOTDIR, NULL, opendir("yo/there"));
}
TEST(dirstream, testDots) {
DIR *dir;
int hasdot = 0;
int hasdotdot = 0;
struct dirent *ent;
ASSERT_SYS(0, 0, close(creat("foo", 0644)));
ASSERT_NE(NULL, (dir = opendir(".")));
while ((ent = readdir(dir))) {
if (!strcmp(ent->d_name, ".")) {
++hasdot;
EXPECT_EQ(DT_DIR, ent->d_type);
}
if (!strcmp(ent->d_name, "..")) {
++hasdotdot;
EXPECT_EQ(DT_DIR, ent->d_type);
}
}
EXPECT_EQ(1, hasdot);
EXPECT_EQ(1, hasdotdot);
EXPECT_SYS(0, 0, closedir(dir));
}
TEST(dirstream, test) {
DIR *dir;
struct dirent *ent;
@ -45,8 +85,14 @@ TEST(dirstream, test) {
EXPECT_NE(-1, touch(file2, 0644));
EXPECT_TRUE(NULL != (dir = opendir(dpath)));
while ((ent = readdir(dir))) {
if (strcmp(ent->d_name, "foo")) hasfoo = true;
if (strcmp(ent->d_name, "bar")) hasbar = true;
if (!strcmp(ent->d_name, "foo")) {
EXPECT_EQ(DT_REG, ent->d_type);
hasfoo = true;
}
if (!strcmp(ent->d_name, "bar")) {
EXPECT_EQ(DT_REG, ent->d_type);
hasbar = true;
}
}
EXPECT_TRUE(hasfoo);
EXPECT_TRUE(hasbar);