1 // SPDX-License-Identifier: GPL-2.0
2 /*
3 * Copyright (c) Wipro Technologies Ltd, 2002. All Rights Reserved.
4 * Copyright (c) 2019 Petr Vorel <petr.vorel@gmail.com>
5 * Author: Saji Kumar.V.R <saji.kumar@wipro.com>
6 */
7
8 #include "setdomainname.h"
9
do_test(void)10 static void do_test(void)
11 {
12 char *new = TST_VALID_DOMAIN_NAME;
13 static char tmp[_UTSNAME_DOMAIN_LENGTH];
14
15 TEST(do_setdomainname(new, strlen(new)));
16
17 if (TST_RET != 0)
18 tst_brk(TFAIL | TTERRNO, "set" SYSCALL_NAME "() failed: %d", TST_ERR);
19
20 if (GET_SYSCALL(tmp, sizeof(tmp)) != 0)
21 tst_brk(TFAIL | TERRNO, "get" SYSCALL_NAME "() failed");
22
23 if (strcmp(tmp, new))
24 tst_res(TFAIL, "get" SYSCALL_NAME "() returned wrong domainname: '%s'", tmp);
25 else
26 tst_res(TPASS, "set" SYSCALL_NAME "() succeed");
27 }
28
29 static struct tst_test test = {
30 .needs_root = 1,
31 .setup = setup,
32 .cleanup = cleanup,
33 .test_all = do_test,
34 .test_variants = TEST_VARIANTS,
35 };
36