1f08c3bdfSopenharmony_ci// SPDX-License-Identifier: GPL-2.0-or-later 2f08c3bdfSopenharmony_ci/* 3f08c3bdfSopenharmony_ci * Copyright (c) 2016 Linux Test Project 4f08c3bdfSopenharmony_ci * Copyright (c) International Business Machines Corp., 2001 5f08c3bdfSopenharmony_ci * 03/2001 - Written by Wayne Boyer 6f08c3bdfSopenharmony_ci * Copyright (c) 2016 Cyril Hrubis <chrubis@suse.cz> 7f08c3bdfSopenharmony_ci * Copyright (C) 2023 SUSE LLC Andrea Cervesato <andrea.cervesato@suse.com> 8f08c3bdfSopenharmony_ci */ 9f08c3bdfSopenharmony_ci 10f08c3bdfSopenharmony_ci/*\ 11f08c3bdfSopenharmony_ci * [Description] 12f08c3bdfSopenharmony_ci * 13f08c3bdfSopenharmony_ci * Tries to set different personalities. 14f08c3bdfSopenharmony_ci * 15f08c3bdfSopenharmony_ci * We set the personality in a child process since it's not guaranteed that we 16f08c3bdfSopenharmony_ci * can set it back in some cases. I.e. PER_LINUX32 cannot be unset on some 64 17f08c3bdfSopenharmony_ci * bit archs. 18f08c3bdfSopenharmony_ci */ 19f08c3bdfSopenharmony_ci 20f08c3bdfSopenharmony_ci#include "tst_test.h" 21f08c3bdfSopenharmony_ci#include "lapi/personality.h" 22f08c3bdfSopenharmony_ci 23f08c3bdfSopenharmony_ci#define PAIR(id) {id, #id} 24f08c3bdfSopenharmony_ci 25f08c3bdfSopenharmony_cistruct personalities { 26f08c3bdfSopenharmony_ci unsigned long pers; 27f08c3bdfSopenharmony_ci const char *name; 28f08c3bdfSopenharmony_ci}; 29f08c3bdfSopenharmony_ci 30f08c3bdfSopenharmony_cistatic struct personalities pers[] = { 31f08c3bdfSopenharmony_ci PAIR(PER_LINUX), 32f08c3bdfSopenharmony_ci PAIR(PER_LINUX_32BIT), 33f08c3bdfSopenharmony_ci PAIR(PER_SVR4), 34f08c3bdfSopenharmony_ci PAIR(PER_SVR3), 35f08c3bdfSopenharmony_ci PAIR(PER_SCOSVR3), 36f08c3bdfSopenharmony_ci PAIR(PER_OSR5), 37f08c3bdfSopenharmony_ci PAIR(PER_WYSEV386), 38f08c3bdfSopenharmony_ci PAIR(PER_ISCR4), 39f08c3bdfSopenharmony_ci PAIR(PER_BSD), 40f08c3bdfSopenharmony_ci PAIR(PER_XENIX), 41f08c3bdfSopenharmony_ci#if defined(__x86_64__) 42f08c3bdfSopenharmony_ci PAIR(PER_LINUX32), 43f08c3bdfSopenharmony_ci#endif 44f08c3bdfSopenharmony_ci PAIR(PER_IRIX32), 45f08c3bdfSopenharmony_ci PAIR(PER_IRIXN32), 46f08c3bdfSopenharmony_ci PAIR(PER_IRIX64), 47f08c3bdfSopenharmony_ci PAIR(PER_RISCOS), 48f08c3bdfSopenharmony_ci PAIR(PER_SOLARIS), 49f08c3bdfSopenharmony_ci PAIR(PER_UW7), 50f08c3bdfSopenharmony_ci PAIR(PER_OSF4), 51f08c3bdfSopenharmony_ci PAIR(PER_HPUX), 52f08c3bdfSopenharmony_ci}; 53f08c3bdfSopenharmony_ci 54f08c3bdfSopenharmony_cistatic void run(unsigned int i) 55f08c3bdfSopenharmony_ci{ 56f08c3bdfSopenharmony_ci pid_t pid; 57f08c3bdfSopenharmony_ci 58f08c3bdfSopenharmony_ci pid = SAFE_FORK(); 59f08c3bdfSopenharmony_ci if (!pid) { 60f08c3bdfSopenharmony_ci SAFE_PERSONALITY(pers[i].pers); 61f08c3bdfSopenharmony_ci 62f08c3bdfSopenharmony_ci TST_EXP_EXPR((unsigned long)SAFE_PERSONALITY(0xffffffff) == pers[i].pers, 63f08c3bdfSopenharmony_ci "%s personality is set", 64f08c3bdfSopenharmony_ci pers[i].name); 65f08c3bdfSopenharmony_ci 66f08c3bdfSopenharmony_ci return; 67f08c3bdfSopenharmony_ci } 68f08c3bdfSopenharmony_ci} 69f08c3bdfSopenharmony_ci 70f08c3bdfSopenharmony_cistatic struct tst_test test = { 71f08c3bdfSopenharmony_ci .test = run, 72f08c3bdfSopenharmony_ci .tcnt = ARRAY_SIZE(pers), 73f08c3bdfSopenharmony_ci .forks_child = 1, 74f08c3bdfSopenharmony_ci}; 75