File: 99_cleanup.t

package info (click to toggle)
net-telnet-cisco 1.10-5.3
  • links: PTS
  • area: main
  • in suites: bullseye, buster, sid
  • size: 160 kB
  • ctags: 32
  • sloc: perl: 792; makefile: 52
file content (83 lines) | stat: -rw-r--r-- 1,537 bytes parent folder | download | duplicates (4)
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
# -*- perl -*-
#
# Not tests, these are cleanup routines.
#

use Test::More tests => 1;
use ExtUtils::MakeMaker;
use File::Path;
use t::Utils;
use Cwd;

my %G;
eval { %G =load() };
if ($@ =~ /Login data not available/) {
    pass "Temp files deleted";
    exit;
}

rm_tmp();
rm_logs();
test_notice();

pass;

exit;

#------------------------------------------------------------
# Subs
#------------------------------------------------------------

sub rm_tmp {
    diag "Deleting tempfiles...";

    if (-e "tmp.txt") {
	if (unlink "tmp.txt") {
	    diag "done.\n"
	} else {
	    diag "Can't delete tmp.txt. Help! $!";
	}
    }
}

sub rm_logs {
    diag "

============================================================
   	      WARNING! WARNING! WARNING!


 $G{LOGDIR}
 contains logs with security information.
 In `perl Makefile.PL` you asked to save them.
 We saved them. Delete them when you see fit.


   	      ALART! BWEEOOOP! ACHTUNG!
============================================================

" if scalar glob <$G{LOGDIR}/*>;
}

sub test_notice {
    diag "
============================================================
   	      WARNING! WARNING! WARNING!


 You are using a persistent login file for testing
 Net::Telnet::Cisco. Your router, login and passwords
 will NOT be deleted automatically!


 Don't forget to remove the data
 when you're done with this command:

 rm $FindBin::Bin/../login.txt


   	      ALART! BWEEOOOP! ACHTUNG!
============================================================
" if -r "login.txt";

}