Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tests fail on ppc64 #15

Closed
eclipseo opened this issue Jul 29, 2021 · 1 comment · Fixed by #16
Closed

Tests fail on ppc64 #15

eclipseo opened this issue Jul 29, 2021 · 1 comment · Fixed by #16

Comments

@eclipseo
Copy link

While building on Fedora Rawhide on ppc64le, numcpus doesn't seem to work properly:

Testing    in: /builddir/build/BUILD/numcpus-0.2.3/_build/src
         PATH: /builddir/build/BUILD/numcpus-0.2.3/_build/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/sbin
       GOPATH: /builddir/build/BUILD/numcpus-0.2.3/_build:/usr/share/gocode
  GO111MODULE: off
      command: go test -buildmode pie -compiler gc -ldflags " -X github.com/tklauser/numcpus/version=0.2.3 -extldflags '-Wl,-z,relro -Wl,--as-needed  -Wl,-z,now -specs=/usr/lib/rpm/redhat/redhat-hardened-ld  '"
      testing: github.com/tklauser/numcpus
github.com/tklauser/numcpus
--- FAIL: TestGetPresent (0.00s)
    numcpus_test.go:103: Present = 8
    numcpus_test.go:105: GetPresent returned 8, want 40 (getconf _NPROCESSORS_CONF)
FAIL
@tklauser
Copy link
Owner

Thanks for the report @eclipseo! Could you please share the content of the files in /sys/devices/system/cpu* as well as the content of /proc/cpuinfo from the machine where this occurs?

tklauser added a commit that referenced this issue Aug 16, 2021
It seems the assumption that `getconf _NPROCESSORS_CONF` returns
the number of CPUs in `/sys/devices/system/cpu/present` is not always
true on all systems.

Inspecting the code of glibc's getconf implementation it seems the value
returned by `getconf _NPROCESSORS_CONF` is the total number of `cpuN`
directories found in `/sys/devices/system/cpu` while
`numcpus.GetPresent` reads `/sys/devices/system/cpu/present`. Thus, drop
the check to avoid failing tests where this might not be true (such as
on some ppc64 systems.

Fixes #15
tklauser added a commit that referenced this issue Aug 16, 2021
It seems the assumption that `getconf _NPROCESSORS_CONF` returns
the number of CPUs in `/sys/devices/system/cpu/present` is not always
true on all systems.

Inspecting the code of glibc's getconf implementation it seems the value
returned by `getconf _NPROCESSORS_CONF` is the total number of `cpuN`
directories found in `/sys/devices/system/cpu` while
`numcpus.GetPresent` reads `/sys/devices/system/cpu/present`. Thus, drop
the check to avoid failing tests where this might not be true (such as
on some ppc64 systems.

Fixes #15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants