`emv_debug_test` fails due to mismatch of the paths when building on Arch Linux
I tried to build emv-utils from Arch Linux AUR: https://aur.archlinux.org/packages/emv-utils-git
$ git clone https://aur.archlinux.org/emv-utils-git.git
$ cd emv-utils-git/
$ makepkg -si
and test #57 failed:
1/78 Test #57: emv_debug_test .............................***Failed Required regular expression not found. Regex=[\[APP\] asdf=1337[
]\[APP\] tests/emv_debug_test.c\[46\]: This is a trace message: DEADBEEF[
]
] 0.02 sec
[APP] asdf=1337
[APP] /usr/src/debug/emv-utils-git/emv-utils/tests/emv_debug_test.c[46]: This is a trace message: DEADBEEF
The problem is the mismatch of the paths: tests/emv_debug_test.c in the regex and /usr/src/debug/emv-utils-git/emv-utils/tests/emv_debug_test.c on my system.
Changing this line: https://github.com/openemv/emv-utils/blob/952fe3bca7d181b366eac59f07aae5d758ba3f00/tests/CMakeLists.txt#L18 to
"\\[APP\\] .*tests/emv_debug_test\.c\\[46\\]: This is a trace message: DEADBEEF[\r\n]"
solves this issue.
Is this the correct solution?
Hi @drygdryg,
Thank you for taking an interest in this project. I'm excited to see that you have made it available on Arch.
Your proposed solution would make the test failure go away but unfortunately wouldn't solve the problem. One of the outcomes of that test is specifically to ensure that trace messages only show a relative path instead of the full path. This line in the build sets the current top-level path of the source tree for emv_debug.c to use when truncating the paths of trace messages. And it seems that for your build, this isn't happening.
I'm not familiar with how Arch AUR builds but if its anything like Gentoo, it may make unexpected modifications to the CMake. Does AUR allow you to make a verbose build that shows the compiler commands so that we can see of CONFIG_SRC_BASE? For example, when building manually the --verbose option can be added to the CMake build step (not the CMake config step) and then the compiler command for emv_debug.c will show something like this: -DCONFIG_SRC_BASE=\"/usr/src/debug/emv-utils-git/emv-utils".
If you're comfortable building from source in general, you can even clone it directly from Github and build it in your home directory using something like cmake -B build -DCMAKE_BUILD_TYPE="RelWithDebInfo" && cmake --build build --verbose && ctest --test-dir build. If that works, but the AUR build doesn't, then we have to dig deeper into what AUR may be doing.
I also had a quick look at https://aur.archlinux.org/emv-utils-git.git and recommend that you add MbedTLS as a dependency. This project has been tested with all MbedTLS LTS version (2.16 / 2.28 / 3.6).