1 /******************************************************************************
2 * Copyright (c) Crackerjack Project., 2007 *
3 * *
4 * This program is free software; you can redistribute it and/or modify *
5 * it under the terms of the GNU General Public License as published by *
6 * the Free Software Foundation; either version 2 of the License, or *
7 * (at your option) any later version. *
8 * *
9 * This program is distributed in the hope that it will be useful, *
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See *
12 * the GNU General Public License for more details. *
13 * *
14 * You should have received a copy of the GNU General Public License *
15 * along with this program; if not, write to the Free Software Foundation, *
16 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA *
17 * *
18 ******************************************************************************/
19
20 /*
21 * Basic test for the add_key() syscall.
22 *
23 * History: Porting from Crackerjack to LTP is done by
24 * Manas Kumar Nayak maknayak@in.ibm.com>
25 */
26
27 #include "config.h"
28 #ifdef HAVE_LINUX_KEYCTL_H
29 # include <linux/keyctl.h>
30 #endif
31 #include "tst_test.h"
32 #include "linux_syscall_numbers.h"
33
verify_add_key(void)34 static void verify_add_key(void)
35 {
36 #ifdef HAVE_LINUX_KEYCTL_H
37
38 TEST(tst_syscall(__NR_add_key, "keyring", "wjkey", NULL, 0,
39 KEY_SPEC_THREAD_KEYRING));
40
41 if (TEST_RETURN == -1)
42 tst_res(TFAIL | TTERRNO, "add_key call failed");
43 else
44 tst_res(TPASS, "add_key call succeeded");
45
46 #else
47 tst_brk(TCONF, "linux/keyctl.h was missing upon compilation.");
48 #endif /* HAVE_LINUX_KEYCTL_H */
49 }
50
51 static struct tst_test test = {
52 .tid = "add_key01",
53 .test_all = verify_add_key,
54 };
55