1
0
mirror of https://github.com/golang/go synced 2024-09-30 18:18:32 -06:00
Commit Graph

73 Commits

Author SHA1 Message Date
Brad Fitzpatrick
ec87dbf913 os: eradicate smallpox after test
Otherwise:

$ go test  -short -cpu=1,1,2,2
--- FAIL: TestLookupEnv (0.00s)
        env_test.go:102: SMALLPOX="virus"
--- FAIL: TestLookupEnv-2 (0.00s)
        env_test.go:102: SMALLPOX="virus"
--- FAIL: TestLookupEnv-2 (0.00s)
        env_test.go:102: SMALLPOX="virus"

Change-Id: Ic1f6dd1bae3c79c4f7da02bc8c30b5e599627a82
Reviewed-on: https://go-review.googlesource.com/9794
Reviewed-by: Rob Pike <r@golang.org>
2015-05-06 17:38:57 +00:00
Rob Pike
072a26331a os: rewrite LookupEnv's test
GOROOT is not dependably set.

When I first wrote this test, I thought it was a waste of time
because the function can't fail if the other environment functions
work, but I didn't want to add functionality without testing it.
Of course, the test broke, and I learned something: GOROOT is not
set on iOS or, to put it more broadly, the world continues to
surprise me with its complexity and horror, such as a version of
cat with syntax coloring.

In that vein, I built this test around smallpox.

Change-Id: Ifa6c218a927399d05c47954fdcaea1015e558fb6
Reviewed-on: https://go-review.googlesource.com/9791
Reviewed-by: Russ Cox <rsc@golang.org>
2015-05-06 16:02:32 +00:00
Aram Hăvărneanu
24396dae67 os/user: small fixes for Solaris
Change-Id: I56149ef6607fb4d9baff9047cb3a47d71cad6fa6
Reviewed-on: https://go-review.googlesource.com/8261
Reviewed-by: Minux Ma <minux@golang.org>
2015-05-06 11:37:41 +00:00
Rob Pike
e8c0d0f2f3 os: add LookupEnv, like Getenv but reports presence
Fixes #9676.

Change-Id: I32fe474cdfa09aff91daa4b10ac4df28ffdaa649
Reviewed-on: https://go-review.googlesource.com/9741
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-05-05 21:05:12 +00:00
Dmitry Vyukov
cfb8b18e75 strings: use LastIndexByte in LastIndex
Change-Id: I1add1b92f5c2688a99133d90bf9789d770fd9f05
Reviewed-on: https://go-review.googlesource.com/9503
Reviewed-by: Matthew Dempsky <mdempsky@google.com>
2015-04-30 08:33:29 +00:00
Benny Siegert
1203420890 os/exec: Document the fact that Cmd cannot be reused.
Update #10305

Change-Id: Iea04758bc200038a1c64457a68100dcdd7f75212
Reviewed-on: https://go-review.googlesource.com/9440
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-04-29 21:08:07 +00:00
Brad Fitzpatrick
015c760893 os: clarify that ModePerm permission bits are the Unix ones
Fixes #7075

Change-Id: I57fcebaaef768b00263b6b91211b1434f6a4b229
Reviewed-on: https://go-review.googlesource.com/8919
Reviewed-by: Josh Bleecher Snyder <josharian@gmail.com>
2015-04-16 16:42:10 +00:00
Alex Brainman
9402e49450 runtime: really pass return value to Windows in externalthreadhandler
When Windows calls externalthreadhandler it expects to receive
return value in AX. We don't set AX anywhere. Change that.
Store ctrlhandler1 and profileloop1 return values into AX before
returning from externalthreadhandler.

Fixes #10215.

Change-Id: Ied04542cc3ebe7d4a26660e970f9f78098143591
Reviewed-on: https://go-review.googlesource.com/8901
Reviewed-by: Minux Ma <minux@golang.org>
Run-TryBot: Alex Brainman <alex.brainman@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-04-15 05:03:42 +00:00
Mikio Hara
3cbe7ea7e9 os: fix TestProgWideChdir on darwin
On darwin, /tmp and /var directories are usually linked to /private.

% cd $TMPDIR; pwd -L
/var/.../T
% pwd -P
/private/var/.../T

Change-Id: I277ff2d096344d9a80e6004a83e9fc3e1716348c
Reviewed-on: https://go-review.googlesource.com/8842
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-04-13 22:26:15 +00:00
David Crawshaw
5ad83082c0 os/exec: skip fork test on darwin/arm64
Just like darwin/arm.

