isolate POSIX builds from the host UCRT, wire lwext4 and ntfs-3g as ext4.sys and ntfs.sys, split the FAT driver into directory/file/async/driver/mount units, add posixsrv and dwm plus input/console/desktop syscall clients and a pile of new smoke targets, rename serial.sys to cereal.sys, name HDA/USB/lwIP/AHCI workers, harden ATA probing/reset/removal around actual hardware deadlines, absent-channel detection, diagnostics and explicit worker lifetime, redo ACPI S5 shutdown around GAS/MMIO and HW-reduced firmware, scan SSDTs for _S5 and deal with Intel SMI sleep trapping, make serial and SMP timeouts use real monotonic deadlines, add thread names and fix terminal thread teardown, scheduler and APC prepare/commit races, make advisory file locks queryable and preserve split ranges and add mutable file append state, add shared-memory pipes with kernel-assisted wait/wake, introduce capability-scoped input and display managers, split surface map rights into read/write, add explicit unmap and replace present with commit/generation/damage tracking while keeping physical presentation under the display manager, decouple native exception classes from Win32 exception numbers and translate them in kernel32, add opaque process startup data, bump the resource protocol to v3 with namespace directories, symlinks and enumeration and service control to v2 with generic READY handle exports, add the new POSIX errno/status surface and rebuild fds around posixsrv-owned shared open descriptions, descriptor-local flags, exact inheritance snapshots, dup/fcntl/record locks and shared-ring pipes, add waitpid, POSIX credentials/groups/sessions/passwd/group lookups and move sockets onto stable open descriptions, port the shells and apps to the new console/input services and surface commit API, teach init to load services.ini and start/supervise RSSRV, DWM and generic services under restricted capabilities while publishing their endpoints through RSSRV, split RSSRV into namespace, volume, display, session, input, console and resource components and make /SystemRoot a real symlink to the independently published system volume, shift the syscall table again, expand lock/resource/surface/POSIX/service/thread smoke coverage, make docs scream ASK QUESTIONS and DISCUSS at LLMs, replace MIT No Attribution with WTFPL+.
This commit is contained in:
1 parent
3dacbd32c8
commit
73abd6f90d
441 files changed
+187073
-6549
No files matched your search
@@ -0,0 +1,149 @@
|
||||
// Native thread-description smoke test.
|
||||
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include <string.h>
|
||||
#include <ntlite/syscall.h>
|
||||
#include <ntlite/status.h>
|
||||
|
||||
#define TEST_NAME_MAIN "thread-name-main"
|
||||
#define TEST_NAME_WORKER "thread-name-worker"
|
||||
#define TEST_MAX_THREADS 16u
|
||||
#define TEST_EVENT_AUTO_RESET 0u
|
||||
|
||||
// Writes one NUL-terminated string to the console.
|
||||
static void print(const char* text) {
|
||||
SYS_WRITE_CONSOLE_REQUEST request = { sizeof(SYS_WRITE_CONSOLE_REQUEST), SysSvFromCstr(text) };
|
||||
(void)SysWriteConsole(&request);
|
||||
}
|
||||
|
||||
// Terminates the test immediately.
|
||||
static void exit_now(int32_t code) {
|
||||
for (;;) SysExitProcess(code);
|
||||
}
|
||||
|
||||
// Fails the test with one diagnostic.
|
||||
static void fail(const char* text) {
|
||||
print("thread_name_smoke: ");
|
||||
print(text);
|
||||
print("\n");
|
||||
exit_now(1);
|
||||
}
|
||||
|
||||
// Sets a description on the supplied native thread handle.
|
||||
static KSTATUS set_name(SYS_HANDLE thread, const char* name) {
|
||||
SYS_SET_THREAD_NAME_REQUEST request;
|
||||
memset(&request, 0, sizeof(request));
|
||||
request.Size = sizeof(request);
|
||||
request.ThreadHandle = thread;
|
||||
request.Name = SysSvFromCstr(name);
|
||||
return SysSetThreadName(&request);
|
||||
}
|
||||
|
||||
// A suspended worker only needs to prove its named handle remains runnable.
|
||||
static void worker(uintptr_t argument) {
|
||||
(void)argument;
|
||||
SysExitThread(0);
|
||||
}
|
||||
|
||||
// A detached worker proves running threads do not need a returned handle or TID.
|
||||
static void detached_worker(uintptr_t argument) {
|
||||
(void)SysSignalEvent((SYS_HANDLE)argument);
|
||||
SysExitThread(0);
|
||||
}
|
||||
|
||||
// Runs the thread-description ABI smoke test.
|
||||
int main(void) {
|
||||
print("thread_name_smoke: start\n");
|
||||
|
||||
if (set_name(SYS_HANDLE_INVALID, TEST_NAME_MAIN) != NTLSTATUS_SUCCESS)
|
||||
fail("set current name failed");
|
||||
|
||||
char name[SYS_THREAD_NAME_MAX];
|
||||
size_t length = 0;
|
||||
KSTATUS status = SysQueryThreadName(SYS_HANDLE_INVALID, name, sizeof(name), &length);
|
||||
if (status != NTLSTATUS_SUCCESS || length != sizeof(TEST_NAME_MAIN) - 1u ||
|
||||
strcmp(name, TEST_NAME_MAIN) != 0)
|
||||
fail("query current name mismatch");
|
||||
|
||||
size_t required = 0;
|
||||
status = SysQueryThreadName(SYS_HANDLE_INVALID, (char*)0, 0, &required);
|
||||
if (status != NTLSTATUS_BUFFER_TOO_SMALL || required != sizeof(TEST_NAME_MAIN) - 1u)
|
||||
fail("length-only query contract mismatch");
|
||||
|
||||
SYS_HANDLE thread = SYS_HANDLE_INVALID;
|
||||
uint32_t tid = 0;
|
||||
SYS_CREATE_THREAD_REQUEST create;
|
||||
memset(&create, 0, sizeof(create));
|
||||
create.Size = sizeof(create);
|
||||
create.Entry = (uintptr_t)worker;
|
||||
create.Priority = 1u;
|
||||
create.Flags = SYS_CREATE_THREAD_FLAG_SUSPENDED;
|
||||
create.ThreadHandleOut = &thread;
|
||||
create.ThreadIdOut = &tid;
|
||||
status = SysCreateThread(&create);
|
||||
if (status != NTLSTATUS_SUCCESS || thread == SYS_HANDLE_INVALID || tid == 0)
|
||||
fail("create suspended worker failed");
|
||||
|
||||
status = set_name(thread, TEST_NAME_WORKER);
|
||||
if (status != NTLSTATUS_SUCCESS)
|
||||
fail("set worker name failed");
|
||||
|
||||
memset(name, 0, sizeof(name));
|
||||
length = 0;
|
||||
status = SysQueryThreadName(thread, name, sizeof(name), &length);
|
||||
if (status != NTLSTATUS_SUCCESS || length != sizeof(TEST_NAME_WORKER) - 1u ||
|
||||
strcmp(name, TEST_NAME_WORKER) != 0)
|
||||
fail("query worker name mismatch");
|
||||
|
||||
SYS_THREAD_INFO threads[TEST_MAX_THREADS];
|
||||
size_t threadCount = 0;
|
||||
status = SysGetThreadList(SysGetCurrentPid(), threads, TEST_MAX_THREADS, &threadCount);
|
||||
if (status != NTLSTATUS_SUCCESS)
|
||||
fail("thread enumeration failed");
|
||||
|
||||
int foundWorker = 0;
|
||||
size_t visible = threadCount < TEST_MAX_THREADS ? threadCount : TEST_MAX_THREADS;
|
||||
for (size_t i = 0; i < visible; ++i) {
|
||||
if (threads[i].ThreadId == tid) {
|
||||
if (strcmp(threads[i].Name, TEST_NAME_WORKER) != 0)
|
||||
fail("thread-list name mismatch");
|
||||
foundWorker = 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!foundWorker)
|
||||
fail("worker missing from thread list");
|
||||
|
||||
uint32_t previousSuspendCount = 0;
|
||||
status = SysResumeThread(thread, &previousSuspendCount);
|
||||
if (status != NTLSTATUS_SUCCESS || previousSuspendCount != 1u)
|
||||
fail("resume worker failed");
|
||||
status = SysWait(thread, SYS_WAIT_FLAG_NONE);
|
||||
if (status != NTLSTATUS_SUCCESS)
|
||||
fail("wait worker failed");
|
||||
(void)SysCloseHandle(thread);
|
||||
|
||||
SYS_HANDLE detachedReady = SYS_HANDLE_INVALID;
|
||||
status = SysCreateEvent(TEST_EVENT_AUTO_RESET, 0, &detachedReady);
|
||||
if (status != NTLSTATUS_SUCCESS)
|
||||
fail("create detached-ready event failed");
|
||||
|
||||
memset(&create, 0, sizeof(create));
|
||||
create.Size = sizeof(create);
|
||||
create.Entry = (uintptr_t)detached_worker;
|
||||
create.Argument = (uintptr_t)detachedReady;
|
||||
create.Priority = 1u;
|
||||
create.Flags = SYS_CREATE_THREAD_FLAG_NONE;
|
||||
status = SysCreateThread(&create);
|
||||
if (status != NTLSTATUS_SUCCESS)
|
||||
fail("create detached worker failed");
|
||||
status = SysWait(detachedReady, SYS_WAIT_FLAG_NONE);
|
||||
if (status != NTLSTATUS_SUCCESS)
|
||||
fail("detached worker did not run");
|
||||
(void)SysCloseHandle(detachedReady);
|
||||
|
||||
print("thread_name_smoke: PASS\n");
|
||||
exit_now(0);
|
||||
return 0;
|
||||
}
|
||||
Reference in new issue
Block a user