|
5 | 5 | // size and has the room; a closed directory's enumeration is refused; and |
6 | 6 | // (0.17) the system is named, this program names itself with the moment it |
7 | 7 | // started, and a rename that does not replace refuses a name that is taken; |
8 | | -// (0.17.1) a joined command line is refused where programs receive vectors. |
| 8 | +// (0.17.1) a joined command line is refused where programs receive vectors; |
| 9 | +// (0.18) a file is mapped, the region holds its bytes and zero after its end. |
9 | 10 | // The terminal is not observed here, |
10 | 11 | // because a test run has none; the implementations observe it on a terminal |
11 | 12 | // they make. |
12 | 13 | #include <openkal/env.h> |
13 | 14 | #include <openkal/fs.h> |
| 15 | +#include <openkal/map.h> |
14 | 16 | #include <openkal/process.h> |
15 | 17 | #include <openkal/stream.h> |
16 | 18 | #include <openkal/task.h> |
@@ -44,6 +46,7 @@ void room(void* p) { |
44 | 46 | int main() { |
45 | 47 | check(KAL_VERSION_MINOR >= 17u || KAL_VERSION_MAJOR > 0u, "the declarations are openkal 0.17 or later"); |
46 | 48 | check(KAL_VERSION_MINOR > 17u || KAL_VERSION_PATCH >= 1u || KAL_VERSION_MAJOR > 0u, "and 0.17.1 or later"); |
| 49 | + check(KAL_VERSION_MINOR >= 18u || KAL_VERSION_MAJOR > 0u, "and 0.18 or later"); |
47 | 50 | check(kal_version() >= KAL_VERSION, "the implementation is at least as new as the declarations"); |
48 | 51 |
|
49 | 52 | probe q{0, 0}; |
@@ -102,6 +105,22 @@ int main() { |
102 | 105 | "a joined command line is refused where programs receive vectors"); |
103 | 106 | } |
104 | 107 |
|
| 108 | + if (root.h && (kal_interfaces() & KAL_IFACE_MAP) != 0) { |
| 109 | + kal_file f{}; |
| 110 | + if (kal_fs_open(root, "okt.m", 5, KAL_OPEN_READ | KAL_OPEN_WRITE | KAL_OPEN_CREATE | KAL_OPEN_TRUNCATE, &f) == kal_ok) { |
| 111 | + kal_stream_write(kal_fs_stream(f), "mapped", 6); |
| 112 | + void* region = nullptr; |
| 113 | + check(kal_map_file(f, 0, 6, 0, ®ion) == kal_ok, "a file is mapped"); |
| 114 | + if (region) { |
| 115 | + const volatile char* b = static_cast<const char*>(region); |
| 116 | + check(b[0] == 'm' && b[5] == 'd' && b[6] == 0, "the region holds the file's bytes and zero after its end"); |
| 117 | + kal_map_release(region, 6); |
| 118 | + } |
| 119 | + kal_fs_close_file(f); |
| 120 | + } |
| 121 | + kal_fs_remove(root, "okt.m", 5); |
| 122 | + } |
| 123 | + |
105 | 124 | if (failures == 0) kal_stream_write(kal_stdout(), "openkal: held\n", 14); |
106 | 125 | return failures == 0 ? 0 : 1; |
107 | 126 | } |
0 commit comments