From 56a76d3b4311d4a11bdad4f5f0250b706d671dd8 Mon Sep 17 00:00:00 2001 From: Mario Fetka Date: Sat, 23 May 2026 13:21:26 +0200 Subject: [PATCH] tests --- kern.c | 23 ++++++--------- kern.h | 4 --- nwtests.c | 84 ++++++++++++++++++++++++++++++++++++------------------- 3 files changed, 64 insertions(+), 47 deletions(-) diff --git a/kern.c b/kern.c index 0f9959f..7f61048 100644 --- a/kern.c +++ b/kern.c @@ -9,11 +9,11 @@ * int Net_Call(unsigned int func, void *req, void *repl); * * New test functions: - * int KERN_CALL Net_Call_C(UI ax, void *req, void *repl); + * int Net_Call_C(unsigned int ax, void *req, void *repl); * int Net_Call_CX(unsigned int ax, unsigned int bx, * unsigned int cx, unsigned int dx, * void *req, void *repl); - * void KERN_CALL Net_Call_C_Dump(void); + * void Net_Call_C_Dump(void); */ #include @@ -22,12 +22,6 @@ #include "net.h" -#if defined(__WATCOMC__) -#define KERN_CALL _Cdecl -#else -#define KERN_CALL -#endif - typedef struct { unsigned int in_ax; unsigned int in_bx; @@ -64,7 +58,7 @@ NET_CALL_C_DEBUG Net_Call_C_Last; * Do not use it blindly for NCP87 yet; the previous F257 test hung through * the old wrapper, so we will first test old calls and register layout. */ -int KERN_CALL Net_Call_C(UI ax, void *req, void *repl) +int KERN_CALL Net_Call_C(unsigned int ax, void *req, void *repl) { return Net_Call_CX(ax, 0, 0, 0, req, repl); } @@ -73,8 +67,8 @@ int KERN_CALL Net_Call_C(UI ax, void *req, void *repl) * Extended variant with BX/CX/DX settable. This lets us experiment without * changing kern.asm every time. */ -int KERN_CALL Net_Call_CX(UI ax, UI bx, - UI cx, UI dx, +int KERN_CALL Net_Call_CX(unsigned int ax, unsigned int bx, + unsigned int cx, unsigned int dx, void *req, void *repl) { union REGS inregs; @@ -116,9 +110,10 @@ int KERN_CALL Net_Call_CX(UI ax, UI bx, Net_Call_C_Last.out_si = outregs.x.si; Net_Call_C_Last.out_di = outregs.x.di; Net_Call_C_Last.out_flags = outregs.x.cflag; - Net_Call_C_Last.rc = outregs.x.ax; + /* kern_wasm.asm clears AH before returning, so return AL only. */ + Net_Call_C_Last.rc = outregs.x.ax & 0x00ff; - return outregs.x.ax; + return Net_Call_C_Last.rc; } /* @@ -178,5 +173,3 @@ UI KERN_CALL Net_Call_C_GetDebug(UI idx) } return 0xffff; } - -#undef KERN_CALL diff --git a/kern.h b/kern.h index 56281b5..cda095e 100644 --- a/kern.h +++ b/kern.h @@ -13,10 +13,6 @@ extern void asm_esr_routine(void); extern void esr_routine(ECB *ecb); extern void KERN_CALL xmemmove(void *ziel, void *quelle, UI anz); extern int KERN_CALL Net_Call(UI func, void *req, void *repl); - -/* kern.c experimental C port / debug wrapper. - * These keep kern_wasm.asm Net_Call() untouched and are used for tests. - */ extern int KERN_CALL Net_Call_C(UI func, void *req, void *repl); extern int KERN_CALL Net_Call_CX(UI func, UI bx, UI cx, UI dx, void *req, void *repl); diff --git a/nwtests.c b/nwtests.c index 9490f4a..f585a87 100644 --- a/nwtests.c +++ b/nwtests.c @@ -1,22 +1,13 @@ -/* - * nwtests.c - developer-only tests - * - * Run by copying net.exe to tests.exe: - * cp build/dosutils/net.exe SYS/public/tests.exe - * - * Then in DOS: - * TESTS - * TESTS NETCALL - */ +/* nwtests.c 20-May-96 */ + +/**************************************************************** + * (C)opyright (C) 1993,1996 Martin Stover, Marburg, Germany * + ****************************************************************/ #include "net.h" -static void tests_usage(void) -{ - fprintf(stdout, "Usage: TESTS [NETCALL]\n"); -} -static int same_arg(char *a, char *b) +static int tests_same_arg(char *a, char *b) { while (*a || *b) { int ca = *a++; @@ -28,7 +19,12 @@ static int same_arg(char *a, char *b) return(1); } -static int test_netcall(void) +static void tests_usage(void) +{ + fprintf(stdout, "Usage: TESTS [OLD|NETCALL]\n"); +} + +static int tests_netcall(void) { unsigned char req[4]; unsigned char repl[4]; @@ -42,10 +38,6 @@ static int test_netcall(void) fprintf(stdout, "Call: INT 21h AH=19h get current drive\n"); fprintf(stdout, "Expected: AL=0 for A:, 1 for B:, 2 for C:, ...\n\n"); - /* - * Safe DOS call. It ignores DS:SI and ES:DI, so it is ideal for testing - * register setup without touching NetWare/NCP. - */ asm_rc = Net_Call(0x1900, req, repl); fprintf(stdout, "ASM Net_Call(1900h) rc=%04X drive=%c:\n", asm_rc, 'A' + (asm_rc & 0xff)); @@ -64,19 +56,55 @@ static int test_netcall(void) return(0); } +static int tests_old(int argc, char *argv[], int mode) +{ + + int level = ncp_17_02(NWCONN, 6); + int dirhandle = alloc_temp_dir_handle(0, "SYS:", 'd', NULL); + int result = -1; + uint8 *path = (argc < 2) ? "SYS:\\TMP" : argv[1]; + if (dirhandle > -1) { + result = ncp_16_02(dirhandle, "SYSTEM/", NULL, NULL, NULL, NULL); + result = ncp_16_02(dirhandle, "SYSTEM", NULL, NULL, NULL, NULL); + } + fprintf(stdout, "dirhandle=%d, result=%d\n", dirhandle, result); + result = redir_device_drive(0x4, "u:", path); + fprintf(stdout, "redir path=%s, result=%d\n", path, result); + + path="Q1"; + result = redir_device_drive(0x3, "LPT1", path); + fprintf(stdout, "redir path=%s, result=%d\n", path, result); + + { + int k =-1; + uint8 devname[20]; + uint8 remotename[130]; + int devicetyp; + while ((result = list_redir(++k, &devicetyp, devname, remotename)) > -1){ + fprintf(stdout, "index=%d, dev=%s(%d), %s result=%d\n", + k, devname, devicetyp, remotename, result); + } + } + if (level > -1) (void) ncp_17_02(NWCONN, level); + return(0); +} + int func_tests(int argc, char *argv[], int mode) { - (void)mode; + if (argc < 2) + return tests_old(argc, argv, mode); - if (argc < 2) { + if (tests_same_arg(argv[1], "NETCALL")) + return tests_netcall(); + + if (tests_same_arg(argv[1], "OLD")) + return tests_old(argc - 1, argv + 1, mode); + + if (tests_same_arg(argv[1], "/?") || tests_same_arg(argv[1], "-?") || + tests_same_arg(argv[1], "?")) { tests_usage(); return(0); } - if (same_arg(argv[1], "NETCALL")) { - return(test_netcall()); - } - - tests_usage(); - return(1); + return tests_old(argc, argv, mode); }