Skip to content

Commit dcc8df6

Browse files
Wrap AES acceleration tests in testsets
1 parent b26bf4b commit dcc8df6

4 files changed

Lines changed: 82 additions & 74 deletions

File tree

test/aarch64/aesni.jl

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,28 @@
11
import Random: seed!
2-
using Test: @test
2+
using Test: @test, @testset
33

44
using RandomNumbers
55
using Random123
66

77
import RandomNumbers: split_uint
88
import Random123: uint64x2, AESNIKey
99

10-
x = zero(uint64x2)
11-
ctr = uint64x2(0x9799b5d54f7b9227, 0xb47607190d0dfefb)
12-
key = 0x07b8e4b6aa98ec245a7da274d3b8146a
13-
aesni_key = AESNIKey(key)
14-
@test rand(AESNI1x(x, ctr, aesni_key), UInt128) 0x60f4c27fe48fe1b8c5f4568a585b0dc0
10+
@testset "Accelerated AESNI" begin
11+
x = zero(uint64x2)
12+
ctr = uint64x2(0x9799b5d54f7b9227, 0xb47607190d0dfefb)
13+
key = 0x07b8e4b6aa98ec245a7da274d3b8146a
14+
aesni_key = AESNIKey(key)
15+
@test rand(AESNI1x(x, ctr, aesni_key), UInt128) 0x60f4c27fe48fe1b8c5f4568a585b0dc0
1516

16-
r = AESNI1x(key)
17-
r1 = AESNI4x(split_uint(key, UInt32))
18-
@test seed_type(r) UInt128
19-
@test seed_type(r1) NTuple{4, UInt32}
20-
@test copyto!(copy(r), r) == r
21-
@test copyto!(copy(r1), r1) == r1
22-
@test UInt128(r.x) rand(r1, UInt128)
23-
@test rand(r, UInt128) rand(r1, UInt128)
24-
set_counter!(r, 0)
25-
set_counter!(r1, 1)
26-
@test rand(r, Tuple{UInt128})[1] rand(r1, UInt128)
17+
r = AESNI1x(key)
18+
r1 = AESNI4x(split_uint(key, UInt32))
19+
@test seed_type(r) UInt128
20+
@test seed_type(r1) NTuple{4, UInt32}
21+
@test copyto!(copy(r), r) == r
22+
@test copyto!(copy(r1), r1) == r1
23+
@test UInt128(r.x) rand(r1, UInt128)
24+
@test rand(r, UInt128) rand(r1, UInt128)
25+
set_counter!(r, 0)
26+
set_counter!(r1, 1)
27+
@test rand(r, Tuple{UInt128})[1] rand(r1, UInt128)
28+
end

test/aarch64/ars.jl

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,31 @@
11
import Random: seed!
2-
using Test: @test
2+
using Test: @test, @testset
33

44
using RandomNumbers
55
using Random123
66

77
import RandomNumbers: split_uint
88
import Random123: uint64x2
99

10-
x = zero(uint64x2)
11-
ctr = uint64x2(0x9799b5d54f7b9227, 0xb47607190d0dfefb)
12-
key = uint64x2(0x07b8e4b6aa98ec24, 0x5a7da274d3b8146a)
13-
@test rand(ARS1x{1}(x, ctr, key), UInt128) 0x1a0b14c707b64224e548ef12331396ef
14-
@test rand(ARS1x{2}(x, ctr, key), UInt128) 0x3ced8e0970690f718336318ba22e8ae1
15-
@test rand(ARS1x{3}(x, ctr, key), UInt128) UInt128(uint64x2(0xb6621a8b006319e8, 0x67c841642c32fc19))
16-
@test rand(ARS1x{10}(x, ctr, key), UInt128) UInt128(uint64x2(0xac35df44f996ed82, 0x4e287697bad2f9a2))
10+
@testset "Accelerated ARS" begin
11+
x = zero(uint64x2)
12+
ctr = uint64x2(0x9799b5d54f7b9227, 0xb47607190d0dfefb)
13+
key = uint64x2(0x07b8e4b6aa98ec24, 0x5a7da274d3b8146a)
14+
@test rand(ARS1x{1}(x, ctr, key), UInt128) 0x1a0b14c707b64224e548ef12331396ef
15+
@test rand(ARS1x{2}(x, ctr, key), UInt128) 0x3ced8e0970690f718336318ba22e8ae1
16+
@test rand(ARS1x{3}(x, ctr, key), UInt128) UInt128(uint64x2(0xb6621a8b006319e8, 0x67c841642c32fc19))
17+
@test rand(ARS1x{10}(x, ctr, key), UInt128) UInt128(uint64x2(0xac35df44f996ed82, 0x4e287697bad2f9a2))
1718

