Add smoke test for timezone loading (#114)

This commit is contained in:
Justine Tunney 2021-03-08 11:42:53 -08:00
parent 33e8fc8687
commit 0a61fe4ea0
12 changed files with 45 additions and 33 deletions

View file

@ -12,7 +12,7 @@
#include "libc/errno.h"
#include "libc/fmt/conv.h"
#include "libc/fmt/fmt.h"
#include "libc/runtime/gc.internal.h"
#include "libc/runtime/gc.h"
#include "libc/runtime/runtime.h"
#include "libc/stdio/stdio.h"
#include "libc/str/str.h"
@ -73,7 +73,7 @@ void GetOpts(int argc, char *argv[]) {
int cp(const char *src, const char *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 (copyfile(src, dst, flags) == -1) goto OnFail;

View file

@ -14,7 +14,6 @@
#include "libc/log/log.h"
#include "libc/mem/mem.h"
#include "libc/nt/thread.h"
#include "libc/runtime/gc.internal.h"
#include "libc/runtime/runtime.h"
#include "libc/stdio/stdio.h"
#include "libc/str/str.h"

View file

@ -14,7 +14,7 @@
#include "libc/log/check.h"
#include "libc/log/log.h"
#include "libc/macros.internal.h"
#include "libc/runtime/gc.internal.h"
#include "libc/runtime/gc.h"
#include "libc/runtime/runtime.h"
#include "libc/sock/sock.h"
#include "libc/stdio/stdio.h"
@ -60,17 +60,17 @@ int main(int argc, char *argv[]) {
urislice2cstr(port, sizeof(port), u.port, url, "80");
path = uripath(&u);
pathstr = path.n ? url + path.i : "/";
msg = gc(xstrcat("GET ", pathstr,
" HTTP/1.1\r\n"
"Host: ",
host,
"\r\n"
"Connection: close\r\n"
"Content-Length: 0\r\n"
"Accept: text/plain; */*\r\n"
"Accept-Encoding: identity\r\n"
"User-Agent: github.com/jart/cosmopolitan\r\n"
"\r\n"));
msg = _gc(xstrcat("GET ", pathstr,
" HTTP/1.1\r\n"
"Host: ",
host,
"\r\n"
"Connection: close\r\n"
"Content-Length: 0\r\n"
"Accept: text/plain; */*\r\n"
"Accept-Encoding: identity\r\n"
"User-Agent: github.com/jart/cosmopolitan\r\n"
"\r\n"));
msglen = strlen(msg);
CHECK_EQ(EAI_SUCCESS, getaddrinfo(host, port, &hints, &addrs));
for (addr = addrs; addr; addr = addr->ai_next) {

View file

@ -7,7 +7,7 @@
http://creativecommons.org/publicdomain/zero/1.0/ │
*/
#endif
#include "libc/runtime/gc.internal.h"
#include "libc/runtime/gc.h"
#include "libc/stdio/stdio.h"
#include "libc/x/x.h"
@ -16,6 +16,6 @@
*/
int main(int argc, char *argv[]) {
puts(gc(xiso8601ts(NULL)));
puts(_gc(xiso8601ts(NULL)));
return 0;
}

View file

@ -12,7 +12,7 @@
#include "libc/log/check.h"
#include "libc/log/log.h"
#include "libc/mem/mem.h"
#include "libc/runtime/gc.internal.h"
#include "libc/runtime/gc.h"
#include "libc/sysv/consts/o.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, 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_NE(-1, close(fd));

View file

@ -11,7 +11,7 @@
#include "libc/calls/struct/dirent.h"
#include "libc/calls/struct/stat.h"
#include "libc/log/check.h"
#include "libc/runtime/gc.internal.h"
#include "libc/runtime/gc.h"
#include "libc/stdio/stdio.h"
#include "libc/str/str.h"
#include "libc/sysv/consts/dt.h"
@ -49,7 +49,7 @@ void List(const char *path) {
if (strcmp(path, ".") == 0) {
vpath = "";
} else if (!endswith(path, "/")) {
vpath = gc(xasprintf("%s/", path));
vpath = _gc(xasprintf("%s/", path));
} else {
vpath = path;
}

View file

@ -16,7 +16,7 @@
#include "libc/calls/struct/timespec.h"
#include "libc/log/check.h"
#include "libc/mem/mem.h"
#include "libc/runtime/gc.internal.h"
#include "libc/runtime/gc.h"
#include "libc/stdio/stdio.h"
#include "libc/sysv/consts/dt.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, ".git") == 0) continue;
if (e->d_type == DT_DIR) {
WalkPaths(gc(path));
WalkPaths(_gc(path));
} else {
CHECK_NE(-1, lstat(path, &st), "%s", path);
f.mt = st.st_mtim;

View file

@ -27,7 +27,6 @@
#include "libc/math.h"
#include "libc/mem/mem.h"
#include "libc/ohmyplus/vector.h"
#include "libc/runtime/gc.internal.h"
#include "libc/runtime/runtime.h"
#include "libc/sock/sock.h"
#include "libc/stdio/stdio.h"

View file

@ -12,7 +12,7 @@
#include "libc/errno.h"
#include "libc/fmt/fmt.h"
#include "libc/log/check.h"
#include "libc/runtime/gc.internal.h"
#include "libc/runtime/gc.h"
#include "libc/stdio/stdio.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,
"owner id", st->st_uid, "group id", st->st_gid,
"device id (if special)", st->st_rdev, "block size", st->st_blksize,
"access time", gc(xiso8601(&st->st_atim)), "modified time",
gc(xiso8601(&st->st_mtim)), "c[omplicated]time",
gc(xiso8601(&st->st_ctim)));
"access time", _gc(xiso8601(&st->st_atim)), "modified time",
_gc(xiso8601(&st->st_mtim)), "c[omplicated]time",
_gc(xiso8601(&st->st_ctim)));
}
int main(int argc, char *argv[]) {

View file

@ -33,11 +33,25 @@ static textwindows int sys_unlink_nt(const char16_t *path) {
}
static textwindows int sys_rmdir_nt(const char16_t *path) {
if (RemoveDirectory(path)) {
return 0;
} else {
return __winerr();
int e, ms;
for (ms = 1;; ms *= 2) {
if (RemoveDirectory(path)) return 0;
/*
* 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) {

View file

@ -29,7 +29,6 @@ ssize_t __zipos_find(struct Zipos *zipos, const struct ZiposUri *name) {
for (i = 0, cf = ZIP_CDIR_OFFSET(zipos->cdir);
i < ZIP_CDIR_RECORDS(zipos->cdir);
++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);
if (name->len == ZIP_CFILE_NAMESIZE(zipos->map + cf) &&
memcmp(name->path, ZIP_CFILE_NAME(zipos->map + cf), name->len) == 0) {

View file

@ -6,6 +6,7 @@ int main(int argc, char *argv[]) {
s = strdup(argv[0]);
s[0] = 'Z';
f = fopen("/dev/null", "w");
fputs(_gc(xiso8601ts(NULL)), f);
fputs(_gc(xasprintf("hello world %d %s\n", argc, s)), f);
fclose(f);
rc = system("exit 42");