Commit Graph

32 Commits

Author SHA1 Message Date
Lynn Boger
c2ed4eda69 unix: fix TestSchedSetaffinity for smt settings
If a system has the ability to disable some cores, as on
ppc64 with the ppc64_cpu command, then TestSchedSetaffinity will
fail if the CPUset passed to Setaffinity includes one that has
been disabled.

This adds a check to use values from the oldMask, which are the valid
cores returned from Getaffinity, to pass to Setaffinity.

Fixes golang/go#27875

Change-Id: I9656f41867afc18e0eaedc4bdef5f75e137a1fcd
Reviewed-on: https://go-review.googlesource.com/137675
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-09-26 16:07:41 +00:00
Leigh McCulloch
d0be0721c3 unix: correct misspelling in test output
The TestRlimitAs function has fatal output that uses the word 'suceeded'
that is a misspelling of 'succeeded'.

Change-Id: Id235c9e38338e09c5c06c4ed4a0037afc8f6f2bd
GitHub-Last-Rev: 84d6abe576
GitHub-Pull-Request: golang/sys#17
Reviewed-on: https://go-review.googlesource.com/134220
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-09-09 12:40:46 +00:00
Tobias Klauser
d9c697bf0b unix: correct argument order for SyncFileRange syscall on linux/ppc64{,le}
On linux/ppc64{,le} the SYS_SYNC_FILE_RANGE2 syscall is used to
implement SyncFileRange. This syscall has a different argument order
than SYS_SYNC_FILE_RANGE. Apart from that the implementations of both
syscalls are the same, so use a simple wrapper to invoke the syscall
with the correct argument order.

For context see:
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git/commit/?id=edd5cd4a9424f22b0fa08bef5e299d41befd5622

Fixes golang/go#27485

Change-Id: Idc154eab7b7c521a34de821e1d1a97095e96fed0
Reviewed-on: https://go-review.googlesource.com/133215
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-09-05 06:47:16 +00:00
Ian Lance Taylor
bd9dbc187b unix: support Faccessat flags argument
The Linux kernel faccessat system call does not take a flags parameter.
The flag parameter to the C library faccessat function is implemented in C.
The unix.Faccessat function takes a flags parameter. In older releases
we have passed the flags parameter to the kernel, which ignored it.
In CL 119495 we started returning an error if any flags were set.
That seems clearly better than ignoring them, but it turns out that some
code was using the flags. The code was previously subtly broken.
Now it is obviously broken. That is better, but we can do better still:
we can implement the flags as the C library does. That is what this CL does.

Change-Id: I02d4bb981ebd39eb35e47c6e5281f85eaea68016
Reviewed-on: https://go-review.googlesource.com/126516
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-07-27 23:04:15 +00:00
Tobias Klauser
c4afb3effa unix: fix TestUtimesNanoAt for filesystems with 1-second resolution time stamps
Some file systems don't support sub-second time stamp resolution. Handle
these correctly by only checking nanoseconds in case Mtim.Nsec is zero.

Fixes golang/go#26034

Change-Id: I1ab400b8e09b5cfdac6b70a33f676770a48180b1
Reviewed-on: https://go-review.googlesource.com/120816
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: jimmy frasche <soapboxcicero@gmail.com>
2018-06-26 15:59:39 +00:00
Tobias Klauser
a200a19cb9 unix: don't check atime in TestUtimesNanoAt
If the underlying filesystem doesn't support atime or was mounted with the
noatime mount option, TestUtimesNanoAt fails when comparing atime:

--- FAIL: TestUtimesNanoAt (0.00s)
	syscall_linux_test.go:144: UtimesNanoAt: wrong atime: {1111 0}
	syscall_linux_test.go:147: UtimesNanoAt: wrong mtime: {3333 0}
FAIL
FAIL	golang.org/x/sys/unix	0.376s

Fix it by dropping the atime comparison, it's enough to verify UtimesNanoAt
working correctly by comparing mtime.

Fixes golang/go#26034

Change-Id: Id868f9d4c6a856a99ae930a46bfe91bd64ca8570
Reviewed-on: https://go-review.googlesource.com/120562
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-06-25 16:25:22 +00:00
Thanabodee Charoenpiriyakij
ad87a3a340 unix: check faccessat flags parameter on Linux
Currently Linux faccessat(2) syscall implementation doesn't support the
flags parameter. As per discuss in golang/go#25845, permit the same flags
as glibc [1].

