Files
mars-nwe/tests/linux/README.md
Mario Fetka 162ff2b10f
All checks were successful
Source release / source-package (push) Successful in 49s
nwconn: implement AFP temporary directory handles
Implement the WebSDK/nwafp.h NCP 0x2222/35 AFP subfunction 0x0b, Alloc Temporary Directory Handle, for the same conservative path-backed subset used by the current AFP Entry ID and File Information probes.\n\nThe documented request carries an AFP volume number, a base AFP Entry ID, and an optional AFP-style path.  mars_nwe still has no persistent CNID/base-ID lookup, so this patch deliberately accepts only requests with a path component and rejects entry-id-only allocation as Invalid Path.  For the supported smoke-test path, raw SYS:-style paths are resolved through the existing NetWare path machinery and the final handle is allocated with nw_alloc_dir_handle() as a temporary, task-scoped NetWare directory handle.\n\nThe implementation keeps the AFP namespace gate intact: without the optional Netatalk/libatalk backend, the endpoint continues to return Invalid Namespace rather than pretending that the Mac namespace exists.  With the backend enabled, successful replies contain the allocated temporary directory handle and the effective-rights mask returned by the existing directory-handle table.  Diagnostics include the AFP volume/base Entry ID input, path, returned handle, and rights so smoke-test output can be matched to server logs.\n\nAdd a Linux ncpfs/libncp smoke helper for the new endpoint.  The helper sends the AFP 0x0b request through NWRequestSimple(), prints the returned handle and rights mask, and immediately deallocates the handle in the same connection via the normal NetWare Deallocate Directory Handle call.  The README documents that these handles are connection/task-local and must not be copied into later tests or reused from server logs.\n\nTests:\n- git diff --check\n- gcc -fsyntax-only tests/linux/afp_temp_dir_handle_smoke.c with temporary local ncpfs header stubs\n\nNot run:\n- Full CMake build in this container: missing gdbm/ncpfs development headers/libraries.\n\nTODO:\n- Replace the path-backed subset with persistent CNID/base-ID lookup once the AFP metadata backend grows durable directory identity support.\n- Verify live Linux smoke cases against SYS:, SYS:PUBLIC, SYS:SYSTEM, and SYS:BURST on a mars_nwe host with ENABLE_NETATALK_LIBATALK=ON.
2026-05-30 09:27:51 +02:00

256 lines
11 KiB
Markdown

