1// SPDX-License-Identifier: GPL-2.0-or-later 2/* 3 * Copyright (c) International Business Machines Corp., 2001 4 */ 5 6/*\ 7 * [Description] 8 * 9 * Tests basic error handing of the shmdt syscall. 10 * 11 * -EINVAL there is no shared memory segment attached at shmaddr. 12 * -EINVAL shmaddr is not aligned on a page boundary. 13 */ 14 15#include <sys/types.h> 16#include <sys/shm.h> 17#include "tst_test.h" 18#include "libnewipc.h" 19 20static void *non_attched_addr; 21static void *unaligned_addr; 22 23struct tcase { 24 void **addr; 25 char *des; 26} tcases[] = { 27 {&non_attched_addr, "shmdt(non_attched_addr)"}, 28 {&unaligned_addr, "shmdt(unaligned_addr)"} 29}; 30 31static void verify_shmdt(unsigned int n) 32{ 33 struct tcase *tc = &tcases[n]; 34 35 TST_EXP_FAIL(shmdt(*tc->addr), EINVAL, "%s", tc->des); 36} 37 38static void setup(void) 39{ 40 non_attched_addr = PROBE_FREE_ADDR(); 41 unaligned_addr = non_attched_addr + SHMLBA - 1; 42} 43 44static struct tst_test test = { 45 .setup = setup, 46 .test = verify_shmdt, 47 .tcnt = ARRAY_SIZE(tcases), 48}; 49