Skip to content
Daniel Markstedt edited this page Dec 20, 2024 · 3 revisions

Netatalk Testing

At present, Netatalk has two test automation suites, both written in pure C:

  • afpd component integration tests
  • afptest system integration test suite

The former can be run stateless through the Meson test runner.

The latter requires a test environment with a correctly configured and running netatalk instance. It can be run stand-alone, or through the Meson test runner (but only spectest; see below.)

The component integration test code is located in test/afpd, and the system integration tests in test/testsuite.

Run the afpd tests

In order to run the tests, build Netatalk with tests enabled, then run the meson test target from within the build directory:

meson setup build -Dwith-tests=true
meson compile -C build
cd build
meson test

Passing results should look something like this:

ninja: Entering directory `/home/atalk/devel/netatalk/build'
ninja: no work to do.
1/2 afpd integration tests - setup        OK              0.42s
2/2 afpd integration tests - run          OK              1.98s

Ok:                 2   
Expected Fail:      0   
Fail:               0   
Unexpected Pass:    0   
Skipped:            0   
Timeout:            0   

Full log written to /home/atalk/devel/netatalk/build/meson-logs/testlog.txt

Note that the suite contains multiple tests. See test.c for the full list of assertions.

Run the spectest test suite

The spectest test suite ensures that there are no breakages in AFP specification conformance. The test runner binary is called afp_spectest.

First, build netatalk with the testsuite enabled. Installation may need root privileges.

meson setup build -Dwith-testsuite=true
meson compile -C build
meson install -C build

Stop netatalk if running, and then configure the environment. Here follows a concrete example, applicable to Debian Linux (and many other Linux flavors). This is a modified script from what's running with autopkgtest in debci. We only set up the requirements for the tier 1 spectests, namely those that can run remotely, without test suite access to the host file system. Root privileges required too execute these commands.

systemctl stop netatalk
groupadd -f afpusers
useradd -G afpusers atalk1
useradd -G afpusers atalk2
echo "atalk1:afpafp" | chpasswd
echo "atalk2:afpafp" | chpasswd
mkdir -p /tmp/afptest1
mkdir -p /tmp/afptest2
chown atalk1:afpusers /tmp/afptest1
chown atalk1:afpusers /tmp/afptest2
chmod 2775 /tmp/afptest1
chmod 2775 /tmp/afptest2

Modify the netatalk config files.

cat <<AFP > /usr/local/etc/afp.conf
[Global]
uam list = uams_clrtxt.so uams_guest.so

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

[test2]
appledouble = ea
path = /tmp/afptest2
valid users = @afpusers
AFP
cat <<EXT > /usr/local/etc/extmap.conf
.         "????"  "????"      Unix Binary                    Unix                      application/octet-stream
.doc      "WDBN"  "MSWD"      Word Document                  Microsoft Word            application/msword
.pdf      "PDF "  "CARO"      Portable Document Format       Acrobat Reader            application/pdf
EXT

Start netatalk again and run the tests.

systemctl start netatalk
afp_spectest -7 -h 127.0.0.1 -p 548 -u atalk1 -d atalk2 -w afpafp -s test1 -S test2

For additional instructions, see the test suite test/testsuite/README and the afptest man page.

The majority of the spec tests are also running in the GitHub CI workflow, the only exceptions being a handful that require special setup that is cumbersome to replicate.

Clone this wiki locally