# Linux NCP smoke tests
This directory contains optional Linux-side integration tests for endpoints that
are easier to exercise from a Unix host than from the DOS test utilities.
The tests use the ncpfs/libncp client library. They are not built by default
because they require the host ncpfs development headers/library and a running
NetWare-compatible server.
Build with:
```sh
cmake -DMARS_NWE_BUILD_LINUX_TESTS=ON ...
cmake --build . --target afp_entry_id_smoke
cmake --build . --target afp_file_info_smoke
cmake --build . --target afp_scan_info_smoke
cmake --build . --target afp_temp_dir_handle_smoke
```
## AFP Entry ID smoke test
`afp_entry_id_smoke` sends the WebSDK-documented NetWare AFP request:
```text
NCP 0x2222/35/12 AFP Get Entry ID From Path Name
```
It uses libncp's `NWRequestSimple()` path, so it goes through the same client
transport stack as other Linux ncpfs utilities.
Example:
```sh
./tests/linux/afp_entry_id_smoke -S MARS -U SUPERVISOR -P secret SYS:PUBLIC
```
The test accepts NetWare-style `VOL:PATH` arguments. By default it sends the
supplied `SYS:`-style path directly with directory handle 0, matching the
verified mars_nwe smoke-test path. `--alloc-handle` is available only for
follow-up debugging of the separate directory-handle allocation path, and
`--dir-handle N` expects a handle that is valid in the current connection.
Useful smoke cases for a standard MARS-NWE `SYS` volume are:
```sh
./tests/linux/afp_entry_id_smoke -S MARS -U SUPERVISOR -P secret SYS:
./tests/linux/afp_entry_id_smoke -S MARS -U SUPERVISOR -P secret SYS:PUBLIC
./tests/linux/afp_entry_id_smoke -S MARS -U SUPERVISOR -P secret SYS:SYSTEM
./tests/linux/afp_entry_id_smoke -S MARS -U SUPERVISOR -P secret SYS:BURST
```
A successful reply prints the request path, directory handle, and returned
32-bit AFP Entry ID. Server-side diagnostics currently mark stat-derived
temporary IDs with `fallback`; that means the endpoint is reachable, but
persistent CNID/AppleDouble entry-id storage is still future Mac-namespace
work.
If the server was built without the optional Netatalk/libatalk backend, the
endpoint is expected to return invalid namespace. To treat that as a successful
negative smoke test, use:
```sh
./tests/linux/afp_entry_id_smoke --allow-invalid-namespace -S MARS -U SUPERVISOR -P secret SYS:PUBLIC
```
For path-resolution negative tests, use `--allow-invalid-path` to accept the
expected `0x9c` Invalid Path completion.
### AFP Get Entry ID From Name
`afp_entry_id_smoke` can also exercise the WebSDK-documented NetWare AFP
request:
```text
NCP 0x2222/35/04 AFP Get Entry ID From Name
```
Use `--from-name` to select this subfunction. The current mars_nwe
implementation supports the same verified path-backed smoke mode as
`AFP Get Entry ID From Path Name`: pass a raw `SYS:`-style path with directory
handle 0 and base Entry ID 0.
Useful smoke cases for a standard MARS-NWE `SYS` volume are:
```sh
./tests/linux/afp_entry_id_smoke --from-name -S MARS -U SUPERVISOR -P secret SYS:
./tests/linux/afp_entry_id_smoke --from-name -S MARS -U SUPERVISOR -P secret SYS:PUBLIC
./tests/linux/afp_entry_id_smoke --from-name -S MARS -U SUPERVISOR -P secret SYS:SYSTEM
./tests/linux/afp_entry_id_smoke --from-name -S MARS -U SUPERVISOR -P secret SYS:BURST
```
A successful reply prints the same 32-bit AFP Entry ID format as the path-name
probe. Server-side diagnostics currently mark stat-derived temporary IDs with
`fallback`; real base-entry-id-relative lookup still depends on persistent
CNID/AppleDouble mapping.
### AFP Get Entry ID From NetWare Handle
`afp_entry_id_smoke` can also exercise the WebSDK-documented NetWare AFP
request:
```text
NCP 0x2222/35/06 AFP Get Entry ID From NetWare Handle
```
Use `--from-handle` to select this subfunction. The smoke test opens the
requested file through libncp in the same connection, passes the returned
6-byte NetWare file handle to the AFP request, and closes the file after the
AFP reply. This is important because NetWare file handles are connection-local:
`--dir-handle N` and file-handle values copied from server logs or unrelated
helper processes are not stable inputs for this request.
Useful smoke cases for a standard MARS-NWE `SYS:PUBLIC` directory are:
```sh
./tests/linux/afp_entry_id_smoke --from-handle -S MARS -U SUPERVISOR -P secret SYS:PUBLIC/pmdflts.ini
./tests/linux/afp_entry_id_smoke --from-handle -S MARS -U SUPERVISOR -P secret SYS:PUBLIC/ohlogscr.bat
```
Successful replies print the resolved volume number, 32-bit AFP Entry ID, and
fork indicator. The current implementation reports the data fork (`fork=0`)
and server diagnostics mark the returned Entry ID as `fallback` when it is
derived from Unix `stat(2)` data rather than persistent CNID, AppleDouble, or
libatalk metadata:
```text
AFP Entry ID From NetWare Handle path=SYS:PUBLIC/pmdflts.ini volume=0 entry_id=0x23c8787d (600340605) fork=0
AFP Entry ID From NetWare Handle path=SYS:PUBLIC/ohlogscr.bat volume=0 entry_id=0x260437f6 (637810678) fork=0
AFP Get Entry ID From NetWare Handle: handle=1 volume=0 unix='/var/mars_nwe/SYS/public/pmdflts.ini' entry=0x23c8787d fallback
AFP Get Entry ID From NetWare Handle: handle=1 volume=0 unix='/var/mars_nwe/SYS/public/ohlogscr.bat' entry=0x260437f6 fallback
```
The concrete fallback Entry IDs vary with filesystem metadata. Persistent
CNID/AppleDouble/libatalk-backed identity, parent Entry ID derivation, and AFP
resource-fork handle semantics remain future Mac-namespace work; the current
smoke coverage only verifies the conservative read-only data-fork mapping.
## AFP Alloc Temporary Directory Handle smoke test
`afp_temp_dir_handle_smoke` sends the WebSDK-documented NetWare AFP request:
```text
NCP 0x2222/35/11 AFP Alloc Temporary Directory Handle
```
The request layout is the AFP volume number, base AFP Entry ID, path length,
and AFP-style path. The current mars_nwe implementation supports the same
conservative path-backed subset as the Entry ID and File Information probes:
pass a raw `SYS:`-style path and keep volume/base Entry ID at zero. Pure
Entry-ID-relative allocation is still rejected with Invalid Path until
persistent CNID/base-ID lookup exists.
Useful smoke cases for a standard MARS-NWE `SYS` volume are:
```sh
./tests/linux/afp_temp_dir_handle_smoke -S MARS -U SUPERVISOR -P secret SYS:
./tests/linux/afp_temp_dir_handle_smoke -S MARS -U SUPERVISOR -P secret SYS:PUBLIC
./tests/linux/afp_temp_dir_handle_smoke -S MARS -U SUPERVISOR -P secret SYS:SYSTEM
./tests/linux/afp_temp_dir_handle_smoke -S MARS -U SUPERVISOR -P secret SYS:BURST
```
A successful reply prints the allocated temporary NetWare directory handle and
the effective-rights mask returned by the server. The smoke helper immediately
deallocates the handle with the normal NetWare Deallocate Directory Handle call
before closing the connection, so the handle value is only useful inside that
client connection and must not be copied into later tests or server logs.
Example output and server diagnostic shape:
```text
AFP Alloc Temporary Dir Handle path=SYS:PUBLIC dir_handle=2 rights=0xff
AFP Alloc Temporary Dir Handle: vol=0 entry=0x00000000 path='SYS:PUBLIC' dir_handle=2 rights=0xff
```
If the server was built without the optional Netatalk/libatalk backend, use
`--allow-invalid-namespace` for the expected negative test. Use
`--allow-invalid-path` for path-resolution negative tests.
## AFP File Information smoke test
`afp_file_info_smoke` sends the WebSDK-documented NetWare AFP file
information requests:
```text
NCP 0x2222/35/05 AFP Get File Information
NCP 0x2222/35/15 AFP 2.0 Get File Information
```
It uses the same libncp `NWRequestSimple()` transport path as the Entry ID
smoke test and sends raw `SYS:`-style path requests with directory handle 0.
The server replies with the read-only AFP file information record currently
implemented by mars_nwe: Entry ID, Parent ID, attributes, data/resource fork
lengths, offspring count, fixed long/short names, and access rights.
Useful smoke cases for a standard MARS-NWE `SYS` volume are:
```sh
./tests/linux/afp_file_info_smoke -S MARS -U SUPERVISOR -P secret SYS:
./tests/linux/afp_file_info_smoke -S MARS -U SUPERVISOR -P secret SYS:PUBLIC
./tests/linux/afp_file_info_smoke -S MARS -U SUPERVISOR -P secret SYS:SYSTEM
./tests/linux/afp_file_info_smoke -S MARS -U SUPERVISOR -P secret SYS:BURST
# AFP 2.0 variant using the same path-backed read-only reply
./tests/linux/afp_file_info_smoke --afp20 -S MARS -U SUPERVISOR -P secret SYS:
./tests/linux/afp_file_info_smoke --afp20 -S MARS -U SUPERVISOR -P secret SYS:PUBLIC
./tests/linux/afp_file_info_smoke --afp20 -S MARS -U SUPERVISOR -P secret SYS:SYSTEM
./tests/linux/afp_file_info_smoke --afp20 -S MARS -U SUPERVISOR -P secret SYS:BURST
```
The AFP 2.0 mode is selected with `--afp20`. It has been verified against
the same `SYS:`, `SYS:PUBLIC`, `SYS:SYSTEM`, and `SYS:BURST` paths and
currently exercises the same path-backed read-only reply as the older call.
The current implementation fills fields that can be derived from Unix `stat(2)` and the optional libatalk
helper wrappers. Server-side diagnostics mark
stat-derived temporary Entry IDs with `fallback`; Parent ID, persistent
CNID/AppleDouble IDs, and fuller Finder Info/resource-fork semantics remain
future Mac-namespace work.
If the server was built without the optional Netatalk/libatalk backend, use
`--allow-invalid-namespace` for the expected negative test. Use
`--allow-invalid-path` for path-resolution negative tests.
## AFP Scan File Information smoke test
`afp_scan_info_smoke` sends the WebSDK-documented NetWare AFP scan request:
```text
NCP 0x2222/35/17 AFP 2.0 Scan File Information
```
It scans one directory entry per request using the same read-only AFP file
information record as `afp_file_info_smoke`. The test sends raw `SYS:`-style
path requests with directory handle 0 and uses the returned `next_last_seen` AFP
Entry ID as the continuation token for the next call.
Useful smoke sequence for a standard MARS-NWE `SYS:PUBLIC` directory:
```sh
./tests/linux/afp_scan_info_smoke -S MARS -U SUPERVISOR -P secret SYS:PUBLIC
./tests/linux/afp_scan_info_smoke -S MARS -U SUPERVISOR -P secret --last-seen 0x23c8787d SYS:PUBLIC
./tests/linux/afp_scan_info_smoke --allow-empty -S MARS -U SUPERVISOR -P secret --last-seen 0x260437f6 SYS:PUBLIC
```
The concrete Entry IDs vary by filesystem metadata and are currently marked as
`fallback` in server diagnostics when they are derived from `stat(2)` rather
than persistent CNID/AppleDouble metadata. The verified smoke path walks
multiple entries in `SYS:PUBLIC` by feeding each returned `next_last_seen` value
into the next request.
If the server was built without the optional Netatalk/libatalk backend, use
`--allow-invalid-namespace` for the expected negative test. Use
`--allow-invalid-path` for path-resolution negative tests, and `--allow-empty`
when a scan continuation is expected to reach the end of the directory.