tests: Allow profile names that don't match an exec

Allow for the regression tests to specify arbitrary profile names
without hitting fatal errors or getting warnings from mkprofile.pl.

This allows for a test to have a line like this:

  genprofile change_profile->':arbitrary_name -- \
	     image=arbitrary_name addimage:$test

In the example above, $test can call aa_change_onexec("arbitrary_name")
and then re-exec itself to test behavior across exec transitions.

Signed-off-by: Tyler Hicks <tyhicks@canonical.com>
Acked-by: John Johansen <john.johansen@canonical.com>
This commit is contained in:
Tyler Hicks 2014-05-27 09:17:31 +02:00
parent 5ffb6eb26b
commit 0cf50140a5
2 changed files with 7 additions and 5 deletions

View file

@ -362,7 +362,7 @@ sub emit_flags($) {
# generate profiles based on cmd line arguments
sub gen_from_args() {
my $bin = shift @ARGV;
!(-e $bin || $nowarn) && print STDERR "Warning: execname '$bin': no such file or directory\n";
my $addimage = 0;
unless ($nodefault) {
gen_default_rules();
@ -396,12 +396,18 @@ sub gen_from_args() {
gen_hat($rule);
} elsif ($rule =~ /^addimage:/) {
gen_addimage($rule);
$addimage = 1;
} else {
gen_file($rule);
}
}
!(-e $bin || $addimage || $nowarn) && print STDERR "Warning: execname '$bin': no such file or directory\n";
print STDOUT "# Profile autogenerated by $__VERSION__\n";
if (not substr($bin, 0, 1) eq "/") {
print STDOUT "profile "
}
print STDOUT "$bin ";
emit_flags('__no_hat');
print STDOUT "{\n";

View file

@ -350,10 +350,6 @@ fi
# mandatory after --
case "$1" in
image=*) imagename=`echo $1 | sed 's/^image=\([^:]*\).*$/\1/'`
if [ ! -x "$imagename" ]
then
fatalerror "invalid imagename specified in input '$1'"
fi
num_emitted=0
shift
;;