mirror of https://github.com/golang/go.git
[dev.regabi] all: merge master (1901853) into dev.regabi
Merge List: + 2021-02-081901853098runtime/metrics: fix panic in readingAllMetric example + 2021-02-08ed3e4afa12syscall/plan9: remove spooky fd action at a distance + 2021-02-05724d0720b3doc/go1.16: add missed heading tag in vet section + 2021-02-05b54cd94d47embed, io/fs: clarify that leading and trailing slashes are disallowed + 2021-02-054516afebedtesting/fstest: avoid symlink-induced failures in tester + 2021-02-048869086d8fruntime: fix typo in histogram.go + 2021-02-03e491c6eea9math/big: fix comment in divRecursiveStep Change-Id: I5e2bd18f42251eeb4ad0bf5c93a08c6a9b873d7b
This commit is contained in:
commit
50449de66a
|
|
@ -364,6 +364,8 @@ func TestFoo(t *testing.T) {
|
||||||
}
|
}
|
||||||
</pre>
|
</pre>
|
||||||
|
|
||||||
|
<h4 id="vet-frame-pointer">New warning for frame pointer</h4>
|
||||||
|
|
||||||
<p><!-- CL 248686, CL 276372 -->
|
<p><!-- CL 248686, CL 276372 -->
|
||||||
The vet tool now warns about amd64 assembly that clobbers the BP
|
The vet tool now warns about amd64 assembly that clobbers the BP
|
||||||
register (the frame pointer) without saving and restoring it,
|
register (the frame pointer) without saving and restoring it,
|
||||||
|
|
|
||||||
|
|
@ -61,12 +61,15 @@
|
||||||
// The Go build system will recognize the directives and arrange for the declared variable
|
// The Go build system will recognize the directives and arrange for the declared variable
|
||||||
// (in the example above, content) to be populated with the matching files from the file system.
|
// (in the example above, content) to be populated with the matching files from the file system.
|
||||||
//
|
//
|
||||||
// The //go:embed directive accepts multiple space-separated patterns for brevity,
|
// The //go:embed directive accepts multiple space-separated patterns for
|
||||||
// but it can also be repeated, to avoid very long lines when there are many patterns.
|
// brevity, but it can also be repeated, to avoid very long lines when there are
|
||||||
// The patterns are interpreted relative to the package directory containing the source file.
|
// many patterns. The patterns are interpreted relative to the package directory
|
||||||
// The path separator is a forward slash, even on Windows systems.
|
// containing the source file. The path separator is a forward slash, even on
|
||||||
// To allow for naming files with spaces in their names, patterns can be written
|
// Windows systems. Patterns may not contain ‘.’ or ‘..’ or empty path elements,
|
||||||
// as Go double-quoted or back-quoted string literals.
|
// nor may they begin or end with a slash. To match everything in the current
|
||||||
|
// directory, use ‘*’ instead of ‘.’. To allow for naming files with spaces in
|
||||||
|
// their names, patterns can be written as Go double-quoted or back-quoted
|
||||||
|
// string literals.
|
||||||
//
|
//
|
||||||
// If a pattern names a directory, all files in the subtree rooted at that directory are
|
// If a pattern names a directory, all files in the subtree rooted at that directory are
|
||||||
// embedded (recursively), except that files with names beginning with ‘.’ or ‘_’
|
// embedded (recursively), except that files with names beginning with ‘.’ or ‘_’
|
||||||
|
|
@ -87,9 +90,6 @@
|
||||||
// Matches for empty directories are ignored. After that, each pattern in a //go:embed line
|
// Matches for empty directories are ignored. After that, each pattern in a //go:embed line
|
||||||
// must match at least one file or non-empty directory.
|
// must match at least one file or non-empty directory.
|
||||||
//
|
//
|
||||||
// Patterns must not contain ‘.’ or ‘..’ path elements nor begin with a leading slash.
|
|
||||||
// To match everything in the current directory, use ‘*’ instead of ‘.’.
|
|
||||||
//
|
|
||||||
// If any patterns are invalid or have invalid matches, the build will fail.
|
// If any patterns are invalid or have invalid matches, the build will fail.
|
||||||
//
|
//
|
||||||
// Strings and Bytes
|
// Strings and Bytes
|
||||||
|
|
|
||||||
|
|
@ -36,6 +36,7 @@ type FS interface {
|
||||||
// sequences of path elements, like “x/y/z”.
|
// sequences of path elements, like “x/y/z”.
|
||||||
// Path names must not contain a “.” or “..” or empty element,
|
// Path names must not contain a “.” or “..” or empty element,
|
||||||
// except for the special case that the root directory is named “.”.
|
// except for the special case that the root directory is named “.”.
|
||||||
|
// Leading and trailing slashes (like “/x” or “x/”) are not allowed.
|
||||||
//
|
//
|
||||||
// Paths are slash-separated on all systems, even Windows.
|
// Paths are slash-separated on all systems, even Windows.
|
||||||
// Backslashes must not appear in path names.
|
// Backslashes must not appear in path names.
|
||||||
|
|
|
||||||
|
|
@ -881,7 +881,7 @@ func (z nat) divRecursiveStep(u, v nat, depth int, tmp *nat, temps []*nat) {
|
||||||
// then floor(u1/v1) >= floor(u/v)
|
// then floor(u1/v1) >= floor(u/v)
|
||||||
//
|
//
|
||||||
// Moreover, the difference is at most 2 if len(v1) >= len(u/v)
|
// Moreover, the difference is at most 2 if len(v1) >= len(u/v)
|
||||||
// We choose s = B-1 since len(v)-B >= B+1 >= len(u/v)
|
// We choose s = B-1 since len(v)-s >= B+1 >= len(u/v)
|
||||||
s := (B - 1)
|
s := (B - 1)
|
||||||
// Except for the first step, the top bits are always
|
// Except for the first step, the top bits are always
|
||||||
// a division remainder, so the quotient length is <= n.
|
// a division remainder, so the quotient length is <= n.
|
||||||
|
|
|
||||||
|
|
@ -26,7 +26,7 @@ const (
|
||||||
// The number of super-buckets (timeHistNumSuperBuckets), on the
|
// The number of super-buckets (timeHistNumSuperBuckets), on the
|
||||||
// other hand, defines the range. To reserve room for sub-buckets,
|
// other hand, defines the range. To reserve room for sub-buckets,
|
||||||
// bit timeHistSubBucketBits is the first bit considered for
|
// bit timeHistSubBucketBits is the first bit considered for
|
||||||
// super-buckets, so super-bucket indicies are adjusted accordingly.
|
// super-buckets, so super-bucket indices are adjusted accordingly.
|
||||||
//
|
//
|
||||||
// As an example, consider 45 super-buckets with 16 sub-buckets.
|
// As an example, consider 45 super-buckets with 16 sub-buckets.
|
||||||
//
|
//
|
||||||
|
|
|
||||||
|
|
@ -88,7 +88,7 @@ func medianBucket(h *metrics.Float64Histogram) float64 {
|
||||||
total = 0
|
total = 0
|
||||||
for i, count := range h.Counts {
|
for i, count := range h.Counts {
|
||||||
total += count
|
total += count
|
||||||
if total > thresh {
|
if total >= thresh {
|
||||||
return h.Buckets[i]
|
return h.Buckets[i]
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -320,14 +320,15 @@ func cexecPipe(p []int) error {
|
||||||
return e
|
return e
|
||||||
}
|
}
|
||||||
|
|
||||||
fd, e := Open("#d/"+itoa(p[1]), O_CLOEXEC)
|
fd, e := Open("#d/"+itoa(p[1]), O_RDWR|O_CLOEXEC)
|
||||||
if e != nil {
|
if e != nil {
|
||||||
Close(p[0])
|
Close(p[0])
|
||||||
Close(p[1])
|
Close(p[1])
|
||||||
return e
|
return e
|
||||||
}
|
}
|
||||||
|
|
||||||
Close(fd)
|
Close(p[1])
|
||||||
|
p[1] = fd
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -403,9 +403,10 @@ func (t *fsTester) checkStat(path string, entry fs.DirEntry) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
fentry := formatEntry(entry)
|
fentry := formatEntry(entry)
|
||||||
finfo := formatInfoEntry(info)
|
fientry := formatInfoEntry(info)
|
||||||
if fentry != finfo {
|
// Note: mismatch here is OK for symlink, because Open dereferences symlink.
|
||||||
t.errorf("%s: mismatch:\n\tentry = %s\n\tfile.Stat() = %s", path, fentry, finfo)
|
if fentry != fientry && entry.Type()&fs.ModeSymlink == 0 {
|
||||||
|
t.errorf("%s: mismatch:\n\tentry = %s\n\tfile.Stat() = %s", path, fentry, fientry)
|
||||||
}
|
}
|
||||||
|
|
||||||
einfo, err := entry.Info()
|
einfo, err := entry.Info()
|
||||||
|
|
@ -413,12 +414,22 @@ func (t *fsTester) checkStat(path string, entry fs.DirEntry) {
|
||||||
t.errorf("%s: entry.Info: %v", path, err)
|
t.errorf("%s: entry.Info: %v", path, err)
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
fentry = formatInfo(einfo)
|
finfo := formatInfo(info)
|
||||||
finfo = formatInfo(info)
|
if entry.Type()&fs.ModeSymlink != 0 {
|
||||||
if fentry != finfo {
|
// For symlink, just check that entry.Info matches entry on common fields.
|
||||||
t.errorf("%s: mismatch:\n\tentry.Info() = %s\n\tfile.Stat() = %s\n", path, fentry, finfo)
|
// Open deferences symlink, so info itself may differ.
|
||||||
|
feentry := formatInfoEntry(einfo)
|
||||||
|
if fentry != feentry {
|
||||||
|
t.errorf("%s: mismatch\n\tentry = %s\n\tentry.Info() = %s\n", path, fentry, feentry)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
feinfo := formatInfo(einfo)
|
||||||
|
if feinfo != finfo {
|
||||||
|
t.errorf("%s: mismatch:\n\tentry.Info() = %s\n\tfile.Stat() = %s\n", path, feinfo, finfo)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Stat should be the same as Open+Stat, even for symlinks.
|
||||||
info2, err := fs.Stat(t.fsys, path)
|
info2, err := fs.Stat(t.fsys, path)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.errorf("%s: fs.Stat: %v", path, err)
|
t.errorf("%s: fs.Stat: %v", path, err)
|
||||||
|
|
|
||||||
|
|
@ -0,0 +1,31 @@
|
||||||
|
// Copyright 2021 The Go Authors. All rights reserved.
|
||||||
|
// Use of this source code is governed by a BSD-style
|
||||||
|
// license that can be found in the LICENSE file.
|
||||||
|
|
||||||
|
package fstest
|
||||||
|
|
||||||
|
import (
|
||||||
|
"internal/testenv"
|
||||||
|
"os"
|
||||||
|
"path/filepath"
|
||||||
|
"testing"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestSymlink(t *testing.T) {
|
||||||
|
testenv.MustHaveSymlink(t)
|
||||||
|
|
||||||
|
tmp := t.TempDir()
|
||||||
|
tmpfs := os.DirFS(tmp)
|
||||||
|
|
||||||
|
if err := os.WriteFile(filepath.Join(tmp, "hello"), []byte("hello, world\n"), 0644); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := os.Symlink(filepath.Join(tmp, "hello"), filepath.Join(tmp, "hello.link")); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
if err := TestFS(tmpfs, "hello", "hello.link"); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
}
|
||||||
Loading…
Reference in New Issue