dcavalca / rpms / util-linux

Forked from rpms/util-linux 2 years ago
Clone

Blame SOURCES/0032-tests-add-new-test-for-chfn-gecos.patch

fe1ca8
From 447b7d7222bf8cb3591d611aa51917bd4453f8d6 Mon Sep 17 00:00:00 2001
fe1ca8
From: Radka Skvarilova <rskvaril@redhat.com>
fe1ca8
Date: Mon, 16 Dec 2019 10:57:32 +0100
fe1ca8
Subject: [PATCH 32/32] tests: add new test for chfn gecos
fe1ca8
fe1ca8
Addresses: http://bugzilla.redhat.com/show_bug.cgi?id=1743555
fe1ca8
Upstream: http://github.com/karelzak/util-linux/commit/02238bff663ce5fe823980d8119f3871cc348764
fe1ca8
Upstream: http://github.com/karelzak/util-linux/commit/b2ef43864f24b1a9c0c67fe2a7177a5110da1b6e
fe1ca8
Signed-off-by: Karel Zak <kzak@redhat.com>
fe1ca8
---
fe1ca8
 tests/commands.sh         |  1 +
fe1ca8
 tests/expected/chfn/gecos |  6 ++++++
fe1ca8
 tests/ts/chfn/gecos       | 36 ++++++++++++++++++++++++++++++++++++
fe1ca8
 3 files changed, 43 insertions(+)
fe1ca8
 create mode 100644 tests/expected/chfn/gecos
fe1ca8
 create mode 100755 tests/ts/chfn/gecos
fe1ca8
fe1ca8
diff --git a/tests/commands.sh b/tests/commands.sh
fe1ca8
index 93100caf6..b56381c9e 100644
fe1ca8
--- a/tests/commands.sh
fe1ca8
+++ b/tests/commands.sh
fe1ca8
@@ -104,3 +104,4 @@ TS_CMD_UUIDPARSE=${TS_CMD_UUIDPARSE-"${ts_commandsdir}uuidparse"}
fe1ca8
 TS_CMD_WHEREIS=${TS_CMD_WHEREIS-"${ts_commandsdir}whereis"}
fe1ca8
 TS_CMD_WIPEFS=${TS_CMD_WIPEFS-"${ts_commandsdir}wipefs"}
fe1ca8
 TS_CMD_CHRT=${TS_CMD_CHRT-"${ts_commandsdir}chrt"}
fe1ca8
+TS_CMD_CHFN=${TS_CMD_CHFN-"${ts_commandsdir}chfn"}
fe1ca8
diff --git a/tests/expected/chfn/gecos b/tests/expected/chfn/gecos
fe1ca8
new file mode 100644
fe1ca8
index 000000000..af7b81b6c
fe1ca8
--- /dev/null
fe1ca8
+++ b/tests/expected/chfn/gecos
fe1ca8
@@ -0,0 +1,6 @@
fe1ca8
+Initialize user
fe1ca8
+testuser_chfn_test:x:9899:9899::/home/testuser_chfn_test:/bin/bash
fe1ca8
+Changing finger information for testuser_chfn_test.
fe1ca8
+
fe1ca8
+Finger information changed.
fe1ca8
+testuser_chfn_test:x:9899:9899:test_gecos:/home/testuser_chfn_test:/bin/bash
fe1ca8
diff --git a/tests/ts/chfn/gecos b/tests/ts/chfn/gecos
fe1ca8
new file mode 100755
fe1ca8
index 000000000..aad27d40a
fe1ca8
--- /dev/null
fe1ca8
+++ b/tests/ts/chfn/gecos
fe1ca8
@@ -0,0 +1,36 @@
fe1ca8
+#!/bin/bash
fe1ca8
+
fe1ca8
+#
fe1ca8
+# Copyright (C) 2019 Radka Skvarilova <rskvaril@redhat.com>
fe1ca8
+#
fe1ca8
+# This file is part of util-linux.
fe1ca8
+#
fe1ca8
+# This file is free software; you can redistribute it and/or modify
fe1ca8
+# it under the terms of the GNU General Public License as published by
fe1ca8
+# the Free Software Foundation; either version 2 of the License, or
fe1ca8
+# (at your option) any later version.
fe1ca8
+#
fe1ca8
+# This file is distributed in the hope that it will be useful,
fe1ca8
+# but WITHOUT ANY WARRANTY; without even the implied warranty of
fe1ca8
+# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
fe1ca8
+# GNU General Public License for more details.
fe1ca8
+#
fe1ca8
+
fe1ca8
+TS_TOPDIR="${0%/*}/../.."
fe1ca8
+TS_DESC="gecos"
fe1ca8
+
fe1ca8
+. $TS_TOPDIR/functions.sh
fe1ca8
+ts_init "$*"
fe1ca8
+
fe1ca8
+ts_skip_nonroot
fe1ca8
+ts_check_test_command "$TS_CMD_CHFN"
fe1ca8
+ts_check_prog "useradd"
fe1ca8
+ts_check_prog "userdel"
fe1ca8
+
fe1ca8
+ts_log "Initialize user"
fe1ca8
+useradd -u 9899 --shell /bin/bash testuser_chfn_test
fe1ca8
+grep testuser /etc/passwd >> $TS_OUTPUT
fe1ca8
+$TS_CMD_CHFN -f test_gecos testuser_chfn_test >>$TS_OUTPUT
fe1ca8
+grep testuser /etc/passwd >> $TS_OUTPUT
fe1ca8
+userdel --remove testuser_chfn_test &> /dev/null
fe1ca8
+ts_finalize
fe1ca8
-- 
fe1ca8
2.21.0
fe1ca8