On Thu, Mar 03, 2016 at 06:11:45PM +0100, Michal Privoznik wrote:
A small test to see how is the nss module working.
Signed-off-by: Michal Privoznik <mprivozn(a)redhat.com>
---
cfg.mk | 2 +-
tests/Makefile.am | 18 ++++
tests/nssdata/virbr0.status | 20 +++++
tests/nssdata/virbr1.status | 14 ++++
tests/nssmock.c | 140 +++++++++++++++++++++++++++++++
tests/nsstest.c | 195 ++++++++++++++++++++++++++++++++++++++++++++
6 files changed, 388 insertions(+), 1 deletion(-)
create mode 100644 tests/nssdata/virbr0.status
create mode 100644 tests/nssdata/virbr1.status
create mode 100644 tests/nssmock.c
create mode 100644 tests/nsstest.c
+int
+open(const char *path, int flags, ...)
+{
+ int ret;
+ char *newpath = NULL;
+
+ init_syms();
+
+ if (STRPREFIX(path, LEASEDIR) &&
No need to prefix it since getrealpath() does that. Call it
unconditionally and then...
+ getrealpath(&newpath, path) < 0)
+ return -1;
+
+ if (flags & O_CREAT) {
+ va_list ap;
+ mode_t mode;
+ va_start(ap, flags);
+ mode = va_arg(ap, mode_t);
+ va_end(ap);
+ ret = realopen(newpath ? newpath : path, flags, mode);
you don't need to do this ternary stuff here.
[...]
+ if (data->ipAddr[i]) {
+ virReportError(VIR_ERR_INTERNAL_ERROR,
+ "Address mismatch. Expected %s got nothing",
+ data->ipAddr[i]);
+ goto cleanup;
+ }
We could get more info out of this more easily if those ERROR and DEBUG
macros in PATCH 5/8 were defined and used based on environment
variable. I know it's a bit slower, but if you build --with-debug or
something like that, I think it might be useful.
Otherwise this and all patches I did not reply too look fine (apart from
all the unnecessary arithmetic, but I already said that, didn't I).
Martin