Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions .github/workflows/build-macos.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,21 @@ on:

jobs:
build-macos:
name: build-macos
name: build-macos with Go ${{ matrix.go-version }}
runs-on: macos-10.15
strategy:
matrix:
include:
- go-version: '1.17'
go-stable: true
- go-version: '1.18'
go-stable: false
steps:
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: '1.17'
go-version: ${{ matrix.go-version }}
stable: ${{ matrix.go-stable }}
- name: Install Dependencies
shell: bash
run: |
Expand Down
11 changes: 10 additions & 1 deletion .github/workflows/linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,15 @@ jobs:
assert-test-linux:
# Run all tests that can run on Linux, with LLVM assertions enabled to catch
# potential bugs.
name: assert-test-linux with Go ${{ matrix.go-version }}
runs-on: ubuntu-latest
strategy:
matrix:
include:
- go-version: '1.17'
go-stable: true
- go-version: '1.18'
go-stable: false
steps:
- name: Checkout
uses: actions/checkout@v2
Expand All @@ -159,7 +167,8 @@ jobs:
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: '1.17'
go-version: ${{ matrix.go-version }}
stable: ${{ matrix.go-stable }}
- name: Install Node.js
uses: actions/setup-node@v2
with:
Expand Down
11 changes: 10 additions & 1 deletion .github/workflows/windows.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,21 @@ on:

