File: test7.pl

package info (click to toggle)
adduser 3.118
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 1,968 kB
  • sloc: perl: 2,290; sh: 124; makefile: 57
file content (33 lines) | stat: -rw-r--r-- 690 bytes parent folder | download | duplicates (7)
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";
}