Changeset 254
- Timestamp:
- 02/18/08 19:00:21 (9 months ago)
- Files:
-
- gpgdir/trunk/test/gpgdir_test.pl (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
- Modified
- Copied
- Moved
gpgdir/trunk/test/gpgdir_test.pl
r252 r254 40 40 my $logfile = 'test.log'; 41 41 my $tarfile = 'gpgdir_test.tar.gz'; 42 43 my $gpg_dir = "$conf_dir/test-gpg"; 44 my $pw_file = "$conf_dir/test.pw"; 45 my $key_id = '375D7DB9'; 42 46 43 47 my $cmd_stdout = "$output_dir/cmd.stdout"; … … 52 56 my $successful_tests = 0; 53 57 54 exit 1unless GetOptions(58 die "[*] Use --help" unless GetOptions( 55 59 'Prepare-results' => \$prepare_results, 56 60 'help' => \$help … … 59 63 exit &prepare_results() if $prepare_results; 60 64 65 &logr("\n[+] ==> Running gpgdir test suite <==\n\n"); 66 61 67 ### execute the tests 62 68 &test_driver('(Setup) gpgdir program compilation', \&perl_compilation); 63 69 &test_driver('(Setup) Command line argument processing', \&getopt_test); 70 &test_driver('(Test mode) gpgdir basic test mode', \&test_mode); 71 72 &logr("\n"); 73 if ($successful_tests) { 74 &logr("[+] ==> Passed $successful_tests/$test_num tests " . 75 "against gpgdir. <==\n"); 76 } 77 if ($failed_tests) { 78 &logr("[+] ==> Failed $failed_tests/$test_num tests " . 79 "against gpgdir. <==\n"); 80 } 81 &logr("[+] This console output has been stored in: $logfile\n\n"); 64 82 65 83 exit 0; … … 77 95 $test_num++; 78 96 return; 97 } 98 99 sub test_mode() { 100 if (&run_cmd("$gpgdirCmd --test --gnupg-dir $gpg_dir " . 101 " --pw-file $pw_file --Key-id $key_id")) { 102 my $found = 0; 103 open F, "< ${cmd_stdout}.$test_num" 104 or die "[*] Could not open ${cmd_stderr}.$test_num: $!"; 105 while (<F>) { 106 if (/Decrypted\s+content\s+matches\s+original/i) { 107 $found = 1; 108 last; 109 } 110 } 111 close F; 112 return 1 if $found; 113 } 114 return &print_errors("fail ($test_num)\n[*] " . 115 "Encrypt/decrypt basic --test mode"); 79 116 } 80 117 … … 106 143 } 107 144 145 sub print_errors() { 146 my $msg = shift; 147 &logr("$msg\n"); 148 if (-e "${cmd_stderr}.$test_num") { 149 &logr(" STDOUT available in: " . 150 "${cmd_stdout}.$test_num file.\n"); 151 } 152 if (-e "${cmd_stderr}.$test_num") { 153 &logr(" STDERR available in: " . 154 "${cmd_stderr}.$test_num file.\n"); 155 } 156 return 0; 157 } 158 108 159 sub run_cmd() { 109 160 my $cmd = shift; … … 119 170 my $rv = 0; 120 171 die "[*] $output_dir does not exist" unless -d $output_dir; 121 die "[*] $logfile does not exist, has fwknop_test.pl been executed?"172 die "[*] $logfile does not exist, has gpgdir_test.pl been executed?" 122 173 unless -e $logfile; 123 174 if (-e $tarfile) {
