1// SPDX-License-Identifier: GPL-2.0-or-later 2/* 3 * Copyright (c) Crackerjack Project., 2007 4 * Ported from Crackerjack to LTP by Manas Kumar Nayak maknayak@in.ibm.com> 5 */ 6 7/*\ 8 * [Description] 9 * 10 * Basic tests for the tkill() errors. 11 * 12 * [Algorithm] 13 * 14 * - EINVAL on an invalid thread ID 15 * - ESRCH when no process with the specified thread ID exists 16 */ 17 18#include <stdio.h> 19#include <stdlib.h> 20#include <errno.h> 21#include <unistd.h> 22#include <signal.h> 23 24#include "tst_test.h" 25#include "lapi/syscalls.h" 26 27static pid_t unused_tid; 28static pid_t inval_tid = -1; 29 30struct test_case_t { 31 int *tid; 32 int exp_errno; 33} tc[] = { 34 {&inval_tid, EINVAL}, 35 {&unused_tid, ESRCH} 36}; 37 38static void setup(void) 39{ 40 unused_tid = tst_get_unused_pid(); 41} 42 43static void run(unsigned int i) 44{ 45 TST_EXP_FAIL(tst_syscall(__NR_tkill, *(tc[i].tid), SIGUSR1), 46 tc[i].exp_errno, "tst_syscall(__NR_tkill) expecting %s", 47 tst_strerrno(tc[i].exp_errno)); 48} 49 50static struct tst_test test = { 51 .tcnt = ARRAY_SIZE(tc), 52 .needs_tmpdir = 1, 53 .setup = setup, 54 .test = run, 55}; 56