poulpy/poulpy-hal/src/test_suite/mod.rs
poulpy-hal/src/test_suite/mod.rsRaw
1pub mod convolution;
2pub mod serialization;
3pub mod svp;
4pub mod vec_znx;
5pub mod vec_znx_big;
6pub mod vec_znx_dft;
7pub mod vmp;
8
9#[macro_export]
10macro_rules! backend_test_suite {
11 (
12 mod $modname:ident,
13 backend = $backend:ty,
14 size = $size:expr,
15 tests = {
16 $( $(#[$attr:meta])* $test_name:ident => $impl:path ),+ $(,)?
17 }
18 ) => {
19 mod $modname {
20 use poulpy_hal::{api::ModuleNew, layouts::Module};
21
22 use once_cell::sync::Lazy;
23
24 static MODULE: Lazy<Module<$backend>> =
25 Lazy::new(|| Module::<$backend>::new($size));
26
27 $(
28 $(#[$attr])*
29 #[test]
30 fn $test_name() {
31 ($impl)(&*MODULE);
32 }
33 )+
34 }
35 };
36}
37
38#[macro_export]
39macro_rules! cross_backend_test_suite {
40 (
41 mod $modname:ident,
42 backend_ref = $backend_ref:ty,
43 backend_test = $backend_test:ty,
44 size = $size:expr,
45 base2k = $base2k:expr,
46 tests = {
47 $( $(#[$attr:meta])* $test_name:ident => $impl:path ),+ $(,)?
48 }
49 ) => {
50 mod $modname {
51 use poulpy_hal::{api::ModuleNew, layouts::Module};
52
53 use once_cell::sync::Lazy;
54
55 static MODULE_REF: Lazy<Module<$backend_ref>> =
56 Lazy::new(|| Module::<$backend_ref>::new($size));
57 static MODULE_TEST: Lazy<Module<$backend_test>> =
58 Lazy::new(|| Module::<$backend_test>::new($size));
59
60 $(
61 $(#[$attr])*
62 #[test]
63 fn $test_name() {
64 ($impl)($base2k, &*MODULE_REF, &*MODULE_TEST);
65 }
66 )+
67 }
68 };
69}