Change-Id: Ia8c912e91259a5073aa3ab2b6509a18aa9a1fce7
Reviewed-on: https://go-review.googlesource.com/8818
Reviewed-by: Minux Ma <minux@golang.org>
2015-04-13 11:53:09 +00:00
David du Colombier
ae740a459e os: add TestProgWideChdir
This test checks the working directory is
always consistent after Chdir in a Go program.

Fixes #10035.

Change-Id: I6abf0e4fcd40680ee572c6b40fc52ab17ef38d54
Reviewed-on: https://go-review.googlesource.com/6382
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: David du Colombier <0intro@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-04-12 19:03:13 +00:00
David Crawshaw
84efd6fc74 os: adjust working dir for darwin/arm64 tests
Just like darwin/arm.

Change-Id: Ib64a3e8ff11249a20b0208bd3b900db318c682b7
Reviewed-on: https://go-review.googlesource.com/8817
Reviewed-by: Minux Ma <minux@golang.org>
Run-TryBot: David Crawshaw <crawshaw@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-04-12 11:51:59 +00:00
Daniel Theophanes
92c57363e0 os: windows Rename should overwrite destination file.
Rename now uses MoveFileEx which was previously not available to
use because it is not supported on Windows 2000.

Change-Id: I583d029c4467c9be6d1574a790c423559b441e87
Reviewed-on: https://go-review.googlesource.com/6140
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
2015-04-09 08:39:52 +00:00
Alex Brainman
32e75bace0 all: fix race when allocating buffer for some windows syscalls
Fixes #9753

Change-Id: I6c641ed7ef4f687a108e7d937ab4b9c24d5baf5d
Reviewed-on: https://go-review.googlesource.com/4940
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-04-08 02:06:31 +00:00
Dmitry Vyukov
c61d86af72 os: give race detector chance to override Exit(0)
Racy tests do not fail currently, they do os.Exit(0).
So if you run go test without -v, you won't even notice.
This was probably introduced with testing.TestMain.

Racy programs do not have the right to finish successfully.

Change-Id: Id133d7424f03d90d438bc3478528683dd02b8846
Reviewed-on: https://go-review.googlesource.com/4371
Reviewed-by: Russ Cox <rsc@golang.org>
2015-03-28 12:42:37 +00:00
Hyang-Ah (Hana) Kim
41d58c3739 os/exec: post-process lsof output on Android.
lsof is used to inspect the open file desciptors in exec_test.go.
In order to limit the output of lsof to the tested process, the tests use
lsof with the -p option, but the version of lsof in android seems to ignore
it. This change adds a post-processing step to filter out irrelevant entries.

Fixes golang/go#10206.

Change-Id: Ia789b8f5e1e9b95c7b55deac92d0d1fbf3ee74fb
Reviewed-on: https://go-review.googlesource.com/8025
Reviewed-by: David Crawshaw <crawshaw@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-03-25 00:34:37 +00:00
Shenghou Ma
398f56fe22 os/signal: skip TestCtrlBreak on windows/386 temporarily
Update #10215.

Change-Id: Ib588f90279a4ef5461492553d50ad77c742b3560
Signed-off-by: Shenghou Ma <minux@golang.org>
Reviewed-on: https://go-review.googlesource.com/7971
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
2015-03-24 01:38:05 +00:00
areski
3f12d27133 bytes, os/exec, strings: fix a few BUG comments
Regular expression noteMarker requires the definition of a (who) section
when reading note from a sequence of comments.

Change-Id: I9635de9b86f00d20ec108097fee4d4a8f76237b2
Reviewed-on: https://go-review.googlesource.com/1952
Reviewed-by: Russ Cox <rsc@golang.org>
2015-03-20 18:34:39 +00:00
Kato Kazuyoshi
9c0b145e4c os: don't return Chmod's error from Mkdir and OpenFile
Mkdir and OpenFile call Chmod internally on *BSD and Solaris,
because these OSes don't handle the sticky bit correctly.

However Chmod's error should be ignored. It shouldn't hide
the fact that a file itself is created.

Fixes #8383

Change-Id: Ia2e0b2ba72712d73a0a48ba5a263432e0fff31a5
Reviewed-on: https://go-review.googlesource.com/2057
Reviewed-by: Russ Cox <rsc@golang.org>
2015-03-20 18:33:00 +00:00
Josh Bleecher Snyder
2adc4e8927 all: use "reports whether" in place of "returns true if(f)"
Comment changes only.

