jaypipes / ghw

Go HardWare discovery/inspection library
Apache License 2.0
1.62k stars 174 forks source link

Fix #306 #307

Closed taigrr closed 2 years ago

taigrr commented 2 years ago

Please see #306 The HEAD of main already fails existing test cases, and this patch causes those test cases to pass.

tai@juggernaut:~/code/foss/ghw/pkg/snapshot[jaypipes ?]$ go test
--- FAIL: TestCloneSystemTree (0.07s)
    clonetree_linux_test.go:85: Expected nil err, but got open /sys/devices/system/node/node0/hugepages/hugepages-1048576kB/demote: permission denied
FAIL
exit status 1
FAIL    github.com/jaypipes/ghw/pkg/snapshot    0.076s
tai@juggernaut:~/code/foss/ghw/pkg/snapshot[jaypipes ?]$ git co hugepages-demote
Switched to branch 'hugepages-demote'
Your branch is up to date with 'origin/hugepages-demote'.
tai@juggernaut:~/code/foss/ghw/pkg/snapshot[hugepages-demote ?]$ go test
PASS
ok      github.com/jaypipes/ghw/pkg/snapshot    0.100s
tai@juggernaut:~/code/foss/ghw/pkg/snapshot[hugepages-demote ?]$
taigrr commented 2 years ago

Looks like the project is using go <= 1.15. I'll update the code to be more backwards compatible.

ffromani commented 2 years ago

the proper fix would be to NOT copy the write-only files, we had some examples of this already. But we can improve later, this seems like a good enough fix. Thanks!

taigrr commented 2 years ago

Aha, I referenced the code here: https://github.com/jaypipes/ghw/blob/c82d7b1ceacb7487d9f12ef97e1ffcf65144977d/pkg/snapshot/clonetree_block_linux.go#L122-L130

ffromani commented 2 years ago

Aha, I referenced the code here:

https://github.com/jaypipes/ghw/blob/c82d7b1ceacb7487d9f12ef97e1ffcf65144977d/pkg/snapshot/clonetree_block_linux.go#L122-L126

sure, again this fix is good! we can perhaps improve even more, but this can wait a bit. Better to have a working ghw-snapshot sooner than later.

If I get some more ghw time this week, I'll perhaps post a further refinement.

jaypipes commented 2 years ago

@taigrr hey, sorry for the late response here, just wanted to say thank you for the bug report and the fix! :)

taigrr commented 2 years ago

@jaypipes no worries, we got there :)