aboutsummaryrefslogtreecommitdiff
path: root/tests/threads/regression/resources.zc
diff options
context:
space:
mode:
Diffstat (limited to 'tests/threads/regression/resources.zc')
-rw-r--r--tests/threads/regression/resources.zc15
1 files changed, 15 insertions, 0 deletions
diff --git a/tests/threads/regression/resources.zc b/tests/threads/regression/resources.zc
new file mode 100644
index 0000000..abc0229
--- /dev/null
+++ b/tests/threads/regression/resources.zc
@@ -0,0 +1,15 @@
+namespace;
+include rt;
+extern int fcntl(int fd, int command);
+int descriptors() { int count = 0; for (int fd = 0; fd < 256; fd++) if (fcntl(fd, 1) >= 0) count++; return count; }
+unchecked fn main() {
+ int before = descriptors(), i = 0, closed = 0;
+ while (i < 24) {
+ int fd = 0;
+ let context = rt.syscall(51, fn() { int value = 1; rt.syscall(44, fd, &value, 1); return 0; } as word, &fd, 0);
+ int result; rt.syscall(45, fd, &result, 1); rt.syscall(52, context, 0, 0);
+ closed += rt.syscall(44, fd, &result, 1) == -1; i++;
+ }
+ rt.put_n(descriptors() == before); rt.put_c(' '); rt.put_n(closed); rt.put_c(' ');
+ rt.put_n(rt.syscall(55, 0, 0, 0)); rt.put_c(' '); rt.put_n(rt.syscall(55, 1, 0, 0)); rt.put_c(' '); rt.put_n(rt.syscall(55, 2, 0, 0)); rt.put_c(10); return 0;
+}