tests/thirdparty: add crypto/internal/bigmod (#355)
Add test case for avo generator in standard library crypto/internal/bigmod. https://github.com/golang/go/tree/go1.20rc2/src/crypto/internal/bigmod https://golang.org/cl/452095 https://words.filippo.io/dispatches/go-1-20-cryptography/ Closes #354
This commit is contained in:
committed by
GitHub
parent
67039b7ed9
commit
12b5abca55
46
.github/workflows/packages.yml
vendored
46
.github/workflows/packages.yml
vendored
@@ -930,7 +930,7 @@ jobs:
|
|||||||
- name: Test
|
- name: Test
|
||||||
working-directory: md4
|
working-directory: md4
|
||||||
run: go test ./...
|
run: go test ./...
|
||||||
golang-go:
|
golang-go-src-crypto-internal-bigmod:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
steps:
|
steps:
|
||||||
- name: Install Go
|
- name: Install Go
|
||||||
@@ -947,7 +947,45 @@ jobs:
|
|||||||
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0
|
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0
|
||||||
with:
|
with:
|
||||||
repository: golang/go
|
repository: golang/go
|
||||||
ref: go1.19
|
ref: go1.20rc2
|
||||||
|
path: go
|
||||||
|
persist-credentials: false
|
||||||
|
- name: Compile Go Toolchain
|
||||||
|
working-directory: go/src
|
||||||
|
run: ./make.bash
|
||||||
|
- name: Avo Module Replacement
|
||||||
|
working-directory: go/src/crypto/internal/bigmod/_asm
|
||||||
|
run: |
|
||||||
|
go mod edit -modfile=go.mod -require=github.com/mmcloughlin/avo@v0.0.0-00010101000000-000000000000
|
||||||
|
go mod edit -modfile=go.mod -replace=github.com/mmcloughlin/avo=${{ github.workspace }}/avo
|
||||||
|
go mod tidy -modfile=go.mod
|
||||||
|
- name: Generate
|
||||||
|
working-directory: go
|
||||||
|
run: env --unset=GOROOT ./bin/go generate -v -x ./src/crypto/internal/bigmod/_asm
|
||||||
|
- name: Diff
|
||||||
|
working-directory: go
|
||||||
|
run: git diff
|
||||||
|
- name: Test
|
||||||
|
working-directory: go
|
||||||
|
run: env --unset=GOROOT ./bin/go test crypto/...
|
||||||
|
golang-go-src-crypto-internal-edwards25519:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Install Go
|
||||||
|
uses: actions/setup-go@c4a742cab115ed795e34d4513e2cf7d472deb55f # v3.3.1
|
||||||
|
with:
|
||||||
|
go-version: 1.19.x
|
||||||
|
check-latest: true
|
||||||
|
- name: Checkout avo
|
||||||
|
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0
|
||||||
|
with:
|
||||||
|
path: avo
|
||||||
|
persist-credentials: false
|
||||||
|
- name: Checkout golang/go
|
||||||
|
uses: actions/checkout@93ea575cb5d8a053eaa0ac8fa3b40d7e05a33cc8 # v3.1.0
|
||||||
|
with:
|
||||||
|
repository: golang/go
|
||||||
|
ref: go1.20rc2
|
||||||
path: go
|
path: go
|
||||||
persist-credentials: false
|
persist-credentials: false
|
||||||
- name: Compile Go Toolchain
|
- name: Compile Go Toolchain
|
||||||
@@ -960,8 +998,8 @@ jobs:
|
|||||||
go mod edit -modfile=go.mod -replace=github.com/mmcloughlin/avo=${{ github.workspace }}/avo
|
go mod edit -modfile=go.mod -replace=github.com/mmcloughlin/avo=${{ github.workspace }}/avo
|
||||||
go mod tidy -modfile=go.mod
|
go mod tidy -modfile=go.mod
|
||||||
- name: Generate
|
- name: Generate
|
||||||
working-directory: go/src/crypto/internal/edwards25519/field/_asm
|
working-directory: go
|
||||||
run: go generate -v -x
|
run: env --unset=GOROOT ./bin/go generate -v -x ./src/crypto/internal/edwards25519/field/_asm
|
||||||
- name: Diff
|
- name: Diff
|
||||||
working-directory: go
|
working-directory: go
|
||||||
run: git diff
|
run: git diff
|
||||||
|
|||||||
2
.github/workflows/thirdparty.yml
vendored
2
.github/workflows/thirdparty.yml
vendored
@@ -25,4 +25,4 @@ jobs:
|
|||||||
persist-credentials: false
|
persist-credentials: false
|
||||||
- name: Run Third-Party Tests
|
- name: Run Third-Party Tests
|
||||||
working-directory: tests/thirdparty
|
working-directory: tests/thirdparty
|
||||||
run: go test -net -suite suite.json
|
run: go test -timeout 15m -args -net -suite suite.json
|
||||||
|
|||||||
48
tests/thirdparty/config.go
vendored
48
tests/thirdparty/config.go
vendored
@@ -132,9 +132,8 @@ func (s *Step) Validate() error {
|
|||||||
|
|
||||||
// Package defines an integration test for a package within a project.
|
// Package defines an integration test for a package within a project.
|
||||||
type Package struct {
|
type Package struct {
|
||||||
// Sub-package within the project under test. All file path references will
|
// Sub-package within the project under test. Used as the root directory for
|
||||||
// be relative to this directory. If empty the root of the repository is
|
// the test unless explicitly overridden.
|
||||||
// used.
|
|
||||||
SubPackage string `json:"pkg,omitempty"`
|
SubPackage string `json:"pkg,omitempty"`
|
||||||
|
|
||||||
// Path to the module file for the avo generator package. This is necessary
|
// Path to the module file for the avo generator package. This is necessary
|
||||||
@@ -142,6 +141,11 @@ type Package struct {
|
|||||||
// version under test.
|
// version under test.
|
||||||
Module string `json:"module"`
|
Module string `json:"module"`
|
||||||
|
|
||||||
|
// Root directory for all steps in the test. All file path references will
|
||||||
|
// be relative to this directory. If empty, the sub-package directory is
|
||||||
|
// used, or otherwise the root of the repository.
|
||||||
|
Root string `json:"root,omitempty"`
|
||||||
|
|
||||||
// Setup steps. These run prior to the insertion of avo replace directives,
|
// Setup steps. These run prior to the insertion of avo replace directives,
|
||||||
// therefore should be used if it's necessary to initialize new go modules
|
// therefore should be used if it's necessary to initialize new go modules
|
||||||
// within the repository.
|
// within the repository.
|
||||||
@@ -219,6 +223,17 @@ func (p *Package) IsRoot() bool {
|
|||||||
return p.SubPackage == ""
|
return p.SubPackage == ""
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// WorkingDirectory returns the base directory for all steps in the test.
|
||||||
|
func (p *Package) WorkingDirectory() string {
|
||||||
|
if p.Root != "" {
|
||||||
|
return p.Root
|
||||||
|
}
|
||||||
|
if p.SubPackage != "" {
|
||||||
|
return p.SubPackage
|
||||||
|
}
|
||||||
|
return ""
|
||||||
|
}
|
||||||
|
|
||||||
// Context specifies execution environment parameters for a third-party test.
|
// Context specifies execution environment parameters for a third-party test.
|
||||||
type Context struct {
|
type Context struct {
|
||||||
// Path to the avo version under test.
|
// Path to the avo version under test.
|
||||||
@@ -272,9 +287,9 @@ func (p *Package) Steps(c *Context) []*Step {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Prepend sub-directory to every step.
|
// Prepend sub-directory to every step.
|
||||||
if p.SubPackage != "" {
|
if dir := p.WorkingDirectory(); dir != "" {
|
||||||
for _, s := range steps {
|
for _, s := range steps {
|
||||||
s.WorkingDirectory = filepath.Join(p.SubPackage, s.WorkingDirectory)
|
s.WorkingDirectory = filepath.Join(dir, s.WorkingDirectory)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -304,20 +319,33 @@ func (p Projects) defaults(set bool) {
|
|||||||
|
|
||||||
// Validate the project collection.
|
// Validate the project collection.
|
||||||
func (p Projects) Validate() error {
|
func (p Projects) Validate() error {
|
||||||
seen := map[string]bool{}
|
// Projects are valid.
|
||||||
for _, prj := range p {
|
for _, prj := range p {
|
||||||
// Project is valid.
|
|
||||||
if err := prj.Validate(); err != nil {
|
if err := prj.Validate(); err != nil {
|
||||||
return fmt.Errorf("project %s: %w", prj.ID(), err)
|
return fmt.Errorf("project %s: %w", prj.ID(), err)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// No duplicate entries.
|
// No duplicate project IDs.
|
||||||
|
pid := map[string]bool{}
|
||||||
|
for _, prj := range p {
|
||||||
id := prj.ID()
|
id := prj.ID()
|
||||||
if seen[id] {
|
if pid[id] {
|
||||||
return fmt.Errorf("duplicate project %q", id)
|
return fmt.Errorf("duplicate project %q", id)
|
||||||
}
|
}
|
||||||
seen[id] = true
|
pid[id] = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// No duplicate test IDs.
|
||||||
|
tid := map[string]bool{}
|
||||||
|
for _, t := range p.Tests() {
|
||||||
|
id := t.ID()
|
||||||
|
if tid[id] {
|
||||||
|
return fmt.Errorf("duplicate test %q", id)
|
||||||
|
}
|
||||||
|
tid[id] = true
|
||||||
|
}
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
20
tests/thirdparty/packages_test.go
vendored
20
tests/thirdparty/packages_test.go
vendored
@@ -2,6 +2,7 @@ package thirdparty
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"flag"
|
"flag"
|
||||||
|
"os"
|
||||||
"os/exec"
|
"os/exec"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"runtime"
|
"runtime"
|
||||||
@@ -69,6 +70,7 @@ type PackageTest struct {
|
|||||||
// Run the test.
|
// Run the test.
|
||||||
func (t *PackageTest) Run() {
|
func (t *PackageTest) Run() {
|
||||||
t.checkout()
|
t.checkout()
|
||||||
|
t.validate()
|
||||||
t.steps()
|
t.steps()
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -88,6 +90,24 @@ func (t *PackageTest) checkout() {
|
|||||||
test.Exec(t.T, "git", "-C", t.repopath, "checkout", "FETCH_HEAD")
|
test.Exec(t.T, "git", "-C", t.repopath, "checkout", "FETCH_HEAD")
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// validate the test configuration relative to the checked out project.
|
||||||
|
func (t *PackageTest) validate() {
|
||||||
|
// Confirm expected directories exist.
|
||||||
|
expect := map[string]string{
|
||||||
|
"package": t.Package.SubPackage,
|
||||||
|
"root": t.Package.WorkingDirectory(),
|
||||||
|
}
|
||||||
|
for name, subdir := range expect {
|
||||||
|
if subdir == "" {
|
||||||
|
continue
|
||||||
|
}
|
||||||
|
path := filepath.Join(t.repopath, subdir)
|
||||||
|
if _, err := os.Stat(path); err != nil {
|
||||||
|
t.Fatalf("expected %s directory: %s", name, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
func (t *PackageTest) steps() {
|
func (t *PackageTest) steps() {
|
||||||
// Determine the path to avo.
|
// Determine the path to avo.
|
||||||
_, self, _, ok := runtime.Caller(1)
|
_, self, _, ok := runtime.Caller(1)
|
||||||
|
|||||||
35
tests/thirdparty/suite.json
vendored
35
tests/thirdparty/suite.json
vendored
@@ -749,9 +749,39 @@
|
|||||||
"stars": 107376
|
"stars": 107376
|
||||||
},
|
},
|
||||||
"default_branch": "master",
|
"default_branch": "master",
|
||||||
"version": "go1.19",
|
"version": "go1.20rc2",
|
||||||
"packages": [
|
"packages": [
|
||||||
{
|
{
|
||||||
|
"pkg": "src/crypto/internal/bigmod",
|
||||||
|
"root": ".",
|
||||||
|
"module": "src/crypto/internal/bigmod/_asm/go.mod",
|
||||||
|
"setup": [
|
||||||
|
{
|
||||||
|
"name": "Compile Go Toolchain",
|
||||||
|
"dir": "src",
|
||||||
|
"commands": [
|
||||||
|
"./make.bash"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"generate": [
|
||||||
|
{
|
||||||
|
"commands": [
|
||||||
|
"env --unset=GOROOT ./bin/go generate -v -x ./src/crypto/internal/bigmod/_asm"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"test": [
|
||||||
|
{
|
||||||
|
"commands": [
|
||||||
|
"env --unset=GOROOT ./bin/go test crypto/..."
|
||||||
|
]
|
||||||
|
}
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"pkg": "src/crypto/internal/edwards25519",
|
||||||
|
"root": ".",
|
||||||
"module": "src/crypto/internal/edwards25519/field/_asm/go.mod",
|
"module": "src/crypto/internal/edwards25519/field/_asm/go.mod",
|
||||||
"setup": [
|
"setup": [
|
||||||
{
|
{
|
||||||
@@ -764,9 +794,8 @@
|
|||||||
],
|
],
|
||||||
"generate": [
|
"generate": [
|
||||||
{
|
{
|
||||||
"dir": "src/crypto/internal/edwards25519/field/_asm",
|
|
||||||
"commands": [
|
"commands": [
|
||||||
"go generate -v -x"
|
"env --unset=GOROOT ./bin/go generate -v -x ./src/crypto/internal/edwards25519/field/_asm"
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
|
|||||||
Reference in New Issue
Block a user