18c2ecf20Sopenharmony_ci// SPDX-License-Identifier: GPL-2.0-or-later
28c2ecf20Sopenharmony_ci/*
38c2ecf20Sopenharmony_ci * Copyright 2015, Michael Ellerman, IBM Corp.
48c2ecf20Sopenharmony_ci *
58c2ecf20Sopenharmony_ci * This test simply tests that certain syscalls are implemented. It doesn't
68c2ecf20Sopenharmony_ci * actually exercise their logic in any way.
78c2ecf20Sopenharmony_ci */
88c2ecf20Sopenharmony_ci
98c2ecf20Sopenharmony_ci#define _GNU_SOURCE
108c2ecf20Sopenharmony_ci#include <errno.h>
118c2ecf20Sopenharmony_ci#include <stdio.h>
128c2ecf20Sopenharmony_ci#include <unistd.h>
138c2ecf20Sopenharmony_ci#include <sys/syscall.h>
148c2ecf20Sopenharmony_ci
158c2ecf20Sopenharmony_ci#include "utils.h"
168c2ecf20Sopenharmony_ci
178c2ecf20Sopenharmony_ci
188c2ecf20Sopenharmony_ci#define DO_TEST(_name, _num)	\
198c2ecf20Sopenharmony_cistatic int test_##_name(void)			\
208c2ecf20Sopenharmony_ci{						\
218c2ecf20Sopenharmony_ci	int rc;					\
228c2ecf20Sopenharmony_ci	printf("Testing " #_name);		\
238c2ecf20Sopenharmony_ci	errno = 0;				\
248c2ecf20Sopenharmony_ci	rc = syscall(_num, -1, 0, 0, 0, 0, 0);	\
258c2ecf20Sopenharmony_ci	printf("\treturned %d, errno %d\n", rc, errno); \
268c2ecf20Sopenharmony_ci	return errno == ENOSYS;			\
278c2ecf20Sopenharmony_ci}
288c2ecf20Sopenharmony_ci
298c2ecf20Sopenharmony_ci#include "ipc.h"
308c2ecf20Sopenharmony_ci#undef DO_TEST
318c2ecf20Sopenharmony_ci
328c2ecf20Sopenharmony_cistatic int ipc_unmuxed(void)
338c2ecf20Sopenharmony_ci{
348c2ecf20Sopenharmony_ci	int tests_done = 0;
358c2ecf20Sopenharmony_ci
368c2ecf20Sopenharmony_ci#define DO_TEST(_name, _num)		\
378c2ecf20Sopenharmony_ci	FAIL_IF(test_##_name());	\
388c2ecf20Sopenharmony_ci	tests_done++;
398c2ecf20Sopenharmony_ci
408c2ecf20Sopenharmony_ci#include "ipc.h"
418c2ecf20Sopenharmony_ci#undef DO_TEST
428c2ecf20Sopenharmony_ci
438c2ecf20Sopenharmony_ci	/*
448c2ecf20Sopenharmony_ci	 * If we ran no tests then it means none of the syscall numbers were
458c2ecf20Sopenharmony_ci	 * defined, possibly because we were built against old headers. But it
468c2ecf20Sopenharmony_ci	 * means we didn't really test anything, so instead of passing mark it
478c2ecf20Sopenharmony_ci	 * as a skip to give the user a clue.
488c2ecf20Sopenharmony_ci	 */
498c2ecf20Sopenharmony_ci	SKIP_IF(tests_done == 0);
508c2ecf20Sopenharmony_ci
518c2ecf20Sopenharmony_ci	return 0;
528c2ecf20Sopenharmony_ci}
538c2ecf20Sopenharmony_ci
548c2ecf20Sopenharmony_ciint main(void)
558c2ecf20Sopenharmony_ci{
568c2ecf20Sopenharmony_ci	return test_harness(ipc_unmuxed, "ipc_unmuxed");
578c2ecf20Sopenharmony_ci}
58