[1] https://sourceware.org/git/?p=glibc.git;a=blob;f=sysdeps/unix/sysv/linux/faccessat.c;h=ea42b2303ff4b2d2d6548ea04376fb265f773436;hb=HEAD

Fixes golang/go#25845

Change-Id: I390ba14b2816283399472f3572967b19d0a36042
Reviewed-on: https://go-review.googlesource.com/119495
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-06-20 13:35:08 +00:00
Tobias Klauser
c11f84a56e unix: don't check atime in TestStatx
On some builders TestStatx occassionally fails when comparing atime
between Statx and Stat/Lstat.

--- FAIL: TestStatx (0.00s)
	syscall_linux_test.go:365: Statx: returned stat atime does not match Lstat

Fix it by dropping the atime comparison, it's enough to verify Statx
working correctly by comparing ctime and mtime. Also, not all
filesystems support atime.

Change-Id: I7da68bd20b9b21274c4993aa2c4241395d2c933a
Reviewed-on: https://go-review.googlesource.com/114616
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-05-25 14:28:21 +00:00
Tobias Klauser
04b83988a0 unix: fix or skip failing tests on android and iOS
The mkfifo syscall is disallowed on android and iOS. sched_setaffinity
is disallowed on android. Skip all tests which use them.

/usr/bin does not exist on android. Use /system/bin in TestGetwd
instead, like TestChdirAndGetwd in the os package.

Like linux, android does not support Fchmodat with flags != 0. Adjust
TestFchmodat accordingly.

TestDevices might stat some device files which are not accessible, skip
those.

iOS cannot exec subprocesses, thus skip TestPassFD.

Fixes golang/go#25535

Change-Id: Ic764b9152f0a7b703ad4f47fdb1a9a5e94718154
Reviewed-on: https://go-review.googlesource.com/114395
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-05-24 13:58:53 +00:00
Hana Kim
f3b0f5faf5 unix: skip TestStatx if the operation is not permitted
Fixes golang/go#25529

Change-Id: Ifb7060106608fab0c87ce4596c9f16c14bde6205
Reviewed-on: https://go-review.googlesource.com/114093
Reviewed-by: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-05-23 20:51:00 +00:00
Tobias Klauser
88eb85aaee unix: add tests for *xattr functions
Based on the tests in github.com/pkg/xattr

Change-Id: I3af73ad538877da042602708248063c218260a2e
Reviewed-on: https://go-review.googlesource.com/114135
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-05-22 22:42:04 +00:00
Tobias Klauser
641605214e unix: enable TestFchmodat for all Unices
Now that Fchmodat is available on all Unices, move TestFchmodat to
syscall_unix_test.go and adjust it such that Fchmodat with
AT_SYMLINK_NOFOLLOW in flags is tested where supported.

Change-Id: I41ef5b874e36d84ed4866706dbba075c39aa00d4
Reviewed-on: https://go-review.googlesource.com/101615
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-03-21 07:42:03 +00:00
Tobias Klauser
5c2edb58fd unix: add Fstatat on OpenBSD
Also enable TestFstatat for all Unices now that they all implement
Fstatat.

Change-Id: I9722437042d5fc0df4a27d3a6a2be3d124c60057
Reviewed-on: https://go-review.googlesource.com/100617
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-03-15 07:57:55 +00:00
Tobias Klauser
8c0ece68c2 unix: extend rlimit test on Linux
The basic Getrlimit functionality is already tested in TestRlimit. Use
the Linux-specific test to check whether setting RLIMIT_AS has the
desired effect regarding mmap, as specified in
http://man7.org/linux/man-pages/man2/getrlimit.2.html

Change-Id: I3e2c5769d9144cb4059735709a89a12f42568465
Reviewed-on: https://go-review.googlesource.com/100175
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2018-03-13 07:58:20 +00:00
Michael Hudson-Doyle
349b81fb5c unix: skip SchedAffinity test on single CPU system
Because you can't bind a thread to the second CPU if it's not there.

Change-Id: I2af4e66667711dc9a3aa23fee073a70cdc5fdd4d
Reviewed-on: https://go-review.googlesource.com/99355
Run-TryBot: Michael Hudson-Doyle <michael.hudson@canonical.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-03-08 02:51:16 +00:00
Tobias Klauser
fff93fa7cd unix: add Statx on Linux
statx(2) allows to get enhanced file status information (not currently
available through the existing stat syscalls), lightweight stat,
heavyweight stat. The Statx_t type used by Statx has consistent field
sizes on all arches (with year-2038-capable timestamps) and is closer to
the BSD implementation of Stat_t.

