zig/lib/std
Jakub Konka d43c08a3e5 Add/fix missing WASI functionality to pass libstd tests
This rather large commit adds/fixes missing WASI functionality
in `libstd` needed to pass the `libstd` tests. As such, now by
default tests targeting `wasm32-wasi` target are enabled in
`test/tests.zig` module. However, they can be disabled by passing
the `-Dskip-wasi=true` flag when invoking the `zig build test`
command. When the flag is set to `false`, i.e., when WASI tests are
included, `wasmtime` with `--dir=.` is used as the default testing
command.

Since the majority of `libstd` tests were relying on `fs.cwd()`
call to get current working directory handle wrapped in `Dir`
struct, in order to make the tests WASI-friendly, `fs.cwd()`
call was replaced with `testing.getTestDir()` function which
resolved to either `fs.cwd()` for non-WASI targets, or tries to
fetch the preopen list from the WASI runtime and extract a
preopen for '.' path.

The summary of changes introduced by this commit:
* implement `Dir.makeDir` and `Dir.openDir` targeting WASI
* implement `Dir.deleteFile` and `Dir.deleteDir` targeting WASI
* fix `os.close` and map errors in `unlinkat`
* move WASI-specific `mkdirat` and `unlinkat` from `std.fs.wasi`
  to `std.os` module
* implement `lseek_{SET, CUR, END}` targeting WASI
* implement `futimens` targeting WASI
* implement `ftruncate` targeting WASI
* implement `readv`, `writev`, `pread{v}`, `pwrite{v}` targeting WASI
* make sure ANSI escape codes are _not_ used in stderr or stdout
  in WASI, as WASI always sanitizes stderr, and sanitizes stdout if
  fd is a TTY
