1f08c3bdfSopenharmony_ci/******************************************************************************/ 2f08c3bdfSopenharmony_ci/* Copyright (c) Crackerjack Project., 2007 */ 3f08c3bdfSopenharmony_ci/* */ 4f08c3bdfSopenharmony_ci/* This program is free software; you can redistribute it and/or modify */ 5f08c3bdfSopenharmony_ci/* it under the terms of the GNU General Public License as published by */ 6f08c3bdfSopenharmony_ci/* the Free Software Foundation; either version 2 of the License, or */ 7f08c3bdfSopenharmony_ci/* (at your option) any later version. */ 8f08c3bdfSopenharmony_ci/* */ 9f08c3bdfSopenharmony_ci/* This program is distributed in the hope that it will be useful, */ 10f08c3bdfSopenharmony_ci/* but WITHOUT ANY WARRANTY; without even the implied warranty of */ 11f08c3bdfSopenharmony_ci/* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See */ 12f08c3bdfSopenharmony_ci/* the GNU General Public License for more details. */ 13f08c3bdfSopenharmony_ci/* */ 14f08c3bdfSopenharmony_ci/* You should have received a copy of the GNU General Public License */ 15f08c3bdfSopenharmony_ci/* along with this program; if not, write to the Free Software Foundation, */ 16f08c3bdfSopenharmony_ci/* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ 17f08c3bdfSopenharmony_ci/* */ 18f08c3bdfSopenharmony_ci/* History: Porting from Crackerjack to LTP is done by */ 19f08c3bdfSopenharmony_ci/* Manas Kumar Nayak maknayak@in.ibm.com> */ 20f08c3bdfSopenharmony_ci/******************************************************************************/ 21f08c3bdfSopenharmony_ci 22f08c3bdfSopenharmony_ci/******************************************************************************/ 23f08c3bdfSopenharmony_ci/* Description: This tests the rt_sigaction() syscall */ 24f08c3bdfSopenharmony_ci/* rt_sigaction Expected EFAULT error check */ 25f08c3bdfSopenharmony_ci/******************************************************************************/ 26f08c3bdfSopenharmony_ci 27f08c3bdfSopenharmony_ci#define _GNU_SOURCE 28f08c3bdfSopenharmony_ci#include <stdio.h> 29f08c3bdfSopenharmony_ci#include <stdlib.h> 30f08c3bdfSopenharmony_ci#include <unistd.h> 31f08c3bdfSopenharmony_ci#include <signal.h> 32f08c3bdfSopenharmony_ci#include <errno.h> 33f08c3bdfSopenharmony_ci#include <sys/syscall.h> 34f08c3bdfSopenharmony_ci#include <string.h> 35f08c3bdfSopenharmony_ci 36f08c3bdfSopenharmony_ci#include "test.h" 37f08c3bdfSopenharmony_ci#include "lapi/syscalls.h" 38f08c3bdfSopenharmony_ci#include "lapi/rt_sigaction.h" 39f08c3bdfSopenharmony_ci 40f08c3bdfSopenharmony_cichar *TCID = "rt_sigaction02"; 41f08c3bdfSopenharmony_cistatic int testno; 42f08c3bdfSopenharmony_ciint TST_TOTAL = 1; 43f08c3bdfSopenharmony_ci 44f08c3bdfSopenharmony_civoid cleanup(void) 45f08c3bdfSopenharmony_ci{ 46f08c3bdfSopenharmony_ci tst_rmdir(); 47f08c3bdfSopenharmony_ci 48f08c3bdfSopenharmony_ci tst_exit(); 49f08c3bdfSopenharmony_ci} 50f08c3bdfSopenharmony_ci 51f08c3bdfSopenharmony_civoid setup(void) 52f08c3bdfSopenharmony_ci{ 53f08c3bdfSopenharmony_ci TEST_PAUSE; 54f08c3bdfSopenharmony_ci tst_tmpdir(); 55f08c3bdfSopenharmony_ci} 56f08c3bdfSopenharmony_ci 57f08c3bdfSopenharmony_cistatic int test_flags[] = 58f08c3bdfSopenharmony_ci { SA_RESETHAND | SA_SIGINFO, SA_RESETHAND, SA_RESETHAND | SA_SIGINFO, 59f08c3bdfSopenharmony_ciSA_RESETHAND | SA_SIGINFO, SA_NOMASK }; 60f08c3bdfSopenharmony_cichar *test_flags_list[] = 61f08c3bdfSopenharmony_ci { "SA_RESETHAND|SA_SIGINFO", "SA_RESETHAND", "SA_RESETHAND|SA_SIGINFO", 62f08c3bdfSopenharmony_ci"SA_RESETHAND|SA_SIGINFO", "SA_NOMASK" }; 63f08c3bdfSopenharmony_ci 64f08c3bdfSopenharmony_cistatic struct test_case_t { 65f08c3bdfSopenharmony_ci int exp_errno; 66f08c3bdfSopenharmony_ci char *errdesc; 67f08c3bdfSopenharmony_ci} test_cases[] = { 68f08c3bdfSopenharmony_ci { 69f08c3bdfSopenharmony_ci EFAULT, "EFAULT"} 70f08c3bdfSopenharmony_ci}; 71f08c3bdfSopenharmony_ci 72f08c3bdfSopenharmony_ciint main(int ac, char **av) 73f08c3bdfSopenharmony_ci{ 74f08c3bdfSopenharmony_ci unsigned int flag; 75f08c3bdfSopenharmony_ci int signal; 76f08c3bdfSopenharmony_ci int lc; 77f08c3bdfSopenharmony_ci 78f08c3bdfSopenharmony_ci tst_parse_opts(ac, av, NULL, NULL); 79f08c3bdfSopenharmony_ci 80f08c3bdfSopenharmony_ci setup(); 81f08c3bdfSopenharmony_ci 82f08c3bdfSopenharmony_ci for (lc = 0; TEST_LOOPING(lc); ++lc) { 83f08c3bdfSopenharmony_ci tst_count = 0; 84f08c3bdfSopenharmony_ci for (testno = 0; testno < TST_TOTAL; ++testno) { 85f08c3bdfSopenharmony_ci for (signal = SIGRTMIN; signal <= SIGRTMAX; signal++) { 86f08c3bdfSopenharmony_ci tst_resm(TINFO, "Signal %d", signal); 87f08c3bdfSopenharmony_ci 88f08c3bdfSopenharmony_ci for (flag = 0; flag < ARRAY_SIZE(test_flags); flag++) { 89f08c3bdfSopenharmony_ci 90f08c3bdfSopenharmony_ci /* * 91f08c3bdfSopenharmony_ci * long sys_rt_sigaction (int sig, const struct sigaction *act, * 92f08c3bdfSopenharmony_ci * truct sigaction *oact, size_t sigsetsize); * 93f08c3bdfSopenharmony_ci * EFAULT: * 94f08c3bdfSopenharmony_ci * An invalid act or oact value was specified * 95f08c3bdfSopenharmony_ci */ 96f08c3bdfSopenharmony_ci 97f08c3bdfSopenharmony_ci TEST(ltp_rt_sigaction(signal, 98f08c3bdfSopenharmony_ci INVAL_SA_PTR, NULL, SIGSETSIZE)); 99f08c3bdfSopenharmony_ci if ((TEST_RETURN == -1) 100f08c3bdfSopenharmony_ci && (TEST_ERRNO == 101f08c3bdfSopenharmony_ci test_cases[0].exp_errno)) { 102f08c3bdfSopenharmony_ci tst_resm(TINFO, 103f08c3bdfSopenharmony_ci "sa.sa_flags = %s ", 104f08c3bdfSopenharmony_ci test_flags_list[flag]); 105f08c3bdfSopenharmony_ci tst_resm(TPASS, 106f08c3bdfSopenharmony_ci "%s failure with sig: %d as expected errno = %s : %s", 107f08c3bdfSopenharmony_ci TCID, signal, 108f08c3bdfSopenharmony_ci test_cases[0].errdesc, 109f08c3bdfSopenharmony_ci strerror(TEST_ERRNO)); 110f08c3bdfSopenharmony_ci } else { 111f08c3bdfSopenharmony_ci tst_resm(TFAIL, 112f08c3bdfSopenharmony_ci "rt_sigaction call succeeded: result = %ld got error %d:but expected %d", 113f08c3bdfSopenharmony_ci TEST_RETURN, 114f08c3bdfSopenharmony_ci TEST_ERRNO, 115f08c3bdfSopenharmony_ci test_cases[0]. 116f08c3bdfSopenharmony_ci exp_errno); 117f08c3bdfSopenharmony_ci tst_resm(TINFO, 118f08c3bdfSopenharmony_ci "sa.sa_flags = %s ", 119f08c3bdfSopenharmony_ci test_flags_list[flag]); 120f08c3bdfSopenharmony_ci } 121f08c3bdfSopenharmony_ci } 122f08c3bdfSopenharmony_ci } 123f08c3bdfSopenharmony_ci 124f08c3bdfSopenharmony_ci } 125f08c3bdfSopenharmony_ci } 126f08c3bdfSopenharmony_ci cleanup(); 127f08c3bdfSopenharmony_ci tst_exit(); 128f08c3bdfSopenharmony_ci} 129