summaryrefslogtreecommitdiffstats
path: root/testsuite/test7.pl
blob: 0a3596cc6d6891c29eb8cf2c9c64ddfe5bb93276 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
#!/usr/bin/perl -w

# expect:
#  - a new system user $USER
#  - Second execution of command does not return an error.

use strict;
use lib_test;

my $username = find_unused_name();

my $cmd = "adduser --system $username";

if (!defined (getpwnam($username))) {
	print "Testing $cmd... ";
	`$cmd`;
	my $error = ($?>>8);
	if ($error) {
	  print "failed\n  adduser returned an errorcode != 0 ($error)\n";
	  exit $error;
	}
	`$cmd`;
	$error = ($?>>8);
	if ($error) {
          print "failed\n double execution with same parameters showed an error (return code $error)\n";
	  exit $error;
	}

	assert(check_user_exist ($username));
	assert(check_homedir_exist ($username));
	print "ok\n";
}