diff --git a/pkgs/by-name/ar/arc_unpacker/fix-test-float-variance.patch b/pkgs/by-name/ar/arc_unpacker/fix-test-float-variance.patch
new file mode 100644
index 000000000000..8f04e7f86ebc
--- /dev/null
+++ b/pkgs/by-name/ar/arc_unpacker/fix-test-float-variance.patch
@@ -0,0 +1,101 @@
+diff --git a/tests/test_support/audio_support.cc b/tests/test_support/audio_support.cc
+index c26022e9..5f50d035 100644
+--- a/tests/test_support/audio_support.cc
++++ b/tests/test_support/audio_support.cc
+@@ -16,6 +16,7 @@
+ // along with arc_unpacker. If not, see .
+
+ #include "test_support/audio_support.h"
++#include
+ #include "algo/format.h"
+ #include "algo/range.h"
+ #include "dec/microsoft/wav_audio_decoder.h"
+@@ -44,13 +45,42 @@ res::Audio tests::get_test_audio()
+ void tests::compare_audio(
+ const res::Audio &actual, const res::Audio &expected)
+ {
++ // Allow for minor variances in audio samples within the specified
++ // threshold. Floating point calculations in some audio decoders yields
++ // slightly differing results across different CPU architectures.
++ //
++ // Affected tests:
++ // * tests/dec/cri/hca_audio_decoder_test.cc
++ // * tests/dec/entis/mio_audio_decoder_test.cc
++ static constexpr int tolerance = 1;
++
+ REQUIRE(actual.codec == expected.codec);
+ REQUIRE(actual.channel_count == expected.channel_count);
+ REQUIRE(actual.sample_rate == expected.sample_rate);
+ REQUIRE(actual.bits_per_sample == expected.bits_per_sample);
+ REQUIRE(actual.extra_codec_headers == expected.extra_codec_headers);
+ REQUIRE(actual.samples.size() == expected.samples.size());
++
++#ifdef __x86_64__
+ tests::compare_binary(actual.samples, expected.samples);
++#else
++ tests::compare_binary(
++ actual.samples,
++ expected.samples,
++ [](const bstr& bytes1, const bstr& bytes2) -> bool {
++ const auto samples1 = reinterpret_cast(bytes1.c_str());
++ const auto samples2 = reinterpret_cast(bytes2.c_str());
++ const auto n_samples = bytes1.size() / sizeof(*samples1);
++ // algo::range is a bit incomplete to work with std::all_of
++ for (const int i : algo::range(n_samples)) {
++ if (std::abs(samples1[i] - samples2[i]) > tolerance) {
++ return false;
++ }
++ }
++ return true;
++ }
++ );
++#endif
+
+ REQUIRE(actual.loops.size() == expected.loops.size());
+ for (const auto i : algo::range(expected.loops.size()))
+diff --git a/tests/test_support/common.cc b/tests/test_support/common.cc
+index b63ffa89..265ef7b1 100644
+--- a/tests/test_support/common.cc
++++ b/tests/test_support/common.cc
+@@ -40,3 +40,19 @@ void au::tests::compare_binary(const bstr &actual, const bstr &expected)
+ INFO(actual_dump << " != " << expected_dump);
+ REQUIRE(actual == expected);
+ }
++
++void au::tests::compare_binary(
++ const bstr &actual,
++ const bstr &expected,
++ std::function compare)
++{
++ const auto max_size = 10000;
++ auto actual_dump = algo::hex(actual);
++ auto expected_dump = algo::hex(expected);
++ if (actual_dump.size() > max_size)
++ actual_dump = actual_dump.substr(0, max_size) + "(...)";
++ if (expected_dump.size() > max_size)
++ expected_dump = expected_dump.substr(0, max_size) + "(...)";
++ INFO(actual_dump << " != " << expected_dump);
++ REQUIRE(compare(actual, expected));
++}
+diff --git a/tests/test_support/common.h b/tests/test_support/common.h
+index 7d8be579..ecd5dcf8 100644
+--- a/tests/test_support/common.h
++++ b/tests/test_support/common.h
+@@ -17,6 +17,7 @@
+
+ #pragma once
+
++#include
+ #include "io/path.h"
+ #include "types.h"
+
+@@ -27,4 +28,9 @@ namespace tests {
+
+ void compare_binary(const bstr &actual, const bstr &expected);
+
++ void compare_binary(
++ const bstr &actual,
++ const bstr &expected,
++ std::function compare);
++
+ } }
diff --git a/pkgs/by-name/ar/arc_unpacker/package.nix b/pkgs/by-name/ar/arc_unpacker/package.nix
index 667b723b868b..aab3999e3619 100644
--- a/pkgs/by-name/ar/arc_unpacker/package.nix
+++ b/pkgs/by-name/ar/arc_unpacker/package.nix
@@ -27,6 +27,7 @@ stdenv.mkDerivation {
};
patches = [
+ ./fix-test-float-variance.patch
(fetchpatch {
name = "failing_tests.patch";
url = "https://aur.archlinux.org/cgit/aur.git/plain/failing_tests.patch?h=arc_unpacker-git&id=bda1ad9f69e6802e703b2e6913d71a36d76cfef9";
@@ -88,8 +89,7 @@ stdenv.mkDerivation {
runHook postInstall
'';
- # A few tests fail on aarch64-linux
- doCheck = !(stdenv.hostPlatform.isLinux && stdenv.hostPlatform.isAarch64);
+ doCheck = true;
meta = with lib; {
description = "Tool to extract files from visual novel archives";
@@ -98,8 +98,5 @@ stdenv.mkDerivation {
maintainers = with maintainers; [ midchildan ];
platforms = platforms.all;
mainProgram = "arc_unpacker";
-
- # unit test failures
- broken = stdenv.hostPlatform.isDarwin && stdenv.hostPlatform.isAarch64;
};
}