netatalk.io

Testing

Netatalk Testing

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

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.

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.

Debian env prep

The following steps were run on Debian Linux, but may work on other Linux flavors. This is a modified script from what’s running with autopkgtest in Debian CI. 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 are required to execute these commands.

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

FreeBSD env prep

pw groupadd afpusers
pw useradd atalk1 -m -G afpusers
pw useradd atalk2 -m -G afpusers
passwd atalk1
passwd atalk2
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

OpenBSD env prep

The following steps were run on OpenBSD, and may work on other BSD flavors.

groupadd afpusers
useradd -m -G afpusers atalk1
useradd -m -G afpusers atalk2
passwd atalk1
passwd atalk2
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

Run tests

Modify the netatalk config files with test users, volumes, and UAMs.

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

Restart netatalk and run the tests. The IP address or domain name you pass to -h is the netatalk host to test against. It can be a remote machine, or the localhost.

When run against a remote host, only the so-called tier 1 tests are executed.

afp_spectest -h 192.168.0.2 -u atalk1 -d atalk2 -w afpafp -s test1 -S test2

When run on localhost, and you pass the local file system path to the primary shared volume with the -c parameter, the so-called tier 2 tests are executed as well. These are tests are involve making local file system modifications to set up certain test preconditions.

afp_spectest -h localhost -u atalk1 -d atalk2 -w afpafp -s test1 -S test2 -c /tmp/afptest1

For additional instructions, see 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 or take too long time to run.

Inspect implemented test functions

To get an authoritative list of test methods that are actually implemented, e.g. not commented out, you can inspect the compiled test binaries.

Build the netatalk source code with testsuite enabled, then run the following commands.

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

This should give you an exhaustive list of tests.

Footnotes

This is a mirror of the Netatalk GitHub Wiki. Please visit the original page if you want to correct an error or contribute new contents.

Last updated 2025-04-18