18-
key = rand(UInt128)
19-
r = ARS1x(key)
20-
r1 = ARS4x(split_uint(key, UInt32))
21-
@test seed_type(r) UInt128
22-
@test seed_type(r1) NTuple{4, UInt32}
23-
@test copyto!(copy(r), r) == r
24-
@test copyto!(copy(r1), r1) == r1
25-
@test UInt128(r.x) rand(r1, UInt128)
26-
@test rand(r, UInt128) rand(r1, UInt128)
27-
set_counter!(r, 0)
28-
set_counter!(r1, 1)
29-
@test rand(r, Tuple{UInt128})[1] rand(r1, UInt128)
19+
key = rand(UInt128)
20+
r = ARS1x(key)
21+
r1 = ARS4x(split_uint(key, UInt32))
22+
@test seed_type(r) UInt128
23+
@test seed_type(r1) NTuple{4, UInt32}
24+
@test copyto!(copy(r), r) == r
25+
@test copyto!(copy(r1), r1) == r1
26+
@test UInt128(r.x) rand(r1, UInt128)
27+
@test rand(r, UInt128) rand(r1, UInt128)
28+
set_counter!(r, 0)
29+
set_counter!(r1, 1)
30+
@test rand(r, Tuple{UInt128})[1] rand(r1, UInt128)
31+
end

test/x86/aesni.jl

Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,28 @@
11
import Random: seed!
2-
using Test: @test
2+
using Test: @test, @testset
33

44
using RandomNumbers
55
using Random123
66

77
import RandomNumbers: split_uint
88
import Random123: __m128i, AESNIKey
99

10-
x = zero(__m128i)
11-
ctr = __m128i(0x9799b5d54f7b9227, 0xb47607190d0dfefb)
12-
key = 0x07b8e4b6aa98ec245a7da274d3b8146a
13-
aesni_key = AESNIKey(key)
14-
@test rand(AESNI1x(x, ctr, aesni_key), UInt128) 0x60f4c27fe48fe1b8c5f4568a585b0dc0
10+
@testset "Accelerated AESNI" begin
11+
x = zero(__m128i)
12+
ctr = __m128i(0x9799b5d54f7b9227, 0xb47607190d0dfefb)
13+
key = 0x07b8e4b6aa98ec245a7da274d3b8146a
14+
aesni_key = AESNIKey(key)
15+
@test rand(AESNI1x(x, ctr, aesni_key), UInt128) 0x60f4c27fe48fe1b8c5f4568a585b0dc0
1516

16-
r = AESNI1x(key)
17-
r1 = AESNI4x(split_uint(key, UInt32))
18-
@test seed_type(r) UInt128
19-
@test seed_type(r1) NTuple{4, UInt32}
20-
@test copyto!(copy(r), r) == r
21-
@test copyto!(copy(r1), r1) == r1
22-
@test UInt128(r.x) rand(r1, UInt128)
23-
@test rand(r, UInt128) rand(r1, UInt128)
24-
set_counter!(r, 0)
25-
set_counter!(r1, 1)
26-
@test rand(r, Tuple{UInt128})[1] rand(r1, UInt128)
17+
r = AESNI1x(key)
18+
r1 = AESNI4x(split_uint(key, UInt32))
19+
@test seed_type(r) UInt128
20+
@test seed_type(r1) NTuple{4, UInt32}
21+
@test copyto!(copy(r), r) == r
22+
@test copyto!(copy(r1), r1) == r1
23+
@test UInt128(r.x) rand(r1, UInt128)
24+
@test rand(r, UInt128) rand(r1, UInt128)
25+
set_counter!(r, 0)
26+
set_counter!(r1, 1)
27+
@test rand(r, Tuple{UInt128})[1] rand(r1, UInt128)
28+
end