jobs:
build-windows:
name: build-windows with Go ${{ matrix.go-version }}
runs-on: windows-2019
strategy:
matrix:
include:
- go-version: '1.17'
go-stable: true
- go-version: '1.18'
go-stable: false
steps:
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: '1.17'
go-version: ${{ matrix.go-version }}
stable: ${{ matrix.go-stable }}
- uses: brechtm/setup-scoop@v2
- name: Install Dependencies
shell: bash
Expand Down
4 changes: 2 additions & 2 deletions builder/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ func NewConfig(options *compileopts.Options) (*compileopts.Config, error) {
if err != nil {
return nil, fmt.Errorf("could not read version from GOROOT (%v): %v", goroot, err)
}
if major != 1 || minor < 15 || minor > 17 {
return nil, fmt.Errorf("requires go version 1.15 through 1.17, got go%d.%d", major, minor)
if major != 1 || minor < 15 || minor > 18 {
return nil, fmt.Errorf("requires go version 1.15 through 1.18, got go%d.%d", major, minor)
}

clangHeaderPath := getClangHeaderPath(goenv.Get("TINYGOROOT"))
Expand Down
1 change: 1 addition & 0 deletions loader/goroot.go
Original file line number Diff line number Diff line change
Expand Up @@ -230,6 +230,7 @@ func pathsToOverride(needsSyscallPackage bool) map[string]bool {
"device/": false,
"examples/": false,
"internal/": true,
"internal/fuzz/": false,
"internal/bytealg/": false,
"internal/reflectlite/": false,
"internal/task/": false,
Expand Down
8 changes: 7 additions & 1 deletion main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ func TestBuild(t *testing.T) {
"stdlib.go",
"string.go",
"structs.go",
"testing.go",
"zeroalloc.go",
}
_, minor, err := goenv.GetGorootVersion(goenv.Get("GOROOT"))
Expand All @@ -76,6 +75,11 @@ func TestBuild(t *testing.T) {
if minor >= 17 {
tests = append(tests, "go1.17.go")
}
if minor >= 18 {
tests = append(tests, "testing_go1.18.go")
} else {
tests = append(tests, "testing_other.go")
}

if *testTarget != "" {
// This makes it possible to run one specific test (instead of all),
Expand Down Expand Up @@ -314,6 +318,8 @@ func runTestWithConfig(name string, t *testing.T, options compileopts.Options, c
txtpath := path[:len(path)-3] + ".txt"
if path[len(path)-1] == '/' {
txtpath = path + "out.txt"
} else if strings.HasPrefix(name, "testing_") {
txtpath = TESTDATA + "/testing.txt"
}
expected, err := ioutil.ReadFile(txtpath)
if err != nil {
Expand Down
133 changes: 133 additions & 0 deletions src/internal/fuzz/fuzz.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,133 @@
// Package fuzz is a shim to allow compilation against Go 1.18.
// It only defines a single type to work with testing/internal/testdeps,
// and hide all the other new dependencies from this package.
package fuzz

import (
"context"
"errors"
"io"
"reflect"
"time"
)

// CorpusEntry represents an individual input for fuzzing.
//
// We must use an equivalent type in the testing and testing/internal/testdeps
// packages, but testing can't import this package directly, and we don't want
// to export this type from testing. Instead, we use the same struct type and
// use a type alias (not a defined type) for convenience.
type CorpusEntry = struct {
Parent string

// Path is the path of the corpus file, if the entry was loaded from disk.
// For other entries, including seed values provided by f.Add, Path is the
// name of the test, e.g. seed#0 or its hash.
Path string

// Data is the raw input data. Data should only be populated for seed
// values. For on-disk corpus files, Data will be nil, as it will be loaded
// from disk using Path.
Data []byte

// Values is the unmarshaled values from a corpus file.
Values []any

Generation int

// IsSeed indicates whether this entry is part of the seed corpus.
IsSeed bool
}

// CoordinateFuzzingOpts is a set of arguments for CoordinateFuzzing.
// The zero value is valid for each field unless specified otherwise.
type CoordinateFuzzingOpts struct {
// Log is a writer for logging progress messages and warnings.
// If nil, io.Discard will be used instead.
Log io.Writer

// Timeout is the amount of wall clock time to spend fuzzing after the corpus
// has loaded. If zero, there will be no time limit.
Timeout time.Duration

// Limit is the number of random values to generate and test. If zero,
// there will be no limit on the number of generated values.
Limit int64

// MinimizeTimeout is the amount of wall clock time to spend minimizing
// after discovering a crasher. If zero, there will be no time limit. If
// MinimizeTimeout and MinimizeLimit are both zero, then minimization will
// be disabled.
MinimizeTimeout time.Duration

// MinimizeLimit is the maximum number of calls to the fuzz function to be
// made while minimizing after finding a crash. If zero, there will be no
// limit. Calls to the fuzz function made when minimizing also count toward
// Limit. If MinimizeTimeout and MinimizeLimit are both zero, then
// minimization will be disabled.
MinimizeLimit int64

// parallel is the number of worker processes to run in parallel. If zero,
// CoordinateFuzzing will run GOMAXPROCS workers.
Parallel int

// Seed is a list of seed values added by the fuzz target with testing.F.Add
// and in testdata.
Seed []CorpusEntry

// Types is the list of types which make up a corpus entry.
// Types must be set and must match values in Seed.
Types []reflect.Type

// CorpusDir is a directory where files containing values that crash the
// code being tested may be written. CorpusDir must be set.
CorpusDir string

// CacheDir is a directory containing additional "interesting" values.
// The fuzzer may derive new values from these, and may write new values here.
CacheDir string
}

// CoordinateFuzzing creates several worker processes and communicates with
// them to test random inputs that could trigger crashes and expose bugs.
// The worker processes run the same binary in the same directory with the
// same environment variables as the coordinator process. Workers also run
// with the same arguments as the coordinator, except with the -test.fuzzworker
// flag prepended to the argument list.
//
// If a crash occurs, the function will return an error containing information
// about the crash, which can be reported to the user.
func CoordinateFuzzing(ctx context.Context, opts CoordinateFuzzingOpts) (err error) {
return errors.New("not implemented")
}

// ReadCorpus reads the corpus from the provided dir. The returned corpus
// entries are guaranteed to match the given types. Any malformed files will
// be saved in a MalformedCorpusError and returned, along with the most recent
// error.
func ReadCorpus(dir string, types []reflect.Type) ([]CorpusEntry, error) {
return nil, errors.New("not implemented")
}

// CheckCorpus verifies that the types in vals match the expected types
// provided.
func CheckCorpus(vals []any, types []reflect.Type) error {
return errors.New("not implemented")
}

func ResetCoverage() {}
func SnapshotCoverage() {}

// RunFuzzWorker is called in a worker process to communicate with the
// coordinator process in order to fuzz random inputs. RunFuzzWorker loops
// until the coordinator tells it to stop.
//
// fn is a wrapper on the fuzz function. It may return an error to indicate
// a given input "crashed". The coordinator will also record a crasher if
// the function times out or terminates the process.
//
// RunFuzzWorker returns an error if it could not communicate with the
// coordinator process.
func RunFuzzWorker(ctx context.Context, fn func(CorpusEntry) error) error {
return errors.New("not implemented")
}
5 changes: 5 additions & 0 deletions src/reflect/value.go
Original file line number Diff line number Diff line change
Expand Up @@ -861,6 +861,11 @@ func (v Value) FieldByIndex(index []int) Value {
panic("unimplemented: (reflect.Value).FieldByIndex()")
}

// FieldByIndexErr returns the nested field corresponding to index.
func (v Value) FieldByIndexErr(index []int) (Value, error) {
return Value{}, &ValueError{Method: "FieldByIndexErr"}
}

func (v Value) FieldByName(name string) Value {
panic("unimplemented: (reflect.Value).FieldByName()")
}
Expand Down
Loading