
                 The Netatalk Test-Suite
                 =======================

This suite contains several small utilities aimed at testing
a) AFP Server conformance to the AFP Specs, e.g. `afp_spectest`
b) benchmarking AFP Servers, e.g. `afp_lantest` and `afp_speedtest`

For end users the most useful utility is probably `afp_lantest` which
is a CLI counterpart for the famous HELIOS Lan Test.

Tests prg in test directory:
============================

Spec conformance tests
----------------------

./afp_spectest:
AFP spec test. Assume exported volumes are only modified with netatalk.
Tier 2 testsets can only be run locally, activated with the -c option.

./afp_logintest:
AFP spec tests for DSI and login. Not included in spectest.


Benchmarking
------------

./afp_lantest
Netatalk implementation of HELIOS Lan Test.

./afp_speedtest
Bench Read, Write and file copy (either Read/Write or FPCopyFile),
it can also run the same tests using Posix syscalls and can
be use for testing afpd speed against local or others protocols.


Helpers
-------

./afparg
The beginning of an AFP CLI client, cf ./afparg -l
FPResolveID <file CNID>
FPCopyFile <source> <dest>

Compilation
===========

Setup meson with the `-Dwith-testsuite=true' option.
Then compile the netatalk package as usual.
The afptest binaries can be found under build/test/testsuite/


Configuration for running the APF spec tests
============================================

- 2 users: <user1> <user2> with the same password
- 3 group: <gp1> <gp2> <common>
- with gp1:user1, gp2:user2, common:user1, user2
- clear text UAM + guest UAM
- an empty volume:
drwxrwsr-x    5 user1   common         176 avr 27 23:56 test/
- some tests need a small read write volume, I'm using a 2 MBytes loopback

example for
afp.conf:
#<<<<<<
[Global]
uam list = uams_clrtxt.so uams_guest.so

[volume1]
appledouble = ea
path = /tmp/afptest1
valid users = @afpusers

[volume2]
appledouble = ea
path = /tmp/afptest2
valid users = @afpusers
#<<<<<<<<

For testing with a Mac, same config (user1 or user2 are not owner)

meson test
----------

You can also run the complete spectest (one user, two users, local access) with
`meson test`. To do so, run:
- `cd build && meson test` once in order to generate a boilerplate config file "spectest.conf"
- edit "build/test/testsuite/spectest.conf" to suit your needs
- run `meson test` again

Return Codes
------------
0 PASSED
1 FAILED
2 NOT TESTED - a test setup step or precondition check failed
3 SKIPPED - test environment requirements not satisfied

Note that SKIPPED is treated as an overall return code 0 for the purpose of test reporting.

Spectest and logintest shall return the same results whether they are run
on a Mac server or afpd.

Example:
--------
Run tier 1 spec tests on server 192.168.2.123
afp_spectest -h 192.168.2.123 -u user1 -d user2 -s volume1 -S volume2 -w toto
Same but on a Mac
afp_spectest -m -h 192.168.2.64 -u user1 -d user2 -s volume1 -w toto

Run tier 2 T2FPMoveAndRename tests with AFP 3.0, running locally on the host.
afp_spectest -f T2FPMoveAndRename_test -3 -h 127.0.0.1 -u user1 -d user2 -w toto -s volume1 -S volume2 -c /tmp/afptest1

At least on linux, it's possible to compile them with LDFLAGS=-rdynamic
and the program can run individual test:
afp_spectest -4 -u <user> -d <seconduser> -w <passwd> -s <vol> -c <path> -f test235

Tests output
------------

Test name
if the test is not executed, reason, ex: SKIPPED (need AFP 3.x)
list of AFP calls executed with error code if any

- if Mac result and Netatalk differ or if Mac result differ between versions, Mac result
Ex:
header.dsi_code       -5000     AFPERR_ACCESS
MAC RESULT: -5019 AFPERR_PARAM    -5010 AFPERR_BUSY
Netatalk returns AFPERR_ACCESS when a Mac return AFPERR_PARAM or AFPERR_BUSY

- if Mac and Netatalk now return the same result:
Warning MAC and Netatalk now same RESULT!

List tests
----------

One way to get a list of tests that are actually implemented,
is to grep for symbols in the compiled binaries.

nm afp_logintest afp_spectest | cut -d " " -f 3 | egrep "^test[[:digit:]]+" | sort -n -k 1.5
