• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1#!/bin/bash
2
3# Copyright 2013 Divya Kothari <divya.s.kothari@gmail.com>
4# Copyright 2013 Robin Mittal <robinmittal.it@gmail.com>
5
6[ -f testing.sh ] && . testing.sh
7
8if [ "$(id -u)" -ne 0 ]
9then
10  echo "$SHOWSKIP: groupdel (not root)"
11  return 2>/dev/null
12  exit
13fi
14
15# Redirecting all output to /dev/null for grep and delgroup
16arg="&>/dev/null"
17
18#testing "name" "command" "result" "infile" "stdin"
19
20testing "group_name (text)" "groupadd toyTestGroup &&
21   grep '^toyTestGroup:' /etc/group $arg && groupdel toyTestGroup $arg &&
22   echo 'yes'" "yes\n" "" ""
23testing "group_name (alphanumeric)" "groupadd toy1Test2Group3 &&
24   grep '^toy1Test2Group3:' /etc/group $arg && groupdel toy1Test2Group3 $arg &&
25   echo 'yes'" "yes\n" "" ""
26testing "group_name (numeric)" "groupadd 987654321 &&
27   grep '^987654321:' /etc/group $arg && groupdel 987654321 $arg &&
28   echo 'yes'" "yes\n" "" ""
29testing "group_name (with ./-)" "groupadd toy.1Test-2Group.3 &&
30   grep '^toy.1Test-2Group.3:' /etc/group $arg &&
31   groupdel toy.1Test-2Group.3 $arg && echo 'yes'" "yes\n" "" ""
32testing "group_name with group_id" "groupadd -g 49999 toyTestGroup &&
33   grep '^toyTestGroup:' /etc/group $arg && groupdel toyTestGroup $arg &&
34   echo 'yes'" "yes\n" "" ""
35