Skip to content

Commit fe36a1b

Browse files
committed
ci: Fix ignored.yml and update FFI tests
1 parent 3e5ab96 commit fe36a1b

10 files changed

Lines changed: 317 additions & 21 deletions

File tree

.github/workflows/ignored.yml

Lines changed: 24 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ name: Extended CI tests
22

33
on:
44
push:
5-
branches: main
5+
branches: [main, ci-ignored]
66
workflow_dispatch:
77

88
permissions:
@@ -14,26 +14,43 @@ concurrency:
1414

1515
jobs:
1616
ignored-test:
17-
runs-on: warp-ubuntu-latest-x64-32x # Needs 128 GB RAM for Lean compilation
17+
runs-on: warp-ubuntu-latest-x64-32x
1818
steps:
1919
- uses: actions/checkout@v6
2020
- uses: actions-rust-lang/setup-rust-toolchain@v1
21+
# Only restore the cache, since `ci.yml` will save the test binary to the cache first
22+
- uses: actions/cache/restore@v4
23+
with:
24+
path: .lake
25+
key: lake-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('lean-toolchain') }}-${{ hashFiles('lake-manifest.json') }}-${{ github.sha }}
26+
restore-keys: lake-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('lean-toolchain') }}-${{ hashFiles('lake-manifest.json') }}
2127
- uses: leanprover/lean-action@v1
2228
with:
2329
auto-config: false
24-
test: true
25-
test-args: "-- --ignored"
30+
# `test-args` is currently broken, so we run `lake test` separately
31+
# Restore once https://github.com/leanprover/lean-action/pull/153 is merged
32+
# test: true
33+
# test-args: "-- --ignored"
34+
use-github-cache: false
35+
- run: lake test -- --ignored
2636

27-
valgrind:
28-
runs-on: warp-ubuntu-latest-x64-16x
37+
valgrind-ffi:
38+
runs-on: warp-ubuntu-latest-x64-8x
2939
steps:
3040
- uses: actions/checkout@v6
3141
- uses: actions-rust-lang/setup-rust-toolchain@v1
42+
# Only restore the cache, since `ci.yml` will save the test binary to the cache first
43+
- uses: actions/cache/restore@v4
44+
with:
45+
path: .lake
46+
key: lake-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('lean-toolchain') }}-${{ hashFiles('lake-manifest.json') }}-${{ github.sha }}
47+
restore-keys: lake-${{ runner.os }}-${{ runner.arch }}-${{ hashFiles('lean-toolchain') }}-${{ hashFiles('lake-manifest.json') }}
3248
- uses: leanprover/lean-action@v1
3349
with:
3450
auto-config: false
3551
build: true
3652
build-args: "IxTests"
53+
use-github-cache: false
3754
- name: Install valgrind
3855
run: sudo apt-get update && sudo apt-get install -y valgrind
3956
- name: Run tests under valgrind
@@ -44,4 +61,4 @@ jobs:
4461
--errors-for-leak-kinds=definite \
4562
--track-origins=yes \
4663
--error-exitcode=1 \
47-
.lake/build/bin/IxTests -- --include-ignored aiur aiur-hashes ixvm
64+
.lake/build/bin/IxTests -- ffi

Ix/Ixon.lean

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1826,11 +1826,11 @@ def rsSerEnv (env : Env) : ByteArray :=
18261826
rsSerEnvFFI env.toRawEnv
18271827

18281828
@[extern "rs_des_env"]
1829-
opaque rsDesEnvFFI : @& ByteArray → Except String RawEnv
1829+
opaque rsDeEnvFFI : @& ByteArray → Except String RawEnv
18301830

18311831
/-- Deserialize bytes to an Ixon.Env using Rust. -/
1832-
def rsDesEnv (bytes : ByteArray) : Except String Env :=
1833-
return (← rsDesEnvFFI bytes).toEnv
1832+
def rsDeEnv (bytes : ByteArray) : Except String Env :=
1833+
return (← rsDeEnvFFI bytes).toEnv
18341834

18351835
end Ixon
18361836

Tests/Aiur/Hashes.lean

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,9 @@ public import Tests.Aiur.Common
44
public import Ix.IxVM.ByteStream
55
public import Ix.IxVM.Blake3
66
public import Ix.IxVM.Sha256
7+
public import Tests.Sha256
78
public import Blake3
89

9-
@[extern "rs_sha256"]
10-
opaque rsSha256 : @&ByteArray → ByteArray
11-
1210
def mkBlake3HashTestCase (size : Nat) : AiurTestCase :=
1311
let inputBytes := Array.range size |>.map Nat.toUInt8
1412
let outputBytes := Blake3.hash ⟨inputBytes⟩ |>.val.data
@@ -19,7 +17,7 @@ def mkBlake3HashTestCase (size : Nat) : AiurTestCase :=
1917

