Fix some more issues

- ARM Neon headers are now exported in libc/isystem/

- stat() and access() now do a better job reporting which files are
  executable which ones aren't. They do this by reading the first two
  bytes in a file to see if it's `MZ` or `#!`.
This commit is contained in:
Justine Tunney 2023-09-21 11:41:42 -07:00
parent 22cf6e11eb
commit 4f5d5a6813
No known key found for this signature in database
GPG key ID: BE714B4575D6E328
17 changed files with 144 additions and 49 deletions

View file

@ -33,7 +33,6 @@
#include "libc/sysv/consts/nr.h"
#include "libc/testlib/ezbench.h"
#include "libc/testlib/testlib.h"
#include "libc/x/x.h"
__static_yoink("zipos");
@ -61,6 +60,31 @@ TEST(stat, enotdir) {
ASSERT_SYS(ENOTDIR, -1, stat("yo/there", &st));
}
TEST(stat, textFileIsntExecutable) {
struct stat st;
ASSERT_SYS(0, 0, touch("foo.txt", 0644));
ASSERT_SYS(0, 0, stat("foo.txt", &st));
ASSERT_FALSE(st.st_mode & 0111);
}
TEST(stat, shebangIsExecutable) {
struct stat st;
ASSERT_SYS(0, 3, creat("foo.sh", 0777));
ASSERT_SYS(0, 2, write(3, "#!", 2));
ASSERT_SYS(0, 0, close(3));
ASSERT_SYS(0, 0, stat("foo.sh", &st));
ASSERT_TRUE(!!(st.st_mode & 0111));
}
TEST(stat, portableExecutableIsExecutable) {
struct stat st;
ASSERT_SYS(0, 3, creat("foo.exe", 0777));
ASSERT_SYS(0, 2, write(3, "MZ", 2));
ASSERT_SYS(0, 0, close(3));
ASSERT_SYS(0, 0, stat("foo.exe", &st));
ASSERT_TRUE(!!(st.st_mode & 0111));
}
TEST(stat, zipos) {
struct stat st;
EXPECT_SYS(0, 0,