[libvirt] [PATCH 0/4] Introduce big test mock

Michal Privoznik mprivozn at redhat.com
Thu Apr 21 10:16:10 UTC 2016


What?
Big test mock that checks all our file accesses whether we are
touching anything outside $srcdir or $builddir.

Why?
Because it has happened in the past (and is happening even now as
you'll see later) that our test suite produces nondeterministic
results because of a file in live system being accessible or
having some specific value.

How?
Well, this is merely introducing a mock library that every C
program on Linux will use. I'm not aware of any approach for our
shell tests. The mock library then collects all the paths outside
$srcdir or $builddir and prints them into a file. The file is
then checked against a white list, because some accesses might be
desirable.
Unfortunately, as you'll learn in the 4/4 commit message, I was
unable to wire this up to 'make check' so this is accessible
under 'make check-access' target.
If there's some access outside aforementioned directories, the
path will be printed out. So far there is plenty of them. For
instance, in qemuxml2argvtest we are checking
/proc/sys/crypto/fips_enabled for each test. Ouch.

What's left to do?
a) Enhance white list
b) Wire this up to 'check'
c) Test
d) Review

Michal Privoznik (4):
  seclabeltest: Update to use VIRT_TEST_MAIN
  tests: Introduce global mock library
  virtestmock: Print invalid file accesses into a file
  tests: Introduce check-file-access.pl

 .gitignore                      |   1 +
 HACKING                         |  11 ++
 Makefile.am                     |   3 +
 cfg.mk                          |   8 +-
 docs/hacking.html.in            |  15 +++
 tests/Makefile.am               |  28 +++-
 tests/check-file-access.pl      | 106 +++++++++++++++
 tests/file_access_whitelist.txt |  19 +++
 tests/seclabeltest.c            |   7 +-
 tests/testutils.c               |  58 ++++++++-
 tests/testutils.h               |  29 +----
 tests/vircgroupmock.c           |   6 +-
 tests/virpcimock.c              |   6 +-
 tests/virtestmock.c             | 279 ++++++++++++++++++++++++++++++++++++++++
 14 files changed, 535 insertions(+), 41 deletions(-)
 create mode 100755 tests/check-file-access.pl
 create mode 100644 tests/file_access_whitelist.txt
 create mode 100644 tests/virtestmock.c

-- 
2.7.3




More information about the libvir-list mailing list