diff --git a/.bzrignore b/.bzrignore index 433cce83d..70dd4d854 100644 --- a/.bzrignore +++ b/.bzrignore @@ -237,3 +237,4 @@ tests/regression/apparmor/unix_fd_client tests/regression/apparmor/unix_fd_server tests/regression/apparmor/unlink tests/regression/apparmor/xattrs +tests/regression/apparmor/coredump diff --git a/tests/regression/apparmor/Makefile b/tests/regression/apparmor/Makefile index dba660371..7068a4086 100644 --- a/tests/regression/apparmor/Makefile +++ b/tests/regression/apparmor/Makefile @@ -22,6 +22,7 @@ SRC=access.c \ chmod.c \ chown.c \ clone.c \ + coredump.c \ deleted.c \ environ.c \ env_check.c \ @@ -113,6 +114,7 @@ TESTS=access \ changehat_misc \ chdir \ clone \ + coredump \ deleted \ environ \ exec \ diff --git a/tests/regression/apparmor/coredump.c b/tests/regression/apparmor/coredump.c index d733ab664..41e910230 100644 --- a/tests/regression/apparmor/coredump.c +++ b/tests/regression/apparmor/coredump.c @@ -1,7 +1,9 @@ +#include int *ptr; /* * Copyright (C) 2002-2005 Novell/SUSE + * Copyright (C) 2010 Canonical, Ltd * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License as @@ -9,7 +11,7 @@ int *ptr; * License. */ -main() +int main(int argc, char *argv[]) { printf("This will cause a sigsegv\n"); diff --git a/tests/regression/apparmor/coredump.sh b/tests/regression/apparmor/coredump.sh index a8bf4db88..52546910a 100644 --- a/tests/regression/apparmor/coredump.sh +++ b/tests/regression/apparmor/coredump.sh @@ -1,7 +1,6 @@ #! /bin/bash -# $Id$ - # Copyright (C) 2002-2005 Novell/SUSE +# Copyright (C) 2010 Canonical, Ltd # # This program is free software; you can redistribute it and/or # modify it under the terms of the GNU General Public License as @@ -11,26 +10,52 @@ #=NAME coredump #=DESCRIPTION coredump test +cleancorefile() +{ + rm -f core core.* +} + checkcorefile() { -_corefilelist=`echo core.*` -if [ "$_corefilelist" = "core.*" ] -then - _corefile=no -else - _corefile=yes -fi + # global _testdesc _pfmode _known outfile + if [ ${1:0:1} == "x" ] ; then + requirement=${1#x} + _known=" (known problem)" + else + requirement=$1 + _known="" + fi -if [ "$1" = "yes" -a "$_corefile" = "no" ] -then - echo "Error: corefile expected but not present - $2" -elif [ "$1" = "no" -a "$_corefile" = "yes" ] -then - echo "Error: corefile present when not expected -- $2" -fi + _corefilelist=`echo core.*` + if [ ! -f core ] && [ "$_corefilelist" = "core.*" ] + then + _corefile=no + else + _corefile=yes + fi -unset _corefile _corefilelist -rm -f core.* + if [ "$requirement" = "yes" -a "$_corefile" = "no" ] ; then + if [ -n $_known ] ; then + echo -n "XFAIL: " + fi + echo "Error: corefile expected but not present - $2" + if [ -z $_known ] ; then + cat $profile + testfailed + fi + elif [ "$requirement" = "no" -a "$_corefile" = "yes" ] ; then + if [ -n "$_known" ] ; then + echo -n "XFAIL: " + fi + echo "Error: corefile present when not expected -- $2" + if [ -z "$_known" ] ; then + cat $profile + testfailed + fi + fi + + unset _corefile _corefilelist + cleancorefile } pwd=`dirname $0` @@ -45,15 +70,18 @@ nocoreperm=ix # enable coredumps ulimit -c 1000000 +cleancorefile +checkcorefile no "COREDUMP (starting with clean slate)" # PASS TEST, no confinement +cleancorefile echo "*** A 'Segmentation Fault' message from bash is expected for the following test" runchecktest "COREDUMP (no confinement)" signal11 checkcorefile yes "COREDUMP (no confinement)" # PASS TEST, with r confinement -genprofile $test:$coreperm -cat $profile +cleancorefile +genprofile image=$test:$coreperm echo echo "*** A 'Segmentation Fault' message from bash is expected for the following test" @@ -61,10 +89,10 @@ runchecktest "COREDUMP ($coreperm confinement)" signal11 checkcorefile yes "COREDUMP ($coreperm confinement)" # FAIL TEST, with x confinement -genprofile $test:$nocoreperm -cat $profile +cleancorefile +genprofile image=$test:$nocoreperm echo echo "*** A 'Segmentation Fault' message from bash is expected for the following test" runchecktest "COREDUMP ($nocoreperm confinement)" signal11 -checkcorefile no "COREDUMP ($nocoreperm confinement)" +checkcorefile xno "COREDUMP ($nocoreperm confinement)" diff --git a/tests/regression/apparmor/prologue.inc b/tests/regression/apparmor/prologue.inc index be5eb6921..ece8b5621 100755 --- a/tests/regression/apparmor/prologue.inc +++ b/tests/regression/apparmor/prologue.inc @@ -415,22 +415,12 @@ fi # it is most often used after --, in fact it is basically # mandatory after -- case "$1" in - profile=*) imagename=`echo $1 | sed 's/^profile=[rix]*//'` - perm=`echo $1 | sed -n 's/^profile=\([rix]*\).*$/\1/p'` - if [ -n "$perm" ] - then - imageperm=$perm - fi - num_emitted=0 - shift - ;; - - image=*) imagename=`echo $1 | sed 's/^image=[rix]*//'` + image=*) imagename=`echo $1 | sed 's/^image=\([^:]*\).*$/\1/'` if [ ! -x "$imagename" ] then fatalerror "invalid imagename specified in input '$1'" fi - perm=`echo $1 | sed -n 's/^image=\([rix]*\).*$/\1/p'` + perm=`echo $1 | sed -n 's/^image=[^:]*:\(.*\)$/\1/p'` if [ -n "$perm" ] then imageperm=$perm