Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
tests,cmd/snap-confine: port older snapd-discard-ns tests #3252
Conversation
zyga
added some commits
Apr 28, 2017
zyga
requested a review
from
jdstrand
Apr 28, 2017
| + echo "We can discard the namespace after a snap runs" | ||
| + test-snapd-tools.success | ||
| + # The last hex is the same as nsfs but older stat on ubuntu 14.04 doesn't know | ||
| + stat -f -c %T /run/snapd/ns/test-snapd-tools.mnt | MATCH 'proc|nsfs|0x6e736673' |
jdstrand
May 1, 2017
Contributor
According to https://github.com/snapcore/spread, "MATCH - Run grep -q -e on stdin. Without match, print error including content." If I run this as is, it fails:
# 17.04
$ stat -f -c %T /run/snapd/ns/hello-world.mnt
nsfs
$ stat -f -c %T /run/snapd/ns/hello-world.mnt | grep -q -e 'proc|nsfs|0x6e736673' || echo FAIL
FAIL
# 14.04
$ stat -f -c %T /run/snapd/ns/hello-world.mnt
UNKNOWN (0x6e736673)
$ stat -f -c %T /run/snapd/ns/hello-world.mnt | grep -q -e 'proc|nsfs|0x6e736673' || echo FAIL
FAIL
You need to backslash the '|'. Eg:
$ stat -f -c %T /run/snapd/ns/hello-world.mnt | grep -q -e 'proc\|nsfs\|0x6e736673' && echo PASS
PASS
zyga
May 2, 2017
Contributor
That part of documentation is out of date. Spread's MATCH is actually grep -q -E "$@". If I use \| with -E the expression no longer works.
| + echo "We can discard the namespace after a snap runs" | ||
| + test-snapd-tools.success | ||
| + # The last hex is the same as nsfs but older stat on ubuntu 14.04 doesn't know | ||
| + stat -f -c %T /run/snapd/ns/test-snapd-tools.mnt | MATCH 'proc|nsfs|0x6e736673' |
jdstrand
May 1, 2017
Contributor
Also, I understand why 'nsfs' and '0x6e736673', but why 'proc'? If that is intentional, please comment on why.
jdstrand
May 2, 2017
Contributor
What kernels? What does the output look like? Please document what stat outputs for each of the greps.
zyga
May 2, 2017
Contributor
NOTE: This is not a new test, I'm just re-enabling an existing test.
The affected kernel is, for example, one used on CentOS 7. I tested 3.10.x which doesn't have nsfs yet. The output of stat is similar, except for the filesystem magic number.
jdstrand
approved these changes
May 2, 2017
Note the added tests are different from the files being removed which is why I felt the comments were warranted.
zyga commentedApr 28, 2017
This patch removes the (unused) spread test from snap-confine directory
and adds the useful parts to the existing spread test for
snap-discard-ns.
Signed-off-by: Zygmunt Krynicki zygmunt.krynicki@canonical.com