aports/testing/rage/fix-tests.patch
Michał Polański 8cc3fa49eb testing/rage: new aport
Simple, modern and secure encryption tool
https://github.com/str4d/rage
2022-05-31 19:15:24 +02:00

92 lines
2.8 KiB
Diff

Patch-Source: https://github.com/str4d/rage/pull/322
From 2b0ad5ce1b270a1ef55d52a93dd8d2e7cd273c15 Mon Sep 17 00:00:00 2001
From: Chris Cowan <agentme49@gmail.com>
Date: Sun, 8 May 2022 20:47:39 -0700
Subject: [PATCH] Fix test and bench support for arm
---
age/Cargo.toml | 4 +++-
age/benches/throughput.rs | 25 +++++++++++++++++++++----
2 files changed, 24 insertions(+), 5 deletions(-)
diff --git a/age/Cargo.toml b/age/Cargo.toml
index 2961fc0e..5aa7ad11 100644
--- a/age/Cargo.toml
+++ b/age/Cargo.toml
@@ -91,7 +91,6 @@ wsl = { version = "0.1", optional = true }
[dev-dependencies]
criterion = "0.3"
-criterion-cycles-per-byte = "0.1"
futures-test = "0.3"
i18n-embed = { version = "0.13", features = ["desktop-requester", "fluent-system"] }
quickcheck = "1"
@@ -100,6 +99,9 @@ quickcheck_macros = "1"
[target.'cfg(unix)'.dev-dependencies]
pprof = { version = "0.8", features = ["criterion", "flamegraph"] }
+[target.'cfg(any(target_arch = "x86", target_arch = "x86_64"))'.dev-dependencies]
+criterion-cycles-per-byte = "0.1"
+
[features]
default = []
armor = []
diff --git a/age/benches/throughput.rs b/age/benches/throughput.rs
index 28f86d16..ed3d367e 100644
--- a/age/benches/throughput.rs
+++ b/age/benches/throughput.rs
@@ -1,7 +1,25 @@
use age::{x25519, Decryptor, Encryptor};
use criterion::{criterion_group, criterion_main, BenchmarkId, Criterion, Throughput};
+
+#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
use criterion_cycles_per_byte::CyclesPerByte;
+#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
+type Criterion_ = Criterion<CyclesPerByte>;
+
+#[cfg(not(any(target_arch = "x86", target_arch = "x86_64")))]
+type Criterion_ = Criterion;
+
+#[cfg(any(target_arch = "x86", target_arch = "x86_64"))]
+fn setup_criterion() -> Criterion_ {
+ Criterion::default().with_measurement(CyclesPerByte)
+}
+
+#[cfg(not(any(target_arch = "x86", target_arch = "x86_64")))]
+fn setup_criterion() -> Criterion_ {
+ Criterion::default()
+}
+
#[cfg(unix)]
use pprof::criterion::{Output, PProfProfiler};
@@ -10,7 +28,7 @@ use std::iter;
const KB: usize = 1024;
-fn bench(c: &mut Criterion<CyclesPerByte>) {
+fn bench(c: &mut Criterion_) {
let identity = x25519::Identity::generate();
let recipient = identity.to_public();
let mut group = c.benchmark_group("age");
@@ -70,15 +88,14 @@ fn bench(c: &mut Criterion<CyclesPerByte>) {
#[cfg(unix)]
criterion_group!(
name = benches;
- config = Criterion::default()
- .with_measurement(CyclesPerByte)
+ config = setup_criterion()
.with_profiler(PProfProfiler::new(100, Output::Flamegraph(None)));
targets = bench
);
#[cfg(not(unix))]
criterion_group!(
name = benches;
- config = Criterion::default()
+ config = setup_criterion()
.with_measurement(CyclesPerByte);
targets = bench
);