]> Cypherpunks.ru repositories - gostls13.git/commitdiff
[dev.regabi] all: merge master (1901853) into dev.regabi
authorCherry Zhang <cherryyz@google.com>
Mon, 8 Feb 2021 19:01:08 +0000 (14:01 -0500)
committerCherry Zhang <cherryyz@google.com>
Mon, 8 Feb 2021 19:01:08 +0000 (14:01 -0500)
Merge List:

+ 2021-02-08 1901853098 runtime/metrics: fix panic in readingAllMetric example
+ 2021-02-08 ed3e4afa12 syscall/plan9: remove spooky fd action at a distance
+ 2021-02-05 724d0720b3 doc/go1.16: add missed heading tag in vet section
+ 2021-02-05 b54cd94d47 embed, io/fs: clarify that leading and trailing slashes are disallowed
+ 2021-02-05 4516afebed testing/fstest: avoid symlink-induced failures in tester
+ 2021-02-04 8869086d8f runtime: fix typo in histogram.go
+ 2021-02-03 e491c6eea9 math/big: fix comment in divRecursiveStep

Change-Id: I5e2bd18f42251eeb4ad0bf5c93a08c6a9b873d7b

doc/go1.16.html
src/embed/embed.go
src/io/fs/fs.go
src/math/big/nat.go
src/runtime/histogram.go
src/runtime/metrics/example_test.go
src/syscall/exec_plan9.go
src/testing/fstest/testfs.go
src/testing/fstest/testfs_test.go [new file with mode: 0644]

index 8d31f63fa2a12eecd2f63b1e6e8694e1776925c9..878bf0d0293954705527215b9775fa3d28c185f8 100644 (file)
@@ -364,6 +364,8 @@ func TestFoo(t *testing.T) {
 }
 </pre>
 
+<h4 id="vet-frame-pointer">New warning for frame pointer</h4>
+
 <p><!-- CL 248686, CL 276372 -->
   The vet tool now warns about amd64 assembly that clobbers the BP
   register (the frame pointer) without saving and restoring it,
index 5f984aaf71d285cecceb00ccd928b85a62a3dad1..7f2719d2a78062ab9749f17fe67c9ea8f4d7ab64 100644 (file)
 // 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.
 //
-// The //go:embed directive accepts multiple space-separated patterns for brevity,
-// but it can also be repeated, to avoid very long lines when there are many patterns.
-// The patterns are interpreted relative to the package directory containing the source file.
-// The path separator is a forward slash, even on Windows systems.
-// To allow for naming files with spaces in their names, patterns can be written
-// as Go double-quoted or back-quoted string literals.
+// The //go:embed directive accepts multiple space-separated patterns for
+// brevity, but it can also be repeated, to avoid very long lines when there are
+// many patterns. The patterns are interpreted relative to the package directory
+// containing the source file. The path separator is a forward slash, even on
+// Windows systems. Patterns may not contain ‘.’ or ‘..’ or empty path elements,
+// 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
 // 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
 // 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.
 //
 // Strings and Bytes
index b691a860498a2136cf97a56905739555bf4946f5..c330f123ad1fab136ed69a26a768f6863d14eb88 100644 (file)
@@ -36,6 +36,7 @@ type FS interface {
 // sequences of path elements, like “x/y/z”.
 // Path names must not contain a “.” or “..” or empty element,
 // 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.
 // Backslashes must not appear in path names.
index 068176e1c1a18c59a8a8bb0a0a13f644a140e4cd..bbd6c8850b604b365011144e9ab8e6744ee27354 100644 (file)
@@ -881,7 +881,7 @@ func (z nat) divRecursiveStep(u, v nat, depth int, tmp *nat, temps []*nat) {
                // then floor(u1/v1) >= floor(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)
                // Except for the first step, the top bits are always
                // a division remainder, so the quotient length is <= n.
index 42baa6c5e2c0df3765e21e307bfdc4c1c808a92d..da4910d341cbcf861059f292eb4576a8e762e75a 100644 (file)
@@ -26,7 +26,7 @@ const (
        // The number of super-buckets (timeHistNumSuperBuckets), on the
        // other hand, defines the range. To reserve room for sub-buckets,
        // 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.
        //
index cade0c38bfde62c046d3e7c9332cff9163b4c23b..624d9d8a6bd1ec9d09c00172866b741efbd7470f 100644 (file)
@@ -88,7 +88,7 @@ func medianBucket(h *metrics.Float64Histogram) float64 {
        total = 0
        for i, count := range h.Counts {
                total += count
-               if total > thresh {
+               if total >= thresh {
                        return h.Buckets[i]
                }
        }
index 47ccbdc384e93a8f826cf0de3b19f5f0e349aa5b..12c4237f69e4e7ed6a8d05257b594c84d276a477 100644 (file)
@@ -320,14 +320,15 @@ func cexecPipe(p []int) error {
                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 {
                Close(p[0])
                Close(p[1])
                return e
        }
 
-       Close(fd)
+       Close(p[1])
+       p[1] = fd
        return nil
 }
 
index a7f8007333e310eef526c61e667b789b2f125301..8fc8acaaf3bf1bb88fda7138002f5678a8266178 100644 (file)
@@ -403,9 +403,10 @@ func (t *fsTester) checkStat(path string, entry fs.DirEntry) {
                return
        }
        fentry := formatEntry(entry)
-       finfo := formatInfoEntry(info)
-       if fentry != finfo {
-               t.errorf("%s: mismatch:\n\tentry = %s\n\tfile.Stat() = %s", path, fentry, finfo)
+       fientry := formatInfoEntry(info)
+       // Note: mismatch here is OK for symlink, because Open dereferences symlink.
+       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()
@@ -413,12 +414,22 @@ func (t *fsTester) checkStat(path string, entry fs.DirEntry) {
                t.errorf("%s: entry.Info: %v", path, err)
                return
        }
-       fentry = formatInfo(einfo)
-       finfo = formatInfo(info)
-       if fentry != finfo {
-               t.errorf("%s: mismatch:\n\tentry.Info() = %s\n\tfile.Stat() = %s\n", path, fentry, finfo)
+       finfo := formatInfo(info)
+       if entry.Type()&fs.ModeSymlink != 0 {
+               // For symlink, just check that entry.Info matches entry on common fields.
+               // 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)
        if err != nil {
                t.errorf("%s: fs.Stat: %v", path, err)
diff --git a/src/testing/fstest/testfs_test.go b/src/testing/fstest/testfs_test.go
new file mode 100644 (file)
index 0000000..5b8813c
--- /dev/null
@@ -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)
+       }
+}