* fix specifying WASI rights when opening/creating files/dirs
* tweak `AtomicFile` to be WASI-compatible
* implement `os.renameatWasi` for WASI-compliant `os.renameat` function
* implement sleep() targeting WASI
* fix `process.getEnvMap` targeting WASI
2020-05-18 16:09:49 +02:00
..
atomic Adds some documentation to std.atomic.Queue. 2020-04-04 13:47:07 -04:00
build Update emit_raw.zig 2020-04-14 16:19:01 -04:00
c macos: use realpath$DARWIN_EXTSN 2020-05-16 12:41:53 -04:00
crypto Merge pull request #5189 from zigazeljko/patch-1 2020-05-16 13:20:14 +03:00
debug std.meta.IntType -> std.meta.Int 2020-04-28 19:11:31 -06:00
event fix oneshot flag erroneusly set as filter_flag 2020-05-07 13:41:17 -04:00
fmt std.meta.IntType -> std.meta.Int 2020-04-28 19:11:31 -06:00
fs Add/fix missing WASI functionality to pass libstd tests 2020-05-18 16:09:49 +02:00
hash Optimization of vectors hashing 2020-05-06 17:08:49 +05:00
heap rework self-hosted compiler for incremental builds 2020-05-10 02:05:54 -04:00
http ArrayList: remove old (before span) API 2020-04-11 20:40:34 -04:00
io Add/fix missing WASI functionality to pass libstd tests 2020-05-18 16:09:49 +02:00
json Merge pull request #5118 from xackus/fix-json-writestream 2020-05-12 17:44:06 +03:00
math fix off-by-one error in sizeInBaseUpperBound 2020-05-01 13:33:46 -04:00
meta std lib fixups for new semantics 2020-03-19 09:53:55 -04:00
net Add/fix missing WASI functionality to pass libstd tests 2020-05-18 16:09:49 +02:00
os Add/fix missing WASI functionality to pass libstd tests 2020-05-18 16:09:49 +02:00
rand ziggurat uses `@truncate` instead of `& 0xff` 2020-04-18 14:41:33 -04:00
special Merge pull request #5020 from jinroh/docs/search-perf 2020-05-16 16:43:41 +03:00
target Merge remote-tracking branch 'origin/master' into llvm10 2020-03-03 09:44:13 -05:00
testing Add explicit error message for too many frees 2020-01-30 01:12:21 -06:00
time mv std/ lib/ 2019-09-25 23:35:41 -04:00
unicode Update all remaining uses of &outStream().stream 2020-04-03 12:12:23 -04:00
valgrind string literals are now null terminated 2019-11-21 20:43:41 -05:00
zig fix zig fmt regression 2020-05-17 15:13:19 +03:00
array_list.zig self-hosted: fix compile errors, except for codegen.zig 2020-05-13 20:06:01 -04:00
array_list_sentineled.zig new ArrayList API: fix std.ArrayListSentineled 2020-04-02 15:14:28 +02:00
ascii.zig Creates `std.ascii.control_code` that contains the C0 control codes as named constants. 2020-05-16 12:46:44 -04:00
atomic.zig mv std/ lib/ 2019-09-25 23:35:41 -04:00
base64.zig mv std/ lib/ 2019-09-25 23:35:41 -04:00
bloom_filter.zig Add mips support to standard library 2020-04-24 15:28:55 -04:00
buf_map.zig Fix BufMap value leak 2020-01-29 22:22:01 -06:00
buf_set.zig Convert a bunch of page_allocator to testing.allocator 2020-01-29 22:22:01 -06:00
build.zig Add/fix missing WASI functionality to pass libstd tests 2020-05-18 16:09:49 +02:00
builtin.zig rename mem.separate to mem.split 2020-04-04 17:37:51 -04:00
c.zig macos: use realpath$DARWIN_EXTSN 2020-05-16 12:41:53 -04:00
child_process.zig update windows impl of child process to new File API 2020-05-02 04:31:26 -04:00
coff.zig new ArrayList API: fix everything else 2020-04-02 16:12:08 +02:00
crypto.zig hashing algorithms: fix logic and index out of bounds 2020-02-24 13:43:54 -05:00
cstr.zig breaking: std.mem.len no longer takes a type argument 2020-03-01 13:21:39 -05:00
debug.zig Make StackIterator next public 2020-05-13 16:21:15 +01:00
dwarf.zig publicize member functions affected by #4909 2020-05-08 14:26:28 +03:00
dwarf_bits.zig debug: Split the DWARF stuff in its own file 2020-02-20 19:41:28 +01:00
dynamic_library.zig publicize member functions affected by #4909 2020-05-08 14:26:28 +03:00
elf.zig std: handle ConnectionTimedOut in switch 2020-05-06 12:52:26 +03:00
event.zig self-hosted libc detection 2020-02-16 13:25:30 -05:00
fifo.zig self-hosted: fix codegen and resolve some analysis bugs 2020-05-14 13:20:27 -04:00
fmt.zig Add/fix missing WASI functionality to pass libstd tests 2020-05-18 16:09:49 +02:00
fs.zig Add/fix missing WASI functionality to pass libstd tests 2020-05-18 16:09:49 +02:00
hash.zig merge dumps tool: merging ast nodes 2019-10-11 18:13:24 -04:00
hash_map.zig self-hosted: rework the memory layout of ir.Module and related types 2020-05-12 01:02:48 -04:00
heap.zig rework self-hosted compiler for incremental builds 2020-05-10 02:05:54 -04:00
http.zig mv std/ lib/ 2019-09-25 23:35:41 -04:00
io.zig Merge pull request #5175 from daurnimator/multi-out-stream 2020-05-16 13:43:50 +03:00
json.zig std.json: support stringify for anyerror 2020-05-17 17:07:27 -04:00
linked_list.zig rework self-hosted compiler for incremental builds 2020-05-10 02:05:54 -04:00
macho.zig delete extra code, more forgiveness 2020-02-22 12:44:21 +01:00
math.zig ZIR: add cmp and condbr instructions 2020-05-01 06:47:20 -04:00
mem.zig Merge remote-tracking branch 'origin/master' into self-hosted-incremental-compilation 2020-05-16 01:26:18 -04:00
meta.zig rename std.meta.IntType to std.meta.Int 2020-04-28 19:11:18 -06:00
mutex.zig introduce operating system version ranges as part of the target 2020-02-28 14:51:53 -05:00
net.zig make Address.getOsSockLen pub 2020-05-11 09:11:05 -06:00
once.zig std: Introduce the Once synchronization primitive 2020-04-18 15:48:32 -04:00
os.zig Add/fix missing WASI functionality to pass libstd tests 2020-05-18 16:09:49 +02:00
packed_int_array.zig Add/fix missing WASI functionality to pass libstd tests 2020-05-18 16:09:49 +02:00
pdb.zig fix more private member access 2020-05-08 15:10:38 +03:00
priority_queue.zig Make PriorityQueue.Iterator public 2020-05-13 18:38:03 +03:00
process.zig Add/fix missing WASI functionality to pass libstd tests 2020-05-18 16:09:49 +02:00
progress.zig std.progress: handle error from FillConsoleOutputAttribute 2020-05-01 15:14:44 -04:00
rand.zig std.meta.IntType -> std.meta.Int 2020-04-28 19:11:31 -06:00
rb.zig rb: fix rb.Node.getLast() that never worked 2020-01-30 12:05:57 -05:00
reset_event.zig std.event.Loop: promote the fs thread to be available for all OS's 2020-05-02 00:41:19 -04:00
segmented_list.zig Convert a bunch of page_allocator to testing.allocator 2020-01-29 22:22:01 -06:00
sort.zig sort.binarySearch: Remove unneeded edge case check 2020-04-09 09:13:47 +01:00
spinlock.zig introduce operating system version ranges as part of the target 2020-02-28 14:51:53 -05:00
start.zig zig fmt 2020-05-05 09:38:02 -06:00
start_windows_tls.zig un-special-case startup code in the std lib 2019-12-12 18:33:44 -05:00
std.zig Add/fix missing WASI functionality to pass libstd tests 2020-05-18 16:09:49 +02:00
target.zig link: introduce the concept of output mode and link mode 2020-05-01 06:47:20 -04:00
testing.zig Add/fix missing WASI functionality to pass libstd tests 2020-05-18 16:09:49 +02:00
thread.zig Update ErrorUnion thread spawn result to return null instead of 0 2020-05-05 04:15:43 -04:00
time.zig Add/fix missing WASI functionality to pass libstd tests 2020-05-18 16:09:49 +02:00
unicode.zig Add mips support to standard library 2020-04-24 15:28:55 -04:00
valgrind.zig short std.builtin enum literals in std lib 2020-03-01 13:57:41 -05:00
zig.zig add ZIR compare output test case to test suite 2020-05-01 06:47:20 -04:00