5 fd = Posix open: "main" flags: 'O_RDONLY'
6 print-line: "fd = " + fd string
9 err-string = Posix strerror: errno
10 print-line: "errno = " + errno string + " (" + err-string + ")"
16 Posix select: fd + 1 reads: fds writes: nil exceptions: nil timeout: nil
17 print-line: "select result = " + result string
19 print-line: "The fd can read without blocking."
24 # Processes: fork, pipe.
25 Test name: "fork/wait" check: test-fork
26 Test name: "pipe" check: test-pipe
27 Test name: "exec" check: test-exec
30 Test name: "Regex" check: regex-test
33 Test name: "directories" check: directory-test
36 send: exception message
45 send: "From the child."
47 # Exit directly, skipping the test result.
48 Posix exit: exit-status
51 send: "From the parent (child = ", child, ")."
52 wait-result = Posix wait-pid: child
53 # OR: wait-result = Posix wait
54 if !wait-result is-valid || !wait-result exited
56 if wait-result exit-status != exit-status
63 values = "foo", "bar", "baz"
68 Posix close-fd: pipe-fds read
69 out-stream = Posix FDOutputStream new: pipe-fds write
71 out-stream send: value
76 Posix close-fd: pipe-fds write
77 in-stream = Posix FDInputStream new: pipe-fds read
78 lines = StreamLinesReader new: in-stream
81 received-value = lines next
82 if received-value != value
97 Posix close-fd: pipe-fds read
98 Posix dup-from: pipe-fds write to: Posix stdout-fd
99 Posix execp: "echo" arguments: "echo", "foo"
102 # This is the parent.
103 Posix close-fd: pipe-fds write
104 in-stream = Posix FDInputStream new: pipe-fds read
105 lines = StreamLinesReader new: in-stream
107 ok = (line && line == "foo")
114 regex = Posix Regex new: "foo"
115 if !regex matches: "boo foo hoo"
117 if regex matches: "bar baz"
121 regex = Posix Regex new: "(f[a-z]*) (f[a-z]*) (f[[:alnum:]]*)" flags: 'extended'
122 haystack = "foo flarf finagle bar baz xoof"
123 expected-results = List from: "foo flarf finagle", "foo", "flarf", "finagle"
124 for match in regex matches: haystack
125 if (match in: haystack) != expected-results pop-front
127 if !expected-results is-empty
135 dir-name = "test-mkdir"
137 start-wd = Posix getcwd
138 Posix mkdir: dir-name mode: 511
140 Posix chdir: dir-name
141 Posix chdir: start-wd
142 Posix rmdir: dir-name
145 Posix chdir: start-wd
146 Posix rmdir: dir-name