2018
def mkSha256HashTestCase (size : Nat) : AiurTestCase :=
2119
let inputBytes := Array.range size |>.map Nat.toUInt8
22-
let outputBytes := rsSha256 ⟨inputBytes⟩ |>.data
20+
let outputBytes := Sha256.hash ⟨inputBytes⟩ |>.data
2321
let input := inputBytes.map .ofUInt8
2422
let output := outputBytes.map .ofUInt8
2523
let buffer := ⟨input, .ofList [(#[0], ⟨0, size⟩)]⟩ -- key is fixed as #[0]

Tests/FFI.lean

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@ module
77
public import Tests.FFI.Basic
88
public import Tests.FFI.Ix
99
public import Tests.FFI.Ixon
10+
public import Tests.FFI.Lifecycle
1011

1112
namespace Tests.FFI
1213

1314
public def suite : List LSpec.TestSeq :=
14-
Tests.FFI.Basic.suite ++ Tests.FFI.Ix.suite ++ Tests.FFI.Ixon.suite
15+
Tests.FFI.Basic.suite ++ Tests.FFI.Ix.suite ++ Tests.FFI.Ixon.suite ++ Tests.FFI.Lifecycle.suite
1516

1617
end Tests.FFI

Tests/FFI/Basic.lean

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,9 @@ def largeNatTests : TestSeq :=
9494
def hashMapEq (m1 m2 : Std.HashMap Nat Nat) : Bool :=
9595
m1.size == m2.size && m1.toList.all fun (k, v) => m2.get? k == some v
9696

97+
def dHashMapRawEq (m1 m2 : DHashMapRaw Nat (fun _ => Nat)) : Bool :=
98+
m1.size == m2.size && m1.toList.all fun ⟨k, v⟩ => m2.get? k == some v
99+
97100
def assocListEq (l1 l2 : AssocList Nat (fun _ => Nat)) : Bool :=
98101
let toSimpleList (l : AssocList Nat (fun _ => Nat)) : List (Nat × Nat) :=
99102
l.toList.map fun ⟨k, v⟩ => (k, v)
@@ -111,6 +114,14 @@ def hashMapTests : TestSeq :=
111114
test "HashMap empty" (hashMapEq (roundtripHashMapNatNat {}) {}) ++
112115
test "HashMap single" (hashMapEq (roundtripHashMapNatNat (({} : Std.HashMap Nat Nat).insert 1 42)) (({} : Std.HashMap Nat Nat).insert 1 42))
113116

117+
def dHashMapRawTests : TestSeq :=
118+
let emptyMap : DHashMapRaw Nat (fun _ => Nat) := {}
119+
let single : DHashMapRaw Nat (fun _ => Nat) := ({} : DHashMapRaw Nat (fun _ => Nat)).insert 1 42
120+
let double : DHashMapRaw Nat (fun _ => Nat) := (({} : DHashMapRaw Nat (fun _ => Nat)).insert 1 42).insert 2 99
121+
test "DHashMapRaw empty" (dHashMapRawEq (roundtripDHashMapRawNatNat emptyMap) emptyMap) ++
122+
test "DHashMapRaw single" (dHashMapRawEq (roundtripDHashMapRawNatNat single) single) ++
123+
test "DHashMapRaw double" (dHashMapRawEq (roundtripDHashMapRawNatNat double) double)
124+
114125
def boolTests : TestSeq :=
115126
test "Bool true" (roundtripBool true == true) ++
116127
test "Bool false" (roundtripBool false == false)
@@ -122,6 +133,7 @@ public def suite : List TestSeq := [
122133
largeNatTests,
123134
assocListTests,
124135
hashMapTests,
136+
dHashMapRawTests,
125137
boolTests,
126138
checkIO "Nat roundtrip" (∀ n : Nat, roundtripNat n == n),
127139
checkIO "String roundtrip" (∀ s : String, roundtripString s == s),
@@ -131,6 +143,9 @@ public def suite : List TestSeq := [
131143
checkIO "Point roundtrip" (∀ p : Point, roundtripPoint p == p),
132144
checkIO "NatTree roundtrip" (∀ t : NatTree, roundtripNatTree t == t),
133145
checkIO "HashMap Nat Nat roundtrip" (∀ m : Std.HashMap Nat Nat, hashMapEq (roundtripHashMapNatNat m) m),
146+
checkIO "DHashMapRaw Nat Nat roundtrip" (∀ m : Std.HashMap Nat Nat,
147+
let raw := m.toList.foldl (init := ({} : DHashMapRaw Nat (fun _ => Nat))) fun acc (k, v) => acc.insert k v
148+
dHashMapRawEq (roundtripDHashMapRawNatNat raw) raw),
134149
]
135150

136151
end Tests.FFI.Basic

0 commit comments

Comments
 (0)