]>
git.ipfire.org Git - thirdparty/openssl.git/blob - test/recipes/15-test_out_option.t
2 # Copyright 2018 The OpenSSL Project Authors. All Rights Reserved.
4 # Licensed under the OpenSSL license (the "License"). You may not use
5 # this file except in compliance with the License. You can obtain a copy
6 # in the file LICENSE in the source distribution or at
7 # https://www.openssl.org/source/license.html
14 use OpenSSL
::Test qw
/:DEFAULT srctop_file/;
15 use OpenSSL
::Test
::Utils
;
17 setup
("test_out_option");
19 # Paths that should generate failure when trying to write to them.
20 # Directories are a safe bet for failure on all platforms.
21 # Note that directories must end with a slash here, because of how
22 # File::Spec massages them into directory specs on some platforms.
30 # Test for trying to create a file in a non-exist directory
33 my @chars = ("A".."Z", "a".."z", "0".."9");
34 $rand_path .= $chars[rand @chars] for 1..32;
35 } while (-d File
::Spec
->catdir('.', $rand_path));
36 $rand_path .= "/randomname.bin";
38 push @failure_paths, $rand_path;
40 # All explicit cross compilations run a risk of failing this, because the
41 # null device provided by perl might not match what the cross compiled
42 # application expects to see as a null device. Therefore, we skip the check
43 # of outputing to the null device if the cross compile prefix is set.
44 if ((config
('CROSS_COMPILE') // '') eq '') {
45 # Check that we can write to the NULL device
46 push @success_paths, File
::Spec
->devnull();
49 plan tests
=> scalar @failure_paths + scalar @success_paths;
51 foreach (@failure_paths) {
52 my $path = File
::Spec
->canonpath($_);
53 ok
(!run
(app
([ 'openssl', 'rand', '-out', $path, '1'])),
54 "invalid output path: $path");
56 foreach (@success_paths) {
57 my $path = File
::Spec
->canonpath($_);
58 ok
(run
(app
([ 'openssl', 'rand', '-out', $path, '1'])),
59 "valid output path: $path");
63 unlink 'randomname.bin' if -f
'randomname.bin';