Change-Id: I56848814564c4aa0988b451df18bebdfc88d6d94
Reviewed-on: https://go-review.googlesource.com/7721
Reviewed-by: Rob Pike <r@golang.org>
2015-03-18 15:14:06 +00:00
Aram Hăvărneanu
a25e3c03f3 os/signal, hash/crc32: add arm64 build tags
Change-Id: I6ca9caec8ccf12618e56dcf6b83328e7acf8b1ec
Reviewed-on: https://go-review.googlesource.com/7148
Reviewed-by: Minux Ma <minux@golang.org>
Reviewed-by: Dave Cheney <dave@cheney.net>
Reviewed-by: Russ Cox <rsc@golang.org>
2015-03-16 18:46:43 +00:00
tnt
de486b24d1 Fixed wrong arguments to formatting functions
Change-Id: I11b4cf00ceeb4441b865e0de3f1674095d1c32d0
Reviewed-on: https://go-review.googlesource.com/7043
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-03-07 02:08:04 +00:00
Alex Brainman
d07e3380b0 os: do not leave /go_os_test/dir after test
Change-Id: Idb8e211bf33d2713735f9cdc868a3458ce799c97
Reviewed-on: https://go-review.googlesource.com/6913
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-03-06 01:35:02 +00:00
David Crawshaw
bfb8ad51d5 os: set TMPDIR on darwin/arm
This is a roll forward of 2adc3bd6ef. It occurred to me that we will
want this code on both darwin/arm and darwin/arm64. Removing _arm from
the file name conveniently avoids #10032.

Change-Id: I3a96a3e7020907d9307af8f696e26ad55b2060f0
Reviewed-on: https://go-review.googlesource.com/6460
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: David Crawshaw <crawshaw@golang.org>
2015-03-02 18:46:11 +00:00
Alex Brainman
29a83af5ef os: add windows test for Hostname
Change-Id: I9b38b3a384722cf000eab18b62f73f90bcb56c5c
Reviewed-on: https://go-review.googlesource.com/6070
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-03-02 01:23:27 +00:00
David Crawshaw
bc674b3d16 os: darwin/arm working dir moved for tests
The go_darwin_arm_exec script now tells lldb to move the working
directory into <bundle>/src/os on startup.

Change-Id: I0ada4969e9ea374f08c84ab736aab2097ac73dd8
Reviewed-on: https://go-review.googlesource.com/6369
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
2015-03-01 16:09:46 +00:00
David Crawshaw
2adc3bd6ef Revert "os: set TMPDIR on darwin/arm"
This reverts commit 87a0d395c3.

Looks like introducing file_darwin_arm.go is confusing something in the API checker (probably go/types) into ignoring file.go, so the O_SYNC symbol is being lost.

No actual bug in this CL AFAIK, but I'll fix the other bug later and then roll this forward.

Change-Id: Ic132fb101e4b5f2716f7a0d15872bf35bdf42139
Reviewed-on: https://go-review.googlesource.com/6331
Reviewed-by: David Crawshaw <crawshaw@golang.org>
2015-02-28 02:40:03 +00:00
David Crawshaw
344f424007 os: fix tests on darwin/arm
Tests that fork are skipped. Tests that create files do so in a
temporary directory, as the initial PWD is read-only. And
darwin/arm returns a strange mkdir error when trying to write to /.

Change-Id: I2de661a85524300bbac226693d72142992dc188d
Reviewed-on: https://go-review.googlesource.com/6312
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-02-28 01:07:43 +00:00
David Crawshaw
87a0d395c3 os: set TMPDIR on darwin/arm
Change-Id: Iee25f4b0a31ece0aae79c68aec809e1e4308f865
Reviewed-on: https://go-review.googlesource.com/6311
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-02-28 01:06:42 +00:00
Hyang-Ah (Hana) Kim
c2025c4131 os: fix LinkError creation on windows.
Not only carrying invalid info but also this caused Error to crash with
null pointer exception.

Change-Id: Ibfe63d20eb9b9178ea618e59c74111e9245a6779
Reviewed-on: https://go-review.googlesource.com/6270
Run-TryBot: Hyang-Ah Hana Kim <hyangah@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2015-02-27 23:31:36 +00:00
David Crawshaw
e4791066c8 os/exec: disable tests on darwin/arm
There is only one process under the iOS sandboxd.

Change-Id: I21b5528366a0248a034801a717f24c60f0733c5f
Reviewed-on: https://go-review.googlesource.com/6101
Reviewed-by: Hyang-Ah Hana Kim <hyangah@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-02-26 16:19:46 +00:00
Carlos Castillo
59e546633d os: Use GetComputerNameEx to get Hostname on win32
The existing Hostname function uses the GetComputerName system
function in windows to determine the hostname. It has some downsides:

  - The name is limited to 15 characters.
  - The name returned is for NetBIOS, other OS's return a DNS name

