clean up and standardize types across the codebase, unify atomic operations, improve UTF-8 handling throughout the system, remove obsolete input and named queue interfaces, redesign process preparation and creation, tighten IPC and service boundaries, improve error handling and reliability, minor documentation cleanup, fix doom surfaces, fix panic in ini parsing.
This commit is contained in:
1 parent
899225f551
commit
c0ad63c27f
226 files changed
+6562
-4147
No files matched your search
@@ -1,6 +1,7 @@
|
||||
// Native syscall contract smoke test.
|
||||
// Verifies public syscall ABI contracts, tick units, and process exit-code round trips.
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include <ntlite/syscall.h>
|
||||
@@ -39,14 +40,14 @@ static void exit_now(int32_t code) {
|
||||
}
|
||||
|
||||
// Checks whether a string view equals a NUL-terminated string.
|
||||
static int view_equals_cstr(SYS_STRING_VIEW view, const char* text) {
|
||||
static bool view_equals_cstr(SYS_STRING_VIEW view, const char* text) {
|
||||
size_t n = 0;
|
||||
while (text[n]) n++;
|
||||
if (view.Length != n || (!view.Data && n != 0)) return 0;
|
||||
if (view.Length != n || (!view.Data && n != 0)) return false;
|
||||
for (size_t i = 0; i < n; i++) {
|
||||
if (view.Data[i] != text[i]) return 0;
|
||||
if (view.Data[i] != text[i]) return false;
|
||||
}
|
||||
return 1;
|
||||
return true;
|
||||
}
|
||||
|
||||
// Fails the test with one plain message.
|
||||
@@ -58,7 +59,7 @@ static void fail(const char* msg) {
|
||||
}
|
||||
|
||||
// Fails the test with one status value.
|
||||
static void fail_status(const char* what, uint32_t status) {
|
||||
static void fail_status(const char* what, KSTATUS status) {
|
||||
print("syscall_contract_smoke: ");
|
||||
print(what);
|
||||
print(" status=");
|
||||
@@ -70,7 +71,7 @@ static void fail_status(const char* what, uint32_t status) {
|
||||
// Verifies the documented tick unit without relying on wall-clock precision.
|
||||
static void check_tick_contract(void) {
|
||||
uint64_t frequency = 0;
|
||||
uint32_t s = SysGetTickFrequency(&frequency);
|
||||
KSTATUS s = SysGetTickFrequency(&frequency);
|
||||
if (s != NTLSTATUS_SUCCESS) fail_status("query tick frequency", s);
|
||||
if (!frequency) fail("tick frequency was zero");
|
||||
|
||||
@@ -100,7 +101,7 @@ static void check_exit_code_contract(void) {
|
||||
req.ResolveModuleName = NtlResolveSystemModuleName;
|
||||
req.ProcessHandleOut = &child;
|
||||
|
||||
uint32_t s = NtlCreateSystemProcess(&req);
|
||||
KSTATUS s = NtlCreateSystemProcess(&req);
|
||||
if (s != NTLSTATUS_SUCCESS) fail_status("create child", s);
|
||||
|
||||
s = SysWait(child, SYS_WAIT_FLAG_NONE);
|
||||
@@ -120,7 +121,7 @@ static void check_request_size_contract(void) {
|
||||
sizeof(SYS_PRINT_DEBUG_REQUEST) - 1u,
|
||||
SysSvFromCstr("size check must not print"),
|
||||
};
|
||||
uint32_t s = SysPrintDebug(&request);
|
||||
KSTATUS s = SysPrintDebug(&request);
|
||||
if (s != NTLSTATUS_INVALID_PARAMETER)
|
||||
fail_status("undersized request was accepted", s);
|
||||
|
||||
@@ -130,6 +131,73 @@ static void check_request_size_contract(void) {
|
||||
fail_status("oversized request was accepted", s);
|
||||
}
|
||||
|
||||
// Exercises strict Unicode scalar boundaries independent of the filesystem.
|
||||
static void check_utf8_contract(void) {
|
||||
static const char valid[] = { 'A', (char)0xC3, (char)0xA9,
|
||||
(char)0xE2, (char)0x82, (char)0xAC,
|
||||
(char)0xF4, (char)0x8F, (char)0xBF, (char)0xBF };
|
||||
static const char overlong[] = { (char)0xC0, (char)0xAF };
|
||||
static const char surrogate[] = { (char)0xED, (char)0xA0, (char)0x80 };
|
||||
static const char tooLarge[] = { (char)0xF4, (char)0x90, (char)0x80, (char)0x80 };
|
||||
static const char truncated[] = { (char)0xE2, (char)0x82 };
|
||||
static const char nul[] = { 'A', 0, 'B' };
|
||||
SYS_STRING_VIEW good = SysSvFromParts(valid, sizeof(valid));
|
||||
if (!SysSvIsUtf8Text(good)) { print("utf8: valid rejected\n"); exit_now(1); }
|
||||
if (SysSvIsUtf8(SysSvFromParts(overlong, sizeof(overlong))) ||
|
||||
SysSvIsUtf8(SysSvFromParts(surrogate, sizeof(surrogate))) ||
|
||||
SysSvIsUtf8(SysSvFromParts(tooLarge, sizeof(tooLarge))) ||
|
||||
SysSvIsUtf8(SysSvFromParts(truncated, sizeof(truncated))) ||
|
||||
SysSvIsUtf8Text(SysSvFromParts(nul, sizeof(nul)))) {
|
||||
print("utf8: invalid accepted\n"); exit_now(1);
|
||||
}
|
||||
if (!SysSvIsUtf8(SysSvFromParts(nul, sizeof(nul))) ||
|
||||
!SysSvIsUtf8Text(SYS_SV_NULL) ||
|
||||
SysSvIsUtf8(SysSvFromParts((const char*)0, 1u))) {
|
||||
print("utf8: byte span mismatch\n"); exit_now(1);
|
||||
}
|
||||
// ext4 enumeration exposes lossy UTF-8 only for display; no raw byte
|
||||
// sequence or partial multibyte scalar may leak into a directory entry.
|
||||
static const char invalidName[] = { 'a', (char)0xFF, 'b' };
|
||||
static const char displayName[] = { 'a', (char)0xEF, (char)0xBF, (char)0xBD, 'b', 0 };
|
||||
char converted[16];
|
||||
size_t copied = SysSvCopyUtf8WithReplacement(
|
||||
SysSvFromParts(invalidName, sizeof(invalidName)), converted, sizeof(converted));
|
||||
if (copied != sizeof(displayName) - 1u || memcmp(converted, displayName, sizeof(displayName)) != 0 ||
|
||||
!SysSvIsUtf8Text(SysSvFromParts(converted, copied))) {
|
||||
print("utf8: replacement projection mismatch\n"); exit_now(1);
|
||||
}
|
||||
char shortName[5];
|
||||
copied = SysSvCopyUtf8WithReplacement(
|
||||
SysSvFromParts(invalidName, sizeof(invalidName)), shortName, sizeof(shortName));
|
||||
if (copied != 4u || shortName[4] != '\0' ||
|
||||
!SysSvIsUtf8Text(SysSvFromParts(shortName, copied))) {
|
||||
print("utf8: replacement truncation split a scalar\n"); exit_now(1);
|
||||
}
|
||||
static const char truncatedScalar[] = { 'x', (char)0xE2, (char)0x82 };
|
||||
copied = SysSvCopyUtf8WithReplacement(
|
||||
SysSvFromParts(truncatedScalar, sizeof(truncatedScalar)), converted, sizeof(converted));
|
||||
if (copied != 7u || !SysSvIsUtf8Text(SysSvFromParts(converted, copied))) {
|
||||
print("utf8: truncated sequence escaped replacement\n"); exit_now(1);
|
||||
}
|
||||
copied = SysSvCopyUtf8WithReplacement(good, converted, sizeof(converted));
|
||||
if (copied != sizeof(valid) || memcmp(converted, valid, sizeof(valid)) != 0) {
|
||||
print("utf8: valid scalars modified by replacement\n"); exit_now(1);
|
||||
}
|
||||
static const char embeddedNul[] = { 'a', 0, 'b' };
|
||||
copied = SysSvCopyUtf8WithReplacement(
|
||||
SysSvFromParts(embeddedNul, sizeof(embeddedNul)), converted, sizeof(converted));
|
||||
if (copied != 5u || !SysSvIsUtf8Text(SysSvFromParts(converted, copied))) {
|
||||
print("utf8: embedded NUL escaped replacement\n"); exit_now(1);
|
||||
}
|
||||
static const char composed[] = { (char)0xC3, (char)0xA9 };
|
||||
static const char decomposed[] = { 'e', (char)0xCC, (char)0x81 };
|
||||
if (!SysSvIsUtf8Text(SysSvFromParts(decomposed, sizeof(decomposed))) ||
|
||||
SysSvEqual(SysSvFromParts(composed, sizeof(composed)),
|
||||
SysSvFromParts(decomposed, sizeof(decomposed)))) {
|
||||
print("utf8: identity was normalized\n"); exit_now(1);
|
||||
}
|
||||
}
|
||||
|
||||
// Runs the syscall ABI contract smoke test.
|
||||
int main(void) {
|
||||
SYS_PEB* peb = SysGetPeb();
|
||||
@@ -138,6 +206,7 @@ int main(void) {
|
||||
}
|
||||
|
||||
print("syscall_contract_smoke: start\n");
|
||||
check_utf8_contract();
|
||||
check_tick_contract();
|
||||
check_request_size_contract();
|
||||
check_exit_code_contract();
|
||||
|
||||
Reference in new issue
Block a user