See http://man7.org/linux/man-pages/man2/statx.2.html for details. The
syscall was added in Linux kernel 4.11.

See https://github.com/tklauser/statx for an example of how this
function and types can be used to report stat(1)-like file status
information.

Change-Id: I9e9642b5b42a393f94fd532453888ce9ba4f0003
Reviewed-on: https://go-review.googlesource.com/87555
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-01-15 08:58:44 +00:00
Tobias Klauser
52ba35ddf9 unix: check error return of os.Symlink in tests on Linux
Change-Id: Iddb6fbcb0f0f834fa9fd7ef95d57aa8c7b4007fd
Reviewed-on: https://go-review.googlesource.com/87575
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2018-01-15 08:58:03 +00:00
Tobias Klauser
12d9d5b281 unix: add SchedGetaffinity and SchedSetaffinity on Linux
SchedGetaffinity and SchedSetaffinity are used to get and set a thread's
CPU affinity mask.

See http://man7.org/linux/man-pages/man2/sched_setaffinity.2.html for
details.

Also add a manual implementation of CpuSet_t and the corresponding
accessor functions (mimicking the CPU_* macros from sched.h).

Fixes golang/go#11243

Change-Id: Ia5abc0053cd06810b3b09ab65c27434f5323c1ad
Reviewed-on: https://go-review.googlesource.com/85915
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2018-01-05 20:31:47 +00:00
Tobias Klauser
236baca679 unix: add timeout tests for Select and Pselect on Linux
Test for correct timeout behavior of Select and Pselect

Updates golang/go#22246

Change-Id: I86d1804c6ddf5072e93f3ef4f359198e732fae94
Reviewed-on: https://go-review.googlesource.com/84955
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-12-20 16:10:48 +00:00
Tobias Klauser
b8f5ef3219 unix: enable TestUname for all GOOSes
Change-Id: I0f9bbda1053bea93b00e47a2d90f380d83c5eb16
Reviewed-on: https://go-review.googlesource.com/82895
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-12-08 15:33:48 +00:00
Tobias Klauser
a204229cd8 unix: remove outdated comment in TestUname, omit string conversion
Follow the review comments by Brad in CL 79918.

Change-Id: Iedb27aa9582502a90231778f5032a2e0109a4621
Reviewed-on: https://go-review.googlesource.com/80015
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-11-27 19:08:27 +00:00
Tobias Klauser
4ff8c001ce unix: add Fstatat on Linux for all GOOSes
Looks like it's enough to just add wrappers pointing to the
corresponding SYS_FSTATAT{,64} or SYS_NEWFSTATAT syscall. Add a test to
verify that assumption which checks that the returned stat data matches
what is returned by Stat/Lstat.

Also add the AT_NO_AUTOMOUNT constant which may be used for the flags
parmeter.

Fixes golang/go#14216

Change-Id: I73f27b483bd97d2dcf09d4b95a7957e75d194395
Reviewed-on: https://go-review.googlesource.com/79795
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-11-24 17:10:47 +00:00
Tobias Klauser
4fe5d79250 unix: use keyed composite literal in TestSelect
Fixes the following vet error:

  syscall_linux_test.go:181: golang.org/x/sys/unix.Timeval composite literal uses unkeyed fields

Change-Id: I6973ad4ecd54b542074610a755573f98eb23f343
Reviewed-on: https://go-review.googlesource.com/75790
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-11-03 17:53:29 +00:00
Tobias Klauser
95c6576299 unix: enable TestPoll for all unix systems
Poll is now supported for all unix systems. Also enable TestPoll for all
of them.

Change-Id: Id6250702bf0d29c49fbeeed4cca21d232b72666a
Reviewed-on: https://go-review.googlesource.com/74310
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-10-31 08:18:56 +00:00
Tobias Klauser
4da7545edf unix: convert Utsname members from {u,}int8 array to byte array
In order to make conversion to string easier, change the Utsname
members from int8 array to byte array.

Also add a test on Linux for Uname and the string conversion of the
Utsname members.

Fixes golang/go#20753

