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