From: Lucas De Marchi Date: Tue, 9 Apr 2013 08:21:42 +0000 (-0300) Subject: testsuite: Wrap syscall() to get calls to finit_module() X-Git-Tag: v13~3 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=0ae58609dc0b983aa17ea7aa38c071cf1830819a;p=platform%2Fupstream%2Fkmod.git testsuite: Wrap syscall() to get calls to finit_module() When we don't have finit_module() in libc (most likely because as of today glibc didn't add it yet), we end up using syscall(__NR_finit_module, ...). In this case we would not wrap the function in the testsuite and thus having some tests failing: TESTSUITE: ERR: could not insert module: Operation not permitted This implementation relies on the fact that this is the only caller of syscall(2), because we can't call libc's syscall(). There's an abort() in place to be future safe: as soon as we need more calls to syscall(), we can detect (and decide what to do). Now we have all tests passing in the testsuite again. --- diff --git a/testsuite/init_module.c b/testsuite/init_module.c index d60ca96..f1e7f82 100644 --- a/testsuite/init_module.c +++ b/testsuite/init_module.c @@ -1,5 +1,6 @@ /* * Copyright (C) 2012-2013 ProFUSION embedded systems + * Copyright (C) 2012-2013 Lucas De Marchi * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU Lesser General Public @@ -35,6 +36,7 @@ #include #include #include +#include #include /* kmod_elf_get_section() is not exported, we need the private header */ @@ -302,6 +304,40 @@ int finit_module(const int fd, const char *args, const int flags) return err; } +TS_EXPORT long int syscall(long int __sysno, ...) +{ + va_list ap; + long ret; + + switch (__sysno) { + case -1: + errno = -ENOSYS; + return -1; + case __NR_finit_module: { + const char *args; + int flags; + int fd; + + va_start(ap, __sysno); + + fd = va_arg(ap, int); + args = va_arg(ap, const char *); + flags = va_arg(ap, int); + + ret = finit_module(fd, args, flags); + + va_end(ap); + return ret; + } + } + + /* + * FIXME: no way to call the libc function - let's hope there are no + * other users. + */ + abort(); +} + /* the test is going away anyway, but lets keep valgrind happy */ void free_resources(void) __attribute__((destructor)); void free_resources(void)