test/x86/ars.jl

Lines changed: 22 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,31 @@
11
import Random: seed!
2-
using Test: @test
2+
using Test: @test, @testset
33

44
using RandomNumbers
55
using Random123
66

77
import RandomNumbers: split_uint
88
import Random123: __m128i
99

10-
x = zero(__m128i)
11-
ctr = __m128i(0x9799b5d54f7b9227, 0xb47607190d0dfefb)
12-
key = __m128i(0x07b8e4b6aa98ec24, 0x5a7da274d3b8146a)
13-
@test rand(ARS1x{1}(x, ctr, key), UInt128) 0x1a0b14c707b64224e548ef12331396ef
14-
@test rand(ARS1x{2}(x, ctr, key), UInt128) 0x3ced8e0970690f718336318ba22e8ae1
15-
@test rand(ARS1x{3}(x, ctr, key), UInt128) UInt128(__m128i(0xb6621a8b006319e8, 0x67c841642c32fc19))
16-
@test rand(ARS1x{10}(x, ctr, key), UInt128) UInt128(__m128i(0xac35df44f996ed82, 0x4e287697bad2f9a2))
10+
@testset "Accelerated ARS" begin
11+
x = zero(__m128i)
12+
ctr = __m128i(0x9799b5d54f7b9227, 0xb47607190d0dfefb)
13+
key = __m128i(0x07b8e4b6aa98ec24, 0x5a7da274d3b8146a)
14+
@test rand(ARS1x{1}(x, ctr, key), UInt128) 0x1a0b14c707b64224e548ef12331396ef
15+
@test rand(ARS1x{2}(x, ctr, key), UInt128) 0x3ced8e0970690f718336318ba22e8ae1
16+
@test rand(ARS1x{3}(x, ctr, key), UInt128) UInt128(__m128i(0xb6621a8b006319e8, 0x67c841642c32fc19))
17+
@test rand(ARS1x{10}(x, ctr, key), UInt128) UInt128(__m128i(0xac35df44f996ed82, 0x4e287697bad2f9a2))
1718

18-
key = rand(UInt128)
19-
r = ARS1x(key)
20-
r1 = ARS4x(split_uint(key, UInt32))
21-
@test seed_type(r) UInt128
22-
@test seed_type(r1) NTuple{4, UInt32}
23-
@test copyto!(copy(r), r) == r
24-
@test copyto!(copy(r1), r1) == r1
25-
@test UInt128(r.x) rand(r1, UInt128)
26-
@test rand(r, UInt128) rand(r1, UInt128)
27-
set_counter!(r, 0)
28-
set_counter!(r1, 1)
29-
@test rand(r, Tuple{UInt128})[1] rand(r1, UInt128)
19+
key = rand(UInt128)
20+
r = ARS1x(key)
21+
r1 = ARS4x(split_uint(key, UInt32))
22+
@test seed_type(r) UInt128
23+
@test seed_type(r1) NTuple{4, UInt32}
24+
@test copyto!(copy(r), r) == r
25+
@test copyto!(copy(r1), r1) == r1
26+
@test UInt128(r.x) rand(r1, UInt128)
27+
@test rand(r, UInt128) rand(r1, UInt128)
28+
set_counter!(r, 0)
29+
set_counter!(r1, 1)
30+
@test rand(r, Tuple{UInt128})[1] rand(r1, UInt128)
31+
end

0 commit comments

Comments
 (0)