11// The C surface of openkal through the implementation for this system.
22//
3- // One observation per declaration the newest round added, in the terms a
4- // caller relies on: a context started with a least stack size is told at least
5- // that size and has the room; a closed directory's enumeration is refused; the
6- // input position is not an error to ask for. The terminal is not observed here,
3+ // Observations of the declarations recent rounds added, in the terms a caller
4+ // relies on: a context started with a least stack size is told at least that
5+ // size and has the room; a closed directory's enumeration is refused; and
6+ // (0.17) the system is named, this program names itself with the moment it
7+ // started, and a rename that does not replace refuses a name that is taken. The terminal is not observed here,
78// because a test run has none; the implementations observe it on a terminal
89// they make.
10+ #include < openkal/env.h>
911#include < openkal/fs.h>
12+ #include < openkal/process.h>
1013#include < openkal/stream.h>
1114#include < openkal/task.h>
1215#include < openkal/version.h>
@@ -37,7 +40,7 @@ void room(void* p) {
3740}
3841
3942int main () {
40- check (KAL_VERSION_MINOR >= 16u || KAL_VERSION_MAJOR > 0u , " the declarations are openkal 0.16 or later" );
43+ check (KAL_VERSION_MINOR >= 17u || KAL_VERSION_MAJOR > 0u , " the declarations are openkal 0.17 or later" );
4144 check (kal_version () >= KAL_VERSION , " the implementation is at least as new as the declarations" );
4245
4346 probe q{0 , 0 };
@@ -60,6 +63,30 @@ int main() {
6063 kal_fs_remove (root, " okt.d" , 5 );
6164 }
6265
66+ {
67+ char system[32 ];
68+ const kal_intptr n = kal_env_system (system, sizeof system);
69+ check (n > 0 , " the system this program runs upon is named" );
70+ }
71+ {
72+ kal_process me{};
73+ kal_program_info info{};
74+ info.self_size = sizeof info;
75+ check (kal_process_self (&me) == kal_ok && kal_process_info (me, KAL_PINFO_ALL , &info) == kal_ok
76+ && info.id != 0 && info.started_ns != 0 && info.ended == 0 ,
77+ " this program names itself, with the moment it started" );
78+ if (me.h ) kal_process_close (me);
79+ }
80+ if (root.h && (kal_fs_props (root) & KAL_FS_PROP_RENAME_NO_REPLACE ) != 0 ) {
81+ kal_file f{};
82+ if (kal_fs_open (root, " okt.a" , 5 , KAL_OPEN_WRITE | KAL_OPEN_CREATE | KAL_OPEN_TRUNCATE , &f) == kal_ok) kal_fs_close_file (f);
83+ if (kal_fs_open (root, " okt.b" , 5 , KAL_OPEN_WRITE | KAL_OPEN_CREATE | KAL_OPEN_TRUNCATE , &f) == kal_ok) kal_fs_close_file (f);
84+ check (kal_fs_rename_flags (root, " okt.a" , 5 , root, " okt.b" , 5 , KAL_RENAME_NO_REPLACE ) == kal_err_exists,
85+ " a rename that does not replace refuses a name that is taken" );
86+ kal_fs_remove (root, " okt.a" , 5 );
87+ kal_fs_remove (root, " okt.b" , 5 );
88+ }
89+
6390 if (failures == 0 ) kal_stream_write (kal_stdout (), " openkal: held\n " , 14 );
6491 return failures == 0 ? 0 : 1 ;
6592}
0 commit comments