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

New api to read and check specific label in context of the given file #2197

Merged
merged 1 commit into from Aug 27, 2019

Conversation

bssrikanth
Copy link
Contributor

Currently there are only methods to get and set the context of the
given file. There are usecases to check for specific labels in the
context of the file. This commit introduces new method to do the same.

Signed-off-by: Srikanth Aithal sraithal@linux.vnet.ibm.com

Currently there are only methods to get and set the context of the
given file. There are usecases to check for specific labels in the
context of the file. This commit introduces new method to do the same.

Signed-off-by: Srikanth Aithal <sraithal@linux.vnet.ibm.com>
@bssrikanth
Copy link
Contributor Author

test results of case when context of filename is returned empty:

2019-08-19 06:41:23,711 utils_selinux    L0296 WARNI| Context of shared filename '/var/lib/libvirt/images/avocado_1t2CsG/test.iso' is None
2019-08-19 06:41:23,759 libvirt_vm       L2140 DEBUG| Destroying VM
2019-08-19 06:41:24,291 libvirt_vm       L2175 WARNI| Requested MAC address release from persistent vm vm1. Ignoring.
2019-08-19 06:41:24,392 virsh            L1434 DEBUG| Undefine VM vm1
2019-08-19 06:41:24,411 virsh            L1418 DEBUG| Define VM from /var/tmp/xml_utils_temp_JiTBLw.xml
2019-08-19 06:41:24,581 virsh            L1434 DEBUG| Undefine VM vm2
2019-08-19 06:41:24,603 virsh            L1418 DEBUG| Define VM from /var/tmp/xml_utils_temp_bOb5BA.xml
2019-08-19 06:41:24,683 stacktrace       L0041 ERROR|
2019-08-19 06:41:24,683 stacktrace       L0044 ERROR| Reproduced traceback from: /usr/local/lib/python2.7/dist-packages/avocado_plugins_vt-69.0-py2.7.egg/avocado_vt/test.py:449
2019-08-19 06:41:24,683 stacktrace       L0047 ERROR| Traceback (most recent call last):
2019-08-19 06:41:24,683 stacktrace       L0047 ERROR|   File "/home/srikanth/avocado-fvt-wrapper/data/avocado-vt/test-providers.d/downloads/powerkvm-libvirt/libvirt/tests/src/virtual_disks/virtual_dd
isks_multivms.py", line 323, in run
2019-08-19 06:41:24,683 stacktrace       L0047 ERROR|     test.fail("Context of shared iso is not expected.")
2019-08-19 06:41:24,683 stacktrace       L0047 ERROR|   File "/usr/local/lib/python2.7/dist-packages/avocado_framework-68.0-py2.7.egg/avocado/core/test.py", line 1025, in fail
2019-08-19 06:41:24,684 stacktrace       L0047 ERROR|     raise exceptions.TestFail(message)
2019-08-19 06:41:24,684 stacktrace       L0047 ERROR| TestFail: Context of shared iso is not expected.
2019-08-19 06:41:24,684 stacktrace       L0048 ERROR|

@bssrikanth
Copy link
Contributor Author

@xutian thanks for reviewing. I have updated right version here. Results are as well posted @ autotest/tp-libvirt#2279

Copy link
Member

@balamuruhans balamuruhans left a comment

Choose a reason for hiding this comment

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

Looks good to me,

logging.debug("Context of shared filename '%s' is '%s'" %
(filename, se_label))
if label not in se_label:
return False
Copy link
Member

Choose a reason for hiding this comment

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

return label not in se_label

else:
logging.warning("Context of shared filename '%s' is None" % filename)
return False
return True
Copy link
Member

Choose a reason for hiding this comment

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

return bool(se_label)

@sathnaga
Copy link
Member

Let's merge this, we can take minor changes as separate PR.

@sathnaga sathnaga merged commit 0df8f94 into avocado-framework:master Aug 27, 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
Development

Successfully merging this pull request may close these issues.

None yet

4 participants