mirror of
https://github.com/jart/cosmopolitan.git
synced 2025-06-27 14:58:30 +00:00
Eliminate some flakes
- Get ASAN working on Windows. - Deleting directories and then recreating them with the same name in a short period of time appears to be a no-no on Windows. - There's no reason to call FlushFileBuffers on close() for pipes, and it's harmful since it might block indefinitely for no good reason.
This commit is contained in:
parent
27c899af56
commit
4e56d89dcd
60 changed files with 588 additions and 751 deletions
|
@ -17,15 +17,17 @@
|
|||
│ PERFORMANCE OF THIS SOFTWARE. │
|
||||
╚─────────────────────────────────────────────────────────────────────────────*/
|
||||
#include "libc/bits/weaken.h"
|
||||
#include "libc/calls/calls.h"
|
||||
#include "libc/calls/internal.h"
|
||||
#include "libc/errno.h"
|
||||
#include "libc/fmt/fmt.h"
|
||||
#include "libc/log/check.h"
|
||||
#include "libc/macros.h"
|
||||
#include "libc/nt/process.h"
|
||||
#include "libc/runtime/runtime.h"
|
||||
#include "libc/stdio/stdio.h"
|
||||
#include "libc/testlib/testlib.h"
|
||||
|
||||
void SetUp(void);
|
||||
void TearDown(void);
|
||||
#include "libc/x/x.h"
|
||||
|
||||
void testlib_finish(void) {
|
||||
if (g_testlib_failed) {
|
||||
|
@ -60,8 +62,18 @@ testonly void testlib_runtestcases(testfn_t *start, testfn_t *end,
|
|||
*
|
||||
* @see ape/ape.lds
|
||||
*/
|
||||
int x;
|
||||
char cwd[PATH_MAX];
|
||||
char tmp[PATH_MAX];
|
||||
const testfn_t *fn;
|
||||
for (fn = start; fn != end; ++fn) {
|
||||
for (x = 0, fn = start; fn != end; ++fn) {
|
||||
if (weaken(testlib_enable_tmp_setup_teardown)) {
|
||||
CHECK_NOTNULL(getcwd(cwd, sizeof(cwd)));
|
||||
snprintf(tmp, sizeof(tmp), "o/tmp/%s.%d.%d",
|
||||
program_invocation_short_name, getpid(), x++);
|
||||
CHECK_NE(-1, makedirs(tmp, 0755), "tmp=%s", tmp);
|
||||
CHECK_NE(-1, chdir(tmp), "tmp=%s", tmp);
|
||||
}
|
||||
if (weaken(SetUp)) weaken(SetUp)();
|
||||
errno = 0;
|
||||
SetLastError(0);
|
||||
|
@ -71,5 +83,9 @@ testonly void testlib_runtestcases(testfn_t *start, testfn_t *end,
|
|||
(*fn)();
|
||||
getpid$sysv();
|
||||
if (weaken(TearDown)) weaken(TearDown)();
|
||||
if (weaken(testlib_enable_tmp_setup_teardown)) {
|
||||
CHECK_NE(-1, chdir(cwd));
|
||||
CHECK_NE(-1, rmrf(tmp));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue