Commit Graph

10 Commits

Author SHA1 Message Date
Michal Privoznik
288e0ab106 tests: Turn virFileWrapperAddPrefix to void
In theory, it's nice to have virFileWrapperAddPrefix() return a
value that indicates if the function succeeded or not. But in
practice, nobody checks for that and in fact blindly believes
that the function succeeded. Therefore, make the function return
nothing and just abort() if it would fail.

Signed-off-by: Michal Privoznik <mprivozn@redhat.com>
Reviewed-by: Martin Kletzander <mkletzan@redhat.com>
Reviewed-by: Erik Skultety <eskultet@redhat.com>
2019-03-13 14:15:35 +01:00
Erik Skultety
5165ff0971 src: More cleanup of some system headers already contained in internal.h
All of the ones being removed are pulled in by internal.h. The only
exception is sanlock which expects the application to include <stdint.h>
before sanlock's headers, because sanlock prototypes use fixed width
int, but they don't include stdint.h themselves, so we have to leave
that one in place.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Acked-by: Michal Privoznik <mprivozn@redhat.com>
2018-09-20 10:16:39 +02:00
Erik Skultety
9403b63102 internal: Move <stdio.h> include to internal.h
It doesn't really make sense for us to have stdlib.h and string.h but
not stdio.h in the internal.h header.

Signed-off-by: Erik Skultety <eskultet@redhat.com>
Acked-by: Michal Privoznik <mprivozn@redhat.com>
2018-09-20 10:16:38 +02:00
Andrea Bolognani
3e7db8d3e8 Remove backslash alignment attempts
Right-aligning backslashes when defining macros or using complex
commands in Makefiles looks cute, but as soon as any changes is
required to the code you end up with either distractingly broken
alignment or unnecessarily big diffs where most of the changes
are just pushing all backslashes a few characters to one side.

Generated using

  $ git grep -El '[[:blank:]][[:blank:]]\\$' | \
    grep -E '*\.([chx]|am|mk)$$' | \
    while read f; do \
      sed -Ei 's/[[:blank:]]*[[:blank:]]\\$/ \\/g' "$f"; \
    done

Signed-off-by: Andrea Bolognani <abologna@redhat.com>
2017-11-03 13:24:12 +01:00
Jiri Denemark
2925f9395e tests: Fix build with clang
clang doesn't like mode_t type as an argument to va_arg():

error: second argument to 'va_arg' is of promotable type 'mode_t' (aka
'unsigned short'); this va_arg has undefined behavior because arguments
will be promoted to 'int'

    mode = va_arg(ap, mode_t);
                      ^~~~~~

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2017-10-05 09:09:50 +02:00
Luyao Huang
3e581d150a tests: Do not ignore mode parameter in mocked open()
This is normally not an issue since the tests which use mocked open() do
not create files. But once coverage build is enabled, gcov_open will use
O_CREATE and real_open will read random data rather than the actual mode
argument.

Signed-off-by: Jiri Denemark <jdenemar@redhat.com>
2017-10-04 11:57:42 +02:00
Martin Kletzander
ab0e027ffe tests: Fix indentation in virfilewrapper.c
Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2017-08-14 10:01:12 +02:00
Daniel P. Berrange
300c7c7035 tests: stub out virfilewrapper.c on Win32
The Win32 platform can not do link time overrides in the same way
that we can on POSIX / ELF based platforms, so we cannot build
the virfilewrapper.c code reliably. Just stub it out on Win32
so it is a no-op. Tests that use this file are already written
to skip on Win32.

Signed-off-by: Daniel P. Berrange <berrange@redhat.com>
2017-05-11 11:45:41 +01:00
Roman Bogorodskiy
058bf5549f tests: fix virfilewrapper
If __lxstat() and __xstat() functions are not available, build fails with:

  CC       virfilewrapper.o
virfilewrapper.c:180:5: error: no previous prototype for function '__lxstat' [-Werror,-Wmissing-prototypes]
int __lxstat(int ver, const char *path, struct stat *sb)
    ^
virfilewrapper.c:208:5: error: no previous prototype for function '__xstat' [-Werror,-Wmissing-prototypes]
int __xstat(int ver, const char *path, struct stat *sb)

Luckily, we already check presence of these functions in configure
using AC_CHECK_FUNCS, so just don't wrap these if they're not available.

Signed-off-by: Roman Bogorodskiy <bogorodskiy@gmail.com>
2017-05-09 17:03:02 +04:00
Martin Kletzander
ae60ea48bc tests: Add virfilewrapper -- the new super "mock"
This mock (which is actually not mock at all, see later) can redirect
all accesses to a path into another path.  There is no need to
create mocks for particular directories, you just create a directory
with all the data a redirect the test there.

In the future, this should also be able to register callbacks for
calls/paths, e.g. when the test is going to write into anything under
"/sys/devices", call function fce();  Then in the open() call we would
add information about the fd into some structure and in write() we
would call fce() with parameters like @path to write to, @data to
be written and pointer to optional return value, so that fce() itself
could stop the call from happening or change its behaviour.  But
that's an idea for a latter day.

This is not a mock because it will not be preloaded, but compiled in
the test itself.  See future patches for usage.

Signed-off-by: Martin Kletzander <mkletzan@redhat.com>
2017-05-09 13:12:40 +02:00