Change-Id: Iec793dfb4a6dd8f3523cf0b6284a6162074f2e9e
Reviewed-on: https://go-review.googlesource.com/74331
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-10-31 08:17:53 +00:00
Tobias Klauser
bb1b7fe501 unix: add test for UtimesNanoAt on Linux
Add a test for UtimesNanoAt which makes sure the timestamp of a symlink
is updated.

Change-Id: I819e43db1d390fb37f011b34e58ff9d3d06595f1
Reviewed-on: https://go-review.googlesource.com/72377
Run-TryBot: Tobias Klauser <tobias.klauser@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
2017-10-25 08:55:50 +00:00
Carlos Eduardo Seo
429f518978 unix: update Select to use newselect on ppc64x
Analog to the runtime package, Select should be using newselect
instead of select. This change addresses this problem and regenerates
zsyscall_linux_* for ppc64 and ppc64le.

Updates golang/go#21946

Change-Id: I7ed5c2490ba2ce556f143f8e8377572ab345f7b8
Reviewed-on: https://go-review.googlesource.com/65091
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Lynn Boger <laboger@linux.vnet.ibm.com>
2017-09-22 12:34:23 +00:00
Tobias Klauser
c23410a886 unix: check Fchmodat flags parameter on Linux
Currently Linux' fchmodat(2) syscall implementation doesn't support the
flags parameter (though it might in future versions [1]). Fchmodat in
x/sys/unix takes the parameter and (wrongly) passes it on to the syscall
which will ignore it.

According to the POSIX.1-2008 manual page [2], AT_SYMLINK_NOFOLLOW is
the only valid value for the flags parameter and EOPNOTSUPP should be
returned in case changing the mode of a symbolic link is not supported
by the underlying system.  EINVAL should be returned for any other value
of the flags parameter.

  [1] https://patchwork.kernel.org/patch/9596301/
  [2] http://pubs.opengroup.org/onlinepubs/9699919799/functions/chmod.html

Change the Fchmodat implementation accordingly and also add the
corresponding test.

Fixes golang/go#20130

Change-Id: I62e677e6674d3702eaf388af0ac3d7e623a35c24
Reviewed-on: https://go-review.googlesource.com/46474
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2017-06-23 14:22:15 +00:00
Matt Layher
a55a760868 unix: add IoctlGetInt and IoctlSetInt on Linux
This CL adds basic integer get/set functions which wrap a generic
ioctl call.  The API is similar the one introduced for solaris/amd64
in CL 14587, but the request parameter has been changed to a uint
instead of an int.  This makes requests with a number larger than the
maximum signed 32-bit integer work on linux/386.

For consistency, the solaris/amd64 API has also been updated to make
use of a uint instead of an int for the request number.

Fixes golang/go#20474

Change-Id: Iaae1ee2e4bb4bfcc420dcec252fe53c8d90ce81d
Reviewed-on: https://go-review.googlesource.com/44009
Run-TryBot: Matt Layher <mdlayher@gmail.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2017-05-24 19:12:47 +00:00
kortschak
5a8c7f28c1 unix: add Ppoll support for linux
Use a shim for Poll on arm64.

Fixes golang/go#16052.

Change-Id: I929e7a2293561bddb9355bf65f98bc68b91905b2
Reviewed-on: https://go-review.googlesource.com/24062
Reviewed-by: Ian Lance Taylor <iant@golang.org>
Run-TryBot: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-06-14 16:43:59 +00:00
kortschak
7f918dd405 unix: add Poll for linux
Change-Id: I273bd852f85d204694872a1615be51dc027b97ee
Reviewed-on: https://go-review.googlesource.com/23661
Run-TryBot: Ian Lance Taylor <iant@golang.org>
Reviewed-by: Ian Lance Taylor <iant@golang.org>
TryBot-Result: Gobot Gobot <gobot@golang.org>
2016-06-11 01:26:39 +00:00
Hiroshi Ioka
7e44b69d78 x/sys/unix: fix invalid syscall on linux/arm
Some system calls are obsolete and no longer available for EABI.
This CL replace such system call usages.

Updates golang/go#14524

Change-Id: Ib99b239455ca677e46d7097911904c45119051bd
Reviewed-on: https://go-review.googlesource.com/19945
Run-TryBot: Brad Fitzpatrick <bradfitz@golang.org>
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
2016-02-28 22:21:53 +00:00