Because the data directory may be a symlink, also log the path it resolves to, so debug.log files show the actual location for that run.
This patch would mostly help developers. I've been testing a potential performance PR across different data directories (for example, SSD versus HDD). After each run, I save the debug.log file. It would be nice if the debug.log file showed which data directory was used for that run.
There are two ways to change which data directory to use: -datadir= on the command line, or by making the default path a symlink. If a script starts bitcoind (e.g., on an RPi with a whole infrastructure, like Umbrel or myNode), changing the startup command arguments may be inconvenient or not even possible. It's easy to change the default directory to be a symlink. But in that case, debug.log doesn't show where the actual data directory is located. This patch adds one line to the logging startup output showing the resolved data directory path (after following symlinks).
I don't think a separate test is needed. I haven't tested on all platforms, but this patch uses primitives already used elsewhere, so it should work everywhere.
Here's an example of the additional line this patch logs during startup, just after the Using data directory line (omitting the timestamp prefix). I'll show both here for context (only the second line is added):
Using data directory /home/larry/.bitcoin
Resolved data directory /sd/.bitcoin
The patch could print this line only if the resolved path differs from the Using data directory path, but we may as well print it every time, because it's only one extra line, and this way any scripts that look for the resolved path are simpler (they can depend on it always being there).