mirror of
https://gitlab.com/apparmor/apparmor.git
synced 2025-03-04 08:24:42 +01:00
Merge SeverityVarsTest: Make order of variable replacements constant
... using [] instead of {} This should keep the order of checking (and therefore code coverage) constant, and should fix the randomly appearing partial coverage in severity.py handle_variable_rank(). In some random cases (depending in which order the replacements were done and checked for their severity), the coverage report indicated that the 'elif' condition was never false. Note: This is only "coverage cosmetics". In "real users", it doesn't matter in which order the variable replacements are checked because the result doesn't depend on the ordering. MR: https://gitlab.com/apparmor/apparmor/-/merge_requests/790 Acked-by: John Johansen <john.johansen@canonical.com>
This commit is contained in:
commit
572c342a2b
1 changed files with 8 additions and 7 deletions
|
@ -89,13 +89,14 @@ class SeverityVarsTest(SeverityBaseTest):
|
|||
|
||||
def _run_test(self, params, expected):
|
||||
vars = {
|
||||
'@{HOME}': {'@{HOMEDIRS}/*/', '/root/'},
|
||||
'@{HOMEDIRS}': {'/home/', '/storage/'},
|
||||
'@{multiarch}': {'*-linux-gnu*'},
|
||||
'@{TFTP_DIR}': {'/var/tftp /srv/tftpboot'},
|
||||
'@{PROC}': {'/proc/'},
|
||||
'@{somepaths}': {'/home/foo/downloads', '@{HOMEDIRS}/foo/.ssh/'},
|
||||
'@{strangevar}': ['/srv/', '/proc/'], # Note: using [] instead of {} is intentional to keep order of checking (and therefore code coverage) constant
|
||||
# Note: using [] instead of {} is intentional to keep order of checking (and therefore code coverage) constant
|
||||
'@{HOME}': ['@{HOMEDIRS}/*/', '/root/'],
|
||||
'@{HOMEDIRS}': ['/home/', '/storage/'],
|
||||
'@{multiarch}': ['*-linux-gnu*'],
|
||||
'@{TFTP_DIR}': ['/var/tftp /srv/tftpboot'],
|
||||
'@{PROC}': ['/proc/'],
|
||||
'@{somepaths}': ['/home/foo/downloads', '@{HOMEDIRS}/foo/.ssh/'],
|
||||
'@{strangevar}': ['/srv/', '/proc/'],
|
||||
}
|
||||
self.sev_db.set_variables(vars)
|
||||
self._simple_severity_w_perm(params[0], params[1], expected)
|
||||
|
|
Loading…
Add table
Reference in a new issue