mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-02-26 15:59:04 +00:00
Add smoke test for timezone loading (#114)
This commit is contained in:
parent
33e8fc8687
commit
0a61fe4ea0
12 changed files with 45 additions and 33 deletions
|
@ -12,7 +12,7 @@
|
||||||
#include "libc/errno.h"
|
#include "libc/errno.h"
|
||||||
#include "libc/fmt/conv.h"
|
#include "libc/fmt/conv.h"
|
||||||
#include "libc/fmt/fmt.h"
|
#include "libc/fmt/fmt.h"
|
||||||
#include "libc/runtime/gc.internal.h"
|
#include "libc/runtime/gc.h"
|
||||||
#include "libc/runtime/runtime.h"
|
#include "libc/runtime/runtime.h"
|
||||||
#include "libc/stdio/stdio.h"
|
#include "libc/stdio/stdio.h"
|
||||||
#include "libc/str/str.h"
|
#include "libc/str/str.h"
|
||||||
|
@ -73,7 +73,7 @@ void GetOpts(int argc, char *argv[]) {
|
||||||
|
|
||||||
int cp(const char *src, const char *dst) {
|
int cp(const char *src, const char *dst) {
|
||||||
if (endswith(dst, "/") || isdirectory(dst)) {
|
if (endswith(dst, "/") || isdirectory(dst)) {
|
||||||
dst = gc(xasprintf("%s/%s", dst, basename));
|
dst = _gc(xasprintf("%s/%s", dst, basename));
|
||||||
}
|
}
|
||||||
if (!force && access(dst, W_OK) == -1 && errno != ENOENT) goto OnFail;
|
if (!force && access(dst, W_OK) == -1 && errno != ENOENT) goto OnFail;
|
||||||
if (copyfile(src, dst, flags) == -1) goto OnFail;
|
if (copyfile(src, dst, flags) == -1) goto OnFail;
|
||||||
|
|
|
@ -14,7 +14,6 @@
|
||||||
#include "libc/log/log.h"
|
#include "libc/log/log.h"
|
||||||
#include "libc/mem/mem.h"
|
#include "libc/mem/mem.h"
|
||||||
#include "libc/nt/thread.h"
|
#include "libc/nt/thread.h"
|
||||||
#include "libc/runtime/gc.internal.h"
|
|
||||||
#include "libc/runtime/runtime.h"
|
#include "libc/runtime/runtime.h"
|
||||||
#include "libc/stdio/stdio.h"
|
#include "libc/stdio/stdio.h"
|
||||||
#include "libc/str/str.h"
|
#include "libc/str/str.h"
|
||||||
|
|
|
@ -14,7 +14,7 @@
|
||||||
#include "libc/log/check.h"
|
#include "libc/log/check.h"
|
||||||
#include "libc/log/log.h"
|
#include "libc/log/log.h"
|
||||||
#include "libc/macros.internal.h"
|
#include "libc/macros.internal.h"
|
||||||
#include "libc/runtime/gc.internal.h"
|
#include "libc/runtime/gc.h"
|
||||||
#include "libc/runtime/runtime.h"
|
#include "libc/runtime/runtime.h"
|
||||||
#include "libc/sock/sock.h"
|
#include "libc/sock/sock.h"
|
||||||
#include "libc/stdio/stdio.h"
|
#include "libc/stdio/stdio.h"
|
||||||
|
@ -60,17 +60,17 @@ int main(int argc, char *argv[]) {
|
||||||
urislice2cstr(port, sizeof(port), u.port, url, "80");
|
urislice2cstr(port, sizeof(port), u.port, url, "80");
|
||||||
path = uripath(&u);
|
path = uripath(&u);
|
||||||
pathstr = path.n ? url + path.i : "/";
|
pathstr = path.n ? url + path.i : "/";
|
||||||
msg = gc(xstrcat("GET ", pathstr,
|
msg = _gc(xstrcat("GET ", pathstr,
|
||||||
" HTTP/1.1\r\n"
|
" HTTP/1.1\r\n"
|
||||||
"Host: ",
|
"Host: ",
|
||||||
host,
|
host,
|
||||||
"\r\n"
|
"\r\n"
|
||||||
"Connection: close\r\n"
|
"Connection: close\r\n"
|
||||||
"Content-Length: 0\r\n"
|
"Content-Length: 0\r\n"
|
||||||
"Accept: text/plain; */*\r\n"
|
"Accept: text/plain; */*\r\n"
|
||||||
"Accept-Encoding: identity\r\n"
|
"Accept-Encoding: identity\r\n"
|
||||||
"User-Agent: github.com/jart/cosmopolitan\r\n"
|
"User-Agent: github.com/jart/cosmopolitan\r\n"
|
||||||
"\r\n"));
|
"\r\n"));
|
||||||
msglen = strlen(msg);
|
msglen = strlen(msg);
|
||||||
CHECK_EQ(EAI_SUCCESS, getaddrinfo(host, port, &hints, &addrs));
|
CHECK_EQ(EAI_SUCCESS, getaddrinfo(host, port, &hints, &addrs));
|
||||||
for (addr = addrs; addr; addr = addr->ai_next) {
|
for (addr = addrs; addr; addr = addr->ai_next) {
|
||||||
|
|
|
@ -7,7 +7,7 @@
|
||||||
│ • http://creativecommons.org/publicdomain/zero/1.0/ │
|
│ • http://creativecommons.org/publicdomain/zero/1.0/ │
|
||||||
╚─────────────────────────────────────────────────────────────────*/
|
╚─────────────────────────────────────────────────────────────────*/
|
||||||
#endif
|
#endif
|
||||||
#include "libc/runtime/gc.internal.h"
|
#include "libc/runtime/gc.h"
|
||||||
#include "libc/stdio/stdio.h"
|
#include "libc/stdio/stdio.h"
|
||||||
#include "libc/x/x.h"
|
#include "libc/x/x.h"
|
||||||
|
|
||||||
|
@ -16,6 +16,6 @@
|
||||||
*/
|
*/
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
puts(gc(xiso8601ts(NULL)));
|
puts(_gc(xiso8601ts(NULL)));
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
#include "libc/log/check.h"
|
#include "libc/log/check.h"
|
||||||
#include "libc/log/log.h"
|
#include "libc/log/log.h"
|
||||||
#include "libc/mem/mem.h"
|
#include "libc/mem/mem.h"
|
||||||
#include "libc/runtime/gc.internal.h"
|
#include "libc/runtime/gc.h"
|
||||||
#include "libc/sysv/consts/o.h"
|
#include "libc/sysv/consts/o.h"
|
||||||
#include "third_party/duktape/duktape.h"
|
#include "third_party/duktape/duktape.h"
|
||||||
|
|
||||||
|
@ -59,7 +59,7 @@ int main(int argc, char *argv[]) {
|
||||||
|
|
||||||
CHECK_NE(-1, (fd = open("zip:examples/hello.js", O_RDONLY)));
|
CHECK_NE(-1, (fd = open("zip:examples/hello.js", O_RDONLY)));
|
||||||
CHECK_NE(-1, fstat(fd, &st));
|
CHECK_NE(-1, fstat(fd, &st));
|
||||||
CHECK_NOTNULL((code = gc(calloc(1, st.st_size + 1))));
|
CHECK_NOTNULL((code = _gc(calloc(1, st.st_size + 1))));
|
||||||
CHECK_EQ(st.st_size, read(fd, code, st.st_size));
|
CHECK_EQ(st.st_size, read(fd, code, st.st_size));
|
||||||
CHECK_NE(-1, close(fd));
|
CHECK_NE(-1, close(fd));
|
||||||
|
|
||||||
|
|
|
@ -11,7 +11,7 @@
|
||||||
#include "libc/calls/struct/dirent.h"
|
#include "libc/calls/struct/dirent.h"
|
||||||
#include "libc/calls/struct/stat.h"
|
#include "libc/calls/struct/stat.h"
|
||||||
#include "libc/log/check.h"
|
#include "libc/log/check.h"
|
||||||
#include "libc/runtime/gc.internal.h"
|
#include "libc/runtime/gc.h"
|
||||||
#include "libc/stdio/stdio.h"
|
#include "libc/stdio/stdio.h"
|
||||||
#include "libc/str/str.h"
|
#include "libc/str/str.h"
|
||||||
#include "libc/sysv/consts/dt.h"
|
#include "libc/sysv/consts/dt.h"
|
||||||
|
@ -49,7 +49,7 @@ void List(const char *path) {
|
||||||
if (strcmp(path, ".") == 0) {
|
if (strcmp(path, ".") == 0) {
|
||||||
vpath = "";
|
vpath = "";
|
||||||
} else if (!endswith(path, "/")) {
|
} else if (!endswith(path, "/")) {
|
||||||
vpath = gc(xasprintf("%s/", path));
|
vpath = _gc(xasprintf("%s/", path));
|
||||||
} else {
|
} else {
|
||||||
vpath = path;
|
vpath = path;
|
||||||
}
|
}
|
||||||
|
|
|
@ -16,7 +16,7 @@
|
||||||
#include "libc/calls/struct/timespec.h"
|
#include "libc/calls/struct/timespec.h"
|
||||||
#include "libc/log/check.h"
|
#include "libc/log/check.h"
|
||||||
#include "libc/mem/mem.h"
|
#include "libc/mem/mem.h"
|
||||||
#include "libc/runtime/gc.internal.h"
|
#include "libc/runtime/gc.h"
|
||||||
#include "libc/stdio/stdio.h"
|
#include "libc/stdio/stdio.h"
|
||||||
#include "libc/sysv/consts/dt.h"
|
#include "libc/sysv/consts/dt.h"
|
||||||
#include "libc/x/x.h"
|
#include "libc/x/x.h"
|
||||||
|
@ -51,7 +51,7 @@ void WalkPaths(const char *dirpath) {
|
||||||
if (strcmp(e->d_name, "o") == 0) continue;
|
if (strcmp(e->d_name, "o") == 0) continue;
|
||||||
if (strcmp(e->d_name, ".git") == 0) continue;
|
if (strcmp(e->d_name, ".git") == 0) continue;
|
||||||
if (e->d_type == DT_DIR) {
|
if (e->d_type == DT_DIR) {
|
||||||
WalkPaths(gc(path));
|
WalkPaths(_gc(path));
|
||||||
} else {
|
} else {
|
||||||
CHECK_NE(-1, lstat(path, &st), "%s", path);
|
CHECK_NE(-1, lstat(path, &st), "%s", path);
|
||||||
f.mt = st.st_mtim;
|
f.mt = st.st_mtim;
|
||||||
|
|
|
@ -27,7 +27,6 @@
|
||||||
#include "libc/math.h"
|
#include "libc/math.h"
|
||||||
#include "libc/mem/mem.h"
|
#include "libc/mem/mem.h"
|
||||||
#include "libc/ohmyplus/vector.h"
|
#include "libc/ohmyplus/vector.h"
|
||||||
#include "libc/runtime/gc.internal.h"
|
|
||||||
#include "libc/runtime/runtime.h"
|
#include "libc/runtime/runtime.h"
|
||||||
#include "libc/sock/sock.h"
|
#include "libc/sock/sock.h"
|
||||||
#include "libc/stdio/stdio.h"
|
#include "libc/stdio/stdio.h"
|
||||||
|
|
|
@ -12,7 +12,7 @@
|
||||||
#include "libc/errno.h"
|
#include "libc/errno.h"
|
||||||
#include "libc/fmt/fmt.h"
|
#include "libc/fmt/fmt.h"
|
||||||
#include "libc/log/check.h"
|
#include "libc/log/check.h"
|
||||||
#include "libc/runtime/gc.internal.h"
|
#include "libc/runtime/gc.h"
|
||||||
#include "libc/stdio/stdio.h"
|
#include "libc/stdio/stdio.h"
|
||||||
#include "libc/x/x.h"
|
#include "libc/x/x.h"
|
||||||
|
|
||||||
|
@ -44,9 +44,9 @@ void PrintFileMetadata(const char *pathname, struct stat *st) {
|
||||||
"hard link count", st->st_nlink, "mode / permissions", st->st_mode,
|
"hard link count", st->st_nlink, "mode / permissions", st->st_mode,
|
||||||
"owner id", st->st_uid, "group id", st->st_gid,
|
"owner id", st->st_uid, "group id", st->st_gid,
|
||||||
"device id (if special)", st->st_rdev, "block size", st->st_blksize,
|
"device id (if special)", st->st_rdev, "block size", st->st_blksize,
|
||||||
"access time", gc(xiso8601(&st->st_atim)), "modified time",
|
"access time", _gc(xiso8601(&st->st_atim)), "modified time",
|
||||||
gc(xiso8601(&st->st_mtim)), "c[omplicated]time",
|
_gc(xiso8601(&st->st_mtim)), "c[omplicated]time",
|
||||||
gc(xiso8601(&st->st_ctim)));
|
_gc(xiso8601(&st->st_ctim)));
|
||||||
}
|
}
|
||||||
|
|
||||||
int main(int argc, char *argv[]) {
|
int main(int argc, char *argv[]) {
|
||||||
|
|
|
@ -33,11 +33,25 @@ static textwindows int sys_unlink_nt(const char16_t *path) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static textwindows int sys_rmdir_nt(const char16_t *path) {
|
static textwindows int sys_rmdir_nt(const char16_t *path) {
|
||||||
if (RemoveDirectory(path)) {
|
int e, ms;
|
||||||
return 0;
|
for (ms = 1;; ms *= 2) {
|
||||||
} else {
|
if (RemoveDirectory(path)) return 0;
|
||||||
return __winerr();
|
/*
|
||||||
|
* Files can linger, for absolutely no reason.
|
||||||
|
* Possibly some Windows Defender bug on Win7.
|
||||||
|
* Sleep for up to one second w/ expo backoff.
|
||||||
|
* Alternative is use Microsoft internal APIs.
|
||||||
|
* Never could have imagined it'd be this bad.
|
||||||
|
*/
|
||||||
|
if ((e = GetLastError()) == kNtErrorDirNotEmpty && ms <= 512) {
|
||||||
|
Sleep(ms);
|
||||||
|
continue;
|
||||||
|
} else {
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
errno = e;
|
||||||
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
textwindows int sys_unlinkat_nt(int dirfd, const char *path, int flags) {
|
textwindows int sys_unlinkat_nt(int dirfd, const char *path, int flags) {
|
||||||
|
|
|
@ -29,7 +29,6 @@ ssize_t __zipos_find(struct Zipos *zipos, const struct ZiposUri *name) {
|
||||||
for (i = 0, cf = ZIP_CDIR_OFFSET(zipos->cdir);
|
for (i = 0, cf = ZIP_CDIR_OFFSET(zipos->cdir);
|
||||||
i < ZIP_CDIR_RECORDS(zipos->cdir);
|
i < ZIP_CDIR_RECORDS(zipos->cdir);
|
||||||
++i, cf += ZIP_CFILE_HDRSIZE(zipos->map + cf)) {
|
++i, cf += ZIP_CFILE_HDRSIZE(zipos->map + cf)) {
|
||||||
if (ZIP_CFILE_MAGIC(zipos->map + cf) != kZipCfileHdrMagic) DebugBreak();
|
|
||||||
assert(ZIP_CFILE_MAGIC(zipos->map + cf) == kZipCfileHdrMagic);
|
assert(ZIP_CFILE_MAGIC(zipos->map + cf) == kZipCfileHdrMagic);
|
||||||
if (name->len == ZIP_CFILE_NAMESIZE(zipos->map + cf) &&
|
if (name->len == ZIP_CFILE_NAMESIZE(zipos->map + cf) &&
|
||||||
memcmp(name->path, ZIP_CFILE_NAME(zipos->map + cf), name->len) == 0) {
|
memcmp(name->path, ZIP_CFILE_NAME(zipos->map + cf), name->len) == 0) {
|
||||||
|
|
|
@ -6,6 +6,7 @@ int main(int argc, char *argv[]) {
|
||||||
s = strdup(argv[0]);
|
s = strdup(argv[0]);
|
||||||
s[0] = 'Z';
|
s[0] = 'Z';
|
||||||
f = fopen("/dev/null", "w");
|
f = fopen("/dev/null", "w");
|
||||||
|
fputs(_gc(xiso8601ts(NULL)), f);
|
||||||
fputs(_gc(xasprintf("hello world %d %s\n", argc, s)), f);
|
fputs(_gc(xasprintf("hello world %d %s\n", argc, s)), f);
|
||||||
fclose(f);
|
fclose(f);
|
||||||
rc = system("exit 42");
|
rc = system("exit 42");
|
||||||
|
|
Loading…
Add table
Reference in a new issue