tests,cmd/snap-confine: port older snapd-discard-ns tests #3252

Merged
merged 5 commits into from May 3, 2017

Conversation

Projects
None yet
2 participants
Contributor

zyga commented Apr 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

zyga added some commits Apr 28, 2017

tests,cmd/snap-confine: port older snapd-discard-ns tests
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>
tests: port test to work on ubuntu 14.04
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>

@zyga zyga requested a review from jdstrand Apr 28, 2017

tests/main/snap-discard-ns/task.yaml
+ 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

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

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.

tests/main/snap-discard-ns/task.yaml
+ 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

jdstrand May 1, 2017

Contributor

Also, I understand why 'nsfs' and '0x6e736673', but why 'proc'? If that is intentional, please comment on why.

@zyga

zyga May 2, 2017

Contributor

proc is there because on some older kernels there is no nsfs yet.

@jdstrand

jdstrand May 2, 2017

Contributor

What kernels? What does the output look like? Please document what stat outputs for each of the greps.

@zyga

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.

tests: justify the use of proc
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>

Note the added tests are different from the files being removed which is why I felt the comments were warranted.

@zyga zyga merged commit 08b42e2 into snapcore:master May 3, 2017

7 checks passed

artful-amd64 autopkgtest finished (success)
Details
continuous-integration/travis-ci/pr The Travis CI build passed
Details
xenial-amd64 autopkgtest finished (success)
Details
xenial-i386 autopkgtest finished (success)
Details
xenial-ppc64el autopkgtest finished (success)
Details
yakkety-amd64 autopkgtest finished (success)
Details
zesty-amd64 autopkgtest finished (success)
Details

@zyga zyga deleted the zyga:followup/snap-confine-spread/1 branch May 3, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment