mirror of
https://github.com/tuneinsight/lattigo.git
synced 2025-09-13 03:27:14 +00:00
go test-based examples testing
It is cleaner, more systematic, and produces more "ok"s when running go test ./...
This commit is contained in:
18
Makefile
18
Makefile
@@ -4,20 +4,6 @@
|
||||
test_gotest:
|
||||
go test -timeout=0 ./...
|
||||
|
||||
.PHONY: test_examples
|
||||
test_examples:
|
||||
@echo Running the examples
|
||||
go run ./examples/ring/vOLE -short > /dev/null
|
||||
go run ./examples/rgsw > /dev/null
|
||||
go run ./examples/bfv > /dev/null
|
||||
go run ./examples/ckks/bootstrapping -short > /dev/null
|
||||
go run ./examples/ckks/advanced/lut -short > /dev/null
|
||||
go run ./examples/ckks/euler > /dev/null
|
||||
go run ./examples/ckks/polyeval > /dev/null
|
||||
go run ./examples/dbfv/pir &> /dev/null
|
||||
go run ./examples/dbfv/psi &> /dev/null
|
||||
@echo ok
|
||||
|
||||
.PHONY: static_check
|
||||
static_check: check_tools
|
||||
@echo Checking correct formatting of files
|
||||
@@ -62,10 +48,10 @@ static_check: check_tools
|
||||
out=`git status --porcelain`; echo "$$out"; [ -z "$$out" ]
|
||||
|
||||
.PHONY: test
|
||||
test: test_gotest test_examples
|
||||
test: test_gotest
|
||||
|
||||
.PHONY: ci_test
|
||||
ci_test: static_check test_gotest test_examples
|
||||
ci_test: static_check test_gotest
|
||||
|
||||
EXECUTABLES = goimports staticcheck
|
||||
.PHONY: get_tools
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"flag"
|
||||
"fmt"
|
||||
"math"
|
||||
"math/bits"
|
||||
@@ -12,6 +13,8 @@ import (
|
||||
"github.com/tuneinsight/lattigo/v4/ring"
|
||||
)
|
||||
|
||||
var flagShort = flag.Bool("short", false, "run the example with a smaller and insecure ring degree.")
|
||||
|
||||
func obliviousRiding() {
|
||||
|
||||
// This example simulates a situation where an anonymous rider
|
||||
@@ -49,6 +52,9 @@ func obliviousRiding() {
|
||||
|
||||
// Number of drivers in the area
|
||||
nbDrivers := 2048 //max is N
|
||||
if *flagShort {
|
||||
nbDrivers = 512
|
||||
}
|
||||
|
||||
// BFV parameters (128 bit security) with plaintext modulus 65929217
|
||||
// Creating encryption parameters from a default params with logN=14, logQP=438 with a plaintext modulus T=65929217
|
||||
@@ -197,5 +203,6 @@ func distance(a, b, c, d uint64) uint64 {
|
||||
}
|
||||
|
||||
func main() {
|
||||
flag.Parse()
|
||||
obliviousRiding()
|
||||
}
|
||||
|
||||
16
examples/bfv/main_test.go
Normal file
16
examples/bfv/main_test.go
Normal file
@@ -0,0 +1,16 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"os"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestMain(t *testing.T) {
|
||||
if testing.Short() {
|
||||
t.Skip("skipped in -short mode")
|
||||
}
|
||||
oldArgs := os.Args
|
||||
defer func() { os.Args = oldArgs }()
|
||||
os.Args = append(os.Args, "-short")
|
||||
main()
|
||||
}
|
||||
16
examples/ckks/advanced/lut/main_test.go
Normal file
16
examples/ckks/advanced/lut/main_test.go
Normal file
@@ -0,0 +1,16 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"os"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestMain(t *testing.T) {
|
||||
if testing.Short() {
|
||||
t.Skip("skipped in -short mode")
|
||||
}
|
||||
oldArgs := os.Args
|
||||
defer func() { os.Args = oldArgs }()
|
||||
os.Args = append(os.Args, "-short")
|
||||
main()
|
||||
}
|
||||
16
examples/ckks/bootstrapping/main_test.go
Normal file
16
examples/ckks/bootstrapping/main_test.go
Normal file
@@ -0,0 +1,16 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"os"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestMain(t *testing.T) {
|
||||
if testing.Short() {
|
||||
t.Skip("skipped in -short mode")
|
||||
}
|
||||
oldArgs := os.Args
|
||||
defer func() { os.Args = oldArgs }()
|
||||
os.Args = append(os.Args, "-short")
|
||||
main()
|
||||
}
|
||||
@@ -638,7 +638,8 @@ func main() {
|
||||
// Then we generate the corresponding Galois keys.
|
||||
// The list of Galois elements can also be obtained with `linTransf.GaloisElements`
|
||||
galEls = params.GaloisElementsForLinearTransform(nonZeroDiagonales, LogBSGSRatio, LogSlots)
|
||||
eval = eval.WithKey(rlwe.NewMemEvaluationKeySet(rlk, kgen.GenGaloisKeysNew(galEls, sk)...))
|
||||
gks = kgen.GenGaloisKeysNew(galEls, sk)
|
||||
eval = eval.WithKey(rlwe.NewMemEvaluationKeySet(rlk, gks...))
|
||||
|
||||
// And we valuate the linear transform
|
||||
eval.LinearTransform(ct1, linTransf, []*rlwe.Ciphertext{res})
|
||||
|
||||
11
examples/ckks/ckks_tutorial/main_test.go
Normal file
11
examples/ckks/ckks_tutorial/main_test.go
Normal file
@@ -0,0 +1,11 @@
|
||||
package main
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestMain(t *testing.T) {
|
||||
if testing.Short() {
|
||||
t.Skip("skipped in -short mode")
|
||||
}
|
||||
t.Skip("test not passing") // TODO: bug in the linear transform API ?
|
||||
main()
|
||||
}
|
||||
10
examples/ckks/euler/main_test.go
Normal file
10
examples/ckks/euler/main_test.go
Normal file
@@ -0,0 +1,10 @@
|
||||
package main
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestMain(t *testing.T) {
|
||||
if testing.Short() {
|
||||
t.Skip("skipped in -short mode")
|
||||
}
|
||||
main()
|
||||
}
|
||||
10
examples/ckks/polyeval/main_test.go
Normal file
10
examples/ckks/polyeval/main_test.go
Normal file
@@ -0,0 +1,10 @@
|
||||
package main
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestMain(t *testing.T) {
|
||||
if testing.Short() {
|
||||
t.Skip("skipped in -short mode")
|
||||
}
|
||||
main()
|
||||
}
|
||||
16
examples/dbfv/pir/main_test.go
Normal file
16
examples/dbfv/pir/main_test.go
Normal file
@@ -0,0 +1,16 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"os"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestMain(t *testing.T) {
|
||||
if testing.Short() {
|
||||
t.Skip("skipped in -short mode")
|
||||
}
|
||||
oldArgs := os.Args
|
||||
defer func() { os.Args = oldArgs }()
|
||||
os.Args = os.Args[:1]
|
||||
main()
|
||||
}
|
||||
16
examples/dbfv/psi/main_test.go
Normal file
16
examples/dbfv/psi/main_test.go
Normal file
@@ -0,0 +1,16 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"os"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestMain(t *testing.T) {
|
||||
if testing.Short() {
|
||||
t.Skip("skipped in -short mode")
|
||||
}
|
||||
oldArgs := os.Args
|
||||
defer func() { os.Args = oldArgs }()
|
||||
os.Args = os.Args[:1]
|
||||
main()
|
||||
}
|
||||
@@ -304,7 +304,8 @@ func main() {
|
||||
// collects the results in an EvaluationKeySet
|
||||
gks := []*rlwe.GaloisKey{}
|
||||
for task := range C.finDone {
|
||||
gks = append(gks, &task)
|
||||
gk := task
|
||||
gks = append(gks, &gk)
|
||||
}
|
||||
evk := rlwe.NewMemEvaluationKeySet(nil, gks...)
|
||||
|
||||
|
||||
10
examples/drlwe/thresh_eval_key_gen/main_test.go
Normal file
10
examples/drlwe/thresh_eval_key_gen/main_test.go
Normal file
@@ -0,0 +1,10 @@
|
||||
package main
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestMain(t *testing.T) {
|
||||
if testing.Short() {
|
||||
t.Skip("skipped in -short mode")
|
||||
}
|
||||
main()
|
||||
}
|
||||
10
examples/rgsw/main_test.go
Normal file
10
examples/rgsw/main_test.go
Normal file
@@ -0,0 +1,10 @@
|
||||
package main
|
||||
|
||||
import "testing"
|
||||
|
||||
func TestMain(t *testing.T) {
|
||||
if testing.Short() {
|
||||
t.Skip("skipped in -short mode")
|
||||
}
|
||||
main()
|
||||
}
|
||||
16
examples/ring/vOLE/main_test.go
Normal file
16
examples/ring/vOLE/main_test.go
Normal file
@@ -0,0 +1,16 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"os"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestMain(t *testing.T) {
|
||||
if testing.Short() {
|
||||
t.Skip("skipped in -short mode")
|
||||
}
|
||||
oldArgs := os.Args
|
||||
defer func() { os.Args = oldArgs }()
|
||||
os.Args = append(os.Args, "-short")
|
||||
main()
|
||||
}
|
||||
Reference in New Issue
Block a user