This change adds to the internal/syscall/windows package a
GetComputerNameEx function, and related enum constants. They are used
instead of the syscall.ComputerName function to implement os.Hostname
on windows.

Fixes #9982

Change-Id: Idc8782785eb1eea37e64022bd201699ce9c4b39c
Reviewed-on: https://go-review.googlesource.com/5852
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
Run-TryBot: Alex Brainman <alex.brainman@gmail.com>
Reviewed-by: Carlos Castillo <cookieo9@gmail.com>
Reviewed-by: Yasuhiro MATSUMOTO <mattn.jp@gmail.com>
2015-02-25 23:16:44 +00:00
Yasuhiro Matsumoto
d866cd6817 all: fix typo in doc
Change-Id: I89fdda2914030dfea3183a8b4681dd4b33489729
Reviewed-on: https://go-review.googlesource.com/4996
Reviewed-by: Minux Ma <minux@golang.org>
2015-02-17 04:37:18 +00:00
mattn
38be309dcf os: fix typo in doc
Change-Id: I9797b44dfa7c2c853b7a656f4f722df2c862824b
Reviewed-on: https://go-review.googlesource.com/4991
Reviewed-by: Andrew Gerrand <adg@golang.org>
2015-02-17 00:21:02 +00:00
Michael MacInnis
194ad16b83 os/signal: add ability to ignore signals and restore initial signal handlers
There is currently no way to ignore signals using the os/signal package.
It is possible to catch a signal and do nothing but this is not the same
as ignoring it. The new function Ignore allows a set of signals to be
ignored. The new function Reset allows the initial handlers for a set of
signals to be restored.

Fixes #5572

Change-Id: I5c0f07956971e3a9ff9b9d9631e6e3a08c20df15
Reviewed-on: https://go-review.googlesource.com/3580
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-02-16 14:23:09 +00:00
mattn
e77fbd598f syscall: Readlink doesn't handle junction on windows
Fixes #9190

Change-Id: I22177687ed834feed165454019d28c11fcbf0fa2
Reviewed-on: https://go-review.googlesource.com/2307
Reviewed-by: Alex Brainman <alex.brainman@gmail.com>
2015-02-12 02:03:25 +00:00
Rahul Chaudhry
afac4f0a40 os: embed "sleep 1" within the test binary itself.
This is an alternative to http://golang.org/cl/4150,
and is motivated by a review comment on that CL.

testKillProcess() tries to build and run the Go equivalent
for "sleep 1". This doesn't work for testing cross compilers
since the Go compiler is not available on the targets. This
change embeds the "sleep 1" functionality within the "os.test"
binary itself.

Change-Id: I6bad513deaa6c9e2704e70319098eb4983f1bb23
Reviewed-on: https://go-review.googlesource.com/4190
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-02-09 16:50:39 +00:00
Brad Fitzpatrick
a35181ba7f os, syscall: revert Yosemite readdir workaround
Reverts https://golang.org/cl/119530044 (OS X 10.10 Yosemite beta
14A299l workaround), since it was fixed in the final Yosemite release.

I verified that the C program http://swtch.com/~rsc/readdirbug.c
passes on Yosemite.

Adds a new test to the os package too, to verify that reading a
regular file as a directory fails.

Fixes #9789 (ReadDir: no error if dirname is a file)

Change-Id: I75286cef88fbb2ebccf045b479e33c810749dcbc
Reviewed-on: https://go-review.googlesource.com/4164
Reviewed-by: Dave Cheney <dave@cheney.net>
2015-02-08 21:04:15 +00:00
David du Colombier
d5d4ab7819 os/signal, runtime: implement notes on Plan 9
This change is an implementation of the signal
runtime and os/signal package on Plan 9.

Contrary to Unix, on Plan 9 a signal is called
a note and is represented by a string.

For this reason, the sigsend and signal_recv
functions had to be reimplemented specifically
for Plan 9.

In order to reuse most of the code and internal
interface of the os/signal package, the note
strings are mapped to integers.

Thanks to Russ Cox for the early review.

Change-Id: I95836645efe21942bb1939f43f87fb3c0eaaef1a
Reviewed-on: https://go-review.googlesource.com/2164
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Rob Pike <r@golang.org>
2015-02-06 19:46:34 +00:00
Péter Surányi
9b6ccb1323 all: don't refer to code.google.com/p/go{,-wiki}/
Only documentation / comment changes. Update references to
point to golang.org permalinks or go.googlesource.com/go.
References in historical release notes under doc are left as is.

