Back to home page

OSCL-LXR

 
 

    


0001 // SPDX-License-Identifier: GPL-2.0-or-later
0002 /*
0003  * Copyright 2015, Michael Ellerman, IBM Corp.
0004  *
0005  * This test simply tests that certain syscalls are implemented. It doesn't
0006  * actually exercise their logic in any way.
0007  */
0008 
0009 #define _GNU_SOURCE
0010 #include <errno.h>
0011 #include <stdio.h>
0012 #include <unistd.h>
0013 #include <sys/syscall.h>
0014 
0015 #include "utils.h"
0016 
0017 
0018 #define DO_TEST(_name, _num)    \
0019 static int test_##_name(void)           \
0020 {                       \
0021     int rc;                 \
0022     printf("Testing " #_name);      \
0023     errno = 0;              \
0024     rc = syscall(_num, -1, 0, 0, 0, 0, 0);  \
0025     printf("\treturned %d, errno %d\n", rc, errno); \
0026     return errno == ENOSYS;         \
0027 }
0028 
0029 #include "ipc.h"
0030 #undef DO_TEST
0031 
0032 static int ipc_unmuxed(void)
0033 {
0034     int tests_done = 0;
0035 
0036 #define DO_TEST(_name, _num)        \
0037     FAIL_IF(test_##_name());    \
0038     tests_done++;
0039 
0040 #include "ipc.h"
0041 #undef DO_TEST
0042 
0043     /*
0044      * If we ran no tests then it means none of the syscall numbers were
0045      * defined, possibly because we were built against old headers. But it
0046      * means we didn't really test anything, so instead of passing mark it
0047      * as a skip to give the user a clue.
0048      */
0049     SKIP_IF(tests_done == 0);
0050 
0051     return 0;
0052 }
0053 
0054 int main(void)
0055 {
0056     return test_harness(ipc_unmuxed, "ipc_unmuxed");
0057 }