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: don't guess in is_classic_confinement_supported #7396

Merged

Conversation

zyga
Copy link
Collaborator

@zyga zyga commented Sep 3, 2019

Snapd can tell us if the system supports classic confinement. We don't
need to inspect SPREAD_SYSTEM to do that.

Signed-off-by: Zygmunt Krynicki me@zygoon.pl

Snapd can tell us if the system supports classic confinement. We don't
need to inspect SPREAD_SYSTEM to do that.

Signed-off-by: Zygmunt Krynicki <me@zygoon.pl>
return 0
;;
esac
if snap debug sandbox-features --required=confinement-options:classic; then
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

That requires snapd to be running though? Given that the travis job complete I guess it's not really called when snapd is down.

Why not:

is_classic_confinement_supported() {
    snap debug sandbox-features --required=confinement-options:classic
}

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm, because I assumed it would break set -e.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It seems like we stumbled into another shell pitfall - set -e does not happen inside shell function, see below. However Maciej suggestion works because its the last command inside the function so the exit status of the function is set correctly.

$ sh /tmp/lala.sh 
#!/bin/sh -e

cat $0

func() {
    echo in_func_header
    false
    echo in_func_footer
}

func
echo $?
echo "after func"

# OUTPUT:
in_func_header
in_func_footer
0
after func

It seems other people stumbled on this as well: https://stackoverflow.com/questions/4072984/how-do-i-get-effect-and-usefuless-of-set-e-inside-a-shell-function - shell is just not a good language it seems :/

@sergiocazzolato
Copy link
Collaborator

Nice change, thanks!!

@bboozzoo bboozzoo merged commit b10af91 into snapcore:master Sep 4, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
4 participants