Change-Id: Icfc14e4998723e2c2d48f9877a91c5abef6794ea
Reviewed-on: https://go-review.googlesource.com/4060
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-02-06 14:41:47 +00:00
David du Colombier
187cccbde1 os: fix TestMkdirAllAtSlash on Plan 9
Since CL 3676, the TestMkdirAllAtSlash test
depends on syscall.EROFS, which isn't defined
on Plan 9.

This change works around this issue by
defining a system dependent isReadonlyError
function.

Change-Id: If972fd2fe4828ee3bcb8537ea7f4ba29f7a87619
Reviewed-on: https://go-review.googlesource.com/3696
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-02-02 17:01:45 +00:00
Dave Cheney
dc51ed2180 os: don't silently skip test
This is a followup to CL 3676.

Rather than silently returning from the test, a pass,
use the Skip facility to mark the test as skipped.

Change-Id: I90d237e770150bf8d69f14fb09874e70894a7f86
Reviewed-on: https://go-review.googlesource.com/3682
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-01-31 05:53:22 +00:00
Rahul Chaudhry
2ffe3255a1 os: allow EROFS in TestMkdirAllAtSlash
On some systems (e.g. ChromeOS), / is mounted read-only.
This results in error code syscall.EROFS, which I guess
is just as valid as syscall.EACCES for this test.

Change-Id: I9188d5437a1b5ac1daa9c68b95b8dcb447666ca3
Reviewed-on: https://go-review.googlesource.com/3676
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2015-01-30 23:37:42 +00:00
David du Colombier
2a74f436aa os: emulate plan 9 libc in stat
This change is a recreation of the CL written
by Nick Owens on http://golang.org/cl/150730043.

If the stat buffer is too short, the kernel
informs us by putting the 2-byte size in the
buffer, so we read that and try again.

This follows the same algorithm as /sys/src/libc/9sys/dirfstat.c.

Fixes #8781.

Change-Id: I01b4ad3a5e705dd4cab6673c7a119f8bef9bbd7c
Reviewed-on: https://go-review.googlesource.com/3281
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-01-26 06:34:07 +00:00
Martin Möhrmann
79c4fad8c2 os: replace itod on posix with general itoa and fix possible infinite recursion
Remove use of itod on posix systems and replace with call to itoa.
Build and use same itoa function on all systems.
Fix infinite recursion in iota function for the case -1<<63.

Change-Id: I89d7e742383c5c4aeef8780501c78a3e1af87a6f
Reviewed-on: https://go-review.googlesource.com/2213
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2015-01-02 16:21:18 +00:00
Kato Kazuyoshi
6262902070 os: handle the sticky bit separately for *BSD and Solaris
open(2) and mkdir(2) won't set the sticky bit on *BSD and Solaris.
This behavior is mentioned on sticky(8).
see also: https://github.com/dotcloud/docker/pull/6587

Fixes #8383.

Change-Id: Ic4733700f9926b9fc2b6fd1f998acec34e518764
Reviewed-on: https://go-review.googlesource.com/1673
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2014-12-17 16:07:28 +00:00
Russ Cox
09d92b6bbf all: power64 is now ppc64
Fixes #8654.

LGTM=austin
R=austin
CC=golang-codereviews
https://golang.org/cl/180600043
2014-12-05 19:13:20 -05:00
Russ Cox
3e804631d9 [dev.cc] all: merge dev.power64 (7667e41f3ced) into dev.cc
This is to reduce the delta between dev.cc and dev.garbage to just garbage collector changes.

These are the files that had merge conflicts and have been edited by hand:
        malloc.go
        mem_linux.go
        mgc.go
        os1_linux.go
        proc1.go
        panic1.go
        runtime1.go

LGTM=austin
R=austin
CC=golang-codereviews
https://golang.org/cl/174180043
2014-11-14 12:10:52 -05:00
Russ Cox
1cdd9b407d os: document that users of Fd should keep f alive
Fixes #9046.

LGTM=r
R=r
CC=golang-codereviews
https://golang.org/cl/162680043
2014-11-06 09:36:51 -05:00
Keith Randall
23ecad07cd os/exec: tell lsof not to block
For some reason lsof is now hanging on my workstation
without the -b (avoid blocking in the kernel) option.
Adding -b makes the test pass and shouldn't hurt.

I don't know how recent the -b option is.  If the builders
are ok with it, it's probably ok.

LGTM=rsc
R=golang-codereviews, bradfitz, rsc
CC=golang-codereviews
https://golang.org/cl/166220043
2014-11-